private void filterOutChangesToSupportedTables(final PeerId peerIdOfNewPeer, final DataTreeCandidateNode rootNode) { final DataTreeCandidateNode tablesChange = rootNode.getModifiedChild(PEER_TABLES); if (tablesChange != null) { this.peerPolicyTracker.onTablesChanged(peerIdOfNewPeer, tablesChange); } }
@Override public final Collection<DataTreeCandidateNode> changedRoutes(final DataTreeCandidateNode routes) { final DataTreeCandidateNode myRoutes = routes.getModifiedChild(this.routesContainerIdentifier); if (myRoutes == null) { return Collections.emptySet(); } final DataTreeCandidateNode routesMap = myRoutes.getModifiedChild(routeNid()); if (routesMap == null) { return Collections.emptySet(); } // Well, given the remote possibility of augmentation, we should perform a filter here, // to make sure the type matches what routeType() reports. return routesMap.getChildNodes(); }
@Override public DataObjectModification<? extends DataObject> getModifiedChild(final PathArgument arg) { final List<YangInstanceIdentifier.PathArgument> domArgumentList = new ArrayList<>(); final BindingCodecTreeNode<?> childCodec = codec.bindingPathArgumentChild(arg, domArgumentList); final Iterator<YangInstanceIdentifier.PathArgument> toEnter = domArgumentList.iterator(); DataTreeCandidateNode current = domData; while (toEnter.hasNext() && current != null) { current = current.getModifiedChild(toEnter.next()); } if (current != null) { return create(childCodec, current); } return null; }
private void filterOutAnyChangeOutsideEffRibsIn(final PeerId peerId, final DataTreeCandidateNode rootNode, final Map<RouteUpdateKey, RouteEntry> ret, final YangInstanceIdentifier rootPath, final DOMDataWriteTransaction tx) { final DataTreeCandidateNode ribIn = rootNode.getModifiedChild(EFFRIBIN_NID); if (ribIn == null) { LOG.trace("Skipping change {}", rootNode.getIdentifier()); return; } final DataTreeCandidateNode table = ribIn.getModifiedChild(TABLES_NID).getModifiedChild(this.tableKey); if (table == null) { LOG.trace("Skipping change {}", rootNode.getIdentifier()); return; } initializeTableWithExistentRoutes(table, peerId, rootPath, tx); updateNodes(table, peerId, tx, ret); }
@Override public DataObjectModification<? extends DataObject> getModifiedChild(final PathArgument arg) { final List<YangInstanceIdentifier.PathArgument> domArgumentList = new ArrayList<>(); final BindingCodecTreeNode<?> childCodec = codec.bindingPathArgumentChild(arg, domArgumentList); final Iterator<YangInstanceIdentifier.PathArgument> toEnter = domArgumentList.iterator(); DataTreeCandidateNode current = domData; while (toEnter.hasNext() && current != null) { current = current.getModifiedChild(toEnter.next()); } if (current != null) { return create(childCodec, current); } return null; }
@SuppressWarnings("rawtypes") @Nullable @Override public TreeNodeModification<? extends TreeNode> getModifiedChild(final TreeArgument childArgument) { final List<YangInstanceIdentifier.PathArgument> domArgumentList = new ArrayList<>(); final BindingTreeNodeCodec<?> childCodec = codec.bindingPathArgumentChild(childArgument, domArgumentList); final Iterator<YangInstanceIdentifier.PathArgument> toEnter = domArgumentList.iterator(); DataTreeCandidateNode current = domData; while (toEnter.hasNext() && current != null) { current = current.getModifiedChild(toEnter.next()); } if (current != null) { return create(childCodec, current); } return null; }
@Override public void onTablesChanged(final PeerId peerId, final DataTreeCandidateNode tablesChange) { final NodeIdentifierWithPredicates supTablesKey = RibSupportUtils.toYangKey(SupportedTables.QNAME, this.localTableKey); final DataTreeCandidateNode localTableNode = tablesChange.getModifiedChild(supTablesKey); if (localTableNode != null) { final Optional<NormalizedNode<?, ?>> dataAfter = localTableNode.getDataAfter(); processSupportedSendReceiveTables(localTableNode.getModifiedChild(SEND_RECEIVE_NID), peerId); if (dataAfter.isPresent()) { final boolean added = this.peerTables.add(peerId); if (added) { LOG.debug("Supported table {} added to peer {}", this.localTableKey, peerId); } } else { final NodeIdentifierWithPredicates value = (NodeIdentifierWithPredicates) localTableNode.getIdentifier(); this.peerTables.remove(peerId); LOG.debug("Removed tables {} from peer {}", value, peerId); } } }
private SimpleRoutingPolicy getSimpleRoutingPolicy(final DataTreeCandidateNode rootNode) { final DataTreeCandidateNode statusChange = rootNode.getModifiedChild(SIMPLE_ROUTING_POLICY_NID); if (statusChange != null) { final Optional<NormalizedNode<?, ?>> maybePeerStatus = statusChange.getDataAfter(); if (maybePeerStatus.isPresent()) { return SimpleRoutingPolicy.valueOf(BindingMapping.getClassName((String) (maybePeerStatus.get()).getValue())); } } return null; }
private DataTreeCandidate applyChanges(final Collection<DataTreeCandidate> changes) { final DataTreeModification modification = dataTree.takeSnapshot().newModification(); for (final DataTreeCandidate change : changes) { DataTreeCandidates.applyToModification(modification, change); } modification.ready(); try { dataTree.validate(modification); } catch (final DataValidationFailedException e) { LOG.error("Validation failed for built modification", e); throw new RuntimeException("Notification validation failed", e); } // strip nodes we do not need since this listener doesn't have to be registered at the root of the DataTree DataTreeCandidateNode modifiedChild = dataTree.prepare(modification).getRootNode(); for (final PathArgument pathArgument : listenerPath.getPathArguments()) { modifiedChild = modifiedChild.getModifiedChild(pathArgument); } if (modifiedChild == null) { modifiedChild = DataTreeCandidateNodes.empty(listenerPath.getLastPathArgument()); } return DataTreeCandidates.newDataTreeCandidate(listenerPath, modifiedChild); } }
private void filterOutPeerRole(final PeerId peerId, final DataTreeCandidateNode rootNode, final YangInstanceIdentifier rootPath) { final DataTreeCandidateNode roleChange = rootNode.getModifiedChild(PEER_ROLE_NID); if (roleChange != null) { if (rootNode.getModificationType() != ModificationType.DELETE) { this.cacheDisconnectedPeers.reconnected(peerId); } // Check for removal final Optional<NormalizedNode<?, ?>> maybePeerRole = roleChange.getDataAfter(); final YangInstanceIdentifier peerPath = IdentifierUtils.peerPath(rootPath); LOG.debug("Data Changed for Peer role {} path {}, dataBefore {}, dataAfter {}", roleChange.getIdentifier(), peerPath , roleChange.getDataBefore(), maybePeerRole); final PeerRole role = PeerRoleUtil.roleForChange(maybePeerRole); final SimpleRoutingPolicy srp = getSimpleRoutingPolicy(rootNode); if(SimpleRoutingPolicy.AnnounceNone == srp) { return; } this.peerPolicyTracker.peerRoleChanged(peerPath, role); } }