Search in sources :

Example 61 with NetworkListener

use of org.glassfish.grizzly.config.dom.NetworkListener 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 62 with NetworkListener

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

the class FindHttpProtocolResource method get.

@GET
@Produces({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_FORM_URLENCODED })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_FORM_URLENCODED })
public ActionReportResult get() {
    Dom dom = getEntity();
    NetworkListener nl = dom.createProxy(NetworkListener.class);
    Protocol p = nl.findHttpProtocol();
    RestActionReporter ar = new RestActionReporter();
    ar.setActionExitCode(ActionReport.ExitCode.SUCCESS);
    ar.getTopMessagePart().getProps().put("protocol", p.getName());
    ActionReportResult result = new ActionReportResult("find-http-protocol", ar, new OptionsResult());
    return result;
}
Also used : Dom(org.jvnet.hk2.config.Dom) ActionReportResult(org.glassfish.admin.rest.results.ActionReportResult) RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) Protocol(org.glassfish.grizzly.config.dom.Protocol) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener) OptionsResult(org.glassfish.admin.rest.results.OptionsResult) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) GET(javax.ws.rs.GET)

Example 63 with NetworkListener

use of org.glassfish.grizzly.config.dom.NetworkListener 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 64 with NetworkListener

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

the class GrizzlyService method getAddressInfoFromVirtualServers.

// get the ports from the http listeners that are associated with
// the virtual servers
private List<AddressInfo> getAddressInfoFromVirtualServers(Collection<String> virtualServers) {
    List<AddressInfo> addressInfos = new ArrayList<AddressInfo>();
    List<NetworkListener> networkListenerList = config.getNetworkConfig().getNetworkListeners().getNetworkListener();
    for (String vs : virtualServers) {
        VirtualServer virtualServer = config.getHttpService().getVirtualServerByName(vs);
        if (virtualServer == null) {
            // non-existent virtual server
            LOGGER.log(Level.WARNING, KernelLoggerInfo.grizzlyNonExistentVS, vs);
            continue;
        }
        String vsNetworkListeners = virtualServer.getNetworkListeners();
        List<String> vsNetworkListenerList = StringUtils.parseStringList(vsNetworkListeners, ",");
        if (vsNetworkListenerList != null && !vsNetworkListenerList.isEmpty()) {
            for (String vsNetworkListener : vsNetworkListenerList) {
                for (NetworkListener networkListener : networkListenerList) {
                    if (networkListener.getName().equals(vsNetworkListener) && Boolean.valueOf(networkListener.getEnabled())) {
                        addressInfos.add(new AddressInfo(networkListener.getAddress(), networkListener.getPort()));
                        break;
                    }
                }
            }
        }
    }
    return addressInfos;
}
Also used : ArrayList(java.util.ArrayList) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Example 65 with NetworkListener

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

the class PortsImpl method createPort.

private Port createPort(Integer portNumber) throws IOException {
    for (NetworkListener nl : network.getNetworkListeners().getNetworkListener()) {
        if (nl.getPort().equals(portNumber.toString())) {
            throw new IOException("Port " + portNumber + " is already configured");
        }
    }
    for (Integer pn : ports.keySet()) {
        if (pn.equals(portNumber)) {
            throw new IOException("Port " + portNumber + " is alredy open");
        }
    }
    PortImpl port = habitat.getService(PortImpl.class);
    port.setPortNumber(portNumber);
    ports.put(portNumber, port);
    return port;
}
Also used : IOException(java.io.IOException) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Aggregations

NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)74 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)21 Protocol (org.glassfish.grizzly.config.dom.Protocol)18 Config (com.sun.enterprise.config.serverbeans.Config)17 NetworkListeners (org.glassfish.grizzly.config.dom.NetworkListeners)14 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)12 Test (org.junit.Test)11 ActionReport (org.glassfish.api.ActionReport)10 CommandTarget (org.glassfish.config.support.CommandTarget)9 Target (org.glassfish.internal.api.Target)9 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)8 HttpService (com.sun.enterprise.config.serverbeans.HttpService)7 ArrayList (java.util.ArrayList)7 Protocols (org.glassfish.grizzly.config.dom.Protocols)7 ObservableBean (org.jvnet.hk2.config.ObservableBean)7 Transactions (org.jvnet.hk2.config.Transactions)7 IOException (java.io.IOException)6 Http (org.glassfish.grizzly.config.dom.Http)6 PropertyVetoException (java.beans.PropertyVetoException)5 ThreadPool (org.glassfish.grizzly.config.dom.ThreadPool)5