/** */ private void checkCacheStartupError(final String name) { GridTestUtils.assertThrows(log, new Callable<Void>() { @Override public Void call() throws Exception { startGrid(name); return null; } }, IgniteCheckedException.class, null); }
/** * @param queue Ignite queue. * @return Cache context. */ protected static GridCacheContext cctx(IgniteQueue queue) { return GridTestUtils.getFieldValue(queue, "cctx"); }
/** * Runs given code in multiple threads. Returns future that ends upon * threads completion. If any thread failed, exception will be thrown * out of this method. * * @param r Runnable. * @param threadNum Thread number. * @param threadName Thread name. * @throws Exception If failed. * @return Future. */ protected IgniteInternalFuture<?> multithreadedAsync(Runnable r, int threadNum, String threadName) throws Exception { return GridTestUtils.runMultiThreadedAsync(r, threadNum, threadName); }
/** * Runs runnable object in specified number of threads. * * @param run Target runnable. * @param threadNum Number of threads. * @param threadName Thread name. * @return Execution time in milliseconds. * @throws Exception Thrown if at least one runnable execution failed. */ public static long runMultiThreaded(Runnable run, int threadNum, String threadName) throws Exception { return runMultiThreaded(makeCallable(run, null), threadNum, threadName); }
/** * Runs runnable object in specified number of threads. * * @param run Target runnable. * @param threadNum Number of threads. * @param threadName Thread name. * @return Future for the run. Future returns execution time in milliseconds. */ public static IgniteInternalFuture<Long> runMultiThreadedAsync(Runnable run, int threadNum, String threadName) { return runMultiThreadedAsync(makeCallable(run, null), threadNum, threadName); }
/** * @param lock IgniteLock. * @throws Exception If failed. */ protected void checkRemovedReentrantLock(final IgniteLock lock) throws Exception { assert GridTestUtils.waitForCondition(new PA() { @Override public boolean apply() { return lock.removed(); } }, 5000); assert lock.removed(); }
/** * Asserts that {@link IOException} will be thrown. * * @param call Callable that cause allocation overflow. */ @SuppressWarnings("ThrowableNotThrown") private void allocationOverflowCheck(Callable<?> call) { GridTestUtils.assertThrowsAnyCause(log, call, IOException.class, "Failed to allocate required memory"); }
/** * Runs callable task asyncronously. * * @param task Callable. * @return Future with task result. */ public static <T> IgniteInternalFuture<T> runAsync(final Callable<T> task) { return runAsync(task, "async-callable-runner"); }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); GridTestUtils.setFieldValue(User.class, "bCryptGensaltLog2Rounds", 4); }
/** * Runs given code in multiple threads and synchronously waits for all threads to complete. * If any thread failed, exception will be thrown out of this method. * * @param c Callable. * @param threadNum Thread number. * @param threadName Thread name. * @throws Exception If failed. */ protected void multithreaded(Callable<?> c, int threadNum, String threadName) throws Exception { GridTestUtils.runMultiThreaded(c, threadNum, threadName); }
/** * @throws Exception If failed. */ @Test public void testMergeServersJoin1() throws Exception { IgniteEx srv0 = startGrid(0); mergeExchangeWaitVersion(srv0, 3); final AtomicInteger idx = new AtomicInteger(1); IgniteInternalFuture<?> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() { @Override public Void call() throws Exception { startGrid(idx.getAndIncrement()); return null; } }, 2, "start-node"); fut.get(); checkCaches(); checkExchanges(srv0, 1, 3); checkExchanges(ignite(1), 3); checkExchanges(ignite(2), 3); }
/** * Test expected failures for 'create' operation. * * @param path File path to create. * @param overwrite Overwrite file if it already exists. Note: you cannot overwrite an existent directory. */ private void assertCreateFails(final String path, final boolean overwrite) { GridTestUtils.assertThrowsInherited(log, new Callable<Object>() { @Override public Object call() throws Exception { igfs.create(path(path), overwrite); return false; } }, IgfsException.class, null); }
GridTestUtils.assertOneToOne( nodes, new P1<GridClientNode>() {
/** * @param services Ignite services. * @param srvcName Service name to wait. * @throws IgniteInterruptedCheckedException If interrupted. */ private void waitForServiceDeploymentIfNeeded(IgniteServices services, String srvcName) throws IgniteInterruptedCheckedException { if (!isEventDrivenServiceProcessorEnabled) GridTestUtils.waitForCondition(() -> services.service(srvcName) != null, DEPLOYMENT_WAIT_TIMEOUT); }
@Override public void run() throws Exception { GridTestUtils.assertThrowsAnyCause(log, new Callable<Object>() { @Override public Object call() throws Exception { cache.getAndPut(key1, badValue); return null; } }, IgniteCheckedException.class, ERR_MSG); assertEquals(0, cache.size()); } });
@Override public void apply(IgniteFuture<String> fut) { GridTestUtils.runAsync(new Callable<Object>() { @Override public Object call() throws Exception { cache.deregisterCacheEntryListener(cfg); return null; } }); } });
/** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { GridTestUtils.setFieldValue(null, TxDeadlockDetection.class, "DEADLOCK_TIMEOUT", getInteger(IGNITE_TX_DEADLOCK_DETECTION_TIMEOUT, 60000)); }
/** * Runs given code in multiple threads and synchronously waits for all * threads to complete. If any thread failed, exception will be thrown * out of this method. * * @param r Runnable. * @param threadNum Thread number. * @param threadName Thread name. * @throws Exception If failed. */ protected void multithreaded(Runnable r, int threadNum, String threadName) throws Exception { GridTestUtils.runMultiThreaded(r, threadNum, threadName); }
/** * Test expected failures for 'append' operation. * * @param path File path to append. * @param create Create file if it doesn't exist yet. */ private void assertAppendFails(final String path, final boolean create) { GridTestUtils.assertThrowsInherited(log, new Callable<Object>() { @Override public Object call() throws Exception { igfs.append(path(path), create); return false; } }, IgfsException.class, null); }
assertEquals(0, evt.dataSize()); assertOneToOne( evtList.subList(3, evtsCnt), new P1<Event>() {