Search in sources :

Example 1 with BoundedQueueThreadPoolService

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();
    }
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) BoundedQueueThreadPoolService(org.jboss.as.threads.BoundedQueueThreadPoolService) ManagedQueueExecutorService(org.jboss.as.threads.ManagedQueueExecutorService) ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) ThreadFactoryService(org.jboss.as.threads.ThreadFactoryService) TimeSpec(org.jboss.as.threads.TimeSpec)

Aggregations

ThreadFactory (java.util.concurrent.ThreadFactory)1 BoundedQueueThreadPoolService (org.jboss.as.threads.BoundedQueueThreadPoolService)1 ManagedQueueExecutorService (org.jboss.as.threads.ManagedQueueExecutorService)1 ThreadFactoryService (org.jboss.as.threads.ThreadFactoryService)1 TimeSpec (org.jboss.as.threads.TimeSpec)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1