X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fstore%2Fimpl%2Ftree%2FListenerTree.java;h=0d73143de2aad021ee17f7577d95eaabdc0af24e;hb=ce0f8ee50fbbc078c679bbf6305442e3aa2a2cfb;hp=f93f40a9cc1f5b9bd85e00543be0497fde16d4de;hpb=408eeef51f435abd2027f9d25ac5592066b202dd;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 f93f40a9cc..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;