private void assertOwners(BlockedTopology t, boolean current, int segmentId, Address... address) { ConsistentHash ch = current ? t.getCacheTopology().getCurrentCH() : t.getCacheTopology().getPendingCH(); assertEquals("Topology: " + t.getCacheTopology(), Arrays.asList(address), ch.locateOwnersForSegment(segmentId)); } }
if (t1.getCacheTopology().getTopologyId() == stableTopologyId + 1) assertEquals(CacheTopology.Phase.NO_REBALANCE, t1.getPhase()); assertEquals(2, t1.getCacheTopology().getActualMembers().size()); assertEquals(null, t1.getCacheTopology().getPendingCH()); assertOwners(t1, true, 0); assertOwners(t1, true, 1, address(1)); assertEquals(2, t2.getCacheTopology().getActualMembers().size()); assertNotNull(t2.getCacheTopology().getPendingCH()); assertOwners(t2, false, 0, address(2)); assertOwners(t2, false, 1, address(1)); assertEquals(2, t3.getCacheTopology().getActualMembers().size()); assertEquals(null, t3.getCacheTopology().getPendingCH()); if (t3.getCacheTopology().getCurrentCH().locatePrimaryOwnerForSegment(0) == null) { ControlledRpcManager.BlockedRequest cancelStateTransfer = rpcManager2.expectCommand(StateRequestCommand.class, request -> assertEquals(StateRequestCommand.Type.CANCEL_STATE_TRANSFER, request.getType()));
private BlockingLocalTopologyManager.BlockedTopology blockNewRebalance(BlockingLocalTopologyManager ltm, BlockingLocalTopologyManager.BlockedTopology blockedTopology) throws InterruptedException { if (blockedTopology.getCacheTopology().getPhase() == CacheTopology.Phase.READ_NEW_WRITE_ALL) { // Block the rebalance start first, and only then unblock the previous topology // Otherwise the order of the rebalance start and topology confirmation wouldn't be deterministic BlockingLocalTopologyManager.BlockedTopology newTopology = ltm.expectTopologyUpdate(CacheTopology.Phase.READ_OLD_WRITE_ALL); blockedTopology.unblock(); ltm.expectPhaseConfirmation().unblock(); return newTopology; } else { assertEquals(CacheTopology.Phase.READ_OLD_WRITE_ALL, blockedTopology.getCacheTopology().getPhase()); ltm.confirmTopologyUpdate(CacheTopology.Phase.READ_NEW_WRITE_ALL); return blockedTopology; } }
public BlockedTopology expectTopologyUpdate(CacheTopology.Phase phase, int topologyId) throws InterruptedException { BlockedTopology blockedTopology = expectTopologyUpdate(); assertEquals(topologyId, blockedTopology.getCacheTopology().getTopologyId()); assertEquals(phase, blockedTopology.getCacheTopology().getPhase()); return blockedTopology; }
public BlockedTopology expectTopologyUpdate(CacheTopology.Phase phase) throws InterruptedException { BlockedTopology blockedTopology = expectTopologyUpdate(); assertTrue("Expected a CH_UPDATE or REBALANCE_START, but got a CONFIRMATION", blockedTopology.getType() != Type.CONFIRMATION); assertEquals(phase, blockedTopology.getCacheTopology().getPhase()); return blockedTopology; }