- public void setDataStoreExecutor(ExecutorService dsExecutor) {
- this.dataStoreExecutorStatsBean = ThreadExecutorStatsMXBeanImpl.create(dsExecutor,
- "notification-executor", getMBeanType(), getMBeanCategory());
- }
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ private OnDemandRaftState getOnDemandRaftState() {
+ String name = getShardName();
+ OnDemandRaftState state = ONDEMAND_RAFT_STATE_CACHE.getIfPresent(name);
+ if (state == null) {
+ statRetrievalError = null;
+ statRetrievalTime = null;
+
+ if (shard != null) {
+ Timeout timeout = new Timeout(10, TimeUnit.SECONDS);
+ try {
+ Stopwatch timer = Stopwatch.createStarted();
+
+ state = (OnDemandRaftState) Await.result(Patterns.ask(shard.getSelf(),
+ GetOnDemandRaftState.INSTANCE, timeout), timeout.duration());
+
+ statRetrievalTime = timer.stop().toString();
+ ONDEMAND_RAFT_STATE_CACHE.put(name, state);
+ } catch (Exception e) {
+ statRetrievalError = e.toString();
+ }
+ }
+
+ state = state != null ? state : OnDemandRaftState.builder().build();
+ }