private LazyDataObjectModification(final BindingCodecTreeNode<T> codec, final DataTreeCandidateNode domData) { this.codec = Preconditions.checkNotNull(codec); this.domData = Preconditions.checkNotNull(domData); this.identifier = codec.deserializePathArgument(domData.getIdentifier()); }
private LazyTreeNodeModification(final BindingTreeNodeCodec<T> codec, final DataTreeCandidateNode domData) { this.codec = Preconditions.checkNotNull(codec); this.domData = Preconditions.checkNotNull(domData); this.identifier = codec.deserializePathArgument(domData.getIdentifier()); }
private LazyDataObjectModification(final BindingCodecTreeNode<T> codec, final DataTreeCandidateNode domData) { this.codec = Preconditions.checkNotNull(codec); this.domData = Preconditions.checkNotNull(domData); this.identifier = codec.deserializePathArgument(domData.getIdentifier()); }
static BindingStructuralType from(final DataTreeCandidateNode domChildNode) { final Optional<NormalizedNode<?, ?>> dataBased = domChildNode.getDataAfter().or(domChildNode.getDataBefore()); if(dataBased.isPresent()) { return from(dataBased.get()); } return from(domChildNode.getIdentifier()); }
public static BindingStructuralType from(final DataTreeCandidateNode domChildNode) { Optional<NormalizedNode<?, ?>> dataBased = domChildNode.getDataAfter(); if (!dataBased.isPresent()) { dataBased = domChildNode.getDataBefore(); } if (dataBased.isPresent()) { return from(dataBased.get()); } return from(domChildNode.getIdentifier()); }
static BindingStructuralType from(final DataTreeCandidateNode domChildNode) { Optional<NormalizedNode<?, ?>> dataBased = domChildNode.getDataAfter(); if (!dataBased.isPresent()) { dataBased = domChildNode.getDataBefore(); } if (dataBased.isPresent()) { return from(dataBased.get()); } return from(domChildNode.getIdentifier()); }
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); }
private static LeafRefContext getReferencedByCtxChild(final LeafRefContext referencedByCtx, final DataTreeCandidateNode childNode) { if (referencedByCtx == null) { return null; } final QName childQName = childNode.getIdentifier().getNodeType(); LeafRefContext childReferencedByCtx = referencedByCtx.getReferencedChildByName(childQName); if (childReferencedByCtx == null) { final NormalizedNode<?, ?> data = childNode.getDataAfter().get(); if (data instanceof MapEntryNode || data instanceof UnkeyedListEntryNode) { childReferencedByCtx = referencedByCtx; } } return childReferencedByCtx; }
private static LeafRefContext getReferencingCtxChild(final LeafRefContext referencingCtx, final DataTreeCandidateNode childNode) { if (referencingCtx == null) { return null; } final QName childQName = childNode.getIdentifier().getNodeType(); LeafRefContext childReferencingCtx = referencingCtx.getReferencingChildByName(childQName); if (childReferencingCtx == null) { final NormalizedNode<?, ?> data = childNode.getDataAfter().get(); if (data instanceof MapEntryNode || data instanceof UnkeyedListEntryNode) { childReferencingCtx = referencingCtx; } } return childReferencingCtx; }
private static LeafRefContext getReferencedByCtxChild(final LeafRefContext referencedByCtx, final DataTreeCandidateNode childNode) { if (referencedByCtx == null) { return null; } final QName childQName = childNode.getIdentifier().getNodeType(); LeafRefContext childReferencedByCtx = referencedByCtx.getReferencedChildByName(childQName); if (childReferencedByCtx == null) { final NormalizedNode<?, ?> data = childNode.getDataAfter().get(); if (data instanceof MapEntryNode || data instanceof UnkeyedListEntryNode) { childReferencedByCtx = referencedByCtx; } } return childReferencedByCtx; }
private static LeafRefContext getReferencingCtxChild(final LeafRefContext referencingCtx, final DataTreeCandidateNode childNode) { if (referencingCtx == null) { return null; } final QName childQName = childNode.getIdentifier().getNodeType(); LeafRefContext childReferencingCtx = referencingCtx.getReferencingChildByName(childQName); if (childReferencingCtx == null) { final NormalizedNode<?, ?> data = childNode.getDataAfter().get(); if (data instanceof MapEntryNode || data instanceof UnkeyedListEntryNode) { childReferencingCtx = referencingCtx; } } return childReferencingCtx; }
@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 static void populateList(final List<TreeNodeModification<? extends TreeNode>> result, final BindingTreeNodeCodec<?> parentCodec, final Collection<DataTreeCandidateNode> domChildNodes) { for (final DataTreeCandidateNode domChildNode : domChildNodes) { final BindingStructuralType type = BindingStructuralType.from(domChildNode); if (type != BindingStructuralType.NOT_ADDRESSABLE) { /* * Even if type is UNKNOWN, from perspective of BindingStructuralType we try to load codec for * it. We will use that type to further specify debug log. */ try { final BindingTreeNodeCodec<?> childCodec = parentCodec.yangPathArgumentChild(domChildNode.getIdentifier()); populateList(result, type, childCodec, domChildNode); } catch (final IllegalArgumentException e) { if (type == BindingStructuralType.UNKNOWN) { LOG.debug("Unable to deserialize unknown DOM node {}", domChildNode, e); } else { LOG.debug("Binding representation for DOM node {} was not found", domChildNode, e); } } } } }
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 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); } } } } }
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); } }
private void validateChildren(final LeafRefContext rootLeafRefCtx, final Collection<DataTreeCandidateNode> children) throws LeafRefDataValidationFailedException { for (final DataTreeCandidateNode dataTreeCandidateNode : children) { if (dataTreeCandidateNode.getModificationType() != ModificationType.UNMODIFIED) { final PathArgument identifier = dataTreeCandidateNode.getIdentifier(); final QName childQName = identifier.getNodeType(); final LeafRefContext referencedByCtx = rootLeafRefCtx.getReferencedChildByName(childQName); final LeafRefContext referencingCtx = rootLeafRefCtx.getReferencingChildByName(childQName); if (referencedByCtx != null || referencingCtx != null) { validateNode(dataTreeCandidateNode, referencedByCtx, referencingCtx, YangInstanceIdentifier.create(identifier)); } } } if (!errorsMessages.isEmpty()) { final StringBuilder message = new StringBuilder(); int errCount = 0; for (final String errorMessage : errorsMessages) { message.append(errorMessage); errCount++; } throw new LeafRefDataValidationFailedException(message.toString(), errCount); } }
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); } }
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())); } } } }