use of org.jboss.as.connector.services.workmanager.NamedWorkManager in project wildfly by wildfly.
the class LongRunningThreadsCheckTestCase method testWmWithLongRunningThreads.
/**
* Tests work manager with long-running-threads set
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testWmWithLongRunningThreads() throws Throwable {
assertNotNull("A2 not found", adminObject2);
MultipleAdminObject1Impl impl = (MultipleAdminObject1Impl) adminObject2;
MultipleResourceAdapter3 adapter = (MultipleResourceAdapter3) impl.getResourceAdapter();
assertNotNull(adapter);
NamedWorkManager manager = adapter.getWorkManager();
assertEquals(wm + 2, manager.getName());
assertFalse(manager.getShortRunningThreadPool().equals(manager.getLongRunningThreadPool()));
}
use of org.jboss.as.connector.services.workmanager.NamedWorkManager in project wildfly by wildfly.
the class MultipleResourceAdapter3 method start.
/**
* This is called when a resource adapter instance is bootstrapped.
*
* @param ctx A bootstrap context containing references
* @throws ResourceAdapterInternalException indicates bootstrap failure.
*/
public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
log.trace("start()");
WorkManager wm = ctx.getWorkManager();
if (wm instanceof NamedWorkManager) {
NamedWorkManager nw = (NamedWorkManager) wm;
setWorkManager(nw);
log.trace("Work-manager:" + nw);
}
}
use of org.jboss.as.connector.services.workmanager.NamedWorkManager in project wildfly by wildfly.
the class WorkManagerAdd method performRuntime.
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException {
String name = JcaWorkManagerDefinition.WmParameters.NAME.getAttribute().resolveModelAttribute(context, resource.getModel()).asString();
boolean elytronEnabled = JcaWorkManagerDefinition.WmParameters.ELYTRON_ENABLED.getAttribute().resolveModelAttribute(context, resource.getModel()).asBoolean();
ServiceTarget serviceTarget = context.getServiceTarget();
NamedWorkManager wm = new NamedWorkManager(name, elytronEnabled);
WorkManagerService wmService = new WorkManagerService(wm);
ServiceBuilder builder = serviceTarget.addService(ConnectorServices.WORKMANAGER_SERVICE.append(name), wmService);
builder.addDependency(ServiceBuilder.DependencyType.OPTIONAL, ThreadsServices.EXECUTOR.append(WORKMANAGER_LONG_RUNNING).append(name), Executor.class, wmService.getExecutorLongInjector());
builder.addDependency(ThreadsServices.EXECUTOR.append(WORKMANAGER_SHORT_RUNNING).append(name), Executor.class, wmService.getExecutorShortInjector());
builder.addDependency(TxnServices.JBOSS_TXN_CONTEXT_XA_TERMINATOR, JBossContextXATerminator.class, wmService.getXaTerminatorInjector()).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
WorkManagerStatisticsService wmStatsService = new WorkManagerStatisticsService(context.getResourceRegistrationForUpdate(), name, true);
serviceTarget.addService(ConnectorServices.WORKMANAGER_STATS_SERVICE.append(name), wmStatsService).addDependency(ConnectorServices.WORKMANAGER_SERVICE.append(name), WorkManager.class, wmStatsService.getWorkManagerInjector()).setInitialMode(ServiceController.Mode.PASSIVE).install();
PathElement peLocaldWm = PathElement.pathElement(org.jboss.as.connector.subsystems.resourceadapters.Constants.STATISTICS_NAME, "local");
final Resource wmResource = new IronJacamarResource.IronJacamarRuntimeResource();
if (!resource.hasChild(peLocaldWm))
resource.registerChild(peLocaldWm, wmResource);
}
use of org.jboss.as.connector.services.workmanager.NamedWorkManager in project wildfly by wildfly.
the class MultipleResourceAdapter2 method start.
/**
* This is called when a resource adapter instance is bootstrapped.
*
* @param ctx A bootstrap context containing references
* @throws ResourceAdapterInternalException indicates bootstrap failure.
*/
public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
log.trace("start()");
if (ctx instanceof NamedBootstrapContext) {
NamedBootstrapContext nc = (NamedBootstrapContext) ctx;
setBootstrapContextName(nc.getName());
log.trace("Bootstrap-context:" + nc.getName());
}
WorkManager wm = ctx.getWorkManager();
if (wm instanceof NamedWorkManager) {
NamedWorkManager nw = (NamedWorkManager) wm;
setWorkManagerName(nw.getName());
log.trace("Work-manager:" + nw.getName());
}
Work myWork1 = new MultipleWork();
Work myWork2 = new MultipleWork();
Work myWork3 = new MultipleWork();
try {
wm.doWork(myWork1);
wm.scheduleWork(myWork2);
wm.startWork(myWork3);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.jboss.as.connector.services.workmanager.NamedWorkManager in project wildfly by wildfly.
the class LongRunningThreadsCheckTestCase method testWmWithoutLongRunningThreads.
/**
* Tests work manager without long-running-threads set
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testWmWithoutLongRunningThreads() throws Throwable {
assertNotNull("A1 not found", adminObject1);
MultipleAdminObject1Impl impl = (MultipleAdminObject1Impl) adminObject1;
MultipleResourceAdapter3 adapter = (MultipleResourceAdapter3) impl.getResourceAdapter();
assertNotNull(adapter);
NamedWorkManager manager = adapter.getWorkManager();
assertEquals(wm + 1, manager.getName());
assertEquals(manager.getShortRunningThreadPool(), manager.getLongRunningThreadPool());
}
Aggregations