@Override protected void safeRun() { ExecutorService e = cfg.getExecutorService(); if (!(e instanceof ThreadPoolExecutor)) return; ThreadPoolExecutor exec = (ThreadPoolExecutor)e; long completedCnt = exec.getCompletedTaskCount(); // If all threads are active and no task has completed since last time and there is // at least one waiting request, then it is possible starvation. if (exec.getPoolSize() == exec.getActiveCount() && completedCnt == lastCompletedCnt && !exec.getQueue().isEmpty()) LT.warn(log, null, "Possible thread pool starvation detected (no task completed in last " + interval + "ms, is executorService pool size large enough?)"); lastCompletedCnt = completedCnt; } }, interval, interval);
/** * @param c Grid configuration. * @return Data transfer object for node executors configuration properties. */ public static VisorExecutorServiceConfig from(GridConfiguration c) { VisorExecutorServiceConfig cfg = new VisorExecutorServiceConfig(); cfg.executeService(compactClass(c.getExecutorService())); cfg.executeServiceShutdown(c.getExecutorServiceShutdown()); cfg.systemExecutorService(compactClass(c.getSystemExecutorService())); cfg.systemExecutorServiceShutdown(c.getSystemExecutorServiceShutdown()); cfg.p2pExecutorService(compactClass(c.getPeerClassLoadingExecutorService())); cfg.p2pExecutorServiceShutdown(c.getSystemExecutorServiceShutdown()); GridClientConnectionConfiguration cc = c.getClientConnectionConfiguration(); if (cc != null) { cfg.restExecutorService(compactClass(cc.getRestExecutorService())); cfg.restExecutorServiceShutdown(cc.isRestExecutorServiceShutdown()); } return cfg; }
/** {@inheritDoc} */ @Override public String getExecutorServiceFormatted() { assert cfg != null; return cfg.getExecutorService().toString(); }
GridIndexingSpi[] indexingSpi = cfg.getIndexingSpi(); execSvc = cfg.getExecutorService(); sysExecSvc = cfg.getSystemExecutorService(); p2pExecSvc = cfg.getPeerClassLoadingExecutorService();
/** * @param ctx Kernal context. */ public GridClosureProcessor(GridKernalContext ctx) { super(ctx); sysPool = ctx.config().getSystemExecutorService(); pubPool = ctx.config().getExecutorService(); ggfsPool = ctx.config().getGgfsExecutorService(); }
drSndHubCfg = cfg.getDrSenderHubConfiguration() != null ? new GridDrSenderHubConfiguration(cfg.getDrSenderHubConfiguration()) : null; execSvc = cfg.getExecutorService(); execSvcShutdown = cfg.getExecutorServiceShutdown(); ggHome = cfg.getGridGainHome();
@Override public void onTimeout() { try { synchronized (mux) { GridTimeoutObject timeoutObj0 = timeoutObj; if (timeoutObj0 == null || timeoutObj0.timeoutId() != id) // The timer was canceled by explicit callcc() call. return; timeoutObj = null; } ExecutorService execSvc = job.isInternal() ? ctx.config().getManagementExecutorService() : ctx.config().getExecutorService(); assert execSvc != null; execSvc.submit(new Runnable() { @Override public void run() { callcc0(); } }); } catch (RejectedExecutionException e) { U.error(log(), "Failed to execute job (will execute synchronously).", e); callcc0(); } } };
/** * @param jobWorker Job worker. * @return {@code True} if job has been submitted to pool. */ private boolean executeAsync(GridJobWorker jobWorker) { try { ctx.config().getExecutorService().execute(jobWorker); if (metricsUpdateFreq > -1L) startedJobsCnt.increment(); return true; } catch (RejectedExecutionException e) { // Remove from active jobs. activeJobs.remove(jobWorker.getJobId(), jobWorker); // Even if job was removed from another thread, we need to reject it // here since job has never been executed. GridException e2 = new GridComputeExecutionRejectedException("Job has been rejected " + "[jobSes=" + jobWorker.getSession() + ", job=" + jobWorker.getJob() + ']', e); if (metricsUpdateFreq > -1L) rejectedJobsCnt.increment(); jobWorker.finishJob(null, e2, true); } return false; }
ctx.config().getSystemExecutorService().execute(taskWorker); else ctx.config().getExecutorService().execute(taskWorker);
/** @throws GridException If registration failed. */ private void registerExecutorMBeans() throws GridException { pubExecSvcMBean = registerExecutorMBean(cfg.getExecutorService(), "GridExecutionExecutor"); sysExecSvcMBean = registerExecutorMBean(cfg.getSystemExecutorService(), "GridSystemExecutor"); mgmtExecSvcMBean = registerExecutorMBean(cfg.getManagementExecutorService(), "GridManagementExecutor"); p2PExecSvcMBean = registerExecutorMBean(cfg.getPeerClassLoadingExecutorService(), "GridClassLoadingExecutor"); drExecSvcMBean = registerExecutorMBean(cfg.getDrExecutorService(), "GridDrExecutor"); GridClientConnectionConfiguration clientCfg = cfg.getClientConnectionConfiguration(); if (clientCfg != null) { restExecSvcMBean = clientCfg.getRestExecutorService() != null ? registerExecutorMBean(clientCfg.getRestExecutorService(), "GridRestExecutor") : null; } }
pubPool = ctx.config().getExecutorService(); p2pPool = ctx.config().getPeerClassLoadingExecutorService(); sysPool = ctx.config().getSystemExecutorService();
/** * @throws GridException Thrown in case of any errors. */ @Override public void start() throws GridException { if (ctx.config().isDaemon()) return; if (!enabled()) U.warn(log, "Indexing is disabled (to enable please configure GridH2IndexingSpi)."); GridIndexingMarshaller m = new IdxMarshaller(); for (GridIndexingSpi spi : getSpis()) { spi.registerMarshaller(m); for (GridCacheConfiguration cacheCfg : ctx.config().getCacheConfiguration()) spi.registerSpace(cacheCfg.getName()); } execSvc = ctx.config().getExecutorService(); startSpi(); for (GridCacheConfiguration ccfg : ctx.config().getCacheConfiguration()){ GridCacheQueryConfiguration qryCfg = ccfg.getQueryConfiguration(); if (qryCfg != null) { for (GridCacheQueryTypeMetadata meta : qryCfg.getTypeMetadata()) declaredTypesByName.put(new TypeName(ccfg.getName(), meta.getType()), meta); if (qryCfg.getTypeResolver() != null) typeResolvers.put(ccfg.getName(), qryCfg.getTypeResolver()); } } if (log.isDebugEnabled()) log.debug(startInfo()); }
/** * Creates resources processor. * * @param ctx Kernal context. */ public GridResourceProcessor(GridKernalContext ctx) { super(ctx); gridInjector = new GridResourceBasicInjector<>(ctx.grid()); ggHomeInjector = new GridResourceBasicInjector<>(ctx.config().getGridGainHome()); ggNameInjector = new GridResourceBasicInjector<>(ctx.config().getGridName()); locHostInjector = new GridResourceBasicInjector<>(ctx.config().getLocalHost()); mbeanSrvInjector = new GridResourceBasicInjector<>(ctx.config().getMBeanServer()); marshInjector = new GridResourceBasicInjector<>(ctx.config().getMarshaller()); execInjector = new GridResourceBasicInjector<Executor>(ctx.config().getExecutorService()); nodeIdInjector = new GridResourceBasicInjector<>(ctx.config().getNodeId()); logInjector = new GridResourceLoggerInjector(ctx.config().getGridLogger()); srvcInjector = new GridResourceServiceInjector(ctx.grid()); addrsRslvrInjector = new GridResourceBasicInjector<>(ctx.config().getAddressResolver()); }
GridDiagnostic.runBackgroundCheck(gridName, cfg.getExecutorService(), log); verChecker0 = new GridUpdateNotifier(gridName, VER, SITE, gw, false); verChecker0.checkForNewVersion(cfg.getExecutorService(), log);
A.notNull(cfg.getGridLogger(), "cfg.getGridLogger()"); A.notNull(cfg.getMarshaller(), "cfg.getMarshaller()"); A.notNull(cfg.getExecutorService(), "cfg.getExecutorService()"); A.notNull(cfg.getUserAttributes(), "cfg.getUserAttributes()");