- actorContext.shutdown();
- DistributedDataStoreFactory.destroyInstance(this);
- }
-
- public ActorContext getActorContext() {
- return actorContext;
- }
-
- public void waitTillReady(){
- LOG.info("Beginning to wait for data store to become ready : {}", type);
-
- try {
- if (waitTillReadyCountDownLatch.await(waitTillReadyTimeInMillis, TimeUnit.MILLISECONDS)) {
- LOG.debug("Data store {} is now ready", type);
- } else {
- LOG.error("Shared leaders failed to settle in {} seconds, giving up", TimeUnit.MILLISECONDS.toSeconds(waitTillReadyTimeInMillis));
- }
- } catch (InterruptedException e) {
- LOG.error("Interrupted while waiting for shards to settle", e);
- }
- }
-
- private ActorRef createShardManager(ActorSystem actorSystem, ClusterWrapper cluster, Configuration configuration,
- DatastoreContext datastoreContext, String shardDispatcher, String shardManagerId,
- PrimaryShardInfoFutureCache primaryShardInfoCache){
- Exception lastException = null;
-
- for(int i=0;i<100;i++) {
- try {
- return actorSystem.actorOf(
- ShardManager.props(cluster, configuration, datastoreContext, waitTillReadyCountDownLatch,
- primaryShardInfoCache).withDispatcher(shardDispatcher).withMailbox(
- ActorContext.MAILBOX), shardManagerId);
- } catch (Exception e){
- lastException = e;
- Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
- LOG.debug(String.format("Could not create actor %s because of %s - waiting for sometime before retrying (retry count = %d)", shardManagerId, e.getMessage(), i));
- }
- }
-
- throw new IllegalStateException("Failed to create Shard Manager", lastException);
- }
-
- @VisibleForTesting
- public CountDownLatch getWaitTillReadyCountDownLatch() {
- return waitTillReadyCountDownLatch;