BUG-5280: implement message queueing
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / actors / dds / DistributedDataStoreClientBehavior.java
index cacda93cb05b9bfe437755aa2b9ae8afd90f8f70..364e462e57c7b923379c2ec5a548c75f88622472 100644 (file)
@@ -14,6 +14,7 @@ import java.util.concurrent.CompletionStage;
 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
 import org.opendaylight.controller.cluster.datastore.actors.client.ClientActorBehavior;
 import org.opendaylight.controller.cluster.datastore.actors.client.ClientActorContext;
+import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -46,10 +47,12 @@ import org.slf4j.LoggerFactory;
 final class DistributedDataStoreClientBehavior extends ClientActorBehavior implements DistributedDataStoreClient {
     private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStoreClientBehavior.class);
 
+    private final ModuleShardBackendResolver resolver;
     private long nextHistoryId;
 
-    DistributedDataStoreClientBehavior(final ClientActorContext context) {
+    DistributedDataStoreClientBehavior(final ClientActorContext context, final ActorContext actorContext) {
         super(context);
+        resolver = new ModuleShardBackendResolver(actorContext);
     }
 
     //
@@ -63,16 +66,17 @@ final class DistributedDataStoreClientBehavior extends ClientActorBehavior imple
         // FIXME: Add state flushing here once we have state
     }
 
-    private ClientActorBehavior createLocalHistory(final CompletableFuture<ClientLocalHistory> future) {
+    private ClientActorBehavior createLocalHistory(final ClientActorBehavior currentBehavior,
+            final CompletableFuture<ClientLocalHistory> future) {
         final LocalHistoryIdentifier historyId = new LocalHistoryIdentifier(getIdentifier(), nextHistoryId++);
         LOG.debug("{}: creating a new local history {} for {}", persistenceId(), historyId, future);
 
         // FIXME: initiate backend instantiation
         future.completeExceptionally(new UnsupportedOperationException("Not implemented yet"));
-        return this;
+        return currentBehavior;
     }
 
-    private ClientActorBehavior shutdown() {
+    private ClientActorBehavior shutdown(final ClientActorBehavior currentBehavior) {
         // FIXME: Add shutdown procedures here
         return null;
     }
@@ -97,7 +101,7 @@ final class DistributedDataStoreClientBehavior extends ClientActorBehavior imple
     @Override
     public CompletionStage<ClientLocalHistory> createLocalHistory() {
         final CompletableFuture<ClientLocalHistory> future = new CompletableFuture<>();
-        context().executeInActor(() -> createLocalHistory(future));
+        context().executeInActor(currentBehavior -> createLocalHistory(currentBehavior, future));
         return future;
     }
 
@@ -105,4 +109,9 @@ final class DistributedDataStoreClientBehavior extends ClientActorBehavior imple
     public void close() {
         context().executeInActor(this::shutdown);
     }
+
+    @Override
+    protected ModuleShardBackendResolver resolver() {
+        return resolver;
+    }
 }