BUG-2138: Listener support in shard frontend
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / sharding / DistributedShardedDOMDataTree.java
index 557543803769413e0baaebb73c1eae218293ba1e..0bb6aac36fc86b6285b06ca227592315fb178d66 100644 (file)
@@ -31,6 +31,7 @@ import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
+import org.opendaylight.controller.cluster.ActorSystemProvider;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient;
 import org.opendaylight.controller.cluster.databroker.actors.dds.SimpleDataStoreClientActor;
@@ -94,10 +95,10 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat
     private final EnumMap<LogicalDatastoreType, DistributedShardRegistration> defaultShardRegistrations =
             new EnumMap<>(LogicalDatastoreType.class);
 
-    public DistributedShardedDOMDataTree(final ActorSystem actorSystem,
+    public DistributedShardedDOMDataTree(final ActorSystemProvider actorSystemProvider,
                                          final DistributedDataStore distributedOperDatastore,
                                          final DistributedDataStore distributedConfigDatastore) {
-        this.actorSystem = Preconditions.checkNotNull(actorSystem);
+        this.actorSystem = Preconditions.checkNotNull(actorSystemProvider).getActorSystem();
         this.distributedOperDatastore = Preconditions.checkNotNull(distributedOperDatastore);
         this.distributedConfigDatastore = Preconditions.checkNotNull(distributedConfigDatastore);
         shardedDOMDataTree = new ShardedDOMDataTree();
@@ -135,8 +136,7 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat
             final T listener, final Collection<DOMDataTreeIdentifier> subtrees,
             final boolean allowRxMerges, final Collection<DOMDataTreeProducer> producers)
             throws DOMDataTreeLoopException {
-
-        throw new UnsupportedOperationException("Not implemented");
+        return shardedDOMDataTree.registerListener(listener, subtrees, allowRxMerges, producers);
     }
 
     @Nonnull
@@ -289,7 +289,7 @@ public class DistributedShardedDOMDataTree implements DOMDataTreeService, DOMDat
     private DistributedShardRegistration initDefaultShard(final LogicalDatastoreType logicalDatastoreType)
             throws DOMDataTreeProducerException, DOMDataTreeShardingConflictException {
         final Collection<Member> members = JavaConverters.asJavaCollectionConverter(
-            Cluster.get(actorSystem).state().members()).asJavaCollection();
+                Cluster.get(actorSystem).state().members()).asJavaCollection();
         final Collection<MemberName> names = Collections2.transform(members,
             m -> MemberName.forName(m.roles().iterator().next()));