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%2Fdatabroker%2Factors%2Fdds%2FDistributedDataStoreClientBehavior.java;h=ff5f8820dda9b90cb7aae48efc2514f697acb65c;hp=917e759a98ea6dab80a186e7edb20ea315a6bb44;hb=c426700e494b8eb18e49c3384d057767a9efed35;hpb=3ebd44f9b7a4a217222036c2889d2a04b4f1eb30 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DistributedDataStoreClientBehavior.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DistributedDataStoreClientBehavior.java index 917e759a98..ff5f8820dd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DistributedDataStoreClientBehavior.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/databroker/actors/dds/DistributedDataStoreClientBehavior.java @@ -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; @@ -45,17 +46,13 @@ import org.slf4j.LoggerFactory; */ final class DistributedDataStoreClientBehavior extends ClientActorBehavior implements DistributedDataStoreClient { private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStoreClientBehavior.class); - private static final Object SHUTDOWN = new Object() { - @Override - public String toString() { - return "SHUTDOWN"; - } - }; + private final ModuleShardBackendResolver resolver; private long nextHistoryId; - DistributedDataStoreClientBehavior(final ClientActorContext context) { + DistributedDataStoreClientBehavior(final ClientActorContext context, final ActorContext actorContext) { super(context); + resolver = new ModuleShardBackendResolver(actorContext); } // @@ -69,24 +66,24 @@ final class DistributedDataStoreClientBehavior extends ClientActorBehavior imple // FIXME: Add state flushing here once we have state } - private void createLocalHistory(final CreateLocalHistoryCommand command) { - final CompletableFuture future = command.future(); + private ClientActorBehavior createLocalHistory(final CompletableFuture 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; + } + + private ClientActorBehavior shutdown() { + // FIXME: Add shutdown procedures here + return null; } @Override protected ClientActorBehavior onCommand(final Object command) { - if (command instanceof CreateLocalHistoryCommand) { - createLocalHistory((CreateLocalHistoryCommand) command); - } else if (command instanceof GetClientRequest) { + if (command instanceof GetClientRequest) { ((GetClientRequest) command).getReplyTo().tell(new Status.Success(this), ActorRef.noSender()); - } else if (SHUTDOWN.equals(command)) { - // FIXME: Add shutdown procedures here - return null; } else { LOG.warn("{}: ignoring unhandled command {}", persistenceId(), command); } @@ -102,13 +99,18 @@ final class DistributedDataStoreClientBehavior extends ClientActorBehavior imple @Override public CompletionStage createLocalHistory() { - final CreateLocalHistoryCommand command = new CreateLocalHistoryCommand(); - self().tell(command, ActorRef.noSender()); - return command.future(); + final CompletableFuture future = new CompletableFuture<>(); + context().executeInActor(() -> createLocalHistory(future)); + return future; } @Override public void close() { - self().tell(SHUTDOWN, ActorRef.noSender()); + context().executeInActor(this::shutdown); + } + + @Override + protected ModuleShardBackendResolver resolver() { + return resolver; } }