public void testInvokeCommandOnAllSuspect() throws Exception {
DistributionManager distributionManager = cache(0).getAdvancedCache().getDistributionManager();
CacheTopology initialTopology = distributionManager.getCacheTopology();
assertEquals(CacheTopology.Phase.NO_REBALANCE, initialTopology.getPhase());
try {
ClusteredGetCommand command =
TestingUtil.extractCommandsFactory(cache(0)).buildClusteredGetCommand("key", 0, 0L);
RpcManager rpcManager0 = cache(0).getAdvancedCache().getRpcManager();
List<Address> newMembers = new ArrayList<>(initialTopology.getMembers());
newMembers.add(SUSPECT);
ConsistentHash newCH = new ReplicatedConsistentHashFactory().create(MurmurHash3.getInstance(), 1, 1,
newMembers, null);
CacheTopology suspectTopology =
new CacheTopology(initialTopology.getTopologyId(), initialTopology.getRebalanceId(), newCH, null, null,
CacheTopology.Phase.NO_REBALANCE, newCH.getMembers(), null);
distributionManager.setCacheTopology(suspectTopology);
command.setTopologyId(rpcManager0.getTopologyId());
CompletionStage<Map<Address, Response>> stage1 =
rpcManager0.invokeCommandOnAll(command, MapResponseCollector.validOnly(), rpcManager0.getSyncRpcOptions());
Exceptions.expectExecutionException(SuspectException.class, stage1.toCompletableFuture());
} finally {
distributionManager.setCacheTopology(initialTopology);
}
}