@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; }
InstanceIdentifier<? extends DataObject> path = remainingPaths.remove(); if (clazz.isAssignableFrom(change.getDataType()) && filter.apply((DataObjectModification<T>) change)) { result.put((InstanceIdentifier<T>) path, (DataObjectModification<T>) change);
InstanceIdentifier<? extends DataObject> path = remainingPaths.remove(); if (clazz.isAssignableFrom(change.getDataType()) && filter.apply((DataObjectModification<T>) change)) { result.put((InstanceIdentifier<T>) path, (DataObjectModification<T>) change);
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; } }
@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); } } } }
/** * 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); } } } }
/** * 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; }
@Nonnull D before, @Nonnull D after) { VtnUpdateType utype = VtnUpdateType.CHANGED; Class<D> dtype = mod.getDataType(); boolean children = handleChildrenFirst(ctx, ectx, mod, dtype, utype);
} else { LOG.error("Modification {} {} {} could not get SxpNode {}", this, logicalDatastoreType, modifiedChildContainer.getDataType(), nodeId);
/** * Extends the given instance identifier path to include the given child. Augmentations are treated in the same way * as children; keyed children are handled correctly. * * @param path The current path. * @param child The child modification to include. * @return The extended path. */ private static <N extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<N>, T extends DataObject> InstanceIdentifier<? extends DataObject> extendPath( InstanceIdentifier path, DataObjectModification child) { Class<N> item = (Class<N>) child.getDataType(); if (child.getIdentifier() instanceof InstanceIdentifier.IdentifiableItem) { K key = (K) ((InstanceIdentifier.IdentifiableItem) child.getIdentifier()).getKey(); KeyedInstanceIdentifier<N, K> extendedPath = path.child(item, key); return extendedPath; } else { InstanceIdentifier<N> extendedPath = path.child(item); return extendedPath; } }
} else { LOG.error("Modification {} {} {} could not get SxpNode {}", this, logicalDatastoreType, modifiedChildContainer.getDataType(), nodeId);
/** * Extends the given instance identifier path to include the given child. Augmentations are treated in the same way * as children; keyed children are handled correctly. * * @param path The current path. * @param child The child modification to include. * @return The extended path. */ private static <N extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<N>, T extends DataObject> InstanceIdentifier<? extends DataObject> extendPath( InstanceIdentifier path, DataObjectModification child) { Class<N> item = (Class<N>) child.getDataType(); if (child.getIdentifier() instanceof InstanceIdentifier.IdentifiableItem) { K key = (K) ((InstanceIdentifier.IdentifiableItem) child.getIdentifier()).getKey(); KeyedInstanceIdentifier<N, K> extendedPath = path.child(item, key); return extendedPath; } else { InstanceIdentifier<N> extendedPath = path.child(item); return extendedPath; } }
/** * Notify the created 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 tree * node. * @param value The created tree node. * @param <D> The type of the tree node. */ private <D extends DataObject> void notifyCreated( TreeChangeContext<T> ctx, C ectx, DataObjectModification<D> mod, @Nonnull D value) { VtnUpdateType utype = VtnUpdateType.CREATED; Class<D> dtype = mod.getDataType(); boolean children = handleChildrenFirst(ctx, ectx, mod, dtype, utype); if (isRequiredEvent(utype) && isRequiredType(dtype)) { IdentifiedData<D> data = createIdentifiedData( dtype, ctx.getPath(), value, utype); if (data != null) { onCreated(ectx, data); } } if (children) { // Children need to be handled after the current node. handleChildren(ctx, ectx, mod); } }
/** * Notify the removed 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 removed * tree nod. * @param value The removed tree node. * @param <D> The type of the tree node. */ private <D extends DataObject> void notifyRemoved( TreeChangeContext<T> ctx, C ectx, DataObjectModification<D> mod, D value) { VtnUpdateType utype = VtnUpdateType.REMOVED; Class<D> dtype = mod.getDataType(); boolean children = handleChildrenFirst(ctx, ectx, mod, dtype, utype); if (isRequiredEvent(utype) && isRequiredType(dtype)) { IdentifiedData<D> data = createIdentifiedData( dtype, ctx.getPath(), value, utype); if (data != null) { onRemoved(ectx, data); } } if (children) { // Children need to be handled after the current node. handleChildren(ctx, ectx, mod); } }