use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class ListThreadpools method execute.
/**
* Executes the command
*
* @param context information
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
try {
List<ThreadPool> poolList = threadPools.getThreadPool();
for (ThreadPool pool : poolList) {
final ActionReport.MessagePart part = report.getTopMessagePart().addChild();
part.setMessage(pool.getName());
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
} catch (Exception e) {
String str = e.getMessage();
report.setMessage(localStrings.getLocalString("list.thread.pools" + ".failed", "List Thread Pools failed because of: " + str));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class DynamicConfigListener method changed.
@Override
public synchronized UnprocessedChangeEvents changed(final PropertyChangeEvent[] events) {
return ConfigSupport.sortAndDispatch(events, new Changed() {
@Override
public <T extends ConfigBeanProxy> NotProcessed changed(TYPE type, Class<T> tClass, T t) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "NetworkConfig changed {0} {1} {2}", new Object[] { type, tClass, t });
}
if (tClass == NetworkListener.class && t instanceof NetworkListener) {
return processNetworkListener(type, (NetworkListener) t, events);
} else if (tClass == Http.class && t instanceof Http) {
return processProtocol(type, (Protocol) t.getParent(), events);
} else if (tClass == FileCache.class && t instanceof FileCache) {
return processProtocol(type, (Protocol) t.getParent().getParent(), null);
} else if (tClass == Ssl.class && t instanceof Ssl) {
/*
* Make sure the SSL parent is in fact a protocol. It could
* be a jmx-connector.
*/
final ConfigBeanProxy parent = t.getParent();
if (parent instanceof Protocol) {
return processProtocol(type, (Protocol) parent, null);
}
} else if (tClass == Protocol.class && t instanceof Protocol) {
return processProtocol(type, (Protocol) t, null);
} else if (tClass == ThreadPool.class && t instanceof ThreadPool) {
NotProcessed notProcessed = null;
ThreadPool threadPool = (ThreadPool) t;
for (NetworkListener listener : threadPool.findNetworkListeners()) {
notProcessed = processNetworkListener(type, listener, null);
}
// Throw an unprocessed event change if one hasn't already if HTTP or ThreadPool monitoring is enabled.
MonitoringService ms = config.getMonitoringService();
String threadPoolLevel = ms.getModuleMonitoringLevels().getThreadPool();
String httpServiceLevel = ms.getModuleMonitoringLevels().getHttpService();
if (((threadPoolLevel != null && !threadPoolLevel.equals(OFF)) || (httpServiceLevel != null && !httpServiceLevel.equals(OFF))) && notProcessed == null) {
notProcessed = new NotProcessed("Monitoring statistics will be incorrect for " + threadPool.getName() + " until restart due to changed attribute(s).");
}
return notProcessed;
} else if (tClass == Transport.class && t instanceof Transport) {
NotProcessed notProcessed = null;
for (NetworkListener listener : ((Transport) t).findNetworkListeners()) {
notProcessed = processNetworkListener(type, listener, null);
}
return notProcessed;
} else if (tClass == VirtualServer.class && t instanceof VirtualServer && !grizzlyService.hasMapperUpdateListener()) {
return processVirtualServer(type, (VirtualServer) t);
} else if (tClass == SystemProperty.class && t instanceof SystemProperty) {
NetworkConfig networkConfig = config.getNetworkConfig();
if ((networkConfig != null) && ((SystemProperty) t).getName().endsWith("LISTENER_PORT")) {
for (NetworkListener listener : networkConfig.getNetworkListeners().getNetworkListener()) {
if (listener.getPort().equals(((SystemProperty) t).getValue())) {
return processNetworkListener(Changed.TYPE.CHANGE, listener, events);
}
}
}
return null;
}
return null;
}
}, logger);
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class CreateThreadpool method preAuthorization.
@Override
public boolean preAuthorization(AdminCommandContext context) {
config = CLIUtil.updateConfigIfNeeded(config, target, habitat);
threadPools = config.getThreadPools();
for (ThreadPool pool : threadPools.getThreadPool()) {
final ActionReport report = context.getActionReport();
if (pool.getName().equals(threadpool_id)) {
report.setMessage(localStrings.getLocalString("create.threadpool.duplicate", "Thread Pool named {0} already exists.", threadpool_id));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return false;
}
}
return true;
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class CreateThreadpool method execute.
/**
* Executes the command with the command parameters passed as Properties
* where the keys are the paramter names and the values the parameter values
*
* @param context information
*/
public void execute(AdminCommandContext context) {
final ActionReport report = context.getActionReport();
if (workqueues != null) {
report.setMessage(localStrings.getLocalString("create.threadpool.deprecated.workqueues", "Deprecated Syntax: --workqueues option is deprecated for create-threadpool command."));
}
try {
ConfigSupport.apply(new SingleConfigCode<ThreadPools>() {
public Object run(ThreadPools param) throws PropertyVetoException, TransactionFailure {
ThreadPool newPool = param.createChild(ThreadPool.class);
newPool.setName(threadpool_id);
newPool.setMaxThreadPoolSize(maxthreadpoolsize);
newPool.setMinThreadPoolSize(minthreadpoolsize);
newPool.setMaxQueueSize(maxQueueSize);
newPool.setIdleThreadTimeoutSeconds(idletimeout);
param.getThreadPool().add(newPool);
return newPool;
}
}, threadPools);
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
} catch (TransactionFailure e) {
String str = e.getMessage();
String def = "Creation of: " + threadpool_id + "failed because of: " + str;
String msg = localStrings.getLocalString("create.threadpool.failed", def, threadpool_id, str);
report.setMessage(msg);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
report.setFailureCause(e);
}
}
use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.
the class CreateHttpListener method getThreadPool.
private ThreadPool getThreadPool(NetworkConfig config) {
final List<ThreadPool> pools = config.getParent(Config.class).getThreadPools().getThreadPool();
ThreadPool target = null;
for (ThreadPool pool : pools) {
if ("http-thread-pool".equals(pool.getName())) {
target = pool;
}
}
if (target == null && !pools.isEmpty()) {
target = pools.get(0);
}
return target;
}
Aggregations