Search in sources :

Example 1 with PCCDispatcherImpl

use of org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl in project bgpcep by opendaylight.

the class PCCMockCommon method createPCCSession.

Future<PCEPSession> createPCCSession(final BigInteger dbVersion) {
    final PCCDispatcherImpl pccDispatcher = new PCCDispatcherImpl(this.messageRegistry);
    final PCEPSessionNegotiatorFactory<PCEPSessionImpl> snf = getSessionNegotiatorFactory();
    final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(3, this.localAddress.getAddress(), 0, -1, new HashedWheelTimer(), Optional.absent());
    return pccDispatcher.createClient(this.remoteAddress, -1, () -> {
        this.pccSessionListener = new PCCSessionListener(1, tunnelManager, false);
        return this.pccSessionListener;
    }, snf, KeyMapping.getKeyMapping(), this.localAddress, dbVersion);
}
Also used : PCCDispatcherImpl(org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl) PCCSessionListener(org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCSessionListener) PCCTunnelManager(org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager) PCEPSessionImpl(org.opendaylight.protocol.pcep.impl.PCEPSessionImpl) HashedWheelTimer(io.netty.util.HashedWheelTimer)

Example 2 with PCCDispatcherImpl

use of org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl in project bgpcep by opendaylight.

the class PCCDispatcherImplTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    this.workerGroup = new NioEventLoopGroup();
    this.bossGroup = new NioEventLoopGroup();
    this.dispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry());
    this.pcepDispatcher = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry(), this.nf, this.bossGroup, this.workerGroup);
    this.serverAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress();
    this.clientAddress = InetSocketAddressUtil.getRandomLoopbackInetSocketAddress(0);
    doReturn(KeyMapping.getKeyMapping()).when(this.dispatcherDependencies).getKeys();
    doReturn(this.serverAddress).when(this.dispatcherDependencies).getAddress();
    doReturn(null).when(this.dispatcherDependencies).getPeerProposal();
}
Also used : PCCDispatcherImpl(org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl) PCEPDispatcherImpl(org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) Before(org.junit.Before)

Example 3 with PCCDispatcherImpl

use of org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl in project bgpcep by opendaylight.

the class PCCsBuilder method createPCCs.

void createPCCs(final BigInteger initialDBVersion, final Optional<TimerHandler> timerHandler) {
    InetAddress currentAddress = this.localAddress.getAddress();
    this.pccDispatcher = new PCCDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry());
    if (timerHandler.isPresent()) {
        timerHandler.get().setPCCDispatcher(this.pccDispatcher);
    }
    for (int i = 0; i < this.pccCount; i++) {
        final PCCTunnelManager tunnelManager = new PCCTunnelManagerImpl(this.lsps, currentAddress, this.redelegationTimeout, this.stateTimeout, this.timer, timerHandler);
        createPCC(new InetSocketAddress(currentAddress, this.localAddress.getPort()), tunnelManager, initialDBVersion);
        currentAddress = InetAddresses.increment(currentAddress);
    }
}
Also used : PCCDispatcherImpl(org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl) PCCTunnelManager(org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress)

Example 4 with PCCDispatcherImpl

use of org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl 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

PCCDispatcherImpl (org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl)4 InetSocketAddress (java.net.InetSocketAddress)2 PCCTunnelManager (org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager)2 HostAndPort (com.google.common.net.HostAndPort)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 HashedWheelTimer (io.netty.util.HashedWheelTimer)1 InetAddress (java.net.InetAddress)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)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 PCEPDispatcherImpl (org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl)1 PCEPSessionImpl (org.opendaylight.protocol.pcep.impl.PCEPSessionImpl)1 PCCSessionListener (org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCSessionListener)1