/** * Version of blockUntilViewsReceived that uses varargsa and cache managers */ public static void blockUntilViewsReceived(long timeout, CacheContainer... cacheContainers) { blockUntilViewsReceived(timeout, true, cacheContainers); }
/** * Version of blockUntilViewsReceived that uses varargs */ public static void blockUntilViewsReceived(long timeout, Cache... caches) { blockUntilViewsReceived(caches, timeout); }
public static void blockUntilViewsReceived(int timeout, boolean barfIfTooManyMembers, Collection caches) { Object first = caches.iterator().next(); if (first instanceof Cache) { blockUntilViewsReceived(timeout, barfIfTooManyMembers, (Cache[]) caches.toArray(new Cache[]{})); } else { blockUntilViewsReceived(timeout, barfIfTooManyMembers, (CacheContainer[]) caches.toArray(new CacheContainer[]{})); } }
public static void blockUntilViewsReceived(int timeout, Collection caches) { Object first = caches.iterator().next(); if (first instanceof Cache) { blockUntilViewsReceived(timeout, (Cache[]) caches.toArray(new Cache[]{})); } else { blockUntilViewsReceived(timeout, (CacheContainer[]) caches.toArray(new CacheContainer[]{})); } }
/** * Waits for the given memebrs to be removed from the cluster. The difference between this and {@link * #blockUntilViewsReceived(long, org.infinispan.manager.CacheContainer...)} methods(s) is that it does not barf if * more than expected memebers is in the cluster - this is because we expect to start with a grater number fo * memebers than we eventually expect. It will barf though, if the number of members is not the one expected but only * after the timeout expieres. */ public static void blockForMemberToFail(long timeout, CacheContainer... cacheContainers) { blockUntilViewsReceived(timeout, false, cacheContainers); areCacheViewsComplete(true, cacheContainers); }
void waitForRehashCompletion() { TestingUtil.blockUntilViewsReceived(60000, false, caches); TestingUtil.waitForNoRebalance(caches); } }
@SuppressWarnings("unchecked") void waitForRehashCompletion() { List<CacheContainer> allCacheManagers = new ArrayList<CacheContainer>(cacheManagers); // Collection already contains all cache managers, no need to add more TestingUtil.blockUntilViewsReceived(60000, false, allCacheManagers); waitForClusterToForm(cacheName); for (int i = 0; i < NUM_JOINERS; i++) { caches.add(joiners.get(i)); } } }
void waitForRehashCompletion() { // need to block until this join has completed! List<Cache> allCaches = new ArrayList<>(caches); allCaches.add(joiner); TestingUtil.blockUntilViewsReceived(60000, allCaches); waitForClusterToForm(cacheName); cacheManagers.add(joinerManager); caches.add(joiner); }
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); } }
public void waitForClusterToForm(String cacheName, long timeout, TimeUnit timeUnit) { List<Cache<Object, Object>> caches = getCaches(cacheName); Cache<Object, Object> cache = caches.get(0); TestingUtil.blockUntilViewsReceived((int) timeUnit.toMillis(timeout), false, caches); if (cache.getCacheConfiguration().clustering().cacheMode().isDistributed()) { TestingUtil.waitForNoRebalance(caches); } }
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); } }
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); } }
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 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); }
@Override protected void createCacheManagers() throws Throwable { ConfigurationBuilder config = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, true); registerCacheManager(TestCacheManagerFactory.createClusteredCacheManager(config)); registerCacheManager(TestCacheManagerFactory.createClusteredCacheManager(config)); TestingUtil.blockUntilViewsReceived(10000, cache(0), cache(1)); }
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 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"); }
private void testRestartOnlyMember(boolean crash) { // The coordinator stays up throughout the test, but the cache only runs on node 1 and then 2 manager(1).defineConfiguration(CACHE_NAME, clusteredConfig.build()); manager(1).getCache(CACHE_NAME); if (crash) { d2.setDiscardAll(true); } manager(1).stop(); TestingUtil.blockUntilViewsReceived(30000, false, manager(0)); addClusterEnabledCacheManager(clusteredConfig, new TransportFlags().withFD(true)); manager(2).getCache(CACHE_NAME); }
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]); } }