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; } } }
@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; } }
@Override public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Node>> changes) { for (DataTreeModification<Node> change : changes) { final DataObjectModification<Node> rootNode = change.getRootNode(); switch (rootNode.getModificationType()) { case WRITE: LOG.debug("Data was Created {}, {}", rootNode.getIdentifier(), rootNode.getDataAfter()); ownershipCandidate.onNodeCreated(TopologyUtil.getNodeId(rootNode.getIdentifier()), rootNode.getDataAfter()); break; case SUBTREE_MODIFIED: LOG.debug("Data was Updated {}, {}", rootNode.getIdentifier(), rootNode.getDataAfter()); ownershipCandidate.onNodeUpdated(TopologyUtil.getNodeId(rootNode.getIdentifier()), rootNode.getDataAfter()); break; case DELETE: LOG.debug("Data was Deleted {}", rootNode.getIdentifier()); ownershipCandidate.onNodeDeleted(TopologyUtil.getNodeId(rootNode.getIdentifier())); } } } }
@Override public boolean apply(@Nullable DataObjectModification<T> input) { return input != null && input.getModificationType() == DataObjectModification .ModificationType.DELETE && input.getDataBefore() != null; } };
@Override public boolean apply(@Nullable DataObjectModification<T> input) { return input != null && input.getDataBefore() != null && input.getDataAfter() != null; } };
@Override protected void handleOperational(DataObjectModification<SxpDomain> c, InstanceIdentifier<SxpNodeIdentity> identifier, SxpNode sxpNode) { LOG.trace("Operational Modification {} {}", getClass(), c.getModificationType()); switch (c.getModificationType()) { case WRITE: if (c.getDataBefore() == null) sxpNode.addDomain(c.getDataAfter()); case SUBTREE_MODIFIED: if (c.getDataAfter() != null) break; case DELETE: sxpNode.removeDomain(Preconditions.checkNotNull(c.getDataBefore()).getDomainName()).close(); break; } }
private void onGlobalChanged(final DataObjectModification<Global> dataObjectModification, final InstanceIdentifier<Bgp> rootIdentifier) { switch (dataObjectModification.getModificationType()) { case DELETE: onGlobalRemoved(rootIdentifier); break; case SUBTREE_MODIFIED: case WRITE: onGlobalModified(rootIdentifier, dataObjectModification.getDataAfter(), null); break; default: break; } }
@Override public boolean apply(DataObjectModification<Network> modifiedNetwork) { return (ModificationType.WRITE == modifiedNetwork.getModificationType() && NetworkUtils.isRouterExternal(modifiedNetwork.getDataAfter())); } }).transform(new Function<DataObjectModification<Network>, Uuid>() {
@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()); } } } }
@Override public boolean apply(@Nullable DataObjectModification<T> input) { return input != null && input.getModificationType() == DataObjectModification .ModificationType.DELETE; } };
private void disconnect(@Nonnull Collection<DataTreeModification<Node>> changes) { for (DataTreeModification<Node> change : changes) { if (change.getRootNode().getModificationType() == DataObjectModification.ModificationType.DELETE) { DataObjectModification<OvsdbNodeAugmentation> ovsdbNodeModification = change.getRootNode().getModifiedAugmentation(OvsdbNodeAugmentation.class); if (ovsdbNodeModification != null && ovsdbNodeModification.getDataBefore() != null) { OvsdbNodeAugmentation ovsdbNode = ovsdbNodeModification.getDataBefore(); ConnectionInfo key = ovsdbNode.getConnectionInfo(); InstanceIdentifier<Node> iid = cm.getInstanceIdentifier(key); try { cm.disconnect(ovsdbNode); LOG.info("OVSDB node has been disconnected:{}", ovsdbNode); cm.stopConnectionReconciliationIfActive(iid.firstIdentifierOf(Node.class), ovsdbNode); } catch (UnknownHostException e) { LOG.warn("Failed to disconnect ovsdbNode", e); } } } } }
@Override public boolean apply(@Nullable DataObjectModification<T> input) { return input != null && input.getDataBefore() != null; } };
/** * Switch the tree node pointer to the specified data object. * * @param mod The data object modification for the child of the * current tree node. */ void push(DataObjectModification<?> mod) { Deque<DataObjectModification<?>> stack = treeStack; if (stack == null) { stack = new LinkedList<>(); treeStack = stack; } stack.addLast(mod); if (pathArguments != null) { pathArguments.addLast(mod.getIdentifier()); } }
/** * 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); } } } }
/** * 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())); }
/** * 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; } }
@Nonnull D before, @Nonnull D after) { VtnUpdateType utype = VtnUpdateType.CHANGED; Class<D> dtype = mod.getDataType(); boolean children = handleChildrenFirst(ctx, ectx, mod, dtype, utype);
/** * 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 void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Session>> changes) { for (DataTreeModification<Session> change : changes) { final DataObjectModification<Session> rootNode = change.getRootNode(); final DataObjectModification.ModificationType modificationType = rootNode.getModificationType(); switch (modificationType) { case WRITE: final Session created = rootNode.getDataAfter(); if (created != null && rootNode.getDataBefore() == null) { publishStartedSession(created); } break; case DELETE: final Session removed = rootNode.getDataBefore(); if (removed != null) { publishEndedSession(removed); } break; } } }
@Override public boolean apply(@Nullable DataObjectModification<T> input) { return input != null && input.getDataBefore() != null && input.getDataAfter() != null; } };