use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.
the class GracefulRestartUtilTest method getLlGracefulCapabilityTest.
@Test
public void getLlGracefulCapabilityTest() {
final Set<BgpPeerUtil.LlGracefulRestartDTO> llGracefulRestartDTOs = new HashSet<>();
llGracefulRestartDTOs.add(new BgpPeerUtil.LlGracefulRestartDTO(IPV4_KEY, STALE_TIME, true));
llGracefulRestartDTOs.add(new BgpPeerUtil.LlGracefulRestartDTO(IPV6_KEY, STALE_TIME, false));
CParameters capability = GracefulRestartUtil.getLlGracefulCapability(llGracefulRestartDTOs);
final CParameters1 params = capability.augmentation(CParameters1.class);
assertNotNull(params);
final LlGracefulRestartCapability llGracefulCapability = params.getLlGracefulRestartCapability();
assertNotNull(llGracefulCapability);
final var tables = llGracefulCapability.getTables();
assertNotNull(tables);
assertEquals(2, tables.size());
assertEquals(STALE_TIME, tables.values().iterator().next().getLongLivedStaleTime().getValue().intValue());
tables.values().forEach(table -> {
assertTrue(isSameKey(IPV4_KEY, table.key()) && table.getAfiFlags().getForwardingState() || isSameKey(IPV6_KEY, table.key()) && !table.getAfiFlags().getForwardingState());
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.
the class GracefulRestartUtilTest method getGracefulCapabilityTest.
@Test
public void getGracefulCapabilityTest() {
final Map<TablesKey, Boolean> gracefulMap = new HashMap<>();
gracefulMap.put(IPV4_KEY, true);
gracefulMap.put(IPV6_KEY, false);
CParameters capability = GracefulRestartUtil.getGracefulCapability(gracefulMap, RESTART_TIME, RESTARTING);
final CParameters1 params = capability.augmentation(CParameters1.class);
assertNotNull(params);
final GracefulRestartCapability gracefulCapability = params.getGracefulRestartCapability();
assertNotNull(gracefulCapability);
assertTrue(gracefulCapability.getRestartFlags().getRestartState());
assertEquals(RESTART_TIME, gracefulCapability.getRestartTime().intValue());
final var tables = gracefulCapability.getTables();
assertNotNull(tables);
assertEquals(2, tables.size());
tables.values().forEach(table -> {
assertTrue(isSameKey(IPV4_KEY, table.key()) && table.getAfiFlags().getForwardingState() || isSameKey(IPV6_KEY, table.key()) && !table.getAfiFlags().getForwardingState());
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables 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.Tables in project bgpcep by opendaylight.
the class BgpPeer method getBgpParameters.
private static List<BgpParameters> getBgpParameters(final AfiSafis afiSafis, final RIB rib, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
final List<BgpParameters> tlvs = new ArrayList<>();
final List<OptionalCapabilities> caps = new ArrayList<>();
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(rib.getLocalAs()).build()).build()).build());
caps.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
caps.add(new OptionalCapabilitiesBuilder().setCParameters(MultiprotocolCapabilitiesUtil.RR_CAPABILITY).build());
final List<AfiSafi> afiSafi = OpenConfigMappingUtil.getAfiSafiWithDefault(afiSafis, false);
final List<AddressFamilies> addPathCapability = OpenConfigMappingUtil.toAddPathCapability(afiSafi, tableTypeRegistry);
if (!addPathCapability.isEmpty()) {
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(addPathCapability).build()).build()).build()).build());
}
final List<BgpTableType> tableTypes = OpenConfigMappingUtil.toTableTypes(afiSafi, tableTypeRegistry);
for (final BgpTableType tableType : tableTypes) {
if (!rib.getLocalTables().contains(tableType)) {
LOG.info("RIB instance does not list {} " + "in its local tables. Incoming data will be dropped.", tableType);
}
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder(tableType).build()).build()).build()).build());
}
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(caps).build());
return tlvs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.
the class LocRibWriter method updateNodes.
@SuppressWarnings("unchecked")
private void updateNodes(final DataObjectModification<Tables> table, final UnsignedInteger peerUuid, final WriteTransaction tx, final Map<RouteUpdateKey, RouteEntry> routes) {
final DataObjectModification<Attributes> attUpdate = table.getModifiedChildContainer(Attributes.class);
if (attUpdate != null && attUpdate.getDataAfter() != null) {
final Attributes newAttValue = attUpdate.getDataAfter();
LOG.trace("Uptodate found for {}", newAttValue);
tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTableIID.child(Attributes.class), newAttValue);
}
final DataObjectModification routesChangesContainer = table.getModifiedChildContainer(this.ribSupport.routesContainerClass());
if (routesChangesContainer == null) {
return;
}
updateRoutesEntries(routesChangesContainer.getModifiedChildren(), peerUuid, routes);
}
Aggregations