@Nonnull @Override public Collection<TreeNodeModification<? extends TreeNode>> getModifiedChildren() { if (childNodesCache == null) { childNodesCache = from(codec, domData.getChildNodes()); } return childNodesCache; }
@Override public Collection<DataObjectModification<? extends DataObject>> getModifiedChildren() { if (childNodesCache == null) { childNodesCache = from(codec, domData.getChildNodes()); } return childNodesCache; }
@Override public Collection<LazyDataObjectModification<? extends DataObject>> getModifiedChildren() { Collection<LazyDataObjectModification<? extends DataObject>> local = childNodesCache; if (local == null) { childNodesCache = local = from(codec, domData.getChildNodes()); } return local; }
private static void populateList(final List<DataObjectModification<? extends DataObject>> result, final BindingStructuralType type, final BindingCodecTreeNode<?> childCodec, final DataTreeCandidateNode domChildNode) { switch (type) { case INVISIBLE_LIST: // We use parent codec intentionally. populateListWithSingleCodec(result, childCodec, domChildNode.getChildNodes()); break; case INVISIBLE_CONTAINER: populateList(result, childCodec, domChildNode.getChildNodes()); break; case UNKNOWN: case VISIBLE_CONTAINER: result.add(create(childCodec, domChildNode)); default: break; } }
private static void populateList(final List<TreeNodeModification<? extends TreeNode>> result, final BindingStructuralType type, final BindingTreeNodeCodec<?> childCodec, final DataTreeCandidateNode domChildNode) { switch (type) { case INVISIBLE_LIST: // We use parent codec intentionally. populateListWithSingleCodec(result, childCodec, domChildNode.getChildNodes()); break; case INVISIBLE_CONTAINER: populateList(result, childCodec, domChildNode.getChildNodes()); break; case UNKNOWN: case VISIBLE_CONTAINER: result.add(create(childCodec, domChildNode)); break; default: } }
private static void populateList(final List<LazyDataObjectModification<? extends DataObject>> result, final BindingStructuralType type, final BindingCodecTreeNode<?> childCodec, final DataTreeCandidateNode domChildNode) { switch (type) { case INVISIBLE_LIST: // We use parent codec intentionally. populateListWithSingleCodec(result, childCodec, domChildNode.getChildNodes()); break; case INVISIBLE_CONTAINER: populateList(result, childCodec, domChildNode.getChildNodes()); break; case UNKNOWN: case VISIBLE_CONTAINER: result.add(create(childCodec, domChildNode)); break; default: } }
@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(); }
public static void applyRootToCursor(final DataTreeModificationCursor cursor, final DataTreeCandidateNode node) { switch (node.getModificationType()) { case DELETE: throw new IllegalArgumentException("Can not delete root."); case WRITE: case SUBTREE_MODIFIED: AbstractNodeIterator iterator = new RootNonExitingIterator(node.getChildNodes().iterator()); do { iterator = iterator.next(cursor); } while (iterator != null); break; case UNMODIFIED: // No-op break; default: throw new IllegalArgumentException("Unsupported modification " + node.getModificationType()); } }
public static void applyRootToCursor(final DataTreeModificationCursor cursor, final DataTreeCandidateNode node) { switch (node.getModificationType()) { case DELETE: throw new IllegalArgumentException("Can not delete root."); case WRITE: case SUBTREE_MODIFIED: AbstractNodeIterator iterator = new RootNonExitingIterator(node.getChildNodes().iterator()); do { iterator = iterator.next(cursor); } while (iterator != null); break; case UNMODIFIED: // No-op break; default: throw new IllegalArgumentException("Unsupported modification " + node.getModificationType()); } }
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()); } }
@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(); }
private void writeTable(final DOMDataWriteTransaction tx, final NodeIdentifierWithPredicates tableKey, final DataTreeCandidateNode table) { final RIBSupportContext ribSupport = getRibSupport(tableKey); final YangInstanceIdentifier tablePath = effectiveTablePath(tableKey); // Create an empty table LOG.trace("Create Empty table", tablePath); ribSupport.createEmptyTableStructure(tx, tablePath); processTableChildren(tx, ribSupport.getRibSupport(), tablePath, table.getChildNodes()); }
@Override public void onDataTreeChanged(@Nonnull final Collection<DataTreeCandidate> changes) { LOG.trace("Data changed called to effective RIB. Change : {}", changes); // we have a lot of transactions created for 'nothing' because a lot of changes // are skipped, so ensure we only create one transaction when we really need it DOMDataWriteTransaction tx = null; for (final DataTreeCandidate tc : changes) { final YangInstanceIdentifier rootPath = tc.getRootPath(); final DataTreeCandidateNode root = tc.getRootNode(); for (final DataTreeCandidateNode table : root.getChildNodes()) { if (tx == null) { tx = this.chain.newWriteOnlyTransaction(); } changeDataTree(tx, rootPath, root, table); } } if (tx != null) { tx.submit(); } }
private void modifyTable(final DOMDataWriteTransaction tx, final NodeIdentifierWithPredicates tableKey, final DataTreeCandidateNode table) { final RIBSupportContext ribSupport = getRibSupport(tableKey); final YangInstanceIdentifier tablePath = effectiveTablePath(tableKey); processTableChildren(tx, ribSupport.getRibSupport(), tablePath, table.getChildNodes()); }
private void updateNodes(final DataTreeCandidateNode table, final PeerId peerId, final DOMDataWriteTransaction tx, final Map<RouteUpdateKey, RouteEntry> routes) { for (final DataTreeCandidateNode child : table.getChildNodes()) { LOG.debug("Modification type {}", child.getModificationType()); if ((Attributes.QNAME).equals(child.getIdentifier().getNodeType())) { if (child.getDataAfter().isPresent()) { // putting uptodate attribute in LOG.trace("Uptodate found for {}", child.getDataAfter()); tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTarget.node(child.getIdentifier()), child.getDataAfter().get()); } continue; } updateRoutesEntries(child, peerId, routes); } }
Stream<Modification> streamChildren() { return dataCandidate.getChildNodes().stream() .map(child -> { final YangInstanceIdentifier childId = id.node(child.getIdentifier()); final Object schemaChild = schemaChild(schemaNode, child.getIdentifier()); // An augment cannot change other augment, so we do not update parent node if we are streaming // children of AugmentationSchema (otherwise we would fail to find schema for nested augmentations): if (updateParentNode) { if (schemaNode instanceof AugmentationSchemaNode) { // child nodes would not have nested augmentations, so we stop moving parentNode: return new Modification(childId, child, parentNode, schemaChild, false); } else { // update parent node: return new Modification(childId, child, schemaNode, schemaChild, true); } } return new Modification(childId, child, parentNode, schemaChild, updateParentNode); }); }
private void validateNode(final DataTreeCandidateNode node, final LeafRefContext referencedByCtx, final LeafRefContext referencingCtx, final YangInstanceIdentifier current) { if (node.getModificationType() == ModificationType.WRITE && node.getDataAfter().isPresent()) { validateNodeData(node.getDataAfter().get(), referencedByCtx, referencingCtx, node.getModificationType(), current); return; } if (node.getModificationType() == ModificationType.DELETE && referencedByCtx != null) { validateNodeData(node.getDataBefore().get(), referencedByCtx, null, node.getModificationType(), current); return; } for (final DataTreeCandidateNode childNode : node.getChildNodes()) { if (childNode.getModificationType() != ModificationType.UNMODIFIED) { final LeafRefContext childReferencedByCtx = getReferencedByCtxChild(referencedByCtx, childNode); final LeafRefContext childReferencingCtx = getReferencingCtxChild(referencingCtx, childNode); if (childReferencedByCtx != null || childReferencingCtx != null) { validateNode(childNode, childReferencedByCtx,childReferencingCtx, current.node(childNode.getIdentifier())); } } } }
private void validateNode(final DataTreeCandidateNode node, final LeafRefContext referencedByCtx, final LeafRefContext referencingCtx, final YangInstanceIdentifier current) { if (node.getModificationType() == ModificationType.WRITE && node.getDataAfter().isPresent()) { validateNodeData(node.getDataAfter().get(), referencedByCtx, referencingCtx, node.getModificationType(), current); return; } if (node.getModificationType() == ModificationType.DELETE && referencedByCtx != null) { validateNodeData(node.getDataBefore().get(), referencedByCtx, null, node.getModificationType(), current); return; } for (final DataTreeCandidateNode childNode : node.getChildNodes()) { if (childNode.getModificationType() != ModificationType.UNMODIFIED) { final LeafRefContext childReferencedByCtx = getReferencedByCtxChild(referencedByCtx, childNode); final LeafRefContext childReferencingCtx = getReferencingCtxChild(referencingCtx, childNode); if (childReferencedByCtx != null || childReferencingCtx != null) { validateNode(childNode, childReferencedByCtx,childReferencingCtx, current.node(childNode.getIdentifier())); } } } }
private void notifyNode(final YangInstanceIdentifier path, final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regNode, final DataTreeCandidateNode candNode) { if (candNode.getModificationType() == ModificationType.UNMODIFIED) { LOG.debug("Skipping unmodified candidate {}", path); return; } final Collection<AbstractDOMDataTreeChangeListenerRegistration<?>> regs = regNode.getRegistrations(); if (!regs.isEmpty()) { notifyListeners(regs, path, candNode); } for (DataTreeCandidateNode candChild : candNode.getChildNodes()) { if (candChild.getModificationType() != ModificationType.UNMODIFIED) { final RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> regChild = regNode.getExactChild(candChild.getIdentifier()); if (regChild != null) { notifyNode(path.node(candChild.getIdentifier()), regChild, candChild); } for (RegistrationTreeNode<AbstractDOMDataTreeChangeListenerRegistration<?>> rc : regNode.getInexactChildren(candChild.getIdentifier())) { notifyNode(path.node(candChild.getIdentifier()), rc, candChild); } } } } }