Search in sources :

Example 1 with AfiSafiType

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType in project bgpcep by opendaylight.

the class TableTypeActivatorTest method testActivator.

@Test
public void testActivator() {
    final TableTypeActivator tableTypeActivator = new TableTypeActivator();
    final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider();
    tableTypeActivator.startBGPTableTypeRegistryProvider(registry);
    final Optional<Class<? extends AfiSafiType>> afiSafiType = registry.getAfiSafiType(IPV4);
    Assert.assertEquals(IPV4LABELLEDUNICAST.class, afiSafiType.get());
    final Optional<Class<? extends AfiSafiType>> afiSafiType2 = registry.getAfiSafiType(IPV6);
    Assert.assertEquals(IPV6LABELLEDUNICAST.class, afiSafiType2.get());
    final Optional<BgpTableType> tableType = registry.getTableType(IPV4LABELLEDUNICAST.class);
    Assert.assertEquals(IPV4, tableType.get());
    final Optional<BgpTableType> tableType2 = registry.getTableType(IPV6LABELLEDUNICAST.class);
    Assert.assertEquals(IPV6, tableType2.get());
    tableTypeActivator.stopBGPTableTypeRegistryProvider();
    tableTypeActivator.close();
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) SimpleBGPTableTypeRegistryProvider(org.opendaylight.protocol.bgp.openconfig.spi.SimpleBGPTableTypeRegistryProvider) AfiSafiType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType) Test(org.junit.Test)

Example 2 with AfiSafiType

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType in project bgpcep by opendaylight.

the class SimpleBGPTableTypeRegistryProvider method registerBGPTableType.

@Override
public synchronized AbstractRegistration registerBGPTableType(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final Class<? extends AfiSafiType> afiSafiType) {
    final BgpTableType tableType = new BgpTableTypeImpl(afi, safi);
    final Class<? extends AfiSafiType> prev = this.tableTypes.putIfAbsent(tableType, afiSafiType);
    Preconditions.checkState(prev == null, "AFI %s SAFI %s is already registered with %s", afi, safi, prev);
    final TablesKey tableKey = new TablesKey(tableType.getAfi(), tableType.getSafi());
    this.tableKeys.put(tableKey, afiSafiType);
    return new AbstractRegistration() {

        @Override
        protected void removeRegistration() {
            synchronized (SimpleBGPTableTypeRegistryProvider.this) {
                SimpleBGPTableTypeRegistryProvider.this.tableTypes.remove(tableType);
                SimpleBGPTableTypeRegistryProvider.this.tableKeys.remove(tableKey);
            }
        }
    };
}
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) AbstractRegistration(org.opendaylight.yangtools.concepts.AbstractRegistration) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)

Example 3 with AfiSafiType

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType in project bgpcep by opendaylight.

the class SimpleBGPTableTypeRegistryProviderTest method testBGPTableTypeRegistryProvider.

@Test
public void testBGPTableTypeRegistryProvider() {
    final Optional<Class<? extends AfiSafiType>> afiSafiType = this.provider.getAfiSafiType(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
    Assert.assertTrue(afiSafiType.isPresent());
    final Optional<Class<? extends AfiSafiType>> afiSafiType2 = this.provider.getAfiSafiType(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class));
    Assert.assertFalse(afiSafiType2.isPresent());
    final Optional<BgpTableType> tableType = this.provider.getTableType(IPV4UNICAST.class);
    Assert.assertTrue(tableType.isPresent());
    final Optional<BgpTableType> tableType2 = this.provider.getTableType(IPV6UNICAST.class);
    Assert.assertFalse(tableType2.isPresent());
    this.registration.close();
    final Optional<BgpTableType> tableType3 = this.provider.getTableType(IPV4UNICAST.class);
    Assert.assertFalse(tableType3.isPresent());
}
Also used : Ipv6AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily) BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily) BgpTableTypeImpl(org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl) AfiSafiType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily) Test(org.junit.Test)

Example 4 with AfiSafiType

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType in project bgpcep by opendaylight.

the class GlobalUtil method buildAfiSafi.

/**
 * Build Afi Safi containing State.
 *
 * @param ribState             containing RIb Operational State
 * @param tablesKey            table Key
 * @param bgpTableTypeRegistry BGP TableType Registry
 * @return Afi Safi Operational State
 */
public static AfiSafi buildAfiSafi(final BGPRibState ribState, final TablesKey tablesKey, final BGPTableTypeRegistryConsumer bgpTableTypeRegistry) {
    final Optional<Class<? extends AfiSafiType>> optAfiSafi = bgpTableTypeRegistry.getAfiSafiType(tablesKey);
    if (!optAfiSafi.isPresent()) {
        return null;
    }
    final State state = new StateBuilder().addAugmentation(GlobalAfiSafiStateAugmentation.class, new GlobalAfiSafiStateAugmentationBuilder().setTotalPaths(ribState.getPathCount(tablesKey)).setTotalPrefixes(ribState.getPrefixesCount(tablesKey)).build()).build();
    return new AfiSafiBuilder().setAfiSafiName(optAfiSafi.get()).setState(state).build();
}
Also used : GlobalAfiSafiStateAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAfiSafiStateAugmentation) AfiSafiBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder) GlobalAfiSafiStateAugmentationBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAfiSafiStateAugmentationBuilder) BGPRibState(org.opendaylight.protocol.bgp.rib.spi.state.BGPRibState) State(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State) StateBuilder(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder) AfiSafiType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType)

Example 5 with AfiSafiType

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType in project bgpcep by opendaylight.

the class TableTypeActivatorTest method testActivator.

@Test
public void testActivator() {
    final TableTypeActivator tableTypeActivator = new TableTypeActivator();
    final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider();
    tableTypeActivator.startBGPTableTypeRegistryProvider(registry);
    final Optional<Class<? extends AfiSafiType>> afiSafiType = registry.getAfiSafiType(EVPN);
    Assert.assertEquals(L2VPNEVPN.class, afiSafiType.get());
    final Optional<BgpTableType> tableType = registry.getTableType(L2VPNEVPN.class);
    Assert.assertEquals(EVPN, tableType.get());
    tableTypeActivator.stopBGPTableTypeRegistryProvider();
    tableTypeActivator.close();
}
Also used : BgpTableType(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType) SimpleBGPTableTypeRegistryProvider(org.opendaylight.protocol.bgp.openconfig.spi.SimpleBGPTableTypeRegistryProvider) AfiSafiType(org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType) Test(org.junit.Test)

Aggregations

AfiSafiType (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType)8 BgpTableType (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType)8 Test (org.junit.Test)7 SimpleBGPTableTypeRegistryProvider (org.opendaylight.protocol.bgp.openconfig.spi.SimpleBGPTableTypeRegistryProvider)6 BgpTableTypeImpl (org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl)2 TableTypeActivator (org.opendaylight.protocol.bgp.linkstate.impl.TableTypeActivator)1 BGPRibState (org.opendaylight.protocol.bgp.rib.spi.state.BGPRibState)1 AfiSafiBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder)1 State (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.State)1 StateBuilder (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder)1 GlobalAfiSafiStateAugmentation (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAfiSafiStateAugmentation)1 GlobalAfiSafiStateAugmentationBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.GlobalAfiSafiStateAugmentationBuilder)1 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)1 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily)1 Ipv6AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily)1 UnicastSubsequentAddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily)1 AbstractRegistration (org.opendaylight.yangtools.concepts.AbstractRegistration)1