Search in sources :

Example 11 with ThreadPool

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

the class CreateHttpListener 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 (!validateInputs(report)) {
        return;
    }
    Target targetUtil = services.getService(Target.class);
    Config newConfig = targetUtil.getConfig(target);
    if (newConfig != null) {
        config = newConfig;
    }
    networkConfig = config.getNetworkConfig();
    HttpService httpService = config.getHttpService();
    if (!(verifyUniqueName(report, networkConfig) && verifyUniquePort(report, networkConfig) && verifyDefaultVirtualServer(report))) {
        return;
    }
    VirtualServer vs = httpService.getVirtualServerByName(defaultVirtualServer);
    boolean listener = false;
    boolean protocol = false;
    boolean transport = false;
    try {
        transport = createOrGetTransport(null);
        protocol = createProtocol(context);
        createHttp(context);
        final ThreadPool threadPool = getThreadPool(networkConfig);
        listener = createNetworkListener(networkConfig, transport, threadPool);
        updateVirtualServer(vs);
    } catch (TransactionFailure e) {
        try {
            if (listener) {
                deleteListener(context);
            }
            if (protocol) {
                deleteProtocol(context);
            }
            if (transport) {
                deleteTransport(context);
            }
        } catch (Exception e1) {
            if (logger.isLoggable(Level.INFO)) {
                logger.log(Level.INFO, e.getMessage(), e);
            }
            throw new RuntimeException(e.getMessage());
        }
        if (logger.isLoggable(Level.INFO)) {
            logger.log(Level.INFO, e.getMessage(), e);
        }
        report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_LISTENER_FAIL), listenerId, e.getMessage()));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(e);
        return;
    }
    report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Target(org.glassfish.internal.api.Target) CommandTarget(org.glassfish.config.support.CommandTarget) Config(com.sun.enterprise.config.serverbeans.Config) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) HttpService(com.sun.enterprise.config.serverbeans.HttpService) ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) ActionReport(org.glassfish.api.ActionReport) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer) PropertyVetoException(java.beans.PropertyVetoException)

Example 12 with ThreadPool

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

the class UpgradeTest method threadPools.

@Test
public void threadPools() {
    List<String> names = new ArrayList<String>();
    for (ThreadPool pool : getHabitat().<Config>getService(Config.class).getThreadPools().getThreadPool()) {
        names.add(pool.getName());
    }
    assertTrue(names.contains("http-thread-pool") && names.contains("thread-pool-1"));
}
Also used : Config(com.sun.enterprise.config.serverbeans.Config) ArrayList(java.util.ArrayList) ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) Test(org.junit.Test)

Example 13 with ThreadPool

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

the class GrizzlyConfigTest method defaults.

@Test
public void defaults() throws IOException {
    GrizzlyConfig grizzlyConfig = null;
    try {
        grizzlyConfig = new GrizzlyConfig("grizzly-config.xml");
        final ThreadPool threadPool = grizzlyConfig.getConfig().getNetworkListeners().getThreadPool().get(0);
        Assert.assertEquals("5", threadPool.getMaxThreadPoolSize());
    } finally {
        if (grizzlyConfig != null) {
            grizzlyConfig.shutdown();
        }
    }
}
Also used : ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) Test(org.junit.Test)

Example 14 with ThreadPool

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

the class AdminEndpointDecider method setValues.

private void setValues() {
    // can't change
    asadminContextRoot = AdminAdapter.PREFIX_URI;
    // asadminHosts       = Collections.emptyList();  //asadmin is handled completely by the adapter, no VS needed
    NetworkListener nl = cfg.getAdminListener();
    ThreadPool tp = nl.findThreadPool();
    if (tp != null) {
        try {
            maxThreadPoolSize = Integer.parseInt(tp.getMaxThreadPoolSize());
        } catch (NumberFormatException ne) {
        }
    }
    String dvs = nl.findHttpProtocol().getHttp().getDefaultVirtualServer();
    guiHosts = Collections.unmodifiableList(Arrays.asList(dvs));
    // same for now
    asadminHosts = guiHosts;
    try {
        address = InetAddress.getByName(nl.getAddress());
    } catch (UnknownHostException e) {
        throw new IllegalStateException(e);
    }
    if (ServerTags.ADMIN_LISTENER_ID.equals(nl.getName())) {
        // at the root context for separate admin-listener
        guiContextRoot = "";
        try {
            port = Integer.parseInt(nl.getPort());
        } catch (NumberFormatException ne) {
            port = ADMIN_PORT;
        }
    } else {
        try {
            port = Integer.parseInt(nl.getPort());
        } catch (NumberFormatException ne) {
            // this is the last resort
            port = 8080;
        }
        // get the context root from admin-service
        AdminService as = cfg.getAdminService();
        if (as == null)
            guiContextRoot = ServerEnvironmentImpl.DEFAULT_ADMIN_CONSOLE_CONTEXT_ROOT;
        else
            setGuiContextRootFromAdminService(as);
    }
}
Also used : AdminService(com.sun.enterprise.config.serverbeans.AdminService) UnknownHostException(java.net.UnknownHostException) ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 15 with ThreadPool

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

the class GrizzlyConfigSchemaMigrator method ensureAdminThreadPool.

private void ensureAdminThreadPool() throws TransactionFailure {
    final ThreadPools threadPools = currentConfig.getThreadPools();
    boolean adminThreadPoolFound = false;
    for (ThreadPool pool : threadPools.getThreadPool()) {
        adminThreadPoolFound |= "admin-thread-pool".equals(pool.getName());
    }
    if (!adminThreadPoolFound) {
        ConfigSupport.apply(new SingleConfigCode<ThreadPools>() {

            @Override
            public Object run(ThreadPools param) throws PropertyVetoException, TransactionFailure {
                final ThreadPool pool = param.createChild(ThreadPool.class);
                param.getThreadPool().add(pool);
                pool.setName("admin-thread-pool");
                pool.setMaxThreadPoolSize("50");
                pool.setMaxQueueSize("256");
                return null;
            }
        }, threadPools);
    }
}
Also used : ThreadPools(com.sun.enterprise.config.serverbeans.ThreadPools) PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) 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