X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fsharding%2FDistributedShardFrontend.java;h=53411a94dc0f75b767b6f5009623cc8b20f88be7;hp=76648974799aee9d1ebfb80476a98586ef070454;hb=20f8f30f4bbf1e982672c1f883a6a18b0e4539de;hpb=13a15f0230ccc28a2ed7212b59dc785accf97b9f diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontend.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontend.java index 7664897479..53411a94dc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontend.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontend.java @@ -29,7 +29,6 @@ import org.opendaylight.mdsal.dom.spi.shard.SubshardProducerSpecification; import org.opendaylight.mdsal.dom.spi.shard.WriteableDOMDataTreeShard; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,14 +45,17 @@ class DistributedShardFrontend implements ReadableWriteableDOMDataTreeShard { private final Map childShards = new HashMap<>(); @GuardedBy("this") private final List producers = new ArrayList<>(); - private final DistributedDataStore distributedDataStore; + + private final DistributedShardChangePublisher publisher; DistributedShardFrontend(final DistributedDataStore distributedDataStore, final DataStoreClient client, final DOMDataTreeIdentifier shardRoot) { - this.distributedDataStore = Preconditions.checkNotNull(distributedDataStore); this.client = Preconditions.checkNotNull(client); this.shardRoot = Preconditions.checkNotNull(shardRoot); + + publisher = new DistributedShardChangePublisher(client, Preconditions.checkNotNull(distributedDataStore), + shardRoot, childShards); } @Override @@ -138,41 +140,6 @@ class DistributedShardFrontend implements ReadableWriteableDOMDataTreeShard { @SuppressWarnings("unchecked") public ListenerRegistration registerTreeChangeListener( final YangInstanceIdentifier treeId, final L listener) { - - final List toStrip = new ArrayList<>(shardRoot.getRootIdentifier().getPathArguments()); - final List stripFrom = new ArrayList<>(treeId.getPathArguments()); - - while (!toStrip.isEmpty()) { - stripFrom.remove(0); - toStrip.remove(0); - } - - return (ListenerRegistration) new ProxyRegistration(distributedDataStore - .registerProxyListener(treeId, YangInstanceIdentifier.create(stripFrom), listener), listener); - } - - private static class ProxyRegistration implements ListenerRegistration { - - private ListenerRegistration proxy; - private DOMDataTreeChangeListener listener; - - private ProxyRegistration( - final ListenerRegistration< - org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener> proxy, - final DOMDataTreeChangeListener listener) { - this.proxy = proxy; - this.listener = listener; - } - - @Override - public DOMDataTreeChangeListener getInstance() { - return listener; - } - - @Override - public void close() { - proxy.close(); - } + return publisher.registerTreeChangeListener(treeId, listener); } - }