private void waitRebalanceEnd() throws Exception { sequencer.advance("rebalance:end"); TestingUtil.waitForNoRebalance(caches()); }
protected void waitForClusterToResize() { TestingUtil.blockUntilViewsReceived(10000, false, caches); TestingUtil.waitForNoRebalance(caches); assertEquals(caches.size(), topology().size()); } }
protected void killMember(int cacheIndex, String cacheName, boolean awaitRehash) { List<Cache<Object, Object>> caches = caches(cacheName); caches.remove(cacheIndex); manager(cacheIndex).stop(); cacheManagers.remove(cacheIndex); if (awaitRehash && caches.size() > 0) { TestingUtil.blockUntilViewsReceived(60000, false, caches); TestingUtil.waitForNoRebalance(caches); } }
@BeforeMethod(alwaysRun = true) public void startSecondCacheManager() throws Exception { if (otherCacheManager == null) { otherCacheManager = createCacheManager(); } else { AssertJUnit.fail("Other cache manager should not be set!"); } Cache otherCache = otherCacheManager.getCache(); TestingUtil.waitForNoRebalance(cache, otherCache); }
public static void waitForNoRebalanceAcrossManagers(EmbeddedCacheManager... managers) { int numberOfManagers = managers.length; assert numberOfManagers > 0; Set<String> testCaches = getInternalAndUserCacheNames(managers[0]); log.debugf("waitForNoRebalance with managers %s, for caches %s", Arrays.toString(managers), testCaches); for (String cacheName : testCaches) { Cache[] caches = new Cache[numberOfManagers]; for (int i = 0; i < numberOfManagers; i++) caches[i] = managers[i].getCache(cacheName); TestingUtil.waitForNoRebalance(caches); } }
private void killCache() { if (stopCacheOnly) { killedCache.stop(); } else { manager(KILLED_INDEX).stop(); } if (waitForStateTransfer) { TestingUtil.waitForNoRebalance(originatorCache, otherCache); } }
private void waitForStateTransfer(int expectedTopologyId, Cache... caches) { waitForNoRebalance(caches); for (Cache c : caches) { CacheTopology cacheTopology = c.getAdvancedCache().getDistributionManager().getCacheTopology(); assertEquals(String.format("Wrong topology on cache %s, expected %d and got %s", c, expectedTopologyId, cacheTopology), expectedTopologyId, cacheTopology.getTopologyId()); } }
public void waitForClusterToForm(String cacheName) { List<Cache<Object, Object>> caches = getCaches(cacheName); Cache<Object, Object> cache = caches.get(0); TestingUtil.blockUntilViewsReceived(10000, caches); if (cache.getCacheConfiguration().clustering().cacheMode().isDistributed()) { TestingUtil.waitForNoRebalance(caches); } }
private void checkRehashed(DistributionManager dm, List<Cache<Object,Object>> caches, List<Address> addresses) { TestingUtil.waitForNoRebalance(caches); assertNull(dm.getCacheTopology().getPendingCH()); ConsistentHash ch = dm.getCacheTopology().getCurrentCH(); assertEquals(addresses, ch.getMembers()); for (int i = 0; i < ch.getNumSegments(); i++) { assertEquals(ch.getNumOwners(), ch.locateOwnersForSegment(i).size()); } } }
protected void waitForClusterToForm(String cacheName) { List<Cache<Object, Object>> caches = getCaches(cacheName); Cache<Object, Object> cache = caches.get(0); TestingUtil.blockUntilViewsReceived(30000, caches); if (cache.getCacheConfiguration().clustering().cacheMode().isClustered()) { TestingUtil.waitForNoRebalance(caches); } }
private void splitCluster() { splitCluster(new int[]{0, 1}, new int[]{2, 3}); TestingUtil.blockUntilViewsChanged(10000, 2, getCache(0), getCache(1), getCache(2), getCache(3)); TestingUtil.waitForNoRebalance(getCache(0), getCache(1)); TestingUtil.waitForNoRebalance(getCache(2), getCache(3)); }
private void checkValue(Object key, String value) { if (!waitForStateTransfer) { TestingUtil.waitForNoRebalance(originatorCache, otherCache); } log.tracef("Checking key: %s", key); InternalCacheEntry d0 = advancedCache(ORIGINATOR_INDEX).getDataContainer().get(key); InternalCacheEntry d1 = advancedCache(OTHER_INDEX).getDataContainer().get(key); assertEquals(d0.getValue(), value); assertEquals(d1.getValue(), value); }
@Override public void split(BaseTxPartitionAndMergeTest test) { test.getLog().debug("Splitting cluster isolating the originator."); test.splitCluster(new int[]{0}, new int[]{1, 2, 3}); assertDegradedPartition(test, 0); TestingUtil.waitForNoRebalance(test.cache(1), test.cache(2), test.cache(3)); test.getLog().debug("Cluster split."); } },
public void testNodeJoin() throws Exception { List<MagicKey> keys = init(); Cache c4 = addClusterEnabledCacheManager(defaultConfig, TRANSPORT_FLAGS).getCache(CACHE_NAME); TestingUtil.blockUntilViewsReceived(30000, false, c1, c2, c3, c4); TestingUtil.waitForNoRebalance(c1, c2, c3, c4); checkValuesInCache(keys, c1, c2, c3, c4); } }
public void testNodeCrash() { List<MagicKey> keys = init(); assertFalse(c2.getCacheManager().isCoordinator()); d2.setDiscardAll(true); TestingUtil.blockUntilViewsReceived(30000, false, c1, c3); TestingUtil.waitForNoRebalance(c1, c3); checkValuesInDC(keys, c1, c3); }
public void testCoordCrash() { List<MagicKey> keys = init(); assertTrue(c1.getCacheManager().isCoordinator()); d1.setDiscardAll(true); TestingUtil.blockUntilViewsReceived(30000, false, c2, c3); TestingUtil.waitForNoRebalance(c2, c3); checkValuesInDC(keys, c2, c3); }
public void testCoordinatorCrashesDuringJoin() { d2.setDiscardAll(true); manager(1).defineConfiguration(CACHE_NAME, clusteredConfig.build()); fork((Callable<Object>) () -> cache(1, CACHE_NAME)); TestingUtil.blockUntilViewsReceived(30000, false, manager(0)); TestingUtil.blockUntilViewsReceived(30000, false, manager(1)); TestingUtil.waitForNoRebalance(cache(1, CACHE_NAME)); } }
public void testConflictResolutionCalled() { Cache c0 = cache(0); Cache c1 = cache(1); assertEquals(1, topologySize(c0)); assertEquals(1, topologySize(c1)); c0.put(1, 1); c1.put(1, 2); enableDiscoveryProtocol(channel(c0)); enableDiscoveryProtocol(channel(c1)); TestingUtil.waitForNoRebalance(c0, c1); assertEquals(MERGE_RESULT, c0.get(1)); }
public void testMergeViewHappens() { discard.setDiscardAll(false); TestingUtil.blockUntilViewsReceived(60000, cache(0), cache(1)); TestingUtil.waitForNoRebalance(cache(0), cache(1)); assert ml0.isMerged && ml1.isMerged; cache(0).put("k", "v2"); assertEquals(cache(0).get("k"), "v2"); assertEquals(cache(1).get("k"), "v2"); }
public void testXidReturnedOnlyOnce() throws Throwable { EmbeddedTransaction dummyTransaction1 = beginAndSuspendTx(this.cache(3)); prepareTransaction(dummyTransaction1); manager(3).stop(); TestingUtil.blockUntilViewsReceived(60000, false, cache(0), cache(1), cache(2)); TestingUtil.waitForNoRebalance(cache(0), cache(1), cache(2)); EmbeddedTransaction dummyTransaction = beginAndSuspendTx(this.cache(0)); Xid[] recover = dummyTransaction.firstEnlistedResource().recover(XAResource.TMSTARTRSCAN | XAResource.TMENDRSCAN); assertEquals(recover.length,1); assertEquals(dummyTransaction1.getXid(), recover[0]); } }