- private void addPathToDataStore(final BestPath path, final boolean isFirstBestPath, final PathArgument routeIdPA,
- final YangInstanceIdentifier locRibTarget, final RIBSupport ribSup, final ExportPolicyPeerTracker peerPT,
- final TablesKey localTK, final DOMDataWriteTransaction tx) {
- final PathArgument routeIdAddPath = ribSup.getRouteIdAddPath(path.getPathId(), routeIdPA);
- final YangInstanceIdentifier pathAddPathTarget = ribSup.routePath(locRibTarget.node(ROUTES_IDENTIFIER),
- routeIdAddPath);
- final MapEntryNode addPathValue = createValue(routeIdAddPath, path);
- final MapEntryNode value = createValue(routeIdPA, path);
- LOG.trace("Selected best value {}", addPathValue);
- fillLocRib(pathAddPathTarget, addPathValue, tx);
- fillAdjRibsOut(isFirstBestPath, path.getAttributes(), value, addPathValue, routeIdPA, routeIdAddPath,
- path.getPeerId(), peerPT, localTK,
- ribSup, tx);
- }
-
- private void fillAdjRibsOut(final boolean isFirstBestPath, final ContainerNode attributes,
- final NormalizedNode<?, ?> value, final MapEntryNode addPathValue, final PathArgument routeId,
- 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 ContainerNode effectiveAttributes = peerGroup.effectiveAttributes(getRoutePeerIdRole(peerPT,
- routePeerId), attributes);
- peerGroup.forEach((destPeer, rootPath) -> {
- final boolean destPeerSupAddPath = peerPT.isAddPathSupportedByPeer(destPeer);
- if (filterRoutes(routePeerId, destPeer, peerPT, localTK, role)
- && 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, routeId, localTK),
- effectiveAttributes, value, ribSup, tx);
- }
- }
- });
- }