/** * Callback that is invoked when kernal is ready. */ public void onKernalStart() { // Accept connections only when grid is ready. if (srvEndpoint != null) new IgniteThread(acceptWorker).start(); }
/** * Executes the given command at some time in the future. The command with the same {@code index} * will be executed in the same thread. * * @param task the runnable task * @param idx Striped index. * @throws RejectedExecutionException if this task cannot be * accepted for execution. * @throws NullPointerException If command is null */ public void execute(Runnable task, int idx) { execs[threadId(idx)].execute(task); }
/** * Create striped thread pool. * * @param concurrentLvl Concurrency level. * @param igniteInstanceName Node name. * @param threadNamePrefix Thread name prefix. */ public IgniteStripedThreadPoolExecutor(int concurrentLvl, String igniteInstanceName, String threadNamePrefix, UncaughtExceptionHandler eHnd) { execs = new ExecutorService[concurrentLvl]; ThreadFactory factory = new IgniteThreadFactory(igniteInstanceName, threadNamePrefix, eHnd); for (int i = 0; i < concurrentLvl; i++) execs[i] = Executors.newSingleThreadExecutor(factory); }
/** * @throws ExecutionException If failed. */ @Test public void testGridThreadPoolExecutor() throws Exception { IgniteThreadPoolExecutor exec = new IgniteThreadPoolExecutor("", "", 1, 1, 0, new LinkedBlockingQueue<Runnable>()); exec.submit(new InterruptingRunnable()).get(); Future<Boolean> fut = exec.submit(new IsInterruptedAssertionCallable()); assert !fut.get() : "Expecting the executor to reset the interrupted flag when reinvoking the thread"; exec.shutdown(); assert exec.awaitTermination(30, SECONDS); }
/** * @throws ExecutionException If failed. */ @Test public void testGridThreadPoolExecutorRejection() throws Exception { IgniteThreadPoolExecutor exec = new IgniteThreadPoolExecutor("", "", 1, 1, 0, new LinkedBlockingQueue<Runnable>()); for (int i = 0; i < 10; i++) exec.submit(new TestRunnable()); exec.shutdown(); assert exec.awaitTermination(30, SECONDS); }
/** * @throws Exception If failed. */ @Test public void testSingleGridThreadExecutor() throws Exception { ExecutorService exec = Executors.newSingleThreadExecutor(new IgniteThreadFactory("gridName", "testThread")); exec.submit(new InterruptingRunnable()).get(); Future<Boolean> fut = exec.submit(new IsInterruptedAssertionCallable()); assert !fut.get() : "Expecting the executorService to reset the interrupted flag when reinvoking the thread"; // Thread is interrupted but Thread.interrupted() is called in AbstractQueuedSynchronizer.acquireInterruptibly // when blockingQueue wants to get the new task (see ThreadPoolExecutor.getTask()). // This will reset the interrupted flag but not the one from GridThread. Any subsequent calls to // Thread.currentThread.isInterrupted() will return true; exec.shutdown(); assert exec.awaitTermination(30, SECONDS); }
/** {@inheritDoc} */ @Override public String toString() { return S.toString(IgniteThread.class, this, "name", getName()); } }
/** * @return If current thread belongs to client. */ private boolean clientThread() { assert Thread.currentThread() instanceof IgniteThread; return ((IgniteThread)Thread.currentThread()).getIgniteInstanceName().contains("client"); }
/** * @throws Exception If failed. */ @Test public void testRebalanceThreadPoolSize() throws Exception { testWrongPoolSize(configuration().setRebalanceThreadPoolSize(WRONG_VALUE)); }
/** * Start this worker. */ void start() { new IgniteThread(this).start(); }
/** * Start this worker. */ void start() { new IgniteThread(this).start(); }
/** * Starts all associated threads to perform accept and read activities. */ public void start() { filterChain.start(); if (acceptWorker != null) new IgniteThread(acceptWorker).start(); for (IgniteThread thread : clientThreads) thread.start(); }
/** * */ private void startCleanupWorker() { cleanupWorker = new CleanupWorker(); new IgniteThread(cleanupWorker).start(); }
/** * Restart worker in IgniteThread. */ public void restart() { assert runner() == null : "WALWriter is still running."; isCancelled = false; new IgniteThread(this).start(); } }
/** * Restart worker in IgniteThread. */ public void restart() { assert runner() == null : "FileArchiver is still running"; isCancelled = false; new IgniteThread(archiver).start(); } }
/** * Restart worker in IgniteThread. */ public void restart() { assert runner() == null : "WalSegmentSyncer is running."; isCancelled = false; new IgniteThread(walSegmentSyncWorker).start(); } }
/** */ void restart() { assert runner() == null : "FileCompressorWorker is still running."; isCancelled = false; new IgniteThread(this).start(); }
/** Restart worker. */ void restart() { assert runner() == null : "FileDecompressor is still running."; isCancelled = false; new IgniteThread(this).start(); } }
/** * Perform initialization routine. * * @return This instance. */ public SchemaOperationWorker start() { if (startGuard.compareAndSet(false, true)) { if (!fut.isDone()) new IgniteThread(this).start(); } return this; }
/** {@inheritDoc} */ @Override public void start() { new IgniteThread(timeoutWorker).start(); if (log.isDebugEnabled()) log.debug("Timeout processor started."); }