X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2Ftree%2FListenerTree.java;h=0d73143de2aad021ee17f7577d95eaabdc0af24e;hb=0552aa7d15d9482a9c24062786a743adca4ab74a;hp=83cfcaca18e9d3e3ad403f5665a91843867edc3f;hpb=c44438579115a5e89139a2ef1afed2037acbfa06;p=controller.git diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java index 83cfcaca18..0d73143de2 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerTree.java @@ -33,15 +33,24 @@ import org.slf4j.LoggerFactory; import com.google.common.base.Optional; import com.google.common.base.Preconditions; +/** + * A set of listeners organized as a tree by node to which they listen. This class + * allows for efficient lookup of listeners when we walk the DataTreeCandidate. + */ public final class ListenerTree { private static final Logger LOG = LoggerFactory.getLogger(ListenerTree.class); private final ReadWriteLock rwLock = new ReentrantReadWriteLock(true); private final Node rootNode = new Node(null, null); private ListenerTree() { - + // Private to disallow direct instantiation } + /** + * Create a new empty instance of the listener tree. + * + * @return An empty instance. + */ public static ListenerTree create() { return new ListenerTree(); } @@ -110,6 +119,14 @@ public final class ListenerTree { } } + /** + * Obtain a tree walking context. This context ensures a consistent view of + * the listener registrations. The context should be closed as soon as it + * is not required, because each unclosed instance blocks modification of + * the listener tree. + * + * @return A walker instance. + */ public Walker getWalker() { /* * TODO: The only current user of this method is local to the datastore. @@ -124,6 +141,10 @@ public final class ListenerTree { return ret; } + /** + * A walking context, pretty much equivalent to an iterator, but it + * exposes the undelying tree structure. + */ public static final class Walker implements AutoCloseable { private final Lock lock; private final Node node; @@ -220,6 +241,13 @@ public final class ListenerTree { children.remove(arg); removeThisIfUnused(); } + + @Override + public String toString() { + return "Node [identifier=" + identifier + ", listeners=" + listeners.size() + ", children=" + children.size() + "]"; + } + + } private abstract static class DataChangeListenerRegistrationImpl>> extends AbstractListenerRegistration //