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());
}
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);
}
}
}
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);
}
Aggregations