Search in sources :

Example 1 with PayaraExecutorServiceConfiguration

use of fish.payara.nucleus.executorservice.PayaraExecutorServiceConfiguration in project Payara by payara.

the class GetPayaraExecutorServiceConfigurationCommand method execute.

@Override
public void execute(AdminCommandContext acc) {
    Config configNode = targetUtil.getConfig(target);
    PayaraExecutorServiceConfiguration payaraExecutorServiceConfiguration = configNode.getExtensionByType(PayaraExecutorServiceConfiguration.class);
    ColumnFormatter columnFormatter = new ColumnFormatter(HEADERS);
    Object[] values = { payaraExecutorServiceConfiguration.getThreadPoolExecutorCorePoolSize(), payaraExecutorServiceConfiguration.getThreadPoolExecutorMaxPoolSize(), payaraExecutorServiceConfiguration.getThreadPoolExecutorKeepAliveTime(), payaraExecutorServiceConfiguration.getThreadPoolExecutorKeepAliveTimeUnit(), payaraExecutorServiceConfiguration.getThreadPoolExecutorQueueSize(), payaraExecutorServiceConfiguration.getScheduledThreadPoolExecutorCorePoolSize() };
    columnFormatter.addRow(values);
    Map<String, Object> map = new HashMap<>();
    Properties extraProps = new Properties();
    map.put("threadPoolExecutorCorePoolSize", values[0]);
    map.put("threadPoolExecutorMaxPoolSize", values[1]);
    map.put("threadPoolExecutorKeepAliveTime", values[2]);
    map.put("threadPoolExecutorKeepAliveTimeUnit", values[3]);
    map.put("threadPoolExecutorQueueSize", values[4]);
    map.put("scheduledThreadPoolExecutorCorePoolSize", values[5]);
    extraProps.put("payaraExecutorServiceConfiguration", map);
    acc.getActionReport().setExtraProperties(extraProps);
    acc.getActionReport().setMessage(columnFormatter.toString());
}
Also used : PayaraExecutorServiceConfiguration(fish.payara.nucleus.executorservice.PayaraExecutorServiceConfiguration) HashMap(java.util.HashMap) Config(com.sun.enterprise.config.serverbeans.Config) Properties(java.util.Properties) ColumnFormatter(com.sun.enterprise.util.ColumnFormatter)

Example 2 with PayaraExecutorServiceConfiguration

use of fish.payara.nucleus.executorservice.PayaraExecutorServiceConfiguration in project Payara by payara.

the class SetPayaraExecutorServiceConfigurationCommand method execute.

@Override
public void execute(AdminCommandContext acc) {
    Config configVal = targetUtil.getConfig(target);
    PayaraExecutorServiceConfiguration payaraExecutorServiceConfiguration = configVal.getExtensionByType(PayaraExecutorServiceConfiguration.class);
    if (payaraExecutorServiceConfiguration != null) {
        try {
            ConfigSupport.apply((PayaraExecutorServiceConfiguration config) -> {
                if (threadPoolExecutorCorePoolSize != null) {
                    config.setThreadPoolExecutorCorePoolSize(threadPoolExecutorCorePoolSize);
                }
                if (threadPoolExecutorMaxPoolSize != null) {
                    config.setThreadPoolExecutorMaxPoolSize(threadPoolExecutorMaxPoolSize);
                }
                if (threadPoolExecutorKeepAliveTime != null) {
                    config.setThreadPoolExecutorKeepAliveTime(threadPoolExecutorKeepAliveTime);
                }
                if (threadPoolExecutorKeepAliveTimeUnit != null) {
                    config.setThreadPoolExecutorKeepAliveTimeUnit(threadPoolExecutorKeepAliveTimeUnit.toUpperCase());
                }
                if (threadPoolExecutorQueueSize != null) {
                    config.setThreadPoolExecutorQueueSize(threadPoolExecutorQueueSize);
                }
                if (scheduledThreadPoolExecutorCorePoolSize != null) {
                    config.setScheduledThreadPoolExecutorCorePoolSize(scheduledThreadPoolExecutorCorePoolSize);
                }
                return null;
            }, payaraExecutorServiceConfiguration);
        } catch (TransactionFailure ex) {
            acc.getActionReport().failure(Logger.getLogger(SetPayaraExecutorServiceConfigurationCommand.class.getName()), "Failed to set executor service configuration", ex);
        }
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) PayaraExecutorServiceConfiguration(fish.payara.nucleus.executorservice.PayaraExecutorServiceConfiguration) Config(com.sun.enterprise.config.serverbeans.Config)

Example 3 with PayaraExecutorServiceConfiguration

use of fish.payara.nucleus.executorservice.PayaraExecutorServiceConfiguration in project Payara by payara.

the class EventsTest method setup.

@Before
public void setup() throws IOException {
    // cludge to run only once yet not depend on a static method.
    if (habitat != null) {
        return;
    }
    habitat = super.getHabitat();
    Server server = habitat.getService(Server.class, "server");
    ActiveDescriptor<Server> descriptor = BuilderHelper.createConstantDescriptor(server, ServerEnvironment.DEFAULT_INSTANCE_NAME, Server.class);
    ServiceLocatorUtilities.addOneDescriptor(habitat, descriptor);
    PayaraExecutorServiceConfiguration executor = habitat.getService(PayaraExecutorServiceConfiguration.class);
    ActiveDescriptor<PayaraExecutorServiceConfiguration> descriptor2 = BuilderHelper.createConstantDescriptor(executor, ServerEnvironment.DEFAULT_INSTANCE_NAME, PayaraExecutorServiceConfiguration.class);
    ServiceLocatorUtilities.addOneDescriptor(habitat, descriptor2);
    try {
        application = File.createTempFile("kerneltest", "tmp");
    } catch (IOException e) {
        e.printStackTrace();
        throw e;
    }
    application.delete();
    application.mkdirs();
    Events events = habitat.getService(Events.class);
    events.register(listener);
}
Also used : Server(com.sun.enterprise.config.serverbeans.Server) PayaraExecutorServiceConfiguration(fish.payara.nucleus.executorservice.PayaraExecutorServiceConfiguration) Events(org.glassfish.api.event.Events) IOException(java.io.IOException)

Aggregations

PayaraExecutorServiceConfiguration (fish.payara.nucleus.executorservice.PayaraExecutorServiceConfiguration)3 Config (com.sun.enterprise.config.serverbeans.Config)2 Server (com.sun.enterprise.config.serverbeans.Server)1 ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 Events (org.glassfish.api.event.Events)1 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)1