use of javax.enterprise.concurrent.ManagedExecutorService in project wildfly by wildfly.
the class ManagedExecutorServiceMetricsTestCase method testManagedScheduledExecutorServiceManagement.
@Test
public void testManagedScheduledExecutorServiceManagement() throws Exception {
final PathAddress pathAddress = EE_SUBSYSTEM_PATH_ADDRESS.append(EESubsystemModel.MANAGED_SCHEDULED_EXECUTOR_SERVICE, RESOURCE_NAME);
// add
final ModelNode addOperation = Util.createAddOperation(pathAddress);
final String jndiName = "java:jboss/ee/concurrency/scheduledexecutor/" + RESOURCE_NAME;
addOperation.get(ManagedScheduledExecutorServiceResourceDefinition.JNDI_NAME).set(jndiName);
// note: threads will increase till CORE_THREADS config value, then reuses if has idle thread
addOperation.get(ManagedScheduledExecutorServiceResourceDefinition.CORE_THREADS).set(2);
// task will be considered hung if duration > 1s
addOperation.get(ManagedScheduledExecutorServiceResourceDefinition.HUNG_TASK_THRESHOLD).set(1000);
final ModelNode addResult = managementClient.getControllerClient().execute(addOperation);
Assert.assertFalse(addResult.get(FAILURE_DESCRIPTION).toString(), addResult.get(FAILURE_DESCRIPTION).isDefined());
try {
// lookup the executor
final ManagedExecutorService executorService = InitialContext.doLookup(jndiName);
Assert.assertNotNull(executorService);
testRuntimeStats(pathAddress, executorService);
} finally {
// remove
final ModelNode removeOperation = Util.createRemoveOperation(pathAddress);
removeOperation.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
final ModelNode removeResult = managementClient.getControllerClient().execute(removeOperation);
Assert.assertFalse(removeResult.get(FAILURE_DESCRIPTION).toString(), removeResult.get(FAILURE_DESCRIPTION).isDefined());
}
}
use of javax.enterprise.concurrent.ManagedExecutorService in project wildfly by wildfly.
the class ManagedExecutorServiceMetricsTestCase method testMaxRequests.
/**
* WFLY-13177 - this tests another edge-case when executor is busy, but a new task is rejected due to a max-requests counter achieved.
* In that case RequestController will reject any other tasks which should not decrease/increase active request counter in RequestController.
*
* @throws Exception
*/
@Test
public void testMaxRequests() throws Exception {
final PathAddress pathAddress = EE_SUBSYSTEM_PATH_ADDRESS.append(EESubsystemModel.MANAGED_EXECUTOR_SERVICE, RESOURCE_NAME);
// add
final ModelNode addOperation = Util.createAddOperation(pathAddress);
final String jndiName = "java:jboss/ee/concurrency/maxrequests/" + RESOURCE_NAME;
addOperation.get(ManagedExecutorServiceResourceDefinition.JNDI_NAME).set(jndiName);
// note: threads will increase till CORE_THREADS config value, then reuses if has idle thread
addOperation.get(ManagedExecutorServiceResourceDefinition.CORE_THREADS).set(2);
addOperation.get(ManagedExecutorServiceResourceDefinition.QUEUE_LENGTH).set(1);
final ModelNode addResult = managementClient.getControllerClient().execute(addOperation);
Assert.assertFalse(addResult.get(FAILURE_DESCRIPTION).toString(), addResult.get(FAILURE_DESCRIPTION).isDefined());
writeAttribute(REQUEST_CONTROLLER_PATH_ADDRESS, MAX_REQUEST_ATTRIBUTE_NAME, 3, true);
try {
final ManagedExecutorService executorService = InitialContext.doLookup(jndiName);
Assert.assertNotNull(executorService);
testActiveRequestStats(pathAddress, executorService);
} finally {
try {
// remove
final ModelNode removeOperation = Util.createRemoveOperation(pathAddress);
removeOperation.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
final ModelNode removeResult = managementClient.getControllerClient().execute(removeOperation);
Assert.assertFalse(removeResult.get(FAILURE_DESCRIPTION).toString(), removeResult.get(FAILURE_DESCRIPTION).isDefined());
} finally {
undefineAttribute(REQUEST_CONTROLLER_PATH_ADDRESS, MAX_REQUEST_ATTRIBUTE_NAME, true);
}
}
}
use of javax.enterprise.concurrent.ManagedExecutorService in project Payara by payara.
the class FaultToleranceService method getManagedExecutorService.
/**
* Gets the configured ManagedExecutorService.
* @return The configured ManagedExecutorService, or the default ManagedExecutorService if the configured one
* couldn't be found
* @throws NamingException If the default ManagedExecutorService couldn't be found
*/
public ManagedExecutorService getManagedExecutorService() throws NamingException {
String managedExecutorServiceName = faultToleranceServiceConfiguration.getManagedExecutorService();
InitialContext ctx = new InitialContext();
ManagedExecutorService managedExecutorService;
// If no name has been set, just get the default
if (managedExecutorServiceName == null || managedExecutorServiceName.isEmpty()) {
managedExecutorService = (ManagedExecutorService) ctx.lookup("java:comp/DefaultManagedExecutorService");
} else {
try {
managedExecutorService = (ManagedExecutorService) ctx.lookup(managedExecutorServiceName);
} catch (NamingException ex) {
logger.log(Level.INFO, "Could not find configured ManagedExecutorService, " + managedExecutorServiceName + ", so resorting to default", ex);
managedExecutorService = (ManagedExecutorService) ctx.lookup("java:comp/DefaultManagedExecutorService");
}
}
return managedExecutorService;
}
use of javax.enterprise.concurrent.ManagedExecutorService in project wildfly by wildfly.
the class ManagedExecutorServiceMetricsTestCase method testManagedExecutorServiceManagement.
@Test
public void testManagedExecutorServiceManagement() throws Exception {
final PathAddress pathAddress = EE_SUBSYSTEM_PATH_ADDRESS.append(EESubsystemModel.MANAGED_EXECUTOR_SERVICE, RESOURCE_NAME);
// add
final ModelNode addOperation = Util.createAddOperation(pathAddress);
final String jndiName = "java:jboss/ee/concurrency/executor/" + RESOURCE_NAME;
addOperation.get(ManagedExecutorServiceResourceDefinition.JNDI_NAME).set(jndiName);
// note: threads will increase till CORE_THREADS config value, then reuses if has idle thread
addOperation.get(ManagedExecutorServiceResourceDefinition.CORE_THREADS).set(2);
// task will be considered hung if duration > 1s
addOperation.get(ManagedExecutorServiceResourceDefinition.HUNG_TASK_THRESHOLD).set(1000);
final ModelNode addResult = managementClient.getControllerClient().execute(addOperation);
Assert.assertFalse(addResult.get(FAILURE_DESCRIPTION).toString(), addResult.get(FAILURE_DESCRIPTION).isDefined());
try {
final ManagedExecutorService executorService = InitialContext.doLookup(jndiName);
Assert.assertNotNull(executorService);
testRuntimeStats(pathAddress, executorService);
} finally {
// remove
final ModelNode removeOperation = Util.createRemoveOperation(pathAddress);
removeOperation.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
final ModelNode removeResult = managementClient.getControllerClient().execute(removeOperation);
Assert.assertFalse(removeResult.get(FAILURE_DESCRIPTION).toString(), removeResult.get(FAILURE_DESCRIPTION).isDefined());
}
}
use of javax.enterprise.concurrent.ManagedExecutorService in project wildfly by wildfly.
the class ManagedExecutorServiceMetricsTestCase method testActiveRequests.
/**
* WFLY-13177 - this tests an edge-case when executor threads are all busy and even queue is at its maximum. In that case
* the executor will reject any other tasks which should not increase active request counter in RequestController.
*
* @throws Exception
*/
@Test
public void testActiveRequests() throws Exception {
final PathAddress pathAddress = EE_SUBSYSTEM_PATH_ADDRESS.append(EESubsystemModel.MANAGED_EXECUTOR_SERVICE, RESOURCE_NAME);
// add
final ModelNode addOperation = Util.createAddOperation(pathAddress);
final String jndiName = "java:jboss/ee/concurrency/activerequests/" + RESOURCE_NAME;
addOperation.get(ManagedExecutorServiceResourceDefinition.JNDI_NAME).set(jndiName);
// note: threads will increase till CORE_THREADS config value, then reuses if has idle thread
addOperation.get(ManagedExecutorServiceResourceDefinition.CORE_THREADS).set(2);
addOperation.get(ManagedExecutorServiceResourceDefinition.QUEUE_LENGTH).set(1);
final ModelNode addResult = managementClient.getControllerClient().execute(addOperation);
Assert.assertFalse(addResult.get(FAILURE_DESCRIPTION).toString(), addResult.get(FAILURE_DESCRIPTION).isDefined());
try {
final ManagedExecutorService executorService = InitialContext.doLookup(jndiName);
Assert.assertNotNull(executorService);
testActiveRequestStats(pathAddress, executorService);
} finally {
// remove
final ModelNode removeOperation = Util.createRemoveOperation(pathAddress);
removeOperation.get(OPERATION_HEADERS, ALLOW_RESOURCE_SERVICE_RESTART).set(true);
final ModelNode removeResult = managementClient.getControllerClient().execute(removeOperation);
Assert.assertFalse(removeResult.get(FAILURE_DESCRIPTION).toString(), removeResult.get(FAILURE_DESCRIPTION).isDefined());
}
}
Aggregations