- }
-
- private void writeRoutePath(final RouteEntryInfo entryInfo, final PeerExportGroup peerGroup,
- final boolean destPeerSupAddPath, final AddPathBestPath path,
- final TablesKey localTK, final RIBSupport ribSup, final DOMDataWriteTransaction tx) {
- final NodeIdentifierWithPredicates routeId = entryInfo.getRouteId();
- final Peer fromPeer = this.peerTracker.getPeer(path.getPeerId());
- final ContainerNode effectiveAttributes
- = peerGroup.effectiveAttributes(fromPeer.getRole(), path.getAttributes());
- final NodeIdentifierWithPredicates routeIdAddPath = ribSup
- .getRouteIdAddPath(destPeerSupAddPath ? path.getPathId() : NON_PATH_ID, routeId);
-
- writeRoute(entryInfo.getToPeerId(), getAdjRibOutYII(ribSup, entryInfo.getRootPath(), routeIdAddPath, localTK),
- effectiveAttributes, createValue(routeIdAddPath, path), ribSup, tx);
- }
-
- private void addPathToDataStore(final RouteEntryDependenciesContainer entryDependencies, final AddPathBestPath path,
- final boolean isFirstBestPath, final NodeIdentifierWithPredicates routeIdPA,
- final ExportPolicyPeerTracker peerPT, final DOMDataWriteTransaction tx) {
- final RIBSupport ribSup = entryDependencies.getRibSupport();
- final NodeIdentifierWithPredicates routeIdAddPath = ribSup.getRouteIdAddPath(path.getPathId(), routeIdPA);
- final NodeIdentifierWithPredicates routeIdAddPathDefault = ribSup.getRouteIdAddPath(NON_PATH_ID, routeIdPA);
- final YangInstanceIdentifier pathAddPathTarget = ribSup.routePath(entryDependencies.getLocRibTableTarget()
- .node(ROUTES_IDENTIFIER), routeIdAddPath);
- final MapEntryNode addPathValue = createValue(routeIdAddPath, path);
- final MapEntryNode defaultValue = createValue(routeIdAddPathDefault, path);
- LOG.trace("Selected best value {}", addPathValue);
- fillLocRib(pathAddPathTarget, addPathValue, tx);
- fillAdjRibsOut(isFirstBestPath, path.getAttributes(), defaultValue, addPathValue, routeIdAddPathDefault,
- routeIdAddPath, path.getPeerId(), peerPT, entryDependencies.getLocalTablesKey(), ribSup, tx);
- }
-
- private void fillAdjRibsOut(final boolean isFirstBestPath, final ContainerNode attributes,
- final MapEntryNode defaultValue, final MapEntryNode addPathValue,
- final PathArgument routeIdAddPathDefault,
- final PathArgument routeIdAddPath, final PeerId routePeerId, final ExportPolicyPeerTracker peerPT,
- final TablesKey localTK, final RIBSupport ribSup, final DOMDataWriteTransaction tx) {
- /*
- * We need to keep track of routers and populate adj-ribs-out, too. If we do not, we need to
- * expose from which client a particular route was learned from in the local RIB, and have
- * the listener perform filtering.
- *
- * We walk the policy set in order to minimize the amount of work we do for multiple peers:
- * if we have two eBGP peers, for example, there is no reason why we should perform the translation
- * multiple times.
- */
- for (final PeerRole role : PeerRole.values()) {
- final PeerExportGroup peerGroup = peerPT.getPeerGroup(role);
- if (peerGroup != null) {
- final Peer fromPeer = this.peerTracker.getPeer(routePeerId);
- final ContainerNode effectiveAttributes = peerGroup.effectiveAttributes(
- fromPeer.getRole(), attributes);
- peerGroup.forEach((destPeer, rootPath) -> {
- final boolean destPeerSupAddPath = peerPT.isAddPathSupportedByPeer(destPeer);
- if (filterRoutes(routePeerId, destPeer, localTK)
- && peersSupportsAddPathOrIsFirstBestPath(destPeerSupAddPath, isFirstBestPath)) {
- if (destPeerSupAddPath) {
- update(destPeer, getAdjRibOutYII(ribSup, rootPath, routeIdAddPath, localTK),
- effectiveAttributes, addPathValue, ribSup, tx);
- } else if (!this.oldNonAddPathBestPathTheSame) {
- update(destPeer, getAdjRibOutYII(ribSup, rootPath, routeIdAddPathDefault, localTK),
- effectiveAttributes, defaultValue, ribSup, tx);
- }
- }
- });
- }