+ return stage;
+ }
+
+ @Override
+ public CompletionStage<ShardBackendInfo> refreshBackendInfo(final Long cookie,
+ final ShardBackendInfo staleInfo) {
+ final ShardState existing = backends.get(cookie);
+ if (existing != null) {
+ if (!staleInfo.equals(existing.getResult())) {
+ return existing.getStage();
+ }
+
+ LOG.debug("Invalidating backend information {}", staleInfo);
+ flushCache(staleInfo.getShardName());
+
+ LOG.trace("Invalidated cache {}", staleInfo);
+ backends.remove(cookie, existing);
+ }
+
+ return getBackendInfo(cookie);
+ }
+
+ @Override
+ public void close() {
+ shardAvailabilityChangesRegFuture.onComplete(new OnComplete<Registration>() {
+ @Override
+ public void onComplete(Throwable failure, Registration reply) {
+ reply.close();
+ }
+ }, ExecutionContexts.global());