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;
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);
}
//
// 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;
}
@Override
public CompletionStage<ClientLocalHistory> createLocalHistory() {
final CompletableFuture<ClientLocalHistory> future = new CompletableFuture<>();
- context().executeInActor(() -> createLocalHistory(future));
+ context().executeInActor(currentBehavior -> createLocalHistory(currentBehavior, future));
return future;
}
public void close() {
context().executeInActor(this::shutdown);
}
+
+ @Override
+ protected ModuleShardBackendResolver resolver() {
+ return resolver;
+ }
}