@Override public List<DataObjectModification<C>> getObjectModifications(DataObjectModification<P> objectModification) { List<DataObjectModification<C>> modifications = new ArrayList<>(); if (objectModification != null) { objectModification.getModifiedChildren().forEach(c -> { if (c.getDataType().equals(container)) modifications.add((DataObjectModification<C>) c); }); } return modifications; } }
private List<DataObjectModification<Interface>> getModifiedInterfaces( DataObjectModification<NetworkElement> netElement) { Collection<DataObjectModification<? extends DataObject>> potentialModifiedInterfaces = netElement.getModifiedChildren(); if (potentialModifiedInterfaces == null) { return Collections.emptyList(); } List<DataObjectModification<Interface>> interfaces = new ArrayList<>(); for (DataObjectModification<? extends DataObject> potentialModifiedInterface : potentialModifiedInterfaces) { if (potentialModifiedInterface.getDataType().isAssignableFrom(Interface.class)) { interfaces.add((DataObjectModification<Interface>) potentialModifiedInterface); } } return interfaces; }
private List<DataObjectModification<EndpointNetwork>> getModifiedEndpointNetworks( DataObjectModification<Interface> modifiedInterface) { Collection<DataObjectModification<? extends DataObject>> potentialModifiedEPs = modifiedInterface.getModifiedChildren(); if (potentialModifiedEPs == null) { return Collections.emptyList(); } List<DataObjectModification<EndpointNetwork>> eps = new ArrayList<>(); for (DataObjectModification<? extends DataObject> potentialModifiedEP : potentialModifiedEPs) { if (potentialModifiedEP.getDataType().isAssignableFrom(EndpointNetwork.class)) { eps.add((DataObjectModification<EndpointNetwork>) potentialModifiedEP); } } return eps; }
private List<DataObjectModification<NetworkElement>> getModifiedNetworkElements( DataObjectModification<NetworkElements> modifiedNEs) { Collection<DataObjectModification<? extends DataObject>> potentialModifiedNetworkElements = modifiedNEs.getModifiedChildren(); if (potentialModifiedNetworkElements == null) { return Collections.emptyList(); } List<DataObjectModification<NetworkElement>> nes = new ArrayList<>(); for (DataObjectModification<? extends DataObject> potentialModifiedNetworkElement : potentialModifiedNetworkElements) { if (potentialModifiedNetworkElement.getDataType().isAssignableFrom(NetworkElement.class)) { nes.add((DataObjectModification<NetworkElement>) potentialModifiedNetworkElement); } } return nes; }
@Override public List<DataObjectModification<C>> getModifications(DataTreeModification<P> treeModification) { List<DataObjectModification<C>> modifications = new ArrayList<>(); if (treeModification != null) { treeModification.getRootNode().getModifiedChildren().forEach(c -> { if (c.getDataType().equals(container)) modifications.add((DataObjectModification<C>) c); }); } return modifications; }
/** * Returns child list item modification if {@code child} was modified by this modification. This method should be * used if the child is defined in a grouping brought into a case inside this object. * * @param caseType Case type class * @param childType Type of list item - must be list item with key * @return Modification of {@code child} if {@code child} was modified, null otherwise. * @throws IllegalArgumentException If supplied {@code childType} class is not valid child according * to generated model. */ default <H extends ChoiceIn<? super T> & DataObject, C extends ChildOf<? super H>> Collection<DataObjectModification<C>> getModifiedChildren(@Nonnull final Class<H> caseType, @Nonnull final Class<C> childType) { final Item<C> item = Item.of(caseType, childType); return (Collection<DataObjectModification<C>>) Collections2.filter(getModifiedChildren(), mod -> item.equals(mod.getIdentifier())); }
for (DataObjectModification<? extends DataObject> child : change.getModifiedChildren()) { remainingChanges.add(child); remainingPaths.add(extendPath(path, child));
for (DataObjectModification<? extends DataObject> child : change.getModifiedChildren()) { remainingChanges.add(child); remainingPaths.add(extendPath(path, child));
private <T extends DataObject> void formatModification(@Nonnull final StringBuilder messageBuilder, @Nonnull final DataObjectModification<T> objectModification) { final String typeName = objectModification.getDataType().getSimpleName(); switch (objectModification.getModificationType()) { case SUBTREE_MODIFIED: for (final DataObjectModification<? extends DataObject> child : objectModification.getModifiedChildren()) { formatModification(messageBuilder, child); } break; case WRITE: messageBuilder.append("\n"); messageBuilder.append("WRITE: type: ").append(typeName).append("\n"); final T dataAfter = objectModification.getDataAfter(); messageBuilder.append(dataAfter.toString()); break; case DELETE: messageBuilder.append("\n"); messageBuilder.append("DELETE: ").append(typeName); break; default: LOG.warn("unknown modification type: {}", typeName); break; } }
/** * Detect modifications of OVSDB termination points in the given node. * * @param mod Modification of node subtree. */ private void scanTerminationPoints( @Nonnull DataObjectModification<Node> mod) { for (DataObjectModification<?> child: mod.getModifiedChildren()) { Class<?> type = child.getDataType(); if (TerminationPoint.class.equals(type)) { @SuppressWarnings("unchecked") DataObjectModification<TerminationPoint> tmod = (DataObjectModification<TerminationPoint>)child; DataObjectModification<OvsdbTerminationPointAugmentation> omod = tmod.getModifiedAugmentation( OvsdbTerminationPointAugmentation.class); if (omod != null) { setModifiedTerminationPoint(omod); } } } }
/** * Handle modification events for direct children of the current tree node. * * @param ctx Runtime information of the notification. * @param ectx An event context created by this instance. * @param mod The data object modification associated with the current * tree node. */ private void handleChildren(TreeChangeContext<T> ctx, C ectx, DataObjectModification<?> mod) { for (DataObjectModification<?> child: mod.getModifiedChildren()) { ctx.push(child); handleTreeNode(ctx, ectx, child); ctx.pop(); } }
@Override public synchronized void onDataTreeChanged(final Collection<DataTreeModification<Bgp>> changes) { if (this.closed) { LOG.trace("BGP Deployer was already closed, skipping changes."); return; } for (final DataTreeModification<Bgp> dataTreeModification : changes) { final InstanceIdentifier<Bgp> rootIdentifier = dataTreeModification.getRootPath().getRootIdentifier(); final DataObjectModification<Bgp> rootNode = dataTreeModification.getRootNode(); LOG.trace("BGP configuration has changed: {}", rootNode); for (final DataObjectModification<? extends DataObject> dataObjectModification : rootNode.getModifiedChildren()) { if (dataObjectModification.getDataType().equals(Global.class)) { onGlobalChanged((DataObjectModification<Global>) dataObjectModification, rootIdentifier); } else if (dataObjectModification.getDataType().equals(Neighbors.class)) { onNeighborsChanged((DataObjectModification<Neighbors>) dataObjectModification, rootIdentifier); } } } }
for (DataObjectModification<? extends DataObject> child : changedNode.getModifiedChildren()) { final List<PathArgument> pathArguments = new ArrayList<>(); for (PathArgument pathArgument : iid.getPathArguments()) {
/** * Finds all modified subnodes of given type in {@link Neutron} node. * * @param <T> * @param iid path to data in root node * @param rootNode modified data of {@link Neutron} node * @return {@link List} of modified subnodes */ private <T extends DataObject> List<DataObjectModification<T>> findModifiedData(InstanceIdentifier<T> iid, DataObjectModification<Neutron> rootNode) { List<DataObjectModification<T>> modDtos = new ArrayList<>(); PeekingIterator<PathArgument> pathArgs = Iterators.peekingIterator(iid.getPathArguments().iterator()); DataObjectModification<? extends DataObject> modifDto = rootNode; while (pathArgs.hasNext()) { pathArgs.next(); for (DataObjectModification<? extends DataObject> childDto : modifDto.getModifiedChildren()) { if (pathArgs.hasNext() && childDto.getDataType().equals(pathArgs.peek().getType())) { if (childDto.getDataType().equals(iid.getTargetType())) { modDtos.add((DataObjectModification<T>) childDto); } else { modifDto = childDto; break; } } } } return modDtos; }
@Override public void onDataTreeChanged(final Collection<DataTreeModification<Bgp>> changes) { for (final DataTreeModification<Bgp> dataTreeModification : changes) { final DataObjectModification<Bgp> rootNode = dataTreeModification.getRootNode(); for (final DataObjectModification<? extends DataObject> dataObjectModification : rootNode.getModifiedChildren()) { switch (dataObjectModification.getModificationType()) { case DELETE: onOpenConfigRemoved(dataObjectModification.getDataBefore()); break; case SUBTREE_MODIFIED: case WRITE: onOpenConfigModified(dataObjectModification); break; default: throw new IllegalArgumentException("Unhandled modification type " + rootNode.getModificationType()); } } } }
final String nodeId = identifier.firstKeyOf(Node.class).getNodeId().getValue(); SxpNode sxpNode = Configuration.getRegisteredNode(nodeId); modifiedChildContainer.getModifiedChildren().stream().filter(m -> m != null).forEach(m -> {
private void onNeighborsChanged(final DataObjectModification<Neighbors> dataObjectModification, final InstanceIdentifier<Bgp> rootIdentifier) { for (final DataObjectModification<? extends DataObject> neighborModification : dataObjectModification.getModifiedChildren()) { switch (neighborModification.getModificationType()) { case DELETE: onNeighborRemoved(rootIdentifier, (Neighbor) neighborModification.getDataBefore()); break; case SUBTREE_MODIFIED: case WRITE: onNeighborModified(rootIdentifier, (Neighbor) neighborModification.getDataAfter(), null); break; default: break; } } }
private void onOpenConfigModified(final DataObjectModification<? extends DataObject> dataObjectModification) { final DataObject modifiedData = dataObjectModification.getDataAfter(); if (modifiedData instanceof Global) { ribImplProvider.onGlobalModified((Global) modifiedData); } else if (modifiedData instanceof Neighbors) { for (final DataObjectModification<? extends DataObject> childModification : dataObjectModification.getModifiedChildren()) { switch (childModification.getModificationType()) { case DELETE: final Neighbor before = (Neighbor) childModification.getDataBefore(); removeNeighbor(before); break; case SUBTREE_MODIFIED: case WRITE: final Neighbor after = (Neighbor) childModification.getDataAfter(); modifyNeighbor(after); break; default: break; } } } else { LOG.info("Skipping unhandled modified data: {}", modifiedData); } }