use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project bgpcep by opendaylight.
the class StateProviderImplTest method testActiveStateProvider.
@Test
public void testActiveStateProvider() throws Exception {
doReturn(true).when(this.bgpRibState).isActive();
doReturn(true).when(this.bgpPeerState).isActive();
try (StateProviderImpl stateProvider = // FIXME: use a properly-controlled executor service
new StateProviderImpl(getDataBroker(), 1, tableTypeRegistry, this.stateProvider, "global-bgp")) {
final Global globalExpected = buildGlobalExpected(0);
this.bgpRibStates.add(this.bgpRibState);
readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
final Global global = bgpRib.getGlobal();
assertEquals(globalExpected, global);
return bgpRib;
});
this.totalPathsCounter.increment();
this.totalPrefixesCounter.increment();
final Global globalExpected2 = buildGlobalExpected(1);
readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
final Global global = bgpRib.getGlobal();
assertEquals(globalExpected2, global);
return bgpRib;
});
this.totalPathsCounter.decrement();
this.totalPrefixesCounter.decrement();
final Global globalExpected3 = buildGlobalExpected(0);
readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
final Global global = bgpRib.getGlobal();
assertEquals(globalExpected3, global);
assertNull(bgpRib.getNeighbors());
assertNull(bgpRib.getPeerGroups());
return bgpRib;
});
this.bgpPeerStates.add(this.bgpPeerState);
final PeerGroup peerGroupExpected = buildGroupExpected();
this.totalPathsCounter.increment();
this.totalPrefixesCounter.increment();
final AfiSafis expectedAfiSafis = buildAfiSafis();
final ErrorHandling expectedErrorHandling = buildErrorHandling();
final GracefulRestart expectedGracefulRestart = buildGracefulRestart();
final Transport expectedTransport = buildTransport();
final Timers expectedTimers = buildTimers();
final BgpNeighborStateAugmentation expectedBgpNeighborState = buildBgpNeighborStateAugmentation();
readDataOperational(getDataBroker(), bgpInstanceIdentifier, bgpRib -> {
final Neighbors neighbors = bgpRib.getNeighbors();
assertNotNull(neighbors);
assertEquals(peerGroupExpected, bgpRib.getPeerGroups().nonnullPeerGroup().values().iterator().next());
final Neighbor neighborResult = neighbors.nonnullNeighbor().values().iterator().next();
assertEquals(new IpAddress(neighborAddress.getIpv4AddressNoZone()), neighborResult.getNeighborAddress());
assertEquals(expectedAfiSafis, neighborResult.getAfiSafis());
assertEquals(expectedErrorHandling, neighborResult.getErrorHandling());
assertEquals(expectedGracefulRestart, neighborResult.getGracefulRestart());
assertEquals(expectedTransport, neighborResult.getTransport());
assertEquals(expectedTimers, neighborResult.getTimers());
final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.State stateResult = neighborResult.getState();
assertEquals(expectedBgpNeighborState, stateResult.augmentation(BgpNeighborStateAugmentation.class));
assertEquals(BgpNeighborState.SessionState.ESTABLISHED, stateResult.augmentation(NeighborStateAugmentation.class).getSessionState());
final List<Class<? extends BgpCapability>> supportedCapabilitiesResult = stateResult.augmentation(NeighborStateAugmentation.class).getSupportedCapabilities();
assertTrue(supportedCapabilitiesResult.containsAll(this.supportedCap));
return bgpRib;
});
this.bgpRibStates.clear();
checkNotPresentOperational(getDataBroker(), this.bgpInstanceIdentifier);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project bgpcep by opendaylight.
the class OpenConfigMappingUtilTest method testIsActive.
@Test
public void testIsActive() {
final TransportBuilder builder = new TransportBuilder();
assertTrue(OpenConfigMappingUtil.isActive(EMPTY_NEIGHBOR, null));
assertTrue(OpenConfigMappingUtil.isActive(new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS).setTransport(builder.build()).build(), null));
final Transport activeFalse = builder.setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder().setPassiveMode(true).build()).build();
assertFalse(OpenConfigMappingUtil.isActive(new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS).setTransport(activeFalse).build(), null));
assertTrue(OpenConfigMappingUtil.isActive(EMPTY_NEIGHBOR, EMPTY_PEERGROUP));
assertFalse(OpenConfigMappingUtil.isActive(EMPTY_NEIGHBOR, new PeerGroupBuilder().setPeerGroupName("foo").setTransport(activeFalse).build()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project bgpcep by opendaylight.
the class OpenConfigMappingUtilTest method testGetLocalAddress.
@Test
public void testGetLocalAddress() {
assertNull(OpenConfigMappingUtil.getLocalAddress(null));
final TransportBuilder transport = new TransportBuilder();
assertNull(OpenConfigMappingUtil.getLocalAddress(transport.build()));
assertNull(OpenConfigMappingUtil.getLocalAddress(transport.setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder().build()).build()));
assertEquals(new IpAddressNoZone(LOCAL_HOST), OpenConfigMappingUtil.getLocalAddress(transport.setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder().setLocalAddress(new BgpNeighborTransportConfig.LocalAddress(new IpAddress(new Ipv4Address(LOCAL_HOST.getValue())))).build()).build()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project bgpcep by opendaylight.
the class OpenConfigMappingUtilTest method testGetPort.
@Test
public void testGetPort() {
final TransportBuilder transport = new TransportBuilder();
assertEquals(PORT, OpenConfigMappingUtil.getPort(NEIGHBOR, null));
assertEquals(PORT, OpenConfigMappingUtil.getPort(new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS).setTransport(transport.build()).build(), null));
assertEquals(PORT, OpenConfigMappingUtil.getPort(new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS).setTransport(transport.setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder().build()).build()).build(), null));
final PortNumber newPort = new PortNumber(Uint16.valueOf(111));
final Config portConfig = new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder().addAugmentation(new NeighborTransportConfigBuilder().setRemotePort(newPort).build()).build();
assertEquals(newPort, OpenConfigMappingUtil.getPort(new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS).setTransport(transport.setConfig(portConfig).build()).build(), null));
assertEquals(newPort, OpenConfigMappingUtil.getPort(new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS).setTransport(transport.setConfig(portConfig).build()).build(), EMPTY_PEERGROUP));
final Config portConfigGroup = new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.ConfigBuilder().addAugmentation(new PeerGroupTransportConfigBuilder().setRemotePort(newPort).build()).build();
assertEquals(newPort, OpenConfigMappingUtil.getPort(EMPTY_NEIGHBOR, new PeerGroupBuilder().setPeerGroupName("foo").setTransport(transport.setConfig(portConfigGroup).build()).build()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project openflowplugin by opendaylight.
the class SwitchConnectionProviderImpl method createAndConfigureServer.
private ServerFacade createAndConfigureServer() {
LOG.debug("Configuring ..");
ServerFacade server;
final ChannelInitializerFactory factory = new ChannelInitializerFactory();
factory.setSwitchConnectionHandler(switchConnectionHandler);
factory.setSwitchIdleTimeout(connConfig.getSwitchIdleTimeout());
factory.setTlsConfig(connConfig.getTlsConfiguration());
factory.setSerializationFactory(serializationFactory);
factory.setDeserializationFactory(deserializationFactory);
factory.setUseBarrier(connConfig.useBarrier());
factory.setChannelOutboundQueueSize(connConfig.getChannelOutboundQueueSize());
final TransportProtocol transportProtocol = (TransportProtocol) connConfig.getTransferProtocol();
// Check if Epoll native transport is available.
// TODO : Add option to disable Epoll.
boolean isEpollEnabled = Epoll.isAvailable();
if (TransportProtocol.TCP.equals(transportProtocol) || TransportProtocol.TLS.equals(transportProtocol)) {
server = new TcpHandler(connConfig.getAddress(), connConfig.getPort(), () -> openflowDiagStatusProvider.reportStatus(diagStatusIdentifier, ServiceState.OPERATIONAL));
final TcpChannelInitializer channelInitializer = factory.createPublishingChannelInitializer();
((TcpHandler) server).setChannelInitializer(channelInitializer);
((TcpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled);
final EventLoopGroup workerGroupFromTcpHandler = ((TcpHandler) server).getWorkerGroup();
connectionInitializer = new TcpConnectionInitializer(workerGroupFromTcpHandler, isEpollEnabled);
connectionInitializer.setChannelInitializer(channelInitializer);
connectionInitializer.run();
} else if (TransportProtocol.UDP.equals(transportProtocol)) {
server = new UdpHandler(connConfig.getAddress(), connConfig.getPort(), () -> openflowDiagStatusProvider.reportStatus(diagStatusIdentifier, ServiceState.OPERATIONAL));
((UdpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled);
((UdpHandler) server).setChannelInitializer(factory.createUdpChannelInitializer());
} else {
throw new IllegalStateException("Unknown transport protocol received: " + transportProtocol);
}
server.setThreadConfig(connConfig.getThreadConfiguration());
return server;
}
Aggregations