Search in sources :

Example 6 with ResourceInfo

use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.

the class ContextServiceDeployer method undeployResource.

@Override
public void undeployResource(Object resource) throws Exception {
    ContextService contextServiceResource = (ContextService) resource;
    ResourceInfo resourceInfo = ResourceUtil.getResourceInfo(contextServiceResource);
    undeployResource(resource, resourceInfo.getApplicationName(), resourceInfo.getModuleName());
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ContextService(org.glassfish.concurrent.config.ContextService)

Example 7 with ResourceInfo

use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.

the class ConcurrentRuntimeTest method testCreateManagedThreadFactory.

// re-enable when API added to ManagedThreadFactoryImpl to retrieve ContextService and threadPriority
@Ignore
@Test
public void testCreateManagedThreadFactory() throws Exception {
    final int THREAD_PRIORITY = 8;
    expect(managedThreadFactoryConfig.getJndiName()).andReturn("concurrent/mtf").anyTimes();
    expect(managedThreadFactoryConfig.getContextInfo()).andReturn("Classloader, JNDI, Security").anyTimes();
    expect(managedThreadFactoryConfig.getContextInfoEnabled()).andReturn("true").anyTimes();
    expect(managedThreadFactoryConfig.getThreadPriority()).andReturn(THREAD_PRIORITY).anyTimes();
    replay(managedThreadFactoryConfig);
    ConcurrentRuntime concurrentRuntime = new ConcurrentRuntime();
    ResourceInfo resource = new ResourceInfo("test");
    ManagedThreadFactoryImpl managedThreadFactory = concurrentRuntime.getManagedThreadFactory(resource, managedThreadFactoryConfig);
    ContextServiceImpl contextService = (ContextServiceImpl) Util.getdFieldValue(managedThreadFactory, "contextService");
    ContextSetupProviderImpl contextSetupProvider = (ContextSetupProviderImpl) contextService.getContextSetupProvider();
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "classloading"));
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "naming"));
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "security"));
    assertFalse((Boolean) Util.getdFieldValue(contextSetupProvider, "workArea"));
    int threadPriority = (Integer) Util.getdFieldValue(managedThreadFactory, "priority");
    assertEquals(THREAD_PRIORITY, threadPriority);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ManagedThreadFactoryImpl(org.glassfish.enterprise.concurrent.ManagedThreadFactoryImpl) ContextServiceImpl(org.glassfish.enterprise.concurrent.ContextServiceImpl) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with ResourceInfo

use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.

the class ConcurrentRuntimeTest method testParseContextInfo_null.

@Test
public void testParseContextInfo_null() throws Exception {
    expect(contextServiceConfig.getJndiName()).andReturn("concurrent/ctxSrv").anyTimes();
    expect(contextServiceConfig.getContextInfo()).andReturn(null).anyTimes();
    expect(contextServiceConfig.getContextInfoEnabled()).andReturn("true");
    replay(contextServiceConfig);
    ConcurrentRuntime concurrentRuntime = new ConcurrentRuntime();
    ResourceInfo resource = new ResourceInfo("test");
    ContextServiceImpl contextService = concurrentRuntime.getContextService(resource, contextServiceConfig);
    ContextSetupProviderImpl contextSetupProvider = (ContextSetupProviderImpl) contextService.getContextSetupProvider();
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "classloading"));
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "naming"));
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "security"));
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "workArea"));
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ContextServiceImpl(org.glassfish.enterprise.concurrent.ContextServiceImpl) Test(org.junit.Test)

Example 9 with ResourceInfo

use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.

the class ConcurrentRuntimeTest method testParseContextInfo_empty.

@Test
public void testParseContextInfo_empty() throws Exception {
    expect(contextServiceConfig.getJndiName()).andReturn("concurrent/ctxSrv").anyTimes();
    expect(contextServiceConfig.getContextInfo()).andReturn("").anyTimes();
    expect(contextServiceConfig.getContextInfoEnabled()).andReturn("true");
    replay(contextServiceConfig);
    ConcurrentRuntime concurrentRuntime = new ConcurrentRuntime();
    ResourceInfo resource = new ResourceInfo("test");
    ContextServiceImpl contextService = concurrentRuntime.getContextService(resource, contextServiceConfig);
    ContextSetupProviderImpl contextSetupProvider = (ContextSetupProviderImpl) contextService.getContextSetupProvider();
    assertFalse((Boolean) Util.getdFieldValue(contextSetupProvider, "classloading"));
    assertFalse((Boolean) Util.getdFieldValue(contextSetupProvider, "naming"));
    assertFalse((Boolean) Util.getdFieldValue(contextSetupProvider, "security"));
    assertFalse((Boolean) Util.getdFieldValue(contextSetupProvider, "workArea"));
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ContextServiceImpl(org.glassfish.enterprise.concurrent.ContextServiceImpl) Test(org.junit.Test)

Example 10 with ResourceInfo

use of org.glassfish.resourcebase.resources.api.ResourceInfo in project Payara by payara.

the class ConcurrentRuntimeTest method testCreateManagedExecutorService.

// re-enable when API added to ManagedThreadFactoryImpl to retrieve ContextService and threadPriority
@Ignore
@Test
public void testCreateManagedExecutorService() throws Exception {
    final int THREAD_PRIORITY = 3;
    final int HUNG_AFTER_SECONDS = 100;
    final int CORE_POOL_SIZE = 1;
    final int MAXIMUM_POOL_SIZE = 5;
    final boolean LONG_RUNNING_TASKS = true;
    final long KEEP_ALIVE_SECONDS = 88L;
    final long THREAD_LIFE_TIME_SECONDS = 99L;
    final int TASK_QUEUE_CAPACITY = 12345;
    expect(managedExecutorServiceConfig.getJndiName()).andReturn("concurrent/mes").anyTimes();
    expect(managedExecutorServiceConfig.getContextInfo()).andReturn("Classloader, JNDI, Security").anyTimes();
    expect(managedExecutorServiceConfig.getContextInfoEnabled()).andReturn("true").anyTimes();
    expect(managedExecutorServiceConfig.getThreadPriority()).andReturn(THREAD_PRIORITY).anyTimes();
    expect(managedExecutorServiceConfig.getHungAfterSeconds()).andReturn(HUNG_AFTER_SECONDS).anyTimes();
    expect(managedExecutorServiceConfig.getCorePoolSize()).andReturn(CORE_POOL_SIZE).anyTimes();
    expect(managedExecutorServiceConfig.getMaximumPoolSize()).andReturn(MAXIMUM_POOL_SIZE).anyTimes();
    expect(managedExecutorServiceConfig.isLongRunningTasks()).andReturn(LONG_RUNNING_TASKS).anyTimes();
    expect(managedExecutorServiceConfig.getKeepAliveSeconds()).andReturn(KEEP_ALIVE_SECONDS).anyTimes();
    expect(managedExecutorServiceConfig.getThreadLifeTimeSeconds()).andReturn(THREAD_LIFE_TIME_SECONDS).anyTimes();
    expect(managedExecutorServiceConfig.getTaskQueueCapacity()).andReturn(TASK_QUEUE_CAPACITY).anyTimes();
    replay(managedExecutorServiceConfig);
    ConcurrentRuntime concurrentRuntime = new ConcurrentRuntime();
    ResourceInfo resource = new ResourceInfo("test");
    ManagedExecutorServiceImpl mes = concurrentRuntime.getManagedExecutorService(resource, managedExecutorServiceConfig);
    ManagedThreadFactoryImpl managedThreadFactory = mes.getManagedThreadFactory();
    assertEquals(HUNG_AFTER_SECONDS * 1000, managedThreadFactory.getHungTaskThreshold());
    ManagedThreadPoolExecutor executor = (ManagedThreadPoolExecutor) Util.getdFieldValue(mes, "threadPoolExecutor");
    assertEquals(CORE_POOL_SIZE, executor.getCorePoolSize());
    assertEquals(KEEP_ALIVE_SECONDS, executor.getKeepAliveTime(TimeUnit.SECONDS));
    assertEquals(MAXIMUM_POOL_SIZE, executor.getMaximumPoolSize());
    long threadLifeTime = (Long) Util.getdFieldValue(executor, "threadLifeTime");
    assertEquals(THREAD_LIFE_TIME_SECONDS, threadLifeTime);
    ContextSetupProviderImpl contextSetupProvider = (ContextSetupProviderImpl) mes.getContextSetupProvider();
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "classloading"));
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "naming"));
    assertTrue((Boolean) Util.getdFieldValue(contextSetupProvider, "security"));
    assertFalse((Boolean) Util.getdFieldValue(contextSetupProvider, "workArea"));
    int threadPriority = (Integer) Util.getdFieldValue(managedThreadFactory, "priority");
    assertEquals(THREAD_PRIORITY, threadPriority);
}
Also used : ResourceInfo(org.glassfish.resourcebase.resources.api.ResourceInfo) ManagedExecutorServiceImpl(org.glassfish.enterprise.concurrent.ManagedExecutorServiceImpl) ManagedThreadFactoryImpl(org.glassfish.enterprise.concurrent.ManagedThreadFactoryImpl) ManagedThreadPoolExecutor(org.glassfish.enterprise.concurrent.internal.ManagedThreadPoolExecutor) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)81 PoolInfo (org.glassfish.resourcebase.resources.api.PoolInfo)15 NamingException (javax.naming.NamingException)14 JdbcResource (org.glassfish.jdbc.config.JdbcResource)9 Test (org.junit.Test)9 ContextServiceImpl (org.glassfish.enterprise.concurrent.ContextServiceImpl)8 ConnectorRuntimeException (com.sun.appserv.connectors.internal.api.ConnectorRuntimeException)7 ConnectorResource (org.glassfish.connectors.config.ConnectorResource)6 RefAddr (javax.naming.RefAddr)5 SerializableObjectRefAddr (org.glassfish.resources.naming.SerializableObjectRefAddr)5 Resources (com.sun.enterprise.config.serverbeans.Resources)4 ResourceException (javax.resource.ResourceException)4 ContextService (org.glassfish.concurrent.config.ContextService)4 ManagedThreadFactory (org.glassfish.concurrent.config.ManagedThreadFactory)4 AdminObjectResource (org.glassfish.connectors.config.AdminObjectResource)4 CustomResource (org.glassfish.resources.config.CustomResource)4 MailResource (org.glassfish.resources.javamail.config.MailResource)4 ManagedConnectionFactory (javax.resource.spi.ManagedConnectionFactory)3 ManagedExecutorService (org.glassfish.concurrent.config.ManagedExecutorService)3 ManagedScheduledExecutorService (org.glassfish.concurrent.config.ManagedScheduledExecutorService)3