Search in sources :

Example 1 with ThreadPool

use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.

the class IIOPUtils method postConstruct.

// private GlassFishORBManager gfORBMgr;
public void postConstruct() {
    processType = processEnv.getProcessType();
    if (processEnv.getProcessType().isServer()) {
        Config c = services.getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
        iiopService = c.getExtensionByType(IiopService.class);
        final Collection<ThreadPool> threadPool = c.getThreadPools().getThreadPool();
        final Collection<NetworkListener> listeners = allByContract(NetworkListener.class);
        final Set<String> names = new TreeSet<String>();
        threadPools = new ArrayList<ThreadPool>();
        for (NetworkListener listener : listeners) {
            names.add(listener.getThreadPool());
        }
        for (ThreadPool pool : threadPool) {
            if (!names.contains(pool.getName())) {
                threadPools.add(pool);
            }
        }
        serverRefs = allByContract(ServerRef.class);
    }
    IIOPUtils.initMe(this);
}
Also used : Config(com.sun.enterprise.config.serverbeans.Config) IiopService(org.glassfish.orb.admin.config.IiopService) TreeSet(java.util.TreeSet) ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) ServerRef(com.sun.enterprise.config.serverbeans.ServerRef) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 2 with ThreadPool

use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.

the class RestMonitoringEndpointDecider method setValues.

private void setValues() {
    NetworkListener networkListener = config.getAdminListener();
    ThreadPool threadPool = networkListener.findThreadPool();
    // Set Thread pool size
    if (threadPool != null) {
        try {
            maxThreadPoolSize = Integer.parseInt(threadPool.getMaxThreadPoolSize());
        } catch (NumberFormatException ex) {
        }
    }
    String defaultVirtualServer = networkListener.findHttpProtocol().getHttp().getDefaultVirtualServer();
    hosts = Collections.unmodifiableList(Arrays.asList(defaultVirtualServer));
    // Set network address
    try {
        address = InetAddress.getByName(networkListener.getAddress());
    } catch (UnknownHostException e) {
        throw new IllegalStateException(e);
    }
    // Set the context root and port number
    if (ServerTags.ADMIN_LISTENER_ID.equals(networkListener.getName())) {
        // Get the context root from the rest monitoring service
        if (restMonitoringServiceConfiguration == null) {
            contextRoot = DEFAULT_CONTEXT_ROOT;
        } else {
            contextRoot = restMonitoringServiceConfiguration.getContextRoot();
        }
        try {
            port = Integer.parseInt(networkListener.getPort());
        } catch (NumberFormatException ne) {
            port = DEFAULT_ADMIN_PORT;
        }
    } else {
        try {
            port = Integer.parseInt(networkListener.getPort());
        } catch (NumberFormatException ne) {
            port = DEFAULT_ADMIN_PORT;
        }
        // Get the context root from the rest monitoring service
        if (restMonitoringServiceConfiguration == null) {
            contextRoot = DEFAULT_CONTEXT_ROOT;
        } else {
            contextRoot = restMonitoringServiceConfiguration.getContextRoot();
        }
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 3 with ThreadPool

use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.

the class WebContainerImpl method bind.

private void bind(Port port, WebListener webListener, String vsId) {
    String protocol = Port.HTTP_PROTOCOL;
    final int portNumber = port.getPortNumber();
    final String defaultVS = vsId;
    final WebListener listener = webListener;
    if (webListener == null) {
        listenerName = getListenerName();
        webListener = new HttpListener();
        webListener.setId(listenerName);
        webListener.setPort(portNumber);
    } else {
        listenerName = webListener.getId();
        protocol = webListener.getProtocol();
    }
    listeners.add(webListener);
    if (protocol.equals(Port.HTTP_PROTOCOL)) {
        securityEnabled = "false";
    } else if (protocol.equals(Port.HTTPS_PROTOCOL)) {
        securityEnabled = "true";
    }
    try {
        ConfigSupport.apply(new SingleConfigCode<Protocols>() {

            public Object run(Protocols param) throws TransactionFailure {
                final Protocol protocol = param.createChild(Protocol.class);
                protocol.setName(listenerName);
                protocol.setSecurityEnabled(securityEnabled);
                param.getProtocol().add(protocol);
                final Http http = protocol.createChild(Http.class);
                http.setDefaultVirtualServer(defaultVS);
                http.setFileCache(http.createChild(FileCache.class));
                protocol.setHttp(http);
                return protocol;
            }
        }, networkConfig.getProtocols());
        ConfigSupport.apply(new ConfigCode() {

            public Object run(ConfigBeanProxy... params) throws TransactionFailure {
                NetworkListeners nls = (NetworkListeners) params[0];
                Transports transports = (Transports) params[1];
                final NetworkListener listener = nls.createChild(NetworkListener.class);
                listener.setName(listenerName);
                listener.setPort(Integer.toString(portNumber));
                listener.setProtocol(listenerName);
                listener.setThreadPool("http-thread-pool");
                if (listener.findThreadPool() == null) {
                    final ThreadPool pool = nls.createChild(ThreadPool.class);
                    pool.setName(listenerName);
                    listener.setThreadPool(listenerName);
                }
                listener.setTransport("tcp");
                if (listener.findTransport() == null) {
                    final Transport transport = transports.createChild(Transport.class);
                    transport.setName(listenerName);
                    listener.setTransport(listenerName);
                }
                nls.getNetworkListener().add(listener);
                return listener;
            }
        }, networkConfig.getNetworkListeners(), networkConfig.getTransports());
        if (webListener.getProtocol().equals("https")) {
            NetworkListener networkListener = networkConfig.getNetworkListener(listenerName);
            Protocol httpProtocol = networkListener.findHttpProtocol();
            ConfigSupport.apply(new SingleConfigCode<Protocol>() {

                public Object run(Protocol param) throws TransactionFailure {
                    Ssl newSsl = param.createChild(Ssl.class);
                    populateSslElement(newSsl, listener);
                    System.out.println("SSL " + newSsl.getKeyStore() + " " + newSsl.getKeyStorePassword() + " " + newSsl.getTrustStore() + " " + newSsl.getTrustStorePassword());
                    param.setSsl(newSsl);
                    return newSsl;
                }
            }, httpProtocol);
        }
        com.sun.enterprise.config.serverbeans.VirtualServer vs = httpService.getVirtualServerByName(config.getVirtualServerId());
        ConfigSupport.apply(new SingleConfigCode<com.sun.enterprise.config.serverbeans.VirtualServer>() {

            public Object run(com.sun.enterprise.config.serverbeans.VirtualServer avs) throws PropertyVetoException {
                avs.addNetworkListener(listenerName);
                return avs;
            }
        }, vs);
    } catch (Exception e) {
        if (listeners.contains(webListener)) {
            listeners.remove(webListener);
        }
        e.printStackTrace();
    }
}
Also used : Protocols(org.glassfish.grizzly.config.dom.Protocols) ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) Http(org.glassfish.grizzly.config.dom.Http) NetworkListeners(org.glassfish.grizzly.config.dom.NetworkListeners) HttpListener(org.glassfish.embeddable.web.HttpListener) Protocol(org.glassfish.grizzly.config.dom.Protocol) Transports(org.glassfish.grizzly.config.dom.Transports) Ssl(org.glassfish.grizzly.config.dom.Ssl) VirtualServer(org.glassfish.embeddable.web.VirtualServer) PropertyVetoException(java.beans.PropertyVetoException) ConfigException(org.glassfish.embeddable.web.ConfigException) GlassFishException(org.glassfish.embeddable.GlassFishException) PropertyVetoException(java.beans.PropertyVetoException) WebListener(org.glassfish.embeddable.web.WebListener) Transport(org.glassfish.grizzly.config.dom.Transport) org.jvnet.hk2.config(org.jvnet.hk2.config) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 4 with ThreadPool

use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.

the class DeleteThreadpool method preAuthorization.

@Override
public boolean preAuthorization(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    config = CLIUtil.updateConfigIfNeeded(config, target, habitat);
    threadPools = config.getThreadPools();
    if (!isThreadPoolExists(threadPools)) {
        report.setMessage(localStrings.getLocalString("delete.threadpool.notexists", "Thread Pool named {0} does not exist.", threadpool_id));
        report.setActionExitCode(ExitCode.FAILURE);
        return false;
    }
    pool = null;
    for (ThreadPool tp : config.getThreadPools().getThreadPool()) {
        if (tp.getName().equals(threadpool_id)) {
            pool = tp;
        }
    }
    List<NetworkListener> nwlsnrList = pool.findNetworkListeners();
    for (NetworkListener nwlsnr : nwlsnrList) {
        if (pool.getName().equals(nwlsnr.getThreadPool())) {
            report.setMessage(localStrings.getLocalString("delete.threadpool.beingused", "{0} threadpool is being used in the network listener {1}", threadpool_id, nwlsnr.getName()));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return false;
        }
    }
    return true;
}
Also used : ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) ActionReport(org.glassfish.api.ActionReport) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 5 with ThreadPool

use of org.glassfish.grizzly.config.dom.ThreadPool in project Payara by payara.

the class DeleteThreadpool 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) {
    ActionReport report = context.getActionReport();
    try {
        ConfigSupport.apply(new SingleConfigCode<ThreadPools>() {

            public Object run(ThreadPools param) throws PropertyVetoException, TransactionFailure {
                List<ThreadPool> poolList = param.getThreadPool();
                for (ThreadPool pool : poolList) {
                    String currPoolId = pool.getName();
                    if (currPoolId != null && currPoolId.equals(threadpool_id)) {
                        poolList.remove(pool);
                        break;
                    }
                }
                return poolList;
            }
        }, threadPools);
        report.setActionExitCode(ExitCode.SUCCESS);
    } catch (TransactionFailure e) {
        String str = e.getMessage();
        report.setMessage(localStrings.getLocalString("delete.threadpool" + ".failed", "Delete Thread Pool failed because of: ", str));
        report.setActionExitCode(ExitCode.FAILURE);
        report.setFailureCause(e);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) List(java.util.List) ActionReport(org.glassfish.api.ActionReport)

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