use of org.camunda.bpm.container.impl.jmx.services.JmxManagedThreadPool in project camunda-bpm-platform by camunda.
the class StartManagedThreadPoolStep method performOperationStep.
public void performOperationStep(DeploymentOperation operationContext) {
final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
JobExecutorXml jobExecutorXml = getJobExecutorXml(operationContext);
int queueSize = getQueueSize(jobExecutorXml);
int corePoolSize = getCorePoolSize(jobExecutorXml);
int maxPoolSize = getMaxPoolSize(jobExecutorXml);
long keepAliveTime = getKeepAliveTime(jobExecutorXml);
// initialize Queue & Executor services
BlockingQueue<Runnable> threadPoolQueue = new ArrayBlockingQueue<Runnable>(queueSize);
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(corePoolSize, maxPoolSize, keepAliveTime, TimeUnit.MILLISECONDS, threadPoolQueue);
threadPoolExecutor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
// construct the service for the thread pool
JmxManagedThreadPool managedThreadPool = new JmxManagedThreadPool(threadPoolQueue, threadPoolExecutor);
// install the service into the container
serviceContainer.startService(ServiceTypes.BPM_PLATFORM, RuntimeContainerDelegateImpl.SERVICE_NAME_EXECUTOR, managedThreadPool);
}
use of org.camunda.bpm.container.impl.jmx.services.JmxManagedThreadPool in project camunda-bpm-platform by camunda.
the class StartManagedThreadPoolStepTest method performOperationStepWithPropertiesInXml.
@Test
public void performOperationStepWithPropertiesInXml() {
Map<String, String> properties = new HashMap<String, String>();
String queueSize = "5";
String corePoolSize = "12";
String maxPoolSize = "20";
String keepAliveTime = "100";
properties.put(JobExecutorXml.CORE_POOL_SIZE, corePoolSize);
properties.put(JobExecutorXml.KEEP_ALIVE_TIME, keepAliveTime);
properties.put(JobExecutorXml.MAX_POOL_SIZE, maxPoolSize);
properties.put(JobExecutorXml.QUEUE_SIZE, queueSize);
jobExecutorXml.setProperties(properties);
step.performOperationStep(deploymentOperation);
PlatformService<JmxManagedThreadPool> service = container.getService(getObjectNameForExecutor());
ThreadPoolExecutor executor = service.getValue().getThreadPoolExecutor();
// since no jobs will start, remaining capacity is sufficent to check the size
assertThat(executor.getQueue().remainingCapacity(), is(Integer.parseInt(queueSize)));
assertThat(executor.getCorePoolSize(), is(Integer.parseInt(corePoolSize)));
assertThat(executor.getMaximumPoolSize(), is(Integer.parseInt(maxPoolSize)));
assertThat(executor.getKeepAliveTime(TimeUnit.MILLISECONDS), is(Long.parseLong(keepAliveTime)));
}
use of org.camunda.bpm.container.impl.jmx.services.JmxManagedThreadPool in project camunda-bpm-platform by camunda.
the class StartManagedThreadPoolStepTest method performOperationStepWithDefaultProperties.
@Test
public void performOperationStepWithDefaultProperties() {
Map<String, String> properties = new HashMap<String, String>();
jobExecutorXml.setProperties(properties);
step.performOperationStep(deploymentOperation);
PlatformService<JmxManagedThreadPool> service = container.getService(getObjectNameForExecutor());
ThreadPoolExecutor executor = service.getValue().getThreadPoolExecutor();
// since no jobs will start, remaining capacity is sufficent to check the size
assertThat(executor.getQueue().remainingCapacity(), is(3));
assertThat(executor.getCorePoolSize(), is(3));
assertThat(executor.getMaximumPoolSize(), is(10));
assertThat(executor.getKeepAliveTime(TimeUnit.MILLISECONDS), is(0L));
}
Aggregations