/** * Runs callable tasks each in separate threads. * * @param calls Callable tasks. * @param threadName Thread name. * @return Execution time in milliseconds. * @throws Exception If failed. */ public static long runMultiThreaded(Iterable<Callable<?>> calls, String threadName) throws Exception { return runMultiThreaded(calls, new GridTestSafeThreadFactory(threadName)); }
/** * Create new thread around runnable task. * * @param r Runnable task to execute in the thread. * @return New thread around runnable task. * @see GridTestThread */ @Override public Thread newThread(final Runnable r) { return newThread(GridTestUtils.makeCallable(r, null)); }
/** */ 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); }
/** * 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); }
/** * 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"); }
/** * Performs an exclusive lock on a file, that * this lock instance was constructed with. * * @throws IgniteCheckedException If failed to perform locking. The file remains open. */ public void lock() throws IgniteCheckedException { lock(false); }
/** {@inheritDoc} */ @Override protected GridSslContextFactory sslContextFactory() { return GridTestUtils.sslContextFactory(); } }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); } }
/** * Fills {@code suite} with PDS test subset, which operates with real page store, but requires long time to * execute. * * @param suite suite to add tests into. * @param ignoredTests Ignored tests. */ private static void addRealPageStoreTestsLongRunning(List<Class<?>> suite, Collection<Class> ignoredTests) { // Basic PageMemory tests. GridTestUtils.addTestIfNeeded(suite, IgnitePdsPageReplacementTest.class, ignoredTests); }
/** * Asserts that the specified runnable completes within the specified timeout. * * @param timeout Timeout. * @param timeUnit Timeout {@link TimeUnit}. * @param runnable {@link Runnable} to check. * @throws Exception In case of any exception distinct from {@link TimeoutException}. */ public static void assertTimeout(long timeout, TimeUnit timeUnit, Runnable runnable) throws Exception { assertTimeout("Timeout occurred.", timeout, timeUnit, runnable); }
/** {@inheritDoc} */ @Override public void accept(String msg) { for (LogMessageListener lsnr : lsnrs) lsnr.accept(msg); }
/** * @param r Runnable to check support. */ protected void checkNotSupported(final RunnableX r) { GridTestUtils.assertThrows(log, new Callable<Object>() { @Override public Object call() throws Exception { r.run(); return null; } }, SQLFeatureNotSupportedException.class, null); }
/** {@inheritDoc} */ @Override protected GridSslContextFactory sslContextFactory() { return GridTestUtils.sslContextFactory(); } }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.CACHE_STORE); MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.LOCAL_CACHE); } }
/** * @param ig Node. */ private void checkExceptionTryUseDataStructure(final Ignite ig){ assertThrows(log, new Callable<Void>() { @Override public Void call() throws Exception { IgniteAtomicSequence seq = ig.atomicSequence("seq", 0, true); return null; } }, IgniteException.class, "Can not perform the operation because the cluster is inactive."); }
/** {@inheritDoc} */ @Override protected GridSslContextFactory sslContextFactory() { return GridTestUtils.sslContextFactory(); } }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { MvccFeatureChecker.failIfNotSupported(MvccFeatureChecker.Feature.NEAR_CACHE); backups = DFLT_BACKUPS; partitions = DFLT_PARTITIONS; }
/** * @param r Runnable to check on closed statement. */ protected void checkStatementClosed(final RunnableX r) { GridTestUtils.assertThrows(log, new Callable<Object>() { @Override public Object call() throws Exception { r.run(); return null; } }, SQLException.class, "Statement is closed"); }
/** * @param ig Node to check. */ private void checkExceptionTryUseService(final Ignite ig) { assertThrows(log, new Callable<Void>() { @Override public Void call() throws Exception { IgniteServices srvs = ig.services(); return null; } }, IgniteException.class, "Can not perform the operation because the cluster is inactive."); }