Search in sources :

Example 26 with NetworkConfig

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

the class CommandThreadPool method postConstruct.

/**
 * Process the instance file if this is DAS and there are instances configured already in this domain
 */
@Override
public void postConstruct() {
    // If this is not the DAS, no need for this pool
    if (serverEnv.isInstance()) {
        return;
    }
    int poolSize = 5;
    Config svrConfig = domain.getConfigNamed("server-config");
    // during build; got to check the reason why later.
    if (svrConfig != null) {
        NetworkConfig nwc = svrConfig.getNetworkConfig();
        if (nwc != null) {
            List<NetworkListener> lss = nwc.getNetworkListeners().getNetworkListener();
            if ((lss != null) && (!lss.isEmpty())) {
                for (NetworkListener ls : lss) {
                    if (ServerTags.ADMIN_LISTENER_ID.equals(ls.getName())) {
                        if (ls.findThreadPool() != null) {
                            poolSize = Integer.parseInt(ls.findThreadPool().getMaxThreadPoolSize());
                        }
                    }
                }
            }
        }
    }
    svc = Executors.newFixedThreadPool(poolSize, new InstanceStateThreadFactory());
}
Also used : Config(com.sun.enterprise.config.serverbeans.Config) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 27 with NetworkConfig

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

the class CreateSsl method findOrCreateProtocol.

public Protocol findOrCreateProtocol(final String name, final boolean create) throws TransactionFailure {
    NetworkConfig networkConfig = config.getNetworkConfig();
    Protocol protocol = networkConfig.findProtocol(name);
    if (protocol == null && create) {
        protocol = (Protocol) ConfigSupport.apply(new SingleConfigCode<Protocols>() {

            @Override
            public Object run(Protocols param) throws TransactionFailure {
                Protocol newProtocol = param.createChild(Protocol.class);
                newProtocol.setName(name);
                newProtocol.setSecurityEnabled("true");
                param.getProtocol().add(newProtocol);
                return newProtocol;
            }
        }, habitat.<Protocols>getService(Protocols.class));
    }
    return protocol;
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) Protocols(org.glassfish.grizzly.config.dom.Protocols) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) Protocol(org.glassfish.grizzly.config.dom.Protocol)

Example 28 with NetworkConfig

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

the class RuntimeRootImpl method getAdminListener.

private NetworkListener getAdminListener() {
    final NetworkConfig network = networkConfig();
    final NetworkListener listener = network.getNetworkListener(ADMIN_LISTENER_NAME);
    return listener;
}
Also used : NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 29 with NetworkConfig

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

the class GrizzlyService method createNetworkProxy.

/*
     * Creates a new NetworkProxy for a particular HttpListner
     * @param listener NetworkListener
     * @param networkConfig HttpService
     */
public synchronized Future<Result<Thread>> createNetworkProxy(NetworkListener listener) {
    if (!Boolean.valueOf(listener.getEnabled())) {
        // in case the listener will be enabled
        addChangeListener(listener);
        LOGGER.log(Level.INFO, KernelLoggerInfo.grizzlyPortDisabled, new Object[] { listener.getName(), listener.getPort() });
        return null;
    }
    // create the proxy for the port.
    GrizzlyProxy proxy = new GrizzlyProxy(this, listener);
    Future<Result<Thread>> future = null;
    try {
        proxy.initialize();
        if (!isLightWeightListener(listener)) {
            final NetworkConfig networkConfig = listener.getParent(NetworkListeners.class).getParent(NetworkConfig.class);
            // attach all virtual servers to this port
            for (VirtualServer vs : networkConfig.getParent(Config.class).getHttpService().getVirtualServer()) {
                List<String> vsListeners = StringUtils.parseStringList(vs.getNetworkListeners(), " ,");
                if (vsListeners == null || vsListeners.isEmpty() || vsListeners.contains(listener.getName())) {
                    if (!hosts.contains(vs.getId())) {
                        hosts.add(vs.getId());
                    }
                }
            }
            addChangeListener(listener);
            addChangeListener(listener.findThreadPool());
            addChangeListener(listener.findTransport());
            final Protocol protocol = listener.findHttpProtocol();
            if (protocol != null) {
                addChangeListener(protocol);
                addChangeListener(protocol.getHttp());
                addChangeListener(protocol.getHttp().getFileCache());
                addChangeListener(protocol.getSsl());
            }
        }
        future = proxy.start();
        // add the new proxy to our list of proxies.
        proxies.add(proxy);
    } catch (Throwable e) {
        final Future<Result<Thread>> errorFuture = Futures.createReadyFuture(new Result<Thread>(e));
        future = errorFuture;
    } finally {
        if (future == null) {
            final FutureImpl<Result<Thread>> errorFuture = Futures.<Result<Thread>>createUnsafeFuture();
            errorFuture.result(new Result<Thread>(new IllegalStateException("Unexpected error")));
            future = errorFuture;
        }
        futures.add(future);
    }
    return future;
}
Also used : NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer) Result(com.sun.enterprise.util.Result) NetworkListeners(org.glassfish.grizzly.config.dom.NetworkListeners) Future(java.util.concurrent.Future) Protocol(org.glassfish.grizzly.config.dom.Protocol)

Example 30 with NetworkConfig

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

the class ServerHelper method getAdminListener.

public static NetworkListener getAdminListener(Config config) {
    NetworkConfig nwc = config.getNetworkConfig();
    if (nwc == null)
        throw new IllegalStateException("Can't operate without <http-service>");
    List<NetworkListener> lss = nwc.getNetworkListeners().getNetworkListener();
    if (lss == null || lss.isEmpty())
        throw new IllegalStateException("Can't operate without at least one <network-listener>");
    for (NetworkListener ls : lss) {
        if (ServerTags.ADMIN_LISTENER_ID.equals(ls.getName())) {
            return ls;
        }
    }
    // if we can't find the admin-listener, then use the first one
    return lss.get(0);
}
Also used : NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Aggregations

NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)33 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)21 Config (com.sun.enterprise.config.serverbeans.Config)18 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)16 Protocol (org.glassfish.grizzly.config.dom.Protocol)14 ActionReport (org.glassfish.api.ActionReport)10 CommandTarget (org.glassfish.config.support.CommandTarget)10 Target (org.glassfish.internal.api.Target)10 NetworkListeners (org.glassfish.grizzly.config.dom.NetworkListeners)6 Protocols (org.glassfish.grizzly.config.dom.Protocols)6 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)5 HttpService (com.sun.enterprise.config.serverbeans.HttpService)4 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)4 PropertyVetoException (java.beans.PropertyVetoException)3 Http (org.glassfish.grizzly.config.dom.Http)3 Ssl (org.glassfish.grizzly.config.dom.Ssl)3 Transport (org.glassfish.grizzly.config.dom.Transport)3 JavaConfig (com.sun.enterprise.config.serverbeans.JavaConfig)2 SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)2 Result (com.sun.enterprise.util.Result)2