+
+ final ActorRef shardActor = shardInformation.getActor();
+ if (shardActor != null) {
+ LOG.debug("{} : Sending Shutdown to Shard actor {}", persistenceId(), shardActor);
+ FiniteDuration duration = shardInformation.getDatastoreContext().getShardRaftConfig()
+ .getElectionTimeOutInterval().$times(3);
+ final Future<Boolean> stopFuture = Patterns.gracefulStop(shardActor, duration, Shutdown.INSTANCE);
+ shardActorStoppingFutures.put(shardName, stopFuture);
+ stopFuture.onComplete(new OnComplete<Boolean>() {
+ @Override
+ public void onComplete(Throwable failure, Boolean result) {
+ if (failure == null) {
+ LOG.debug("{} : Successfully shut down Shard actor {}", persistenceId(), shardActor);
+ } else {
+ LOG.warn("{}: Failed to shut down Shard actor {}", persistenceId(), shardActor, failure);
+ }
+
+ self().tell((RunnableMessage) () -> shardActorStoppingFutures.remove(shardName),
+ ActorRef.noSender());
+ }
+ }, new Dispatchers(context().system().dispatchers()).getDispatcher(Dispatchers.DispatcherType.Client));
+ }
+
+ LOG.debug("{} : Local Shard replica for shard {} has been removed", persistenceId(), shardName);