public static void applyToCursor(final DataTreeModificationCursor cursor, final DataTreeCandidate candidate) { DataTreeCandidateNodes.applyToCursor(cursor, candidate.getRootNode()); }
public static void applyToCursor(final DataTreeModificationCursor cursor, final DataTreeCandidate candidate) { DataTreeCandidateNodes.applyToCursor(cursor, candidate.getRootNode()); }
@Override public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) { LOG.debug("Data change received for AdjRibOut {}", changes); for (final DataTreeCandidate tc : changes) { LOG.trace("Change {} type {}", tc.getRootNode(), tc.getRootNode().getModificationType()); for (final DataTreeCandidateNode child : tc.getRootNode().getChildNodes()) { processSupportedFamilyRoutes(child); } } this.session.flush(); }
void onDataTreeChanged(final YangInstanceIdentifier rootPath, final Collection<DataTreeCandidate> changes) { final List<DataTreeCandidate> newCandidates = changes.stream() .map(candidate -> DataTreeCandidates.newDataTreeCandidate(rootPath, candidate.getRootNode())) .collect(Collectors.toList()); delegate.onDataTreeChanged(Collections.singleton(applyChanges(newCandidates))); }
@Override protected synchronized void appendInitial(final State state) { // We are still starting up, so all we need to do is squash reported changes to an initial write event final DataTreeCandidate last = Iterables.getLast(state.changes); changes.clear(); final Optional<NormalizedNode<?, ?>> lastData = last.getRootNode().getDataAfter(); if (lastData.isPresent()) { changes.add(DataTreeCandidates.fromNormalizedNode(last.getRootPath(), lastData.get())); } }
public static void validate(final DataTreeCandidate tree, final LeafRefContext rootLeafRefCtx) throws LeafRefDataValidationFailedException { final Optional<NormalizedNode<?, ?>> root = tree.getRootNode().getDataAfter(); if (root.isPresent()) { new LeafRefValidation(root.get()).validateChildren(rootLeafRefCtx, tree.getRootNode().getChildNodes()); } }
public static void validate(final DataTreeCandidate tree, final LeafRefContext rootLeafRefCtx) throws LeafRefDataValidationFailedException { final Optional<NormalizedNode<?, ?>> root = tree.getRootNode().getDataAfter(); if (root.isPresent()) { new LeafRefValidation(root.get()).validateChildren(rootLeafRefCtx, tree.getRootNode().getChildNodes()); } }
LazyDataTreeModification(final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> path, final BindingCodecTreeNode<T> codec, final DataTreeCandidate domChange) { this.path = new DataTreeIdentifier<>(datastoreType, path); this.rootNode = LazyDataObjectModification.create(codec, domChange.getRootNode()); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static <T extends TreeNode> DataTreeModification<T> create(final BindingToNormalizedNodeCodec codec, final DataTreeCandidate domChange, final LogicalDatastoreType datastoreType) { final Entry<InstanceIdentifier<?>, BindingTreeNodeCodec<?>> codecCtx = codec.getSubtreeCodec(domChange.getRootPath()); final DataTreeIdentifier<?> path = DataTreeIdentifier.create(datastoreType, codecCtx.getKey()); final TreeNodeModification<?> modification = LazyTreeNodeModification.create(codecCtx.getValue(), domChange.getRootNode()); return new LazyDataTreeModification(path, modification); }
@SuppressWarnings({"unchecked", "rawtypes"}) static <T extends DataObject> DataTreeModification<T> create(final BindingToNormalizedNodeCodec codec, final DataTreeCandidate domChange, final LogicalDatastoreType datastoreType) { final Entry<InstanceIdentifier<?>, BindingCodecTreeNode<?>> codecCtx = codec.getSubtreeCodec( domChange.getRootPath()); final DataTreeIdentifier<?> path = DataTreeIdentifier.create(datastoreType, codecCtx.getKey()); final DataObjectModification<?> modification = LazyDataObjectModification.create(codecCtx.getValue(), domChange.getRootNode()); return new LazyDataTreeModification(path, modification); }
private static void applyToCursorAwareModification(final CursorAwareDataTreeModification modification, final DataTreeCandidate candidate) { final YangInstanceIdentifier candidatePath = candidate.getRootPath(); if (candidatePath.isEmpty()) { try (DataTreeModificationCursor cursor = modification.openCursor()) { DataTreeCandidateNodes.applyRootToCursor(cursor, candidate.getRootNode()); } } else { try (DataTreeModificationCursor cursor = modification.openCursor(candidatePath.getParent()).get()) { DataTreeCandidateNodes.applyRootedNodeToCursor(cursor, candidatePath, candidate.getRootNode()); } } }
private static void applyToCursorAwareModification(final CursorAwareDataTreeModification modification, final DataTreeCandidate candidate) { final YangInstanceIdentifier candidatePath = candidate.getRootPath(); if (candidatePath.isEmpty()) { try (DataTreeModificationCursor cursor = modification.openCursor()) { DataTreeCandidateNodes.applyRootToCursor(cursor, candidate.getRootNode()); } } else { try (DataTreeModificationCursor cursor = modification.openCursor(candidatePath.getParent()).get()) { DataTreeCandidateNodes.applyRootedNodeToCursor(cursor, candidatePath, candidate.getRootNode()); } } }
/** * Process a candidate tree with respect to registered listeners. * * @param candidate candidate three which needs to be processed */ protected final void processCandidateTree(@Nonnull final DataTreeCandidate candidate) { final DataTreeCandidateNode node = candidate.getRootNode(); if (node.getModificationType() == ModificationType.UNMODIFIED) { LOG.debug("Skipping unmodified candidate {}", candidate); return; } try (final RegistrationTreeSnapshot<AbstractDOMDataTreeChangeListenerRegistration<?>> snapshot = takeSnapshot()) { final List<PathArgument> toLookup = ImmutableList.copyOf(candidate.getRootPath().getPathArguments()); lookupAndNotify(toLookup, 0, snapshot.getRootNode(), candidate); } }
private Map<RouteUpdateKey, RouteEntry> update(final DOMDataWriteTransaction tx, final Collection<DataTreeCandidate> changes) { final Map<RouteUpdateKey, RouteEntry> ret = new HashMap<>(); for (final DataTreeCandidate tc : changes) { final YangInstanceIdentifier rootPath = tc.getRootPath(); final DataTreeCandidateNode rootNode = tc.getRootNode(); final PeerId peerId = IdentifierUtils.peerKeyToPeerId(rootPath); filterOutPeerRole(peerId, rootNode, rootPath); filterOutChangesToSupportedTables(peerId, rootNode); filterOutAnyChangeOutsideEffRibsIn(peerId, rootNode, ret, rootPath, tx); } return ret; }
/** * Process a candidate tree with respect to registered listeners. * * @param candidate candidate three which needs to be processed */ protected final void processCandidateTree(@Nonnull final DataTreeCandidate candidate) { final DataTreeCandidateNode node = candidate.getRootNode(); if (node.getModificationType() == ModificationType.UNMODIFIED) { LOG.debug("Skipping unmodified candidate {}", candidate); return; } try (RegistrationTreeSnapshot<AbstractDOMDataTreeChangeListenerRegistration<?>> snapshot = takeSnapshot()) { lookupAndNotify(candidate.getRootPath().getPathArguments(), 0, snapshot.getRootNode(), candidate); } }
private void lookupAndNotify(final List<PathArgument> args, final int offset, final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node, final DataTreeCandidate candidate) { if (args.size() != offset) { final PathArgument arg = args.get(offset); final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> exactChild = node.getExactChild(arg); if (exactChild != null) { lookupAndNotify(args, offset + 1, exactChild, candidate); } for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> c : node.getInexactChildren(arg)) { lookupAndNotify(args, offset + 1, c, candidate); } } else { notifyNode(candidate.getRootPath(), node, candidate.getRootNode()); } }
private void lookupAndCreateCanCommits(final List<PathArgument> args, final int offset, final RegistrationTreeNode<ActorRef> node) { if (args.size() != offset) { final PathArgument arg = args.get(offset); final RegistrationTreeNode<ActorRef> exactChild = node.getExactChild(arg); if (exactChild != null) { lookupAndCreateCanCommits(args, offset + 1, exactChild); } for (final RegistrationTreeNode<ActorRef> c : node.getInexactChildren(arg)) { lookupAndCreateCanCommits(args, offset + 1, c); } } else { lookupAndCreateCanCommits(candidate.getRootPath(), node, candidate.getRootNode()); } }
private void lookupAndNotify(final List<PathArgument> args, final int offset, final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node, final DataTreeCandidate candidate) { if (args.size() != offset) { final PathArgument arg = args.get(offset); final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> exactChild = node.getExactChild(arg); if (exactChild != null) { lookupAndNotify(args, offset + 1, exactChild, candidate); } for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> c : node.getInexactChildren(arg)) { lookupAndNotify(args, offset + 1, c, candidate); } } else { notifyNode(candidate.getRootPath(), node, candidate.getRootNode()); } }
private void lookupAndNotify(final List<PathArgument> args, final int offset, final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> node, final DataTreeCandidate candidate, final Multimap<AbstractDOMDataTreeChangeListenerRegistration<?>, DataTreeCandidate> listenerChanges) { if (args.size() != offset) { final PathArgument arg = args.get(offset); final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> exactChild = node.getExactChild(arg); if (exactChild != null) { lookupAndNotify(args, offset + 1, exactChild, candidate, listenerChanges); } for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> c : node.getInexactChildren(arg)) { lookupAndNotify(args, offset + 1, c, candidate, listenerChanges); } } else { notifyNode(candidate.getRootPath(), node, candidate.getRootNode(), listenerChanges); } }
private DataObjectUpdates getUpdates(final DataTreeWriteContext dataTreeContext) { DataObjectUpdates updates = dataTreeContext.getUpdates(); if (updates != null) { return updates; } else { final DataTreeCandidate candidate = dataTreeContext.getCandidate(); final DataTreeCandidateNode rootNode = candidate.getRootNode(); final YangInstanceIdentifier rootPath = candidate.getRootPath(); LOG.trace("ConfigDataTree.getUpdates() rootPath={}, rootNode={}, dataBefore={}, dataAfter={}", rootPath, rootNode, rootNode.getDataBefore(), rootNode.getDataAfter()); final ModificationDiff modificationDiff = new ModificationDiff.ModificationDiffBuilder() .setCtx(schema).build(rootNode); LOG.debug("ConfigDataTree.getUpdates() diff: {}", modificationDiff); // Distinguish between updates (create + update) and deletes updates = toBindingAware(writerRegistry, modificationDiff.getUpdates()); dataTreeContext.setUpdates(updates); return updates; } }