use of org.jboss.as.threads.BoundedQueueThreadPoolService in project camunda-bpm-platform by camunda.
the class JobExecutorAdd method performRuntimeThreadPool.
protected void performRuntimeThreadPool(OperationContext context, ModelNode model, String name, ServiceName jobExecutorThreadPoolServiceName, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException {
ServiceTarget serviceTarget = context.getServiceTarget();
ThreadFactoryService threadFactory = new ThreadFactoryService();
threadFactory.setThreadGroupName(THREAD_POOL_GRP_NAME + name);
ServiceName threadFactoryServiceName = ServiceNames.forThreadFactoryService(name);
ServiceBuilder<ThreadFactory> factoryBuilder = serviceTarget.addService(threadFactoryServiceName, threadFactory);
if (verificationHandler != null) {
factoryBuilder.addListener(verificationHandler);
}
if (newControllers != null) {
newControllers.add(factoryBuilder.install());
} else {
factoryBuilder.install();
}
final BoundedQueueThreadPoolService threadPoolService = new BoundedQueueThreadPoolService(SubsystemAttributeDefinitons.CORE_THREADS.resolveModelAttribute(context, model).asInt(), SubsystemAttributeDefinitons.MAX_THREADS.resolveModelAttribute(context, model).asInt(), SubsystemAttributeDefinitons.QUEUE_LENGTH.resolveModelAttribute(context, model).asInt(), false, new TimeSpec(TimeUnit.SECONDS, SubsystemAttributeDefinitons.KEEPALIVE_TIME.resolveModelAttribute(context, model).asInt()), SubsystemAttributeDefinitons.ALLOW_CORE_TIMEOUT.resolveModelAttribute(context, model).asBoolean());
ServiceBuilder<ManagedQueueExecutorService> builder = serviceTarget.addService(jobExecutorThreadPoolServiceName, threadPoolService).addDependency(threadFactoryServiceName, ThreadFactory.class, threadPoolService.getThreadFactoryInjector()).setInitialMode(ServiceController.Mode.ACTIVE);
if (verificationHandler != null) {
builder.addListener(verificationHandler);
}
if (newControllers != null) {
newControllers.add(builder.install());
} else {
builder.install();
}
}
Aggregations