/** * @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); }
utilityPool.execute(new Runnable() { @Override public void run() { if (spiState == DISCONNECTED) {
final CountDownLatch stopLatch = new CountDownLatch(THREAD_CNT); IgniteThreadPoolExecutor exec = new IgniteThreadPoolExecutor( THREAD_CNT, THREAD_CNT, Long.MAX_VALUE, new LinkedBlockingQueue<Runnable>(), assert exec.prestartAllCoreThreads() == THREAD_CNT; exec.shutdown(); assert exec.awaitTermination(30, SECONDS);
/** * @param c Closure to run. */ void runInWorkerThread(Runnable c) { IgniteThreadPoolExecutor pool; synchronized (stateMux) { if (connState == ConnectionState.STOPPED) { LT.warn(log, "Do not run closure, node is stopped."); return; } if (utilityPool == null) { utilityPool = new IgniteThreadPoolExecutor("zk-discovery-pool", igniteInstanceName, 0, 1, 2000, new LinkedBlockingQueue<Runnable>()); } pool = utilityPool; } pool.submit(c); }
/** {@inheritDoc} */ @Override public void stop(boolean cancel) throws IgniteCheckedException { if (!isEnabled) return; ctx.io().removeMessageListener(GridTopic.TOPIC_AUTH, ioLsnr); ctx.event().removeDiscoveryEventListener(discoLsnr, DISCO_EVT_TYPES); cancelFutures("Node stopped"); if (!cancel) exec.shutdown(); else exec.shutdownNow(); }
/** * @param prestart Prestart flag. */ public void startThreads(boolean prestart) { execSvc = new IgniteThreadPoolExecutor(nodeId.toString(), null, 40, 40, Long.MAX_VALUE, new LinkedBlockingQueue<Runnable>()); // Improve concurrency for testing. if (prestart) execSvc.prestartAllCoreThreads(); }
asyncRunner.shutdownNow(); asyncRunner.awaitTermination(2, TimeUnit.MINUTES);
/** {@inheritDoc} */ @Override public void stop(boolean cancel) { busyLock.block(); // Clear interrupted flag temporarily. boolean interrupted = Thread.interrupted(); if (secondaryFs != null) { // Force all workers to finish their batches. for (IgfsFileWorkerBatch batch : workerMap.values()) batch.cancel(); try { if (secondaryFs instanceof LifecycleAware) ((LifecycleAware)secondaryFs).stop(); } catch (Exception e) { log.error("Failed to close secondary file system.", e); } } // Restore interrupted flag. if (interrupted) Thread.currentThread().interrupt(); if (dualPool != null) dualPool.shutdownNow(); }
/** * Constructs IGFS IPC handler. * * @param igfsCtx Context. * @param endpointCfg Endpoint configuration. * @param mgmt Management flag. */ IgfsIpcHandler(IgfsContext igfsCtx, IgfsIpcEndpointConfiguration endpointCfg, boolean mgmt) { assert igfsCtx != null; ctx = igfsCtx.kernalContext(); igfs = igfsCtx.igfs(); // Keep buffer size multiple of block size so no extra byte array copies is performed. bufSize = igfsCtx.configuration().getBlockSize() * 2; // Create thread pool for request handling. int threadCnt = endpointCfg.getThreadCount(); String prefix = "igfs-" + igfsCtx.igfs().name() + (mgmt ? "mgmt-" : "") + "-ipc"; pool = new IgniteThreadPoolExecutor(prefix, igfsCtx.kernalContext().igniteInstanceName(), threadCnt, threadCnt, Long.MAX_VALUE, new LinkedBlockingQueue<Runnable>()); log = ctx.log(IgfsIpcHandler.class); }
/** {@inheritDoc} */ @Override public void stop(boolean cancel) throws IgniteCheckedException { if (!isEnabled) return; ctx.io().removeMessageListener(GridTopic.TOPIC_AUTH, ioLsnr); ctx.event().removeDiscoveryEventListener(discoLsnr, DISCO_EVT_TYPES); cancelFutures("Node stopped"); if (!cancel) exec.shutdown(); else exec.shutdownNow(); }
asyncRunner.shutdownNow(); asyncRunner.awaitTermination(2, TimeUnit.MINUTES);
/** {@inheritDoc} */ @Override public void stop(boolean cancel) { busyLock.block(); // Clear interrupted flag temporarily. boolean interrupted = Thread.interrupted(); if (secondaryFs != null) { // Force all workers to finish their batches. for (IgfsFileWorkerBatch batch : workerMap.values()) batch.cancel(); try { if (secondaryFs instanceof LifecycleAware) ((LifecycleAware)secondaryFs).stop(); } catch (Exception e) { log.error("Failed to close secondary file system.", e); } } // Restore interrupted flag. if (interrupted) Thread.currentThread().interrupt(); if (dualPool != null) dualPool.shutdownNow(); }
/** * @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); }
dualPool = secondaryFs != null ? new IgniteThreadPoolExecutor(4, Integer.MAX_VALUE, 5000L, new SynchronousQueue<Runnable>(), new IgfsThreadFactory(cfg.getName())) : null;
/** */ private void addDefaultUser() { assert users != null && users.isEmpty(); User dfltUser = User.defaultUser(); // Put to local map to be ready for authentication. users.put(dfltUser.name(), dfltUser); // Put to MetaStore when it will be ready. exec.execute(new RefreshUsersStorageWorker(new ArrayList<>(Collections.singleton(dfltUser)))); }
execSvc = new IgniteThreadPoolExecutor( "pub", cfg.getIgniteInstanceName(), svcExecSvc = new IgniteThreadPoolExecutor( "svc", cfg.getGridName(), sysExecSvc = new IgniteThreadPoolExecutor( "sys", cfg.getIgniteInstanceName(), mgmtExecSvc = new IgniteThreadPoolExecutor( "mgmt", cfg.getIgniteInstanceName(), p2pExecSvc = new IgniteThreadPoolExecutor( "p2p", cfg.getIgniteInstanceName(), igfsExecSvc = new IgniteThreadPoolExecutor( cfg.getIgfsThreadPoolSize(), cfg.getIgfsThreadPoolSize(), restExecSvc = new IgniteThreadPoolExecutor( "rest", myCfg.getIgniteInstanceName(), utilityCacheExecSvc = new IgniteThreadPoolExecutor(
dualPool.execute(batch);
utilityPool = new IgniteThreadPoolExecutor("disco-pool", spi.ignite().name(), 0,
/** * Register operation, future and add operation worker to execute queue. * * @param op User operation. */ private void submitOperation(UserManagementOperation op) { synchronized (mux) { UserOperationFinishFuture fut = opFinishFuts.get(op.id()); if (fut == null) { fut = new UserOperationFinishFuture(op.id()); opFinishFuts.put(op.id(), fut); } if (!fut.workerSubmitted()) { fut.workerSubmitted(true); activeOps.put(op.id(), op); exec.execute(new UserOperationWorker(op, fut)); } } }
exec = new IgniteThreadPoolExecutor( "auth", ctx.config().getIgniteInstanceName(),