use of com.google.cloud.compute.v1.Route in project bgpcep by opendaylight.
the class LocRibWriter method updateRoutesEntries.
@SuppressWarnings("unchecked")
private void updateRoutesEntries(final Collection<DataObjectModification<? extends DataObject>> routeChanges, final UnsignedInteger routerId, final Map<RouteUpdateKey, RouteEntry> routes) {
for (final DataObjectModification<? extends DataObject> route : routeChanges) {
final Identifier routeKey = ((InstanceIdentifier.IdentifiableItem) route.getIdentifier()).getKey();
RouteEntry entry = this.routeEntries.get(routeKey);
final Route newRoute = (Route) route.getDataAfter();
final Route oldRoute = (Route) route.getDataBefore();
if (newRoute != null) {
if (entry == null) {
entry = createEntry(routeKey);
}
final long pathId = this.ribSupport.extractPathId(newRoute);
entry.addRoute(routerId, pathId, newRoute);
this.totalPathsCounter.increment();
} else if (oldRoute != null && entry != null) {
this.totalPathsCounter.decrement();
final long pathId = this.ribSupport.extractPathId(oldRoute);
if (entry.removeRoute(routerId, pathId)) {
this.routeEntries.remove(routeKey);
this.totalPrefixesCounter.decrement();
LOG.trace("Removed route from {}", routerId);
}
}
final RouteUpdateKey routeUpdateKey = new RouteUpdateKey(routerId, routeKey);
LOG.debug("Updated route {} entry {}", routeKey, entry);
routes.put(routeUpdateKey, entry);
}
}
use of com.google.cloud.compute.v1.Route in project bgpcep by opendaylight.
the class AddPathAbstractRouteEntry method writeRoutePath.
@SuppressWarnings("unchecked")
private void writeRoutePath(final RouteEntryInfo entryInfo, final boolean destPeerSupAddPath, final AddPathBestPath path, final TablesKey localTK, final RouteEntryDependenciesContainer routeEntryDep, final WriteTransaction tx) {
final Identifier routeKey = entryInfo.getRouteKey();
final RIBSupport ribSupport = routeEntryDep.getRibSupport();
final BGPRouteEntryExportParameters baseExp = new BGPRouteEntryExportParametersImpl(this.peerTracker.getPeer(path.getPeerId()), entryInfo.getToPeer());
final Optional<Attributes> effAttrib = routeEntryDep.getRoutingPolicies().applyExportPolicies(baseExp, path.getAttributes());
Identifier newRouteKey = ribSupport.createNewRouteKey(destPeerSupAddPath ? path.getPathId() : NON_PATH_ID_VALUE, routeKey);
final Peer toPeer = entryInfo.getToPeer();
final Route route = createRoute(ribSupport, newRouteKey, destPeerSupAddPath ? path.getPathId() : NON_PATH_ID_VALUE, path);
InstanceIdentifier ribOutIId = ribSupport.createRouteIdentifier(toPeer.getRibOutIId(localTK), newRouteKey);
if (effAttrib.isPresent() && route != null) {
LOG.debug("Write route {} to peer AdjRibsOut {}", route, toPeer.getPeerId());
tx.put(LogicalDatastoreType.OPERATIONAL, ribOutIId, route);
tx.put(LogicalDatastoreType.OPERATIONAL, ribOutIId.child(Attributes.class), effAttrib.get());
}
}
use of com.google.cloud.compute.v1.Route in project bgpcep by opendaylight.
the class AddPathAbstractRouteEntry method addPathToDataStore.
private void addPathToDataStore(final RouteEntryDependenciesContainer entryDep, final AddPathBestPath path, final boolean isFirstBestPath, final Identifier routeKey, final WriteTransaction tx) {
final RIBSupport ribSup = entryDep.getRibSupport();
final Identifier routeKeyAddPath = ribSup.createNewRouteKey(path.getPathId(), routeKey);
final Identifier routeKeyAddNonPath = ribSup.createNewRouteKey(NON_PATH_ID_VALUE, routeKey);
final Route routeAddPath = createRoute(ribSup, routeKeyAddPath, path.getPathId(), path);
final Route routeNonAddPath = createRoute(ribSup, routeKeyAddNonPath, NON_PATH_ID_VALUE, path);
final KeyedInstanceIdentifier<Tables, TablesKey> locRibTarget = entryDep.getLocRibTableTarget();
final InstanceIdentifier routeTarget = ribSup.createRouteIdentifier(locRibTarget, routeKeyAddPath);
LOG.debug("Write route to LocRib {}", routeAddPath);
tx.put(LogicalDatastoreType.OPERATIONAL, routeTarget, routeAddPath);
fillAdjRibsOut(isFirstBestPath, path.getAttributes(), routeNonAddPath, routeAddPath, routeKeyAddNonPath, routeKeyAddPath, path.getPeerId(), entryDep.getLocalTablesKey(), entryDep, tx);
}
use of com.google.cloud.compute.v1.Route in project bgpcep by opendaylight.
the class ComplexRouteEntry method createRoute.
@Override
public Route createRoute(final RIBSupport ribSup, final Identifier routeKey, final long pathId, final AddPathBestPath path) {
final OffsetMap map = getOffsets();
final Route route = map.getValue(this.values, map.offsetOf(path.getRouteKey()));
return ribSup.createRoute(route, routeKey, pathId, path.getAttributes());
}
use of com.google.cloud.compute.v1.Route in project bgpcep by opendaylight.
the class ComplexRouteEntry method createRoute.
@Override
public Route createRoute(final RIBSupport ribSup, Identifier routeKey, final long pathId, final BaseBestPath path) {
final OffsetMap map = getOffsets();
final Route route = map.getValue(this.values, map.offsetOf(path.getRouterId()));
return ribSup.createRoute(route, routeKey, pathId, path.getAttributes());
}
Aggregations