Search in sources :

Example 1 with PCEPSessionNegotiatorFactory

use of org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory in project bgpcep by opendaylight.

the class PCCMock method main.

public static void main(final String[] args) throws InterruptedException, ExecutionException {
    Preconditions.checkArgument(args.length > 0, "Host and port of server must be provided.");
    final List<PCEPCapability> caps = new ArrayList<>();
    final PCEPSessionProposalFactory proposal = new BasePCEPSessionProposalFactory((short) 120, (short) 30, caps);
    final PCEPSessionNegotiatorFactory snf = new DefaultPCEPSessionNegotiatorFactory(proposal, 0);
    final HostAndPort serverHostAndPort = HostAndPort.fromString(args[0]);
    final InetSocketAddress serverAddr = new InetSocketAddress(serverHostAndPort.getHost(), serverHostAndPort.getPortOrDefault(12345));
    final InetSocketAddress clientAddr = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(0);
    try (PCCDispatcherImpl pccDispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry())) {
        pccDispatcher.createClient(serverAddr, -1, SimpleSessionListener::new, snf, KeyMapping.getKeyMapping(), clientAddr).get();
    }
}
Also used : PCCDispatcherImpl(org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl) HostAndPort(com.google.common.net.HostAndPort) DefaultPCEPSessionNegotiatorFactory(org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory) InetSocketAddress(java.net.InetSocketAddress) BasePCEPSessionProposalFactory(org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory) ArrayList(java.util.ArrayList) PCEPCapability(org.opendaylight.protocol.pcep.PCEPCapability) BasePCEPSessionProposalFactory(org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory) PCEPSessionProposalFactory(org.opendaylight.protocol.pcep.PCEPSessionProposalFactory) DefaultPCEPSessionNegotiatorFactory(org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory) PCEPSessionNegotiatorFactory(org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory)

Aggregations

HostAndPort (com.google.common.net.HostAndPort)1 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1 PCEPCapability (org.opendaylight.protocol.pcep.PCEPCapability)1 PCEPSessionNegotiatorFactory (org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory)1 PCEPSessionProposalFactory (org.opendaylight.protocol.pcep.PCEPSessionProposalFactory)1 BasePCEPSessionProposalFactory (org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory)1 DefaultPCEPSessionNegotiatorFactory (org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory)1 PCCDispatcherImpl (org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl)1