Search in sources :

Example 1 with NamedWorkManager

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()));
}
Also used : NamedWorkManager(org.jboss.as.connector.services.workmanager.NamedWorkManager) MultipleAdminObject1Impl(org.jboss.as.test.integration.jca.rar.MultipleAdminObject1Impl) MultipleResourceAdapter3(org.jboss.as.test.integration.jca.rar.MultipleResourceAdapter3) Test(org.junit.Test)

Example 2 with NamedWorkManager

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);
    }
}
Also used : NamedWorkManager(org.jboss.as.connector.services.workmanager.NamedWorkManager) WorkManager(javax.resource.spi.work.WorkManager) NamedWorkManager(org.jboss.as.connector.services.workmanager.NamedWorkManager)

Example 3 with NamedWorkManager

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);
}
Also used : NamedWorkManager(org.jboss.as.connector.services.workmanager.NamedWorkManager) WorkManagerService(org.jboss.as.connector.services.workmanager.WorkManagerService) WorkManagerStatisticsService(org.jboss.as.connector.services.workmanager.statistics.WorkManagerStatisticsService) PathElement(org.jboss.as.controller.PathElement) ServiceTarget(org.jboss.msc.service.ServiceTarget) Resource(org.jboss.as.controller.registry.Resource) IronJacamarResource(org.jboss.as.connector.subsystems.resourceadapters.IronJacamarResource) ServiceBuilder(org.jboss.msc.service.ServiceBuilder)

Example 4 with NamedWorkManager

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();
    }
}
Also used : NamedWorkManager(org.jboss.as.connector.services.workmanager.NamedWorkManager) WorkManager(javax.resource.spi.work.WorkManager) NamedWorkManager(org.jboss.as.connector.services.workmanager.NamedWorkManager) NamedBootstrapContext(org.jboss.as.connector.services.bootstrap.NamedBootstrapContext) Work(javax.resource.spi.work.Work) ResourceException(javax.resource.ResourceException) ResourceAdapterInternalException(javax.resource.spi.ResourceAdapterInternalException)

Example 5 with NamedWorkManager

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());
}
Also used : NamedWorkManager(org.jboss.as.connector.services.workmanager.NamedWorkManager) MultipleAdminObject1Impl(org.jboss.as.test.integration.jca.rar.MultipleAdminObject1Impl) MultipleResourceAdapter3(org.jboss.as.test.integration.jca.rar.MultipleResourceAdapter3) Test(org.junit.Test)

Aggregations

NamedWorkManager (org.jboss.as.connector.services.workmanager.NamedWorkManager)5 WorkManager (javax.resource.spi.work.WorkManager)2 MultipleAdminObject1Impl (org.jboss.as.test.integration.jca.rar.MultipleAdminObject1Impl)2 MultipleResourceAdapter3 (org.jboss.as.test.integration.jca.rar.MultipleResourceAdapter3)2 Test (org.junit.Test)2 ResourceException (javax.resource.ResourceException)1 ResourceAdapterInternalException (javax.resource.spi.ResourceAdapterInternalException)1 Work (javax.resource.spi.work.Work)1 NamedBootstrapContext (org.jboss.as.connector.services.bootstrap.NamedBootstrapContext)1 WorkManagerService (org.jboss.as.connector.services.workmanager.WorkManagerService)1 WorkManagerStatisticsService (org.jboss.as.connector.services.workmanager.statistics.WorkManagerStatisticsService)1 IronJacamarResource (org.jboss.as.connector.subsystems.resourceadapters.IronJacamarResource)1 PathElement (org.jboss.as.controller.PathElement)1 Resource (org.jboss.as.controller.registry.Resource)1 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1