use of org.apache.ignite.configuration.ExecutorConfiguration in project ignite by apache.
the class CustomThreadPool method customPool.
void customPool() {
// tag::pool-config[]
IgniteConfiguration cfg = new IgniteConfiguration();
cfg.setExecutorConfiguration(new ExecutorConfiguration("myPool").setSize(16));
// end::pool-config[]
Ignite ignite = Ignition.start(cfg);
ignite.compute().run(new OuterRunnable());
}
use of org.apache.ignite.configuration.ExecutorConfiguration in project ignite by apache.
the class PoolProcessor method start.
/**
* {@inheritDoc}
*/
@Override
public void start() throws IgniteCheckedException {
super.start();
IgniteConfiguration cfg = ctx.config();
UncaughtExceptionHandler oomeHnd = ctx.uncaughtExceptionHandler();
UncaughtExceptionHandler excHnd = new UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
ctx.failure().process(new FailureContext(FailureType.CRITICAL_ERROR, e));
}
};
validateThreadPoolSize(cfg.getPublicThreadPoolSize(), "public");
execSvc = createExecutorService("pub", cfg.getIgniteInstanceName(), cfg.getPublicThreadPoolSize(), cfg.getPublicThreadPoolSize(), DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.PUBLIC_POOL, oomeHnd);
execSvc.allowCoreThreadTimeOut(true);
validateThreadPoolSize(cfg.getServiceThreadPoolSize(), "service");
svcExecSvc = createExecutorService("svc", cfg.getIgniteInstanceName(), cfg.getServiceThreadPoolSize(), cfg.getServiceThreadPoolSize(), DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.SERVICE_POOL, oomeHnd);
svcExecSvc.allowCoreThreadTimeOut(true);
validateThreadPoolSize(cfg.getSystemThreadPoolSize(), "system");
sysExecSvc = createExecutorService("sys", cfg.getIgniteInstanceName(), cfg.getSystemThreadPoolSize(), cfg.getSystemThreadPoolSize(), DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.SYSTEM_POOL, oomeHnd);
sysExecSvc.allowCoreThreadTimeOut(true);
validateThreadPoolSize(cfg.getStripedPoolSize(), "stripedPool");
WorkersRegistry workerRegistry = ctx.workersRegistry();
stripedExecSvc = createStripedExecutor(cfg.getStripedPoolSize(), cfg.getIgniteInstanceName(), "sys", log, new IgniteInClosure<Throwable>() {
@Override
public void apply(Throwable t) {
ctx.failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, t));
}
}, false, workerRegistry, cfg.getFailureDetectionTimeout());
// Note that since we use 'LinkedBlockingQueue', number of
// maximum threads has no effect.
// Note, that we do not pre-start threads here as management pool may
// not be needed.
validateThreadPoolSize(cfg.getManagementThreadPoolSize(), "management");
mgmtExecSvc = createExecutorService("mgmt", cfg.getIgniteInstanceName(), cfg.getManagementThreadPoolSize(), cfg.getManagementThreadPoolSize(), DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.MANAGEMENT_POOL, oomeHnd);
mgmtExecSvc.allowCoreThreadTimeOut(true);
// Note that since we use 'LinkedBlockingQueue', number of
// maximum threads has no effect.
// Note, that we do not pre-start threads here as class loading pool may
// not be needed.
validateThreadPoolSize(cfg.getPeerClassLoadingThreadPoolSize(), "peer class loading");
p2pExecSvc = createExecutorService("p2p", cfg.getIgniteInstanceName(), cfg.getPeerClassLoadingThreadPoolSize(), cfg.getPeerClassLoadingThreadPoolSize(), DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.P2P_POOL, oomeHnd);
p2pExecSvc.allowCoreThreadTimeOut(true);
dataStreamerExecSvc = createStripedExecutor(cfg.getDataStreamerThreadPoolSize(), cfg.getIgniteInstanceName(), "data-streamer", log, new IgniteInClosure<Throwable>() {
@Override
public void apply(Throwable t) {
ctx.failure().process(new FailureContext(SYSTEM_WORKER_TERMINATION, t));
}
}, true, workerRegistry, cfg.getFailureDetectionTimeout());
// Note that we do not pre-start threads here as this pool may not be needed.
validateThreadPoolSize(cfg.getAsyncCallbackPoolSize(), "async callback");
callbackExecSvc = new IgniteStripedThreadPoolExecutor(cfg.getAsyncCallbackPoolSize(), cfg.getIgniteInstanceName(), "callback", oomeHnd, false, 0);
if (cfg.getConnectorConfiguration() != null) {
validateThreadPoolSize(cfg.getConnectorConfiguration().getThreadPoolSize(), "connector");
restExecSvc = createExecutorService("rest", cfg.getIgniteInstanceName(), cfg.getConnectorConfiguration().getThreadPoolSize(), cfg.getConnectorConfiguration().getThreadPoolSize(), DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.UNDEFINED, oomeHnd);
restExecSvc.allowCoreThreadTimeOut(true);
}
validateThreadPoolSize(cfg.getUtilityCacheThreadPoolSize(), "utility cache");
utilityCacheExecSvc = createExecutorService("utility", cfg.getIgniteInstanceName(), cfg.getUtilityCacheThreadPoolSize(), cfg.getUtilityCacheThreadPoolSize(), cfg.getUtilityCacheKeepAliveTime(), new LinkedBlockingQueue<>(), GridIoPolicy.UTILITY_CACHE_POOL, oomeHnd);
utilityCacheExecSvc.allowCoreThreadTimeOut(true);
affExecSvc = createExecutorService("aff", cfg.getIgniteInstanceName(), 1, 1, DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.AFFINITY_POOL, oomeHnd);
affExecSvc.allowCoreThreadTimeOut(true);
if (IgniteComponentType.INDEXING.inClassPath()) {
int cpus = Runtime.getRuntime().availableProcessors();
idxExecSvc = createExecutorService("idx", cfg.getIgniteInstanceName(), cpus, cpus * 2, 3000L, new LinkedBlockingQueue<>(1000), GridIoPolicy.IDX_POOL, oomeHnd);
int buildIdxThreadPoolSize = cfg.getBuildIndexThreadPoolSize();
validateThreadPoolSize(buildIdxThreadPoolSize, "build-idx");
buildIdxExecSvc = createExecutorService("build-idx-runner", cfg.getIgniteInstanceName(), buildIdxThreadPoolSize, buildIdxThreadPoolSize, DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.UNDEFINED, oomeHnd);
buildIdxExecSvc.allowCoreThreadTimeOut(true);
}
validateThreadPoolSize(cfg.getQueryThreadPoolSize(), "query");
qryExecSvc = createExecutorService("query", cfg.getIgniteInstanceName(), cfg.getQueryThreadPoolSize(), cfg.getQueryThreadPoolSize(), DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.QUERY_POOL, oomeHnd);
qryExecSvc.allowCoreThreadTimeOut(true);
schemaExecSvc = createExecutorService("schema", cfg.getIgniteInstanceName(), 2, 2, DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.SCHEMA_POOL, oomeHnd);
schemaExecSvc.allowCoreThreadTimeOut(true);
validateThreadPoolSize(cfg.getRebalanceThreadPoolSize(), "rebalance");
rebalanceExecSvc = createExecutorService("rebalance", cfg.getIgniteInstanceName(), cfg.getRebalanceThreadPoolSize(), cfg.getRebalanceThreadPoolSize(), DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.UNDEFINED, excHnd);
rebalanceExecSvc.allowCoreThreadTimeOut(true);
if (CU.isPersistenceEnabled(ctx.config())) {
snpExecSvc = createExecutorService(SNAPSHOT_RUNNER_THREAD_PREFIX, cfg.getIgniteInstanceName(), cfg.getSnapshotThreadPoolSize(), cfg.getSnapshotThreadPoolSize(), DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.UNDEFINED, excHnd);
snpExecSvc.allowCoreThreadTimeOut(true);
reencryptExecSvc = createExecutorService("reencrypt", ctx.igniteInstanceName(), 1, 1, DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.UNDEFINED, oomeHnd);
reencryptExecSvc.allowCoreThreadTimeOut(true);
}
if (cfg.getClientConnectorConfiguration() != null) {
thinClientExec = new IgniteThreadPoolExecutor("client-connector", cfg.getIgniteInstanceName(), cfg.getClientConnectorConfiguration().getThreadPoolSize(), cfg.getClientConnectorConfiguration().getThreadPoolSize(), 0, new LinkedBlockingQueue<>(), GridIoPolicy.UNDEFINED, oomeHnd);
}
rebalanceStripedExecSvc = createStripedThreadPoolExecutor(cfg.getRebalanceThreadPoolSize(), cfg.getIgniteInstanceName(), "rebalance-striped", excHnd, true, DFLT_THREAD_KEEP_ALIVE_TIME);
if (!F.isEmpty(cfg.getExecutorConfiguration())) {
validateCustomExecutorsConfiguration(cfg.getExecutorConfiguration());
customExecs = new HashMap<>();
for (ExecutorConfiguration execCfg : cfg.getExecutorConfiguration()) {
ThreadPoolExecutor exec = createExecutorService(execCfg.getName(), cfg.getIgniteInstanceName(), execCfg.getSize(), execCfg.getSize(), DFLT_THREAD_KEEP_ALIVE_TIME, new LinkedBlockingQueue<>(), GridIoPolicy.UNDEFINED, oomeHnd);
customExecs.put(execCfg.getName(), exec);
}
}
}
use of org.apache.ignite.configuration.ExecutorConfiguration in project ignite by apache.
the class GridMBeansTest method getConfiguration.
/**
* {@inheritDoc}
*
* This implementation registers adds custom executors to the configuration.
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setExecutorConfiguration(new ExecutorConfiguration(CUSTOM_EXECUTOR_0), new ExecutorConfiguration(CUSTOM_EXECUTOR_1));
return cfg;
}
use of org.apache.ignite.configuration.ExecutorConfiguration in project ignite by apache.
the class GridNodeMetricsLogSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setMetricsLogFrequency(1000);
cfg.setExecutorConfiguration(new ExecutorConfiguration(CUSTOM_EXECUTOR_0), new ExecutorConfiguration(CUSTOM_EXECUTOR_1));
cfg.setGridLogger(strLog);
return cfg;
}
use of org.apache.ignite.configuration.ExecutorConfiguration in project ignite by apache.
the class IgniteComputeCustomExecutorConfigurationSelfTest method testConfigurations.
/**
* @throws Exception If failed.
*/
@Test
public void testConfigurations() throws Exception {
try {
checkStartWithInvalidConfiguration(getConfiguration("node0").setExecutorConfiguration(new ExecutorConfiguration()));
checkStartWithInvalidConfiguration(getConfiguration("node0").setExecutorConfiguration(new ExecutorConfiguration("")));
checkStartWithInvalidConfiguration(getConfiguration("node0").setExecutorConfiguration(new ExecutorConfiguration("exec").setSize(-1)));
checkStartWithInvalidConfiguration(getConfiguration("node0").setExecutorConfiguration(new ExecutorConfiguration("exec").setSize(0)));
} finally {
Ignition.stopAll(true);
}
}
Aggregations