X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-inmemory-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2FResolveDataChangeState.java;h=a644dca91d901cebda997c0f183eb57596887fdb;hp=3db4115af67908bed3c4edfcfbb2d91cdae3baae;hb=c5f3be93482d6b06d95ebf22b2ef2723fd813f89;hpb=72ad7baa35bfd2621029a2ebdce55fb62424c6ff diff --git a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java index 3db4115af6..a644dca91d 100644 --- a/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java +++ b/opendaylight/md-sal/sal-inmemory-datastore/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ResolveDataChangeState.java @@ -7,11 +7,9 @@ */ package org.opendaylight.controller.md.sal.dom.store.impl; -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -19,10 +17,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; - import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent.Builder; -import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerTree.Node; +import org.opendaylight.mdsal.dom.spi.RegistrationTreeNode; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; @@ -40,16 +37,18 @@ import org.slf4j.LoggerFactory; */ final class ResolveDataChangeState { private static final Logger LOG = LoggerFactory.getLogger(ResolveDataChangeState.class); + /** - * Inherited from all parents + * Inherited from all parents. */ private final Iterable inheritedSub; + /** - * Inherited from immediate parent + * Inherited from immediate parent. */ private final Collection inheritedOne; private final YangInstanceIdentifier nodeId; - private final Collection nodes; + private final Collection>> nodes; private final Map, Builder> subBuilders; private final Map, Builder> oneBuilders; @@ -57,7 +56,7 @@ final class ResolveDataChangeState { private ResolveDataChangeState(final YangInstanceIdentifier nodeId, final Iterable inheritedSub, final Collection inheritedOne, - final Collection nodes) { + final Collection>> nodes) { this.nodeId = Preconditions.checkNotNull(nodeId); this.nodes = Preconditions.checkNotNull(nodes); this.inheritedSub = Preconditions.checkNotNull(inheritedSub); @@ -69,19 +68,21 @@ final class ResolveDataChangeState { final Map, Builder> sub = new HashMap<>(); final Map, Builder> one = new HashMap<>(); final Map, Builder> base = new HashMap<>(); - for (Node n : nodes) { - for (DataChangeListenerRegistration l : n.getListeners()) { + for (RegistrationTreeNode> n : nodes) { + for (DataChangeListenerRegistration l : n.getRegistrations()) { final Builder b = DOMImmutableDataChangeEvent.builder(DataChangeScope.BASE); switch (l.getScope()) { - case BASE: - base.put(l, b); - break; - case ONE: - one.put(l, b); - break; - case SUBTREE: - sub.put(l, b); - break; + case BASE: + base.put(l, b); + break; + case ONE: + one.put(l, b); + break; + case SUBTREE: + sub.put(l, b); + break; + default: + break; } } } @@ -102,12 +103,12 @@ final class ResolveDataChangeState { * Create an initial state handle at a particular root node. * * @param rootId root instance identifier - * @param root root node - * @return + * @param registrationTreeNode root node */ - public static ResolveDataChangeState initial(final YangInstanceIdentifier rootId, final Node root) { + public static ResolveDataChangeState initial(final YangInstanceIdentifier rootId, + final RegistrationTreeNode> registrationTreeNode) { return new ResolveDataChangeState(rootId, Collections.emptyList(), - Collections.emptyList(), Collections.singletonList(root)); + Collections.emptyList(), Collections.singletonList(registrationTreeNode)); } /** @@ -153,7 +154,7 @@ final class ResolveDataChangeState { } /** - * Get the current path + * Get the current path. * * @return Current path. */ @@ -198,8 +199,6 @@ final class ResolveDataChangeState { /** * Add an event to all current listeners. - * - * @param event */ public void addEvent(final DOMImmutableDataChangeEvent event) { // Subtree builders get always notified @@ -257,13 +256,14 @@ final class ResolveDataChangeState { LOG.trace("Collected events {}", map); } - private static Collection getListenerChildrenWildcarded(final Collection parentNodes, + private static Collection>> getListenerChildrenWildcarded( + final Collection>> parentNodes, final PathArgument child) { if (parentNodes.isEmpty()) { return Collections.emptyList(); } - final List result = new ArrayList<>(); + final List>> result = new ArrayList<>(); if (child instanceof NodeWithValue || child instanceof NodeIdentifierWithPredicates) { NodeIdentifier wildcardedIdentifier = new NodeIdentifier(child.getNodeType()); addChildNodes(result, parentNodes, wildcardedIdentifier); @@ -272,11 +272,13 @@ final class ResolveDataChangeState { return result; } - private static void addChildNodes(final List result, final Collection parentNodes, final PathArgument childIdentifier) { - for (Node node : parentNodes) { - Optional child = node.getChild(childIdentifier); - if (child.isPresent()) { - result.add(child.get()); + private static void addChildNodes(final List>> result, + final Collection>> parentNodes, + final PathArgument childIdentifier) { + for (RegistrationTreeNode> node : parentNodes) { + RegistrationTreeNode> child = node.getExactChild(childIdentifier); + if (child != null) { + result.add(child); } } }