terminationTask); } else { taskPool = new EnhancedQueueExecutorTaskPool(new EnhancedQueueExecutor.Builder() .setCorePoolSize(builder.getCoreWorkerPoolSize()) .setMaximumPoolSize(builder.getMaxWorkerPoolSize()) .setKeepAliveTime(builder.getWorkerKeepAlive(), TimeUnit.MILLISECONDS) .setThreadFactory(new WorkerThreadFactory(builder.getThreadGroup(), builder.getWorkerStackSize(), markThreadAsDaemon)) .setTerminationTask(terminationTask) .setRegisterMBean(true) .setMBeanName(workerName) .build() );
EnhancedQueueExecutor(final Builder builder) { this.acc = getContext(); int maxSize = builder.getMaximumPoolSize(); int coreSize = Math.min(builder.getCorePoolSize(), maxSize); this.handoffExecutor = builder.getHandoffExecutor(); this.exceptionHandler = builder.getExceptionHandler(); this.threadFactory = builder.getThreadFactory(); this.terminationTask = builder.getTerminationTask(); this.growthResistance = builder.getGrowthResistance(); final long keepAliveTime = builder.getKeepAliveTime(TimeUnit.NANOSECONDS); threadStatus = withCoreSize(withMaxSize(withAllowCoreTimeout(0L, builder.allowsCoreThreadTimeOut()), maxSize), coreSize); timeoutNanos = max(1L, keepAliveTime); queueSize = withMaxQueueSize(withCurrentQueueSize(0L, 0), builder.getMaximumQueueSize()); mxBean = new MXBeanImpl(); if (builder.isRegisterMBean()) { final String configuredName = builder.getMBeanName(); final String finalName = configuredName != null ? configuredName : "threadpool-" + sequence.getAndIncrement(); handle = doPrivileged(new PrivilegedAction<ObjectInstance>() {
executorService = new ThreadPoolExecutor(THREAD_POOL_CORE_SIZE, THREAD_POOL_MAX_SIZE, 30L, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>(WORK_QUEUE_SIZE), threadFactory); } else { executorService = new EnhancedQueueExecutor.Builder() .setCorePoolSize(THREAD_POOL_CORE_SIZE) .setMaximumPoolSize(THREAD_POOL_MAX_SIZE) .setKeepAliveTime(30L, TimeUnit.MILLISECONDS) .setMaximumQueueSize(WORK_QUEUE_SIZE) .setThreadFactory(threadFactory) .build();
executorService = new ThreadPoolExecutor(THREAD_POOL_CORE_SIZE, THREAD_POOL_MAX_SIZE, 30L, TimeUnit.MILLISECONDS, new LinkedBlockingDeque<>(WORK_QUEUE_SIZE), threadFactory); } else { executorService = new EnhancedQueueExecutor.Builder() .setCorePoolSize(THREAD_POOL_CORE_SIZE) .setMaximumPoolSize(THREAD_POOL_MAX_SIZE) .setKeepAliveTime(30L, TimeUnit.MILLISECONDS) .setMaximumQueueSize(WORK_QUEUE_SIZE) .setThreadFactory(threadFactory) .build();
target.addService(pmSvcName, pathManager).addAliases(PathManagerService.SERVICE_NAME).install(); if (legacyModelVersion == null) { ExecutorService mgmtExecutor = new EnhancedQueueExecutor.Builder() .setCorePoolSize(512) .setMaximumPoolSize(1024) .setKeepAliveTime(20L, TimeUnit.SECONDS) .build(); Service<ExecutorService> mgmtExecSvc = new ValueService<>(new ImmediateValue<>(mgmtExecutor)); target.addService(AbstractControllerService.EXECUTOR_CAPABILITY.getCapabilityServiceName(), mgmtExecSvc).install();
builder.install(); if (legacyModelVersion == null) { ExecutorService mgmtExecutor = new EnhancedQueueExecutor.Builder() .setCorePoolSize(1) .setMaximumPoolSize(256) .setKeepAliveTime(20L, TimeUnit.SECONDS) .build(); Service<ExecutorService> mgmtExecSvc = new ValueService<>(new ImmediateValue<>(mgmtExecutor)); target.addService(AbstractControllerService.EXECUTOR_CAPABILITY.getCapabilityServiceName(), mgmtExecSvc).install();
target.addService(pmSvcName, pathManager).addAliases(PathManagerService.SERVICE_NAME).install(); if (legacyModelVersion == null) { ExecutorService mgmtExecutor = new EnhancedQueueExecutor.Builder() .setCorePoolSize(512) .setMaximumPoolSize(1024) .setKeepAliveTime(20L, TimeUnit.SECONDS) .build(); Service<ExecutorService> mgmtExecSvc = new ValueService<>(new ImmediateValue<>(mgmtExecutor)); target.addService(AbstractControllerService.EXECUTOR_CAPABILITY.getCapabilityServiceName(), mgmtExecSvc).install();
builder.install(); if (legacyModelVersion == null) { ExecutorService mgmtExecutor = new EnhancedQueueExecutor.Builder() .setCorePoolSize(1) .setMaximumPoolSize(256) .setKeepAliveTime(20L, TimeUnit.SECONDS) .build(); Service<ExecutorService> mgmtExecSvc = new ValueService<>(new ImmediateValue<>(mgmtExecutor)); target.addService(AbstractControllerService.EXECUTOR_CAPABILITY.getCapabilityServiceName(), mgmtExecSvc).install();
terminationTask); } else { taskPool = new EnhancedQueueExecutorTaskPool(new EnhancedQueueExecutor.Builder() .setCorePoolSize(builder.getCoreWorkerPoolSize()) .setMaximumPoolSize(builder.getMaxWorkerPoolSize()) .setKeepAliveTime(builder.getWorkerKeepAlive(), TimeUnit.MILLISECONDS) .setThreadFactory(new WorkerThreadFactory(builder.getThreadGroup(), builder.getWorkerStackSize(), markThreadAsDaemon)) .setTerminationTask(terminationTask) .setRegisterMBean(true) .setMBeanName(workerName) .build() );
EnhancedQueueExecutor(final Builder builder) { this.acc = getContext(); int maxSize = builder.getMaximumPoolSize(); int coreSize = Math.min(builder.getCorePoolSize(), maxSize); this.handoffExecutor = builder.getHandoffExecutor(); this.exceptionHandler = builder.getExceptionHandler(); this.threadFactory = builder.getThreadFactory(); this.terminationTask = builder.getTerminationTask(); this.growthResistance = builder.getGrowthResistance(); final long keepAliveTime = builder.getKeepAliveTime(TimeUnit.NANOSECONDS); threadStatus = withCoreSize(withMaxSize(withAllowCoreTimeout(0L, builder.allowsCoreThreadTimeOut()), maxSize), coreSize); timeoutNanos = max(1L, keepAliveTime); queueSize = withMaxQueueSize(withCurrentQueueSize(0L, 0), builder.getMaximumQueueSize()); mxBean = new MXBeanImpl(); if (builder.isRegisterMBean()) { final String configuredName = builder.getMBeanName(); final String finalName = configuredName != null ? configuredName : "threadpool-" + sequence.getAndIncrement(); handle = doPrivileged(new PrivilegedAction<ObjectInstance>() {
EnhancedQueueExecutor(final Builder builder) { this.acc = getContext(); int maxSize = builder.getMaximumPoolSize(); int coreSize = Math.min(builder.getCorePoolSize(), maxSize); this.handoffExecutor = builder.getHandoffExecutor(); this.exceptionHandler = builder.getExceptionHandler(); this.threadFactory = builder.getThreadFactory(); this.terminationTask = builder.getTerminationTask(); this.growthResistance = builder.getGrowthResistance(); final long keepAliveTime = builder.getKeepAliveTime(TimeUnit.NANOSECONDS); threadStatus = withCoreSize(withMaxSize(withAllowCoreTimeout(0L, builder.allowsCoreThreadTimeOut()), maxSize), coreSize); timeoutNanos = max(1L, keepAliveTime); queueSize = withMaxQueueSize(withCurrentQueueSize(0L, 0), builder.getMaximumQueueSize()); mxBean = new MXBeanImpl(); if (builder.isRegisterMBean()) { final String configuredName = builder.getMBeanName(); final String finalName = configuredName != null ? configuredName : "threadpool-" + sequence.getAndIncrement(); handle = doPrivileged(new PrivilegedAction<ObjectInstance>() {
delegate = new EnhancedQueueExecutor.Builder() .setCorePoolSize(corePoolSize) .setMaximumPoolSize(maximumPoolSize) .setKeepAliveTime(keepAliveTime, unit) .setTerminationTask(new Runnable() { public void run() { shutdownComplete(shutdownInitiated); .setThreadFactory(threadFactory) .build();
/** {@inheritDoc} */ @Override public synchronized void start(StartContext context) throws StartException { MGMT_OP_LOGGER.debugf("Starting operation handler service %s", context.getController().getName()); responseAttachmentSupport = new ResponseAttachmentInputStreamSupport(scheduledExecutor.getValue()); final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<JBossThreadFactory>() { public JBossThreadFactory run() { return new JBossThreadFactory(new ThreadGroup("management-handler-thread"), Boolean.FALSE, null, "%G - %t", null, null); } }); if (EnhancedQueueExecutor.DISABLE_HINT) { ThreadPoolExecutor executor = new ThreadPoolExecutor(POOL_CORE_SIZE, POOL_MAX_SIZE, 600L, TimeUnit.SECONDS, new LinkedBlockingDeque<>(WORK_QUEUE_SIZE), threadFactory); // Allow the core threads to time out as well executor.allowCoreThreadTimeOut(true); this.clientRequestExecutor = executor; } else { this.clientRequestExecutor = new EnhancedQueueExecutor.Builder() .setCorePoolSize(POOL_CORE_SIZE) .setMaximumPoolSize(POOL_MAX_SIZE) .setKeepAliveTime(600L, TimeUnit.SECONDS) .setMaximumQueueSize(WORK_QUEUE_SIZE) .setThreadFactory(threadFactory) .allowCoreThreadTimeOut(true) .build(); } }
delegate = new EnhancedQueueExecutor.Builder() .setCorePoolSize(corePoolSize) .setMaximumPoolSize(maximumPoolSize) .setKeepAliveTime(keepAliveTime, unit) .setTerminationTask(new Runnable() { public void run() { shutdownComplete(shutdownInitiated); .setThreadFactory(threadFactory) .build();
/** {@inheritDoc} */ @Override public synchronized void start(StartContext context) throws StartException { MGMT_OP_LOGGER.debugf("Starting operation handler service %s", context.getController().getName()); responseAttachmentSupport = new ResponseAttachmentInputStreamSupport(scheduledExecutor.getValue()); final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<JBossThreadFactory>() { public JBossThreadFactory run() { return new JBossThreadFactory(new ThreadGroup("management-handler-thread"), Boolean.FALSE, null, "%G - %t", null, null); } }); if (EnhancedQueueExecutor.DISABLE_HINT) { ThreadPoolExecutor executor = new ThreadPoolExecutor(POOL_CORE_SIZE, POOL_MAX_SIZE, 600L, TimeUnit.SECONDS, new LinkedBlockingDeque<>(WORK_QUEUE_SIZE), threadFactory); // Allow the core threads to time out as well executor.allowCoreThreadTimeOut(true); this.clientRequestExecutor = executor; } else { this.clientRequestExecutor = new EnhancedQueueExecutor.Builder() .setCorePoolSize(POOL_CORE_SIZE) .setMaximumPoolSize(POOL_MAX_SIZE) .setKeepAliveTime(600L, TimeUnit.SECONDS) .setMaximumQueueSize(WORK_QUEUE_SIZE) .setThreadFactory(threadFactory) .allowCoreThreadTimeOut(true) .build(); } }
@Override public synchronized void start(StartContext context) throws StartException { final String namePattern = "External Management Request Threads -- %t"; final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<ThreadFactory>() { public ThreadFactory run() { return new JBossThreadFactory(threadGroup, Boolean.FALSE, null, namePattern, null, null); } }); int poolSize = getPoolSize(); if (EnhancedQueueExecutor.DISABLE_HINT) { final BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>(WORK_QUEUE_SIZE); executorService = new ThreadPoolExecutor(poolSize, poolSize, 60L, TimeUnit.SECONDS, workQueue, threadFactory); } else { executorService = new EnhancedQueueExecutor.Builder() .setCorePoolSize(poolSize) .setMaximumPoolSize(poolSize) .setKeepAliveTime(60L, TimeUnit.SECONDS) .setMaximumQueueSize(WORK_QUEUE_SIZE) .setThreadFactory(threadFactory) .build(); } }
@Override public synchronized void start(StartContext context) throws StartException { final String namePattern = "External Management Request Threads -- %t"; final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<ThreadFactory>() { public ThreadFactory run() { return new JBossThreadFactory(threadGroup, Boolean.FALSE, null, namePattern, null, null); } }); int poolSize = getPoolSize(); if (EnhancedQueueExecutor.DISABLE_HINT) { final BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<Runnable>(WORK_QUEUE_SIZE); executorService = new ThreadPoolExecutor(poolSize, poolSize, 60L, TimeUnit.SECONDS, workQueue, threadFactory); } else { executorService = new EnhancedQueueExecutor.Builder() .setCorePoolSize(poolSize) .setMaximumPoolSize(poolSize) .setKeepAliveTime(60L, TimeUnit.SECONDS) .setMaximumQueueSize(WORK_QUEUE_SIZE) .setThreadFactory(threadFactory) .build(); } }
@Override public synchronized void start(final StartContext context) throws StartException { if (EnhancedQueueExecutor.DISABLE_HINT) { executorService = new ThreadPoolExecutor(1, Integer.MAX_VALUE, 5L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), threadFactory); } else { executorService = new EnhancedQueueExecutor.Builder() .setCorePoolSize(1) .setMaximumPoolSize(4096) .setKeepAliveTime(5L, TimeUnit.SECONDS) .setThreadFactory(threadFactory) .build(); } }
@Override public synchronized void start(final StartContext context) throws StartException { if (EnhancedQueueExecutor.DISABLE_HINT) { executorService = new ThreadPoolExecutor(1, Integer.MAX_VALUE, 5L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), threadFactory); } else { executorService = new EnhancedQueueExecutor.Builder() .setCorePoolSize(1) .setMaximumPoolSize(4096) .setKeepAliveTime(5L, TimeUnit.SECONDS) .setThreadFactory(threadFactory) .build(); } }
static ExecutorService createDefaultExecutor() { final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<JBossThreadFactory>() { public JBossThreadFactory run() { return new JBossThreadFactory(defaultThreadGroup, Boolean.FALSE, null, "%G " + executorCount.incrementAndGet() + "-%t", null, null); } }); final int maxThreads = getSystemProperty("org.jboss.as.controller.client.max-threads", 6); return EnhancedQueueExecutor.DISABLE_HINT ? new ThreadPoolExecutor(2, maxThreads, 60, TimeUnit.SECONDS, new LinkedBlockingDeque<>(), threadFactory) : new EnhancedQueueExecutor.Builder() .setCorePoolSize(2) .setMaximumPoolSize(maxThreads) .setKeepAliveTime(60, TimeUnit.SECONDS) .setThreadFactory(threadFactory) .build(); }