X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fsharding%2FDistributedShardFrontend.java;h=31bc8b6949156662cecdc9a62f116458b589eaad;hb=7e62b4a59f9e43bcd0585845f1aeb55c44199f27;hp=8edfddedf49be40e3a51e584ab9cd905d03fb3ca;hpb=c1336f9b497bc6867536a24f629c3f0b002ccb2f;p=controller.git 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 8edfddedf4..31bc8b6949 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 @@ -17,7 +17,7 @@ import java.util.Map; import javax.annotation.Nonnull; import javax.annotation.concurrent.GuardedBy; import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient; -import org.opendaylight.controller.cluster.datastore.DistributedDataStore; +import org.opendaylight.controller.cluster.datastore.AbstractDataStore; import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.api.DOMDataTreeShard; @@ -45,20 +45,23 @@ class DistributedShardFrontend implements ReadableWriteableDOMDataTreeShard { private final Map childShards = new HashMap<>(); @GuardedBy("this") private final List producers = new ArrayList<>(); - private final DistributedDataStore distributedDataStore; - DistributedShardFrontend(final DistributedDataStore distributedDataStore, + private final DistributedShardChangePublisher publisher; + + DistributedShardFrontend(final AbstractDataStore 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 public synchronized DOMDataTreeShardProducer createProducer(final Collection paths) { for (final DOMDataTreeIdentifier prodPrefix : paths) { - Preconditions.checkArgument(paths.contains(prodPrefix), "Prefix %s is not contained under shard root", + Preconditions.checkArgument(shardRoot.contains(prodPrefix), "Prefix %s is not contained under shard root", prodPrefix, paths); } @@ -105,11 +108,8 @@ class DistributedShardFrontend implements ReadableWriteableDOMDataTreeShard { continue; } - SubshardProducerSpecification spec = affectedSubshards.get(maybeAffected.getPrefix()); - if (spec == null) { - spec = new SubshardProducerSpecification(maybeAffected); - affectedSubshards.put(maybeAffected.getPrefix(), spec); - } + SubshardProducerSpecification spec = affectedSubshards.computeIfAbsent(maybeAffected.getPrefix(), + k -> new SubshardProducerSpecification(maybeAffected)); spec.addPrefix(bindPath); } } @@ -136,7 +136,6 @@ class DistributedShardFrontend implements ReadableWriteableDOMDataTreeShard { @Override public ListenerRegistration registerTreeChangeListener( final YangInstanceIdentifier treeId, final L listener) { - throw new UnsupportedOperationException("Listener registration not supported"); + return publisher.registerTreeChangeListener(treeId, listener); } - }