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