Search in sources :

Example 1 with FileCache

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

the class CreateHttp method execute.

/**
 * Executes the command with the command parameters passed as Properties
 * where the keys are the parameter names and the values the parameter
 * values.
 *
 * @param context information
 */
public void execute(AdminCommandContext context) {
    Target targetUtil = services.getService(Target.class);
    Config newConfig = targetUtil.getConfig(target);
    if (newConfig != null) {
        config = newConfig;
    }
    final ActionReport report = context.getActionReport();
    // check for duplicates
    Protocols protocols = config.getNetworkConfig().getProtocols();
    Protocol protocol = null;
    for (Protocol p : protocols.getProtocol()) {
        if (protocolName.equals(p.getName())) {
            protocol = p;
        }
    }
    if (protocol == null) {
        report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_FAIL_PROTOCOL_NOT_FOUND), protocolName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    if (protocol.getHttp() != null) {
        report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_FAIL_DUPLICATE), protocolName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    // Add to the <network-config>
    try {
        ConfigSupport.apply(new SingleConfigCode<Protocol>() {

            public Object run(Protocol param) throws TransactionFailure {
                Http http = param.createChild(Http.class);
                final FileCache cache = http.createChild(FileCache.class);
                cache.setEnabled("false");
                http.setFileCache(cache);
                http.setDefaultVirtualServer(defaultVirtualServer);
                http.setDnsLookupEnabled(dnsLookupEnabled == null ? null : dnsLookupEnabled.toString());
                http.setMaxConnections(maxConnections);
                http.setRequestTimeoutSeconds(requestTimeoutSeconds);
                http.setTimeoutSeconds(timeoutSeconds);
                http.setXpoweredBy(xPoweredBy == null ? null : xPoweredBy.toString());
                http.setServerHeader(serverHeader == null ? null : serverHeader.toString());
                http.setXframeOptions(xFrameOptions == null ? null : xFrameOptions.toString());
                http.setServerName(serverName);
                // HTTP2 options
                http.setHttp2Enabled(http2Enabled);
                if (http2MaxConcurrentStreams != null) {
                    http.setHttp2MaxConcurrentStreams(http2MaxConcurrentStreams);
                }
                if (http2InitialWindowSizeInBytes != null) {
                    http.setHttp2InitialWindowSizeInBytes(http2InitialWindowSizeInBytes);
                }
                if (http2MaxFramePayloadSizeInBytes != null) {
                    http.setHttp2MaxFramePayloadSizeInBytes(http2MaxFramePayloadSizeInBytes);
                }
                if (http2MaxHeaderListSizeInBytes != null) {
                    http.setHttp2MaxHeaderListSizeInBytes(http2MaxHeaderListSizeInBytes);
                }
                if (http2StreamsHighWaterMark != null) {
                    http.setHttp2StreamsHighWaterMark(http2StreamsHighWaterMark.toString());
                }
                if (http2CleanPercentage != null) {
                    http.setHttp2CleanPercentage(http2CleanPercentage.toString());
                }
                if (http2CleanFrequencyCheck != null) {
                    http.setHttp2CleanFrequencyCheck(http2CleanFrequencyCheck);
                }
                if (http2DisableCipherCheck != null) {
                    http.setHttp2DisableCipherCheck(http2DisableCipherCheck);
                }
                if (http2PushEnabled != null) {
                    http.setHttp2PushEnabled(http2PushEnabled);
                }
                param.setHttp(http);
                return http;
            }
        }, protocol);
    } catch (TransactionFailure e) {
        report.setMessage(MessageFormat.format(rb.getString(LogFacade.CREATE_HTTP_REDIRECT_FAIL), protocolName, e.getMessage() == null ? "No reason given." : 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) Protocols(org.glassfish.grizzly.config.dom.Protocols) Config(com.sun.enterprise.config.serverbeans.Config) Http(org.glassfish.grizzly.config.dom.Http) ActionReport(org.glassfish.api.ActionReport) Protocol(org.glassfish.grizzly.config.dom.Protocol) FileCache(org.glassfish.grizzly.config.dom.FileCache)

Example 2 with FileCache

use of org.glassfish.grizzly.config.dom.FileCache 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)

Aggregations

FileCache (org.glassfish.grizzly.config.dom.FileCache)2 Http (org.glassfish.grizzly.config.dom.Http)2 Protocol (org.glassfish.grizzly.config.dom.Protocol)2 Config (com.sun.enterprise.config.serverbeans.Config)1 MonitoringService (com.sun.enterprise.config.serverbeans.MonitoringService)1 SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)1 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)1 ActionReport (org.glassfish.api.ActionReport)1 CommandTarget (org.glassfish.config.support.CommandTarget)1 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)1 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)1 Protocols (org.glassfish.grizzly.config.dom.Protocols)1 Ssl (org.glassfish.grizzly.config.dom.Ssl)1 ThreadPool (org.glassfish.grizzly.config.dom.ThreadPool)1 Transport (org.glassfish.grizzly.config.dom.Transport)1 Target (org.glassfish.internal.api.Target)1 Changed (org.jvnet.hk2.config.Changed)1 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)1 NotProcessed (org.jvnet.hk2.config.NotProcessed)1 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)1