Search in sources :

Example 1 with SimpleRIBExtensionProviderContext

use of org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext in project bgpcep by opendaylight.

the class AbstractAddPathTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    this.ribActivator = new RIBActivator();
    this.ribExtension = new SimpleRIBExtensionProviderContext();
    this.ribActivator.startRIBExtensionProvider(this.ribExtension);
    this.bgpActivator = new BGPActivator();
    this.inetActivator = new org.opendaylight.protocol.bgp.inet.BGPActivator();
    this.context = new SimpleBGPExtensionProviderContext();
    this.bgpActivator.start(this.context);
    this.inetActivator.start(this.context);
    this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
    final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
    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(BgpRib.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(Attributes1.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MpReachNlri.class));
    this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
    this.schemaContext = moduleInfoBackedContext.getSchemaContext();
    if (!Epoll.isAvailable()) {
        this.worker = new NioEventLoopGroup();
        this.boss = new NioEventLoopGroup();
    }
    this.serverRegistry = new StrictBGPPeerRegistry();
    this.serverDispatcher = new BGPDispatcherImpl(this.context.getMessageRegistry(), this.boss, this.worker, this.serverRegistry);
    doReturn(Mockito.mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
    this.codecsRegistry = CodecsRegistryImpl.create(this.mappingService.getCodecFactory(), this.ribExtension.getClassLoadingStrategy());
}
Also used : RIBActivator(org.opendaylight.protocol.bgp.inet.RIBActivator) BGPActivator(org.opendaylight.protocol.bgp.parser.impl.BGPActivator) AdvertizedRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes) BindingToNormalizedNodeCodec(org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec) BindingNormalizedNodeCodecRegistry(org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) ModuleInfoBackedContext(org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) MultiprotocolCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapability) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) ClusterSingletonService(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) 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) BgpRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib) Before(org.junit.Before)

Example 2 with SimpleRIBExtensionProviderContext

use of org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext in project bgpcep by opendaylight.

the class AbstractRIBTestSetup method mockRib.

public void mockRib() throws Exception {
    final RIBExtensionProviderContext context = new SimpleRIBExtensionProviderContext();
    final ModuleInfoBackedContext strategy = createClassLoadingStrategy();
    final SchemaContext schemaContext = strategy.tryToCreateSchemaContext().get();
    this.codecFactory = createCodecFactory(strategy, schemaContext);
    final List<BgpTableType> localTables = new ArrayList<>();
    localTables.add(new BgpTableTypeImpl(AFI, SAFI));
    this.a1 = new RIBActivator();
    this.a1.startRIBExtensionProvider(context);
    final CodecsRegistryImpl codecsRegistry = CodecsRegistryImpl.create(this.codecFactory, GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
    mockedMethods();
    doReturn(mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
    this.rib = new RIBImpl(new RibId("test"), new AsNumber(5L), RIB_ID, context, this.dispatcher, codecsRegistry, this.dom, getDataBroker(), this.policies, this.peerTracker, localTables, Collections.singletonMap(new TablesKey(AFI, SAFI), BasePathSelectionModeFactory.createBestPathSelectionStrategy(this.peerTracker)));
    this.rib.onGlobalContextUpdated(schemaContext);
    this.ribSupport = getRib().getRibSupportContext().getRIBSupport(KEY);
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) RIBActivator(org.opendaylight.protocol.bgp.inet.RIBActivator) ArrayList(java.util.ArrayList) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) ModuleInfoBackedContext(org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) RibId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.RibId) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) RIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) ClusterSingletonService(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService) SchemaContext(org.opendaylight.yangtools.yang.model.api.SchemaContext) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)

Example 3 with SimpleRIBExtensionProviderContext

use of org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext in project bgpcep by opendaylight.

the class ParserToSalTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    final String hexMessages = "/bgp_hex.txt";
    final List<byte[]> bgpMessages = HexDumpBGPFileParser.parseMessages(ParserToSalTest.class.getResourceAsStream(hexMessages));
    this.mock = new BGPMock(new EventBus("test"), ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry(), Lists.newArrayList(fixMessages(bgpMessages)));
    Mockito.doReturn(GlobalEventExecutor.INSTANCE.newSucceededFuture(null)).when(this.dispatcher).createReconnectingClient(Mockito.any(InetSocketAddress.class), Mockito.anyInt(), Mockito.any(KeyMapping.class));
    this.ext1 = new SimpleRIBExtensionProviderContext();
    this.ext2 = new SimpleRIBExtensionProviderContext();
    this.baseact = new RIBActivator();
    this.lsact = new org.opendaylight.protocol.bgp.linkstate.impl.RIBActivator();
    this.baseact.startRIBExtensionProvider(this.ext1);
    this.lsact.startRIBExtensionProvider(this.ext2);
    this.codecsRegistry = CodecsRegistryImpl.create(this.bindingCodecTreeFactory, GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy());
}
Also used : RIBActivator(org.opendaylight.protocol.bgp.inet.RIBActivator) InetSocketAddress(java.net.InetSocketAddress) EventBus(com.google.common.eventbus.EventBus) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) BGPMock(org.opendaylight.protocol.bgp.rib.mock.BGPMock) Before(org.junit.Before)

Example 4 with SimpleRIBExtensionProviderContext

use of org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext 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 5 with SimpleRIBExtensionProviderContext

use of org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext in project bgpcep by opendaylight.

the class RIBActivatorTest method testRIBActivator.

@Test
public void testRIBActivator() {
    final RIBActivator ribAct = new RIBActivator();
    final RIBExtensionProviderContext context = new SimpleRIBExtensionProviderContext();
    assertNull(context.getRIBSupport(L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class));
    ribAct.startRIBExtensionProvider(context);
    assertNotNull(context.getRIBSupport(L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class));
    ribAct.close();
}
Also used : SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) L2vpnAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.L2vpnAddressFamily) RIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) EvpnSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.EvpnSubsequentAddressFamily) Test(org.junit.Test)

Aggregations

SimpleRIBExtensionProviderContext (org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext)6 RIBActivator (org.opendaylight.protocol.bgp.inet.RIBActivator)4 Before (org.junit.Before)3 ModuleInfoBackedContext (org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext)3 ClusterSingletonService (org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService)3 RIBExtensionProviderContext (org.opendaylight.protocol.bgp.rib.spi.RIBExtensionProviderContext)3 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)2 InetSocketAddress (java.net.InetSocketAddress)2 Test (org.junit.Test)2 BindingToNormalizedNodeCodec (org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec)2 BindingNormalizedNodeCodecRegistry (org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry)2 ClusterSingletonServiceRegistration (org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration)2 BGPActivator (org.opendaylight.protocol.bgp.parser.impl.BGPActivator)2 SimpleBGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext)2 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)2 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)2 MultiprotocolCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapability)2 AdvertizedRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes)2 EventBus (com.google.common.eventbus.EventBus)1 ArrayList (java.util.ArrayList)1