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);
}
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();
}
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);
}
}
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();
}
}
Aggregations