use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.
the class BaseAbstractRouteEntry method removePathFromDataStore.
@SuppressWarnings("unchecked")
private void removePathFromDataStore(final RouteEntryDependenciesContainer entryDep, final Identifier routeKey, final WriteTransaction tx) {
LOG.trace("Best Path removed {}", this.removedBestPath);
final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget = entryDep.getLocRibTableTarget();
final RIBSupport ribSup = entryDep.getRibSupport();
Identifier newRouteKey = ribSup.createNewRouteKey(this.removedBestPath.getPathId(), routeKey);
if (newRouteKey == null) {
newRouteKey = routeKey;
}
final InstanceIdentifier routeTarget = ribSup.createRouteIdentifier(locRibTarget, newRouteKey);
LOG.debug("Delete route from LocRib {}", routeTarget);
tx.delete(LogicalDatastoreType.OPERATIONAL, routeTarget);
fillAdjRibsOut(null, null, newRouteKey, this.removedBestPath.getPeerId(), entryDep, tx);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.
the class BaseAbstractRouteEntry method addPathToDataStore.
@SuppressWarnings("unchecked")
private void addPathToDataStore(final RouteEntryDependenciesContainer entryDep, final Identifier routeKey, final WriteTransaction tx) {
final RIBSupport ribSup = entryDep.getRibSupport();
Identifier newRouteKey = ribSup.createNewRouteKey(this.bestPath.getPathId(), routeKey);
if (newRouteKey == null) {
newRouteKey = routeKey;
}
final Route route = createRoute(ribSup, newRouteKey, this.bestPath.getPathId(), this.bestPath);
LOG.trace("Selected best route {}", route);
final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget = entryDep.getLocRibTableTarget();
final InstanceIdentifier routeTarget = ribSup.createRouteIdentifier(locRibTarget, newRouteKey);
LOG.debug("Write route to LocRib {}", route);
tx.put(LogicalDatastoreType.OPERATIONAL, routeTarget, route);
fillAdjRibsOut(this.bestPath.getAttributes(), route, newRouteKey, this.bestPath.getPeerId(), entryDep, tx);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.
the class AdjRibsInWriterTest method testTransform.
@Test
public void testTransform() {
this.writer = AdjRibInWriter.create(YangInstanceIdentifier.of(Rib.QNAME), PeerRole.Ebgp, this.chain);
assertNotNull(this.writer);
final YangInstanceIdentifier peerPath = YangInstanceIdentifier.builder().node(Rib.QNAME).node(Peer.QNAME).nodeWithKey(Peer.QNAME, AdjRibInWriter.PEER_ID_QNAME, this.peerIp).build();
this.writer.transform(new PeerId(this.peerIp), this.registry, this.tableTypes, ADD_PATH_TABLE_MAPS);
verifyPeerSkeletonInsertedCorrectly(peerPath);
// verify supported tables were inserted for ipv4
Mockito.verify(this.tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.eq(peerPath.node(SupportedTables.QNAME).node(RibSupportUtils.toYangKey(SupportedTables.QNAME, K4))), Mockito.any(NormalizedNode.class));
verifyUptodateSetToFalse(peerPath);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.
the class BGPPeer method onSessionUp.
@Override
public synchronized void onSessionUp(final BGPSession session) {
this.session = session;
if (this.session instanceof BGPSessionStateProvider) {
((BGPSessionStateProvider) this.session).registerMessagesCounter(this);
}
final List<AddressFamilies> addPathTablesType = session.getAdvertisedAddPathTableTypes();
final Set<BgpTableType> advertizedTableTypes = session.getAdvertisedTableTypes();
final List<BgpTableType> advertizedGracefulRestartTableTypes = session.getAdvertisedGracefulRestartTableTypes();
LOG.info("Session with peer {} went up with tables {} and Add Path tables {}", this.name, advertizedTableTypes, addPathTablesType);
this.rawIdentifier = InetAddresses.forString(session.getBgpId().getValue()).getAddress();
final Set<TablesKey> setTables = advertizedTableTypes.stream().map(t -> new TablesKey(t.getAfi(), t.getSafi())).collect(Collectors.toSet());
this.tables = ImmutableSet.copyOf(setTables);
setAdvertizedGracefulRestartTableTypes(advertizedGracefulRestartTableTypes.stream().map(t -> new TablesKey(t.getAfi(), t.getSafi())).collect(Collectors.toList()));
this.addPathTableMaps = ImmutableMap.copyOf(mapTableTypesFamilies(addPathTablesType));
this.trackerRegistration = this.rib.getPeerTracker().registerPeer(this);
for (final TablesKey key : this.tables) {
createAdjRibOutListener(key, true);
}
addBgp4Support();
this.effRibInWriter = EffectiveRibInWriter.create(this, this.rib, this.rib.createPeerChain(this), this.peerIId, this.tables);
registerPrefixesCounters(this.effRibInWriter, this.effRibInWriter);
this.ribWriter = this.ribWriter.transform(this.peerId, this.rib.getRibSupportContext(), this.tables, this.addPathTableMaps);
if (this.rpcRegistry != null) {
this.rpcRegistration = this.rpcRegistry.addRoutedRpcImplementation(BgpPeerRpcService.class, new BgpPeerRpc(this, session, this.tables));
final KeyedInstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer, PeerKey> path = this.rib.getInstanceIdentifier().child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer.class, new PeerKey(this.peerId));
this.rpcRegistration.registerPath(PeerContext.class, path);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.graceful.restart.capability.Tables in project bgpcep by opendaylight.
the class LocRibWriter method update.
@SuppressWarnings("unchecked")
private Map<RouteUpdateKey, RouteEntry> update(final WriteTransaction tx, final Collection<DataTreeModification<Tables>> changes) {
final Map<RouteUpdateKey, RouteEntry> ret = new HashMap<>();
for (final DataTreeModification<Tables> tc : changes) {
final DataObjectModification<Tables> table = tc.getRootNode();
final DataTreeIdentifier<Tables> rootPath = tc.getRootPath();
final KeyedInstanceIdentifier<Peer, PeerKey> peerKIid = (KeyedInstanceIdentifier<Peer, PeerKey>) rootPath.getRootIdentifier().firstIdentifierOf(Peer.class);
final UnsignedInteger peerUuid = RouterIds.routerIdForPeerId(peerKIid.getKey().getPeerId());
/*
Initialize Peer with routes under loc rib
*/
if (!this.routeEntries.isEmpty() && table.getDataBefore() == null) {
final org.opendaylight.protocol.bgp.rib.spi.Peer peer = this.peerTracker.getPeer(peerKIid.getKey().getPeerId());
if (peer != null && peer.supportsTable(this.entryDep.getLocalTablesKey())) {
LOG.debug("Peer {} table has been created, inserting existent routes", peer.getPeerId());
this.routeEntries.forEach((key, value) -> value.initializeBestPaths(this.entryDep, new RouteEntryInfoImpl(peer, key), tx));
}
}
/*
Process new routes from Peer
*/
updateNodes(table, peerUuid, tx, ret);
}
return ret;
}
Aggregations