Search in sources :

Example 11 with BGPExtensionProviderContext

use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.

the class ActivatorTest method testActivator.

@Test
public void testActivator() throws Exception {
    final BGPActivator act = new BGPActivator(true, ServiceLoaderRSVPExtensionProviderContext.getSingletonInstance().getRsvpRegistry());
    final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
    assertNull(context.getAddressFamilyRegistry().classForFamily(16388));
    assertNull(context.getSubsequentAddressFamilyRegistry().classForFamily(71));
    act.start(context);
    assertEquals(LinkstateAddressFamily.class, context.getAddressFamilyRegistry().classForFamily(16388));
    assertEquals(LinkstateSubsequentAddressFamily.class, context.getSubsequentAddressFamilyRegistry().classForFamily(71));
    act.close();
}
Also used : SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) BGPActivator(org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator) Test(org.junit.Test)

Example 12 with BGPExtensionProviderContext

use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.

the class BGPTestTool method initializeActivator.

private static BGPDispatcher initializeActivator() {
    final BGPActivator activator = new BGPActivator();
    final BGPExtensionProviderContext ctx = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
    activator.start(ctx);
    final org.opendaylight.protocol.bgp.inet.BGPActivator inetActivator = new org.opendaylight.protocol.bgp.inet.BGPActivator();
    inetActivator.start(ctx);
    final org.opendaylight.protocol.bgp.evpn.impl.BGPActivator evpnActivator = new org.opendaylight.protocol.bgp.evpn.impl.BGPActivator();
    evpnActivator.start(ctx);
    final SimpleFlowspecExtensionProviderContext fsContext = new SimpleFlowspecExtensionProviderContext();
    final FlowspecActivator flowspecActivator = new FlowspecActivator(fsContext);
    final org.opendaylight.protocol.bgp.flowspec.BGPActivator flowspecBGPActivator = new org.opendaylight.protocol.bgp.flowspec.BGPActivator(flowspecActivator);
    flowspecBGPActivator.start(ctx);
    final org.opendaylight.protocol.bgp.labeled.unicast.BGPActivator labeledActivator = new org.opendaylight.protocol.bgp.labeled.unicast.BGPActivator();
    labeledActivator.start(ctx);
    final org.opendaylight.protocol.bgp.l3vpn.ipv4.BgpIpv4Activator bgpIpv4Activator = new org.opendaylight.protocol.bgp.l3vpn.ipv4.BgpIpv4Activator();
    bgpIpv4Activator.start(ctx);
    final org.opendaylight.protocol.bgp.l3vpn.ipv6.BgpIpv6Activator bgpIpv6Activator = new org.opendaylight.protocol.bgp.l3vpn.ipv6.BgpIpv6Activator();
    bgpIpv6Activator.start(ctx);
    return new BGPDispatcherImpl(ctx.getMessageRegistry(), new NioEventLoopGroup(), new NioEventLoopGroup(), new StrictBGPPeerRegistry());
}
Also used : FlowspecActivator(org.opendaylight.protocol.bgp.flowspec.FlowspecActivator) BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) ServiceLoaderBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext) StrictBGPPeerRegistry(org.opendaylight.protocol.bgp.rib.impl.StrictBGPPeerRegistry) SimpleFlowspecExtensionProviderContext(org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) BGPActivator(org.opendaylight.protocol.bgp.parser.impl.BGPActivator) BGPDispatcherImpl(org.opendaylight.protocol.bgp.rib.impl.BGPDispatcherImpl)

Example 13 with BGPExtensionProviderContext

use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.

the class BmpMonitorImplTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    doAnswer(invocationOnMock -> {
        BmpMonitorImplTest.this.singletonService = (ClusterSingletonService) invocationOnMock.getArguments()[0];
        this.singletonService.instantiateServiceInstance();
        return BmpMonitorImplTest.this.singletonServiceRegistration;
    }).when(this.clusterSSProv).registerClusterSingletonService(any(ClusterSingletonService.class));
    doAnswer(invocationOnMock -> BmpMonitorImplTest.this.singletonService.closeServiceInstance()).when(this.singletonServiceRegistration).close();
    doAnswer(invocationOnMock -> {
        this.singletonService2 = (ClusterSingletonService) invocationOnMock.getArguments()[0];
        this.singletonService2.instantiateServiceInstance();
        return BmpMonitorImplTest.this.singletonServiceRegistration2;
    }).when(this.clusterSSProv2).registerClusterSingletonService(any(ClusterSingletonService.class));
    doAnswer(invocationOnMock -> BmpMonitorImplTest.this.singletonService2.closeServiceInstance()).when(this.singletonServiceRegistration2).close();
    this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
    final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(InitiationMessage.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(CParameters1.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpParameters.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MultiprotocolCapability.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(DestinationIpv4Case.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(AdvertizedRoutes.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(SentOpen.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(ReceivedOpen.class));
    this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
    this.ribActivator = new RIBActivator();
    this.ribExtension = new SimpleRIBExtensionProviderContext();
    this.ribActivator.startRIBExtensionProvider(this.ribExtension);
    this.bgpActivator = new BGPActivator();
    final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
    this.bgpActivator.start(context);
    final SimpleBmpExtensionProviderContext ctx = new SimpleBmpExtensionProviderContext();
    this.bmpActivator = new BmpActivator(context);
    this.bmpActivator.start(ctx);
    this.msgRegistry = ctx.getBmpMessageRegistry();
    this.dispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), ctx.getBmpMessageRegistry(), new DefaultBmpSessionFactory());
    final InetSocketAddress inetAddress = new InetSocketAddress(InetAddresses.forString(MONITOR_LOCAL_ADDRESS), MONITOR_LOCAL_PORT);
    final DOMDataWriteTransaction wTx = getDomBroker().newWriteOnlyTransaction();
    final ContainerNode parentNode = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(BmpMonitor.QNAME)).addChild(ImmutableNodes.mapNodeBuilder(Monitor.QNAME).build()).build();
    wTx.merge(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.of(BmpMonitor.QNAME), parentNode);
    wTx.submit();
    final BmpDeployerDependencies bmpDependecies = new BmpDeployerDependencies(getDataBroker(), getDomBroker(), this.ribExtension, this.mappingService.getCodecFactory(), getSchemaContext(), this.clusterSSProv);
    this.bmpApp = new BmpMonitoringStationImpl(bmpDependecies, this.dispatcher, MONITOR_ID, inetAddress, null);
    readDataOperational(getDataBroker(), BMP_II, monitor -> {
        assertEquals(1, monitor.getMonitor().size());
        final Monitor bmpMonitor = monitor.getMonitor().get(0);
        assertEquals(MONITOR_ID, bmpMonitor.getMonitorId());
        assertEquals(0, bmpMonitor.getRouter().size());
        assertEquals(MONITOR_ID, bmpMonitor.getMonitorId());
        assertEquals(0, bmpMonitor.getRouter().size());
        return monitor;
    });
}
Also used : AdvertizedRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes) RIBActivator(org.opendaylight.protocol.bgp.inet.RIBActivator) SimpleBmpExtensionProviderContext(org.opendaylight.protocol.bmp.spi.registry.SimpleBmpExtensionProviderContext) BindingToNormalizedNodeCodec(org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec) InetSocketAddress(java.net.InetSocketAddress) BindingNormalizedNodeCodecRegistry(org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry) CParameters1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.CParameters1) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) BmpMonitor(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.BmpMonitor) Monitor(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.bmp.monitor.Monitor) BmpDeployerDependencies(org.opendaylight.protocol.bmp.impl.config.BmpDeployerDependencies) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) BmpActivator(org.opendaylight.protocol.bmp.parser.BmpActivator) BGPActivator(org.opendaylight.protocol.bgp.parser.impl.BGPActivator) ReceivedOpen(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.ReceivedOpen) ModuleInfoBackedContext(org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext) InitiationMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.InitiationMessage) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) BmpDispatcherImpl(org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl) MultiprotocolCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapability) SentOpen(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.peer.up.SentOpen) ClusterSingletonService(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) DefaultBmpSessionFactory(org.opendaylight.protocol.bmp.impl.session.DefaultBmpSessionFactory) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction) DestinationIpv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4Case) Before(org.junit.Before)

Example 14 with BGPExtensionProviderContext

use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.

the class BmpDispatcherImplTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    doNothing().when(this.mockedSession).handlerRemoved(any(ChannelHandlerContext.class));
    doNothing().when(this.mockedSession).handlerAdded(any(ChannelHandlerContext.class));
    doNothing().when(this.mockedSession).channelRegistered(any(ChannelHandlerContext.class));
    doNothing().when(this.mockedSession).channelActive(any(ChannelHandlerContext.class));
    doNothing().when(this.mockedSession).channelInactive(any(ChannelHandlerContext.class));
    doNothing().when(this.mockedSession).channelUnregistered(any(ChannelHandlerContext.class));
    doNothing().when(this.mockedSession).channelReadComplete(any(ChannelHandlerContext.class));
    this.bgpActivator = new BGPActivator();
    final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
    this.bgpActivator.start(context);
    final SimpleBmpExtensionProviderContext ctx = new SimpleBmpExtensionProviderContext();
    this.bmpActivator = new BmpActivator(context);
    this.bmpActivator.start(ctx);
    final BmpMessageRegistry messageRegistry = ctx.getBmpMessageRegistry();
    this.dispatcher = new BmpDispatcherImpl(new NioEventLoopGroup(), new NioEventLoopGroup(), messageRegistry, (channel, sessionListenerFactory) -> BmpDispatcherImplTest.this.mockedSession);
}
Also used : CheckUtil.checkEquals(org.opendaylight.protocol.util.CheckUtil.checkEquals) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) Mock(org.mockito.Mock) BmpMessageRegistry(org.opendaylight.protocol.bmp.spi.registry.BmpMessageRegistry) BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) Mockito.timeout(org.mockito.Mockito.timeout) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) MockitoAnnotations(org.mockito.MockitoAnnotations) BmpSessionListenerFactory(org.opendaylight.protocol.bmp.api.BmpSessionListenerFactory) After(org.junit.After) BmpActivator(org.opendaylight.protocol.bmp.parser.BmpActivator) Before(org.junit.Before) BmpSession(org.opendaylight.protocol.bmp.api.BmpSession) SimpleBmpExtensionProviderContext(org.opendaylight.protocol.bmp.spi.registry.SimpleBmpExtensionProviderContext) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.doNothing(org.mockito.Mockito.doNothing) InetSocketAddress(java.net.InetSocketAddress) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) BGPActivator(org.opendaylight.protocol.bgp.parser.impl.BGPActivator) Mockito.verify(org.mockito.Mockito.verify) CheckUtil.waitFutureSuccess(org.opendaylight.protocol.util.CheckUtil.waitFutureSuccess) ChannelFuture(io.netty.channel.ChannelFuture) Matchers.any(org.mockito.Matchers.any) Channel(io.netty.channel.Channel) BmpDispatcher(org.opendaylight.protocol.bmp.api.BmpDispatcher) BmpDispatcherImpl(org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl) BmpDispatcherImpl(org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) BGPActivator(org.opendaylight.protocol.bgp.parser.impl.BGPActivator) SimpleBmpExtensionProviderContext(org.opendaylight.protocol.bmp.spi.registry.SimpleBmpExtensionProviderContext) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) BmpMessageRegistry(org.opendaylight.protocol.bmp.spi.registry.BmpMessageRegistry) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) BmpActivator(org.opendaylight.protocol.bmp.parser.BmpActivator) Before(org.junit.Before)

Example 15 with BGPExtensionProviderContext

use of org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext in project bgpcep by opendaylight.

the class PMSITunnelAttributeHandlerTest method setUp.

@Before
public void setUp() {
    final BGPExtensionProviderContext ctx = new SimpleBGPExtensionProviderContext();
    final org.opendaylight.protocol.bgp.parser.impl.BGPActivator inetActivator = new org.opendaylight.protocol.bgp.parser.impl.BGPActivator();
    inetActivator.start(ctx);
    final BGPActivator bgpActivator = new BGPActivator();
    bgpActivator.start(ctx);
    this.handler = ctx.getAttributeRegistry();
}
Also used : SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) BGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext) ServiceLoaderBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext) BGPActivator(org.opendaylight.protocol.bgp.evpn.impl.BGPActivator) Before(org.junit.Before)

Aggregations

BGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext)20 SimpleBGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext)15 Test (org.junit.Test)10 Before (org.junit.Before)7 ServiceLoaderBGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext)6 BGPActivator (org.opendaylight.protocol.bgp.parser.impl.BGPActivator)5 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)4 BmpActivator (org.opendaylight.protocol.bmp.parser.BmpActivator)4 SimpleBmpExtensionProviderContext (org.opendaylight.protocol.bmp.spi.registry.SimpleBmpExtensionProviderContext)4 ByteBuf (io.netty.buffer.ByteBuf)3 BGPActivator (org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator)3 Attributes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.Attributes)3 InetSocketAddress (java.net.InetSocketAddress)2 FlowspecActivator (org.opendaylight.protocol.bgp.flowspec.FlowspecActivator)2 SimpleFlowspecExtensionProviderContext (org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext)2 BmpDispatcherImpl (org.opendaylight.protocol.bmp.impl.BmpDispatcherImpl)2 Channel (io.netty.channel.Channel)1 ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 After (org.junit.After)1