- /*
- * 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 (PeerRole role : PeerRole.values()) {
- final PeerExportGroup peerGroup = peerPolicyTracker.getPeerGroup(role);
- if (peerGroup != null) {
- final ContainerNode attributes = null;
- final PeerId peerId = e.getKey().getPeerId();
- final ContainerNode effectiveAttributes = peerGroup.effectiveAttributes(peerId, attributes);
-
- for (final Entry<PeerId, YangInstanceIdentifier> pid : peerGroup.getPeers()) {
- // This points to adj-rib-out for a particular peer/table combination
- final YangInstanceIdentifier routeTarget = pid.getValue().node(e.getKey().getRouteId());
-
- if (effectiveAttributes != null && value != null && !peerId.equals(pid.getKey())) {
- tx.put(LogicalDatastoreType.OPERATIONAL, routeTarget, value);
- tx.put(LogicalDatastoreType.OPERATIONAL, routeTarget.node(attributesIdentifier), effectiveAttributes);
- } else {
- tx.delete(LogicalDatastoreType.OPERATIONAL, routeTarget);
- }
- }
+ private void updateRoutesEntries(final DataTreeCandidateNode child, final PeerId peerId, final Map<RouteUpdateKey, RouteEntry> routes) {
+ final UnsignedInteger routerId = RouterIds.routerIdForPeerId(peerId);
+ final Collection<DataTreeCandidateNode> modifiedRoutes = this.ribSupport.changedRoutes(child);
+ for (final DataTreeCandidateNode route : modifiedRoutes) {
+ final PathArgument routeId = this.ribSupport.createRouteKeyPathArgument(route.getIdentifier());
+ RouteEntry entry = this.routeEntries.get(routeId);
+ final Optional<NormalizedNode<?, ?>> maybeData = route.getDataAfter();
+ final Optional<NormalizedNode<?, ?>> maybeDataBefore = route.getDataBefore();
+ if (maybeData.isPresent()) {
+ if (entry == null) {
+ entry = createEntry(routeId);