Search in sources :

Example 6 with ThreadPool

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);
    }
}
Also used : ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) ActionReport(org.glassfish.api.ActionReport)

Example 7 with ThreadPool

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);
}
Also used : ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) Http(org.glassfish.grizzly.config.dom.Http) Ssl(org.glassfish.grizzly.config.dom.Ssl) SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer) FileCache(org.glassfish.grizzly.config.dom.FileCache) ConfigBeanProxy(org.jvnet.hk2.config.ConfigBeanProxy) Changed(org.jvnet.hk2.config.Changed) NotProcessed(org.jvnet.hk2.config.NotProcessed) Protocol(org.glassfish.grizzly.config.dom.Protocol) Transport(org.glassfish.grizzly.config.dom.Transport) MonitoringService(com.sun.enterprise.config.serverbeans.MonitoringService) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 8 with ThreadPool

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;
}
Also used : ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) ActionReport(org.glassfish.api.ActionReport)

Example 9 with ThreadPool

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);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) ActionReport(org.glassfish.api.ActionReport)

Example 10 with ThreadPool

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;
}
Also used : ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool)

Aggregations

ThreadPool (org.glassfish.grizzly.config.dom.ThreadPool)16 ActionReport (org.glassfish.api.ActionReport)6 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)6 PropertyVetoException (java.beans.PropertyVetoException)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)5 Config (com.sun.enterprise.config.serverbeans.Config)3 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)3 ThreadPools (com.sun.enterprise.config.serverbeans.ThreadPools)2 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)2 UnknownHostException (java.net.UnknownHostException)2 Http (org.glassfish.grizzly.config.dom.Http)2 NetworkListeners (org.glassfish.grizzly.config.dom.NetworkListeners)2 Protocol (org.glassfish.grizzly.config.dom.Protocol)2 Ssl (org.glassfish.grizzly.config.dom.Ssl)2 Transport (org.glassfish.grizzly.config.dom.Transport)2 Test (org.junit.Test)2 AdminService (com.sun.enterprise.config.serverbeans.AdminService)1 HttpService (com.sun.enterprise.config.serverbeans.HttpService)1 MonitoringService (com.sun.enterprise.config.serverbeans.MonitoringService)1 ServerRef (com.sun.enterprise.config.serverbeans.ServerRef)1