ModuleShardBackendResolver extends AbstractShardBackendResolver { @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.getName()); LOG.trace("Invalidated cache {}", staleInfo); backends.remove(cookie, existing); } return getBackendInfo(cookie); } ModuleShardBackendResolver(final ClientIdentifier clientId, final ActorUtils actorUtils); @Override CompletionStage<ShardBackendInfo> getBackendInfo(final Long cookie); @Override CompletionStage<ShardBackendInfo> refreshBackendInfo(final Long cookie,
            final ShardBackendInfo staleInfo); @Override void close(); @Override String resolveCookieName(Long cookie);  }
@Test public void testRefreshBackendInfo() throws Exception { final CompletionStage<ShardBackendInfo> backendInfo = moduleShardBackendResolver.getBackendInfo(0L); contextProbe.expectMsgClass(ConnectClientRequest.class); final TestProbe staleBackendProbe = new TestProbe(system, "staleBackend"); final ConnectClientSuccess msg = new ConnectClientSuccess(CLIENT_ID, 0L, staleBackendProbe.ref(), Collections.emptyList(), dataTree, 3); contextProbe.reply(msg); final ShardBackendInfo staleBackendInfo = TestUtils.getWithTimeout(backendInfo.toCompletableFuture()); final CompletionStage<ShardBackendInfo> refreshed = moduleShardBackendResolver.refreshBackendInfo(0L, staleBackendInfo); contextProbe.expectMsgClass(ConnectClientRequest.class); final TestProbe refreshedBackendProbe = new TestProbe(system, "refreshedBackend"); final ConnectClientSuccess msg2 = new ConnectClientSuccess(CLIENT_ID, 1L, refreshedBackendProbe.ref(), Collections.emptyList(), dataTree, 3); contextProbe.reply(msg2); final ShardBackendInfo refreshedBackendInfo = TestUtils.getWithTimeout(refreshed.toCompletableFuture()); Assert.assertEquals(staleBackendInfo.getCookie(), refreshedBackendInfo.getCookie()); Assert.assertEquals(refreshedBackendProbe.ref(), refreshedBackendInfo.getActor()); }