@Override protected void setup() throws Exception { super.setup(); loader = (AdvancedLoadWriteStore) TestingUtil.getFirstLoader(cache); }
public static <T, W extends T> W wrapComponent(Cache<?, ?> cache, Class<T> tClass, WrapFactory<T, W, Cache<?, ?>> factory, boolean rewire) { T current = extractComponent(cache, tClass); W wrap = factory.wrap(cache, current); replaceComponent(cache, tClass, wrap, rewire); return wrap; }
public static <T, W extends T> W wrapGlobalComponent(CacheContainer cacheContainer, Class<T> tClass, WrapFactory<T, W, CacheContainer> factory, boolean rewire) { T current = extractGlobalComponent(cacheContainer, tClass); W wrap = factory.wrap(cacheContainer, current); replaceComponent(cacheContainer, tClass, wrap, rewire); return wrap; }
@Override protected void crashCacheManagers(EmbeddedCacheManager... cacheManagers) { TestingUtil.killCacheManagers(cacheManagers); } }
@Override protected void teardown() { super.teardown(); TestingUtil.recursiveFileRemove(LOCATION); }
@Override protected void teardown() { TestingUtil.clearContent(cacheManager); super.teardown(); }
public static CommandsFactory extractCommandsFactory(Cache<?, ?> cache) { if (cache instanceof AbstractDelegatingCache) { // Need to unwrap to the base cache return extractCommandsFactory(extractField(cache, "cache")); } return (CommandsFactory) extractField(cache, "commandsFactory"); }
/** * 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); }
@Override public Boolean call() throws Exception { if(throwException) { throwException = false; throw new TestException(); } return true; } }
protected LockManager lockManager(int i) { return TestingUtil.extractLockManager(cache(i)); }
protected LockManager lockManager(int i, String cacheName) { return TestingUtil.extractLockManager(getCache(i, cacheName)); }
private Stressor(Cache<String, String> cache, int cacheId, int workerId, Set<String> keysToIgnore) { this.cache = cache; tm = TestingUtil.getTransactionManager(cache); this.cacheId = cacheId; this.workerId = workerId; this.keysToIgnore = keysToIgnore; }
@Override public void run() { TestingUtil.sleepThread(period); } }
/** * Expects any commands. The moment a single command is detected, the {@link #waitForRpc()} command will be * unblocked. */ public void expectAny() { expect(c -> true); }
/** * Blocks for a predefined amount of time (30 Seconds) until commands defined in any of the expect*() methods have * been detected. If the commands have not been detected by this time, an exception is thrown. */ public void waitForRpc() { waitForRpc(30, TimeUnit.SECONDS); }
/** * Returns true if at least "duration" millis elapsed since the specified "start" time (millis). */ public static boolean moreThanDurationElapsed(long start, long duration) { return now() - duration >= start; }
protected void waitForClusterToForm(String... names) { if (names != null && names.length != 0) { for (String name : names) { waitForClusterToForm(name); } } else { waitForClusterToForm(); } }
/** * Equivalent to {@code runConcurrently(30, SECONDS, tasks)} */ protected void runConcurrently(ExceptionRunnable... tasks) throws Exception { runConcurrently(30, TimeUnit.SECONDS, tasks); }
@Override protected void setup() throws Exception { super.setup(); store = (AdvancedLoadWriteStore) TestingUtil.getFirstLoader(cache); }
@Override public Integer call() throws Exception { throw new TestException(); } }