@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 applyToCursor(final DataTreeModificationCursor cursor, final DataTreeCandidate candidate) { DataTreeCandidateNodes.applyToCursor(cursor, candidate.getRootNode()); }
@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()); return new LazyDataTreeModification(datastoreType, codecCtx.getKey(), codecCtx.getValue(), domChange); }
public static void applyToCursor(final DataTreeModificationCursor cursor, final DataTreeCandidate candidate) { DataTreeCandidateNodes.applyToCursor(cursor, candidate.getRootNode()); }
private Collection<DataTreeCohortActor.CanCommit> perform(final RegistrationTreeNode<ActorRef> rootNode) { final List<PathArgument> toLookup = candidate.getRootPath().getPathArguments(); lookupAndCreateCanCommits(toLookup, 0, rootNode); return messages; } }
@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); }
@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(); }
@Override public void onDataTreeChanged(final Collection<DataTreeCandidate> dataTreeCandidates) { for (final DataTreeCandidate dataTreeCandidate : dataTreeCandidates) { final YangInstanceIdentifier agentKey = dataTreeCandidate.getRootPath(); final DataObjectModification<AmqpUserAgent> changeDiff = null; // todo - remove null; and initialize switch (changeDiff.getModificationType()) { case WRITE: createOrReplace(agentKey, changeDiff.getDataAfter()); break; case DELETE: removeAndClose(agentKey); default: LOG.info("Unsupported change type {} for {}", changeDiff.getModificationType(), agentKey); break; } } } }
@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); }
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))); }
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; }
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()); } }
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()); } } }
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()); } }
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()); } } }
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()); }
/** * 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); } }
@Override protected void notifyListener(final Iterator<State> iterator) { final Stopwatch clock = Stopwatch.createStarted(); final List<DataTreeCandidate> changes = new ArrayList<>(); while (iterator.hasNext()) { final State state = iterator.next(); final List<DataTreeCandidate> candidates = state.changes; if (!candidates.isEmpty()) { // Update current subtree snapshot based on last candidate node final DataTreeCandidateNode lastRoot = candidates.get(candidates.size() - 1).getRootNode(); final Optional<NormalizedNode<?, ?>> optData = lastRoot.getDataAfter(); if (optData.isPresent()) { subtrees.put(state.getIdentifier(), optData.get()); } else { subtrees.remove(state.getIdentifier()); } // Append changes changes.addAll(candidates); } } final int size = changes.size(); if (size != 0) { // Note: it is okay to leak changes, we must never leak mutable subtrees. listener.onDataTreeChanged(changes, ImmutableMap.copyOf(subtrees)); LOG.trace("Listener {} processed {} changes in {}", listener, size, clock); } } }
/** * 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); } }
final Optional<NormalizedNode<?, ?>> last = Iterables.getLast(changes).getRootNode().getDataAfter(); if (last.isPresent()) { listener.onDataTreeChanged(changes, ImmutableMap.of(treeId, last.get()));