use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.
the class GracefulRestartUtilTest method getGracefulBgpParametersTest.
@Test
public void getGracefulBgpParametersTest() {
final OptionalCapabilities cap1 = new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build();
final OptionalCapabilities cap2 = new OptionalCapabilitiesBuilder().setCParameters(MultiprotocolCapabilitiesUtil.RR_CAPABILITY).build();
final List<OptionalCapabilities> fixedCaps = new ArrayList<>();
fixedCaps.add(cap1);
fixedCaps.add(cap2);
final Set<TablesKey> gracefulTables = new HashSet<>();
gracefulTables.add(IPV4_KEY);
gracefulTables.add(IPV6_KEY);
final Set<TablesKey> preservedTables = new HashSet<>();
preservedTables.add(IPV4_KEY);
final Map<TablesKey, Boolean> gracefulMap = new HashMap<>();
gracefulMap.put(IPV4_KEY, true);
gracefulMap.put(IPV6_KEY, false);
final OptionalCapabilities expectedGracefulCapability = new OptionalCapabilitiesBuilder().setCParameters(GracefulRestartUtil.getGracefulCapability(gracefulMap, RESTART_TIME, RESTARTING)).build();
final Set<BgpPeerUtil.LlGracefulRestartDTO> llGracefulDTOs = Collections.singleton(new BgpPeerUtil.LlGracefulRestartDTO(IPV4_KEY, STALE_TIME, true));
final OptionalCapabilities expectedLlGracefulCapability = new OptionalCapabilitiesBuilder().setCParameters(GracefulRestartUtil.getLlGracefulCapability(llGracefulDTOs)).build();
final BgpParameters parameters = GracefulRestartUtil.getGracefulBgpParameters(fixedCaps, gracefulTables, preservedTables, RESTART_TIME, RESTARTING, llGracefulDTOs);
final List<OptionalCapabilities> capabilities = parameters.getOptionalCapabilities();
assertTrue(capabilities != null);
assertEquals(4, capabilities.size());
assertTrue(capabilities.contains(cap1));
assertTrue(capabilities.contains(cap2));
assertTrue(capabilities.contains(expectedGracefulCapability));
assertTrue(capabilities.contains(expectedLlGracefulCapability));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.
the class SimpleRIBExtensionProviderContext method registerRIBSupport.
@Override
public <T extends RIBSupport<?, ?>> RIBSupportRegistration<T> registerRIBSupport(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final T support) {
final TablesKey key = new TablesKey(afi, safi);
final RIBSupport<?, ?> prev = this.supports.putIfAbsent(key, support);
checkArgument(prev == null, "AFI %s SAFI %s is already registered with %s", afi, safi, prev);
this.domSupports.put(RibSupportUtils.toYangTablesKey(afi, safi), support);
return new AbstractRIBSupportRegistration<>(support) {
@Override
protected void removeRegistration() {
// FIXME: clean up registrations, too
SimpleRIBExtensionProviderContext.this.supports.remove(key);
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.
the class LinkstateTopologyBuilderTest method setUp.
@Before
@Override
public void setUp() {
super.setUp();
this.linkstateTopoBuilder = new LinkstateTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID, LISTENER_RESTART_TIME, LISTENER_ENFORCE_COUNTER);
this.linkstateTopoBuilder.start();
this.tablePathIID = LOC_RIB_REF.getInstanceIdentifier().builder().child(LocRib.class).child(Tables.class, new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class)).build();
this.linkstateNodeRouteKey = getLinkstateRouteKey("node-route");
this.linkstatePrefixRouteKey = getLinkstateRouteKey("prefix-route");
this.linkstateLinkRouteKey = getLinkstateRouteKey("link-route");
this.linkstateNodeRouteIID = createLinkstateRouteIID(this.linkstateNodeRouteKey);
this.linkstatePrefixRouteIID = createLinkstateRouteIID(this.linkstatePrefixRouteKey);
this.linkstateLinkRouteIID = createLinkstateRouteIID(this.linkstateLinkRouteKey);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.
the class AbstractTopologyBuilder method registerDataChangeListener.
/**
* Register to data tree change listener.
*/
private synchronized void registerDataChangeListener() {
Preconditions.checkState(this.listenerRegistration == null, "Topology Listener on topology %s has been registered before.", this.getInstanceIdentifier());
final InstanceIdentifier<Tables> tablesId = this.locRibReference.getInstanceIdentifier().child(LocRib.class).child(Tables.class, new TablesKey(this.afi, this.safi));
final DataTreeIdentifier<T> id = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, getRouteWildcard(tablesId));
this.listenerRegistration = this.dataProvider.registerDataTreeChangeListener(id, this);
LOG.debug("Registered listener {} on topology {}. Timestamp={}", this, this.getInstanceIdentifier(), this.listenerScheduledRestartTime);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesKey in project bgpcep by opendaylight.
the class BmpRibInWriter method addRoutes.
private synchronized void addRoutes(final MpReachNlri nlri, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes attributes) {
final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi());
final TableContext ctx = this.tables.get(key);
if (ctx == null) {
LOG.debug("No table for {}, not accepting NLRI {}", key, nlri);
return;
}
final DOMDataTreeWriteTransaction tx = this.chain.newWriteOnlyTransaction();
ctx.writeRoutes(tx, nlri, attributes);
LOG.trace("Write routes {}", nlri);
tx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
LOG.trace("Successful commit");
}
@Override
public void onFailure(final Throwable trw) {
LOG.error("Failed commit", trw);
}
}, MoreExecutors.directExecutor());
}
Aggregations