private Future<Void> simulateTopologyUpdate(Cache<Object, Object> cache) { StateTransferLock stl4 = TestingUtil.extractComponent(cache, StateTransferLock.class); DistributionManager dm4 = cache.getAdvancedCache().getDistributionManager(); LocalizedCacheTopology cacheTopology = dm4.getCacheTopology(); int newTopologyId = cacheTopology.getTopologyId() + 1; CacheTopology newTopology = new CacheTopology(newTopologyId, cacheTopology.getRebalanceId(), cacheTopology.getCurrentCH(), cacheTopology.getPendingCH(), cacheTopology.getUnionCH(), cacheTopology.getPhase(), cacheTopology.getActualMembers(), cacheTopology.getMembersPersistentUUIDs()); dm4.setCacheTopology(newTopology); return fork(() -> stl4.notifyTransactionDataReceived(newTopologyId)); } }
public void testNewTopologySentAfterOverlappingMerge() { TestingUtil.waitForNoRebalanceAcrossManagers(managers()); int initialTopology = advancedCache(0).getRpcManager().getTopologyId(); expectCompleteTopology(client, initialTopology); PartitionDescriptor p1 = new PartitionDescriptor(0); // isolatePartitions will always result in a CR fail as Node 0 tries to contact Node 1 in order to receive segments // which is not possible as all messages received by Node 1 from Node 0 are discarded by the DISCARD protocol. // Therefore, it is necessary for the state transfer timeout to be < then the timeout utilised by TestingUtil::waitForNoRebalance isolatePartition(p1.getNodes()); eventuallyEquals(1, () -> advancedCache(0).getDistributionManager().getCacheTopology().getActualMembers().size()); eventuallyExpectPartialTopology(client, initialTopology + 1); partition(0).merge(partition(1)); int finalTopologyId = initialTopology + (partitionHandling == PartitionHandling.DENY_READ_WRITES ? 2 : 7); eventuallyExpectCompleteTopology(client, finalTopologyId); // Check that we got the number of topology updates to NO_REBALANCE right // With DENY_READ_WRITES: // T+1: DEGRADED_MODE in partition [A] // T+2: back to AVAILABLE // With ALLOW_READ_WRITES: // With ALLOW_READ_WRITES: // T+2: CONFLICT_RESOLUTION, preferred CH: owners = (1) [test-NodeA-22368: 256+0] // T+3: NO_REBALANCE update topology after CR and before rebalance begins // T+4:READ_OLD (rebalance starts), T+5:READ_ALL, T+6:READ_NEW, T+7: NO_REBALANCE LocalizedCacheTopology newTopology = advancedCache(0).getDistributionManager().getCacheTopology(); assertEquals(CacheTopology.Phase.NO_REBALANCE, newTopology.getPhase()); }
public void testNewTopologySentAfterCleanMerge() { TestingUtil.waitForNoRebalanceAcrossManagers(managers()); int initialTopology = advancedCache(0).getRpcManager().getTopologyId(); expectCompleteTopology(client, initialTopology); PartitionDescriptor p0 = new PartitionDescriptor(0); PartitionDescriptor p1 = new PartitionDescriptor(1); splitCluster(p0.getNodes(), p1.getNodes()); eventuallyEquals(1, () -> advancedCache(0).getDistributionManager().getCacheTopology().getActualMembers().size()); eventuallyEquals(1, () -> advancedCache(1).getDistributionManager().getCacheTopology().getActualMembers().size()); expectPartialTopology(client, initialTopology + 1); partition(0).merge(partition(1)); int finalTopologyId = initialTopology + (partitionHandling == PartitionHandling.DENY_READ_WRITES ? 4 : 8); eventuallyExpectCompleteTopology(client, finalTopologyId); // Check that we got the number of topology updates to NO_REBALANCE right // With DENY_READ_WRITES: // T+1: DEGRADED_MODE in both partitions // T+3: merged, still DEGRADED_MODE // T+4: back to AVAILABLE // With ALLOW_READ_WRITES: // T+2: NO_REBALANCE in partition [B] before merge // T+3: CONFLICT_RESOLUTION, preferred CH: owners = (1) [test-NodeA-22368: 256+0] // T+4: NO_REBALANCE update topology after CR and before rebalance begins // T+5:READ_OLD (rebalance starts), T+6:READ_ALL, T+7:READ_NEW, T+8: NO_REBALANCE LocalizedCacheTopology newTopology = advancedCache(0).getDistributionManager().getCacheTopology(); assertEquals(CacheTopology.Phase.NO_REBALANCE, newTopology.getPhase()); assertEquals(finalTopologyId, newTopology.getTopologyId()); }