/** * 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()); } }
/** * 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())); }
@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 void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Node>> collection) { for (DataTreeModification<Node> change : collection) { final DataObjectModification<Node> rootNode = change.getRootNode(); switch (rootNode.getModificationType()) { case SUBTREE_MODIFIED: LOG.debug("Config for node {} updated", TopologyUtil.getNodeId(rootNode.getIdentifier())); disconnectNode(TopologyUtil.getNodeId(rootNode.getIdentifier())); connectNode(TopologyUtil.getNodeId(rootNode.getIdentifier()), rootNode.getDataAfter()); break; case WRITE: LOG.debug("Config for node {} created", TopologyUtil.getNodeId(rootNode.getIdentifier())); if (activeConnectors.containsKey(TopologyUtil.getNodeId(rootNode.getIdentifier()))) { LOG.warn("RemoteDevice{{}} was already configured, reconfiguring..", TopologyUtil.getNodeId(rootNode.getIdentifier())); disconnectNode(TopologyUtil.getNodeId(rootNode.getIdentifier())); } connectNode(TopologyUtil.getNodeId(rootNode.getIdentifier()), rootNode.getDataAfter()); break; case DELETE: LOG.debug("Config for node {} deleted", TopologyUtil.getNodeId(rootNode.getIdentifier())); disconnectNode(TopologyUtil.getNodeId(rootNode.getIdentifier())); break; } } }
/** * 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; } }
@Override public void remove(DataTreeModification<Evc> removedDataObject) { if (removedDataObject.getRootPath() != null && removedDataObject.getRootNode() != null) { log.info("evc {} deleted", removedDataObject.getRootNode().getIdentifier()); removeEvc(removedDataObject); } }
/** * 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; } }
@Override public void add(DataTreeModification<FlowCapableNodeConnector> newDataObject) { if (newDataObject.getRootPath() != null && newDataObject.getRootNode() != null) { log.info("node connector {} created", newDataObject.getRootNode().getIdentifier()); addFlowCapableNodeConnector(newDataObject); } }
args.addLast(mod.getIdentifier());
@Override public void add(DataTreeModification<Evc> newDataObject) { if (newDataObject.getRootPath() != null && newDataObject.getRootNode() != null) { log.info("evc {} created", newDataObject.getRootNode().getIdentifier()); addEvc(newDataObject); } }
@Override public void update(DataTreeModification<Evc> modifiedDataObject) { if (modifiedDataObject.getRootPath() != null && modifiedDataObject.getRootNode() != null) { log.info("evc {} updated", modifiedDataObject.getRootNode().getIdentifier()); updateEvc(modifiedDataObject); } }
@Override public void update(DataTreeModification<FlowCapableNodeConnector> modifiedDataObject) { if (modifiedDataObject.getRootPath() != null && modifiedDataObject.getRootNode() != null) { log.info("node connector {} updated", modifiedDataObject.getRootNode().getIdentifier()); updateFlowCapableNodeConnector(modifiedDataObject); } }
@Override public void remove(DataTreeModification<FlowCapableNodeConnector> removedDataObject) { if (removedDataObject.getRootPath() != null && removedDataObject.getRootNode() != null) { log.info("node connector {} deleted", removedDataObject.getRootNode().getIdentifier()); removeFlowCapableNodeConnector(removedDataObject); } }
@Override public void update(final DataTreeModification<Link> modifiedDataObject) { if (modifiedDataObject.getRootPath() != null && modifiedDataObject.getRootNode() != null) { LOG.info("evc link {} updated", modifiedDataObject.getRootNode().getIdentifier()); final EvcUpdateCommand evcUpdateCmd = new EvcUpdateCommand(dataBroker, modifiedDataObject); evcUpdateCmd.execute(); } } }
@Override public void add(final DataTreeModification<Node> newDataObject) { if (newDataObject.getRootPath() != null && newDataObject.getRootNode() != null) { LOG.info("uni node {} created", newDataObject.getRootNode().getIdentifier()); final UniAddCommand uniAddCmd = new UniAddCommand(dataBroker, newDataObject); uniAddCmd.execute(); } }
@Override public void remove(final DataTreeModification<Node> removedDataObject) { if (removedDataObject.getRootPath() != null && removedDataObject.getRootNode() != null) { LOG.info("uni node {} deleted", removedDataObject.getRootNode().getIdentifier()); final UniRemoveCommand uniRemoveCmd = new UniRemoveCommand(dataBroker, removedDataObject); uniRemoveCmd.execute(); } }
@Override public void update(final DataTreeModification<Node> modifiedDataObject) { if (modifiedDataObject.getRootPath() != null && modifiedDataObject.getRootNode() != null) { LOG.info("uni node {} updated", modifiedDataObject.getRootNode().getIdentifier()); final UniUpdateCommand uniUpdateCmd = new UniUpdateCommand(dataBroker, modifiedDataObject); uniUpdateCmd.execute(); } }
@Override public void add(final DataTreeModification<Link> newDataObject) { if (newDataObject.getRootPath() != null && newDataObject.getRootNode() != null) { LOG.info("evc link {} created", newDataObject.getRootNode().getIdentifier()); final EvcAddCommand evcAddCmd = new EvcAddCommand(dataBroker, newDataObject); evcAddCmd.execute(); } }
@Override public void add(final DataTreeModification<Node> newDataObject) { if (newDataObject.getRootPath() != null && newDataObject.getRootNode() != null) { LOG.info("ovs node {} created", newDataObject.getRootNode().getIdentifier()); final OvsNodeAddCommand ovsNodeAddCmd = new OvsNodeAddCommand(dataBroker, newDataObject); ovsNodeAddCmd.execute(); } }
@Override public void remove(final DataTreeModification<Link> removedDataObject) { if (removedDataObject.getRootPath() != null && removedDataObject.getRootNode() != null) { LOG.info("evc link {} deleted", removedDataObject.getRootNode().getIdentifier()); final EvcRemoveCommand evcRemovedCmd = new EvcRemoveCommand(dataBroker, removedDataObject); evcRemovedCmd.execute(); } }