use of com.ctrip.xpipe.concurrent.DefaultExecutorFactory in project x-pipe by ctripcorp.
the class AbstractSpringConfigContext method getGlobalExecutor.
@Bean(name = GLOBAL_EXECUTOR)
public ExecutorService getGlobalExecutor() {
int corePoolSize = OsUtils.getMultiCpuOrMax(GLOBAL_THREAD_MULTI_CORE, GLOBAL_THREAD_MAX);
int maxPoolSize = 2 * OsUtils.getCpuCount();
DefaultExecutorFactory executorFactory = new DefaultExecutorFactory(GLOBAL_EXECUTOR, corePoolSize, maxPoolSize, new ThreadPoolExecutor.AbortPolicy());
return executorFactory.createExecutorService();
}
use of com.ctrip.xpipe.concurrent.DefaultExecutorFactory in project x-pipe by ctripcorp.
the class DefaultRedisSessionManager method postConstruct.
@PostConstruct
public void postConstruct() {
int corePoolSize = 30 * OsUtils.getCpuCount();
int maxPoolSize = 512;
DefaultExecutorFactory executorFactory = new DefaultExecutorFactory("RedisSession", corePoolSize, maxPoolSize, new ThreadPoolExecutor.AbortPolicy());
executors = executorFactory.createExecutorService();
int fixedPoolSize = OsUtils.getCpuCount();
pingAndDelayExecutor = new DefaultExecutorFactory("Ping-Delay-Executor", fixedPoolSize, fixedPoolSize, new ThreadPoolExecutor.CallerRunsPolicy()).createExecutorService();
scheduled.scheduleAtFixedRate(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
try {
removeUnusedRedises();
} catch (Exception e) {
logger.error("[removeUnusedRedises]", e);
}
for (RedisSession redisSession : sessions.values()) {
try {
redisSession.check();
} catch (Exception e) {
logger.error("[check]" + redisSession, e);
}
}
}
}, 5, 5, TimeUnit.SECONDS);
}
Aggregations