Search in sources :

Example 1 with BootCommand

use of fish.payara.micro.boot.runtime.BootCommand in project Payara by payara.

the class PayaraMicroImpl method configurePorts.

private void configurePorts() throws GlassFishException {
    PortBinder portBinder = new PortBinder();
    if (httpPort != Integer.MIN_VALUE) {
        if (autoBindHttp == true) {
            // Log warnings if overriding other options
            logPortPrecedenceWarnings(false);
            // Search for an available port from the specified port
            try {
                int port = portBinder.findAvailablePort(httpPort, autoBindRange);
                preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.network-listeners.network-listener.http-listener.port=" + port));
                preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.network-listeners.network-listener.http-listener.enabled=true"));
            } catch (BindException ex) {
                LOGGER.log(Level.SEVERE, "No available port found in range: " + httpPort + " - " + (httpPort + autoBindRange), ex);
                throw new GlassFishException("Could not bind HTTP port");
            }
        } else {
            // Log warnings if overriding other options
            logPortPrecedenceWarnings(false);
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.network-listeners.network-listener.http-listener.port=" + httpPort));
        }
    } else if (autoBindHttp == true) {
        // Log warnings if overriding other options
        logPortPrecedenceWarnings(false);
        // Search for an available port from the default HTTP port
        try {
            int port = portBinder.findAvailablePort(defaultHttpPort, autoBindRange);
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.network-listeners.network-listener.http-listener.port=" + port));
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.network-listeners.network-listener.http-listener.enabled=true"));
        } catch (BindException ex) {
            LOGGER.log(Level.SEVERE, "No available port found in range: " + defaultHttpPort + " - " + (defaultHttpPort + autoBindRange), ex);
            throw new GlassFishException("Could not bind HTTP port");
        }
    }
    if (sslPort != Integer.MIN_VALUE) {
        if (autoBindSsl == true) {
            // Log warnings if overriding other options
            logPortPrecedenceWarnings(true);
            // Search for an available port from the specified port
            try {
                int port = portBinder.findAvailablePort(sslPort, autoBindRange);
                preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.network-listeners.network-listener.https-listener.port=" + port));
                preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.network-listeners.network-listener.https-listener.enabled=true"));
            } catch (BindException ex) {
                LOGGER.log(Level.SEVERE, "No available port found in range: " + sslPort + " - " + (sslPort + autoBindRange), ex);
                throw new GlassFishException("Could not bind SSL port");
            }
        } else {
            // Log warnings if overriding other options
            logPortPrecedenceWarnings(true);
            // Set the port as normal
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.network-listeners.network-listener.https-listener.port=" + sslPort));
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.network-listeners.network-listener.https-listener.enabled=true"));
        }
    } else if (autoBindSsl == true) {
        // Log warnings if overriding other options
        logPortPrecedenceWarnings(true);
        // Search for an available port from the default HTTPS port
        try {
            int port = portBinder.findAvailablePort(defaultHttpsPort, autoBindRange);
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.network-listeners.network-listener.https-listener.port=" + port));
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.network-listeners.network-listener.https-listener.enabled=true"));
        } catch (BindException ex) {
            LOGGER.log(Level.SEVERE, "No available port found in range: " + defaultHttpsPort + " - " + (defaultHttpsPort + autoBindRange), ex);
            throw new GlassFishException("Could not bind SSL port");
        }
    }
    if (sslCert != null) {
        preBootCommands.add(new BootCommand("set", "configs.config.server-config.network-config.protocols.protocol.https-listener.ssl.cert-nickname=" + sslCert));
    }
}
Also used : GlassFishException(org.glassfish.embeddable.GlassFishException) BootCommand(fish.payara.micro.boot.runtime.BootCommand) BindException(java.net.BindException)

Example 2 with BootCommand

use of fish.payara.micro.boot.runtime.BootCommand in project Payara by payara.

the class PayaraMicroImpl method configureHazelcast.

private void configureHazelcast() {
    // check hazelcast cluster overrides
    if (noCluster) {
        preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-config-specific-configuration.enabled=false"));
        preBootCommands.add(new BootCommand("set", "configs.config.server-config.ejb-container.ejb-timer-service.ejb-timer-service=Dummy"));
    } else {
        if (hzPort > Integer.MIN_VALUE) {
            preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.multicast-port=" + hzPort));
        }
        if (hzStartPort > Integer.MIN_VALUE) {
            preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.start-port=" + hzStartPort));
        }
        if (hzMulticastGroup != null) {
            preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.multicast-group=" + hzMulticastGroup));
        }
        if (alternateHZConfigFile != null) {
            preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.hazelcast-configuration-file=" + alternateHZConfigFile.getName()));
        }
        preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-config-specific-configuration.lite=" + liteMember));
        if (hzClusterName != null) {
            preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.cluster-group-name=" + hzClusterName));
        }
        if (hzClusterPassword != null) {
            preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.cluster-group-password=" + hzClusterPassword));
        }
        if (instanceName != null) {
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-config-specific-configuration.member-name=" + instanceName));
            preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.generate-names=false"));
        }
        if (instanceGroup != null) {
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.hazelcast-config-specific-configuration.member-group=" + instanceGroup));
        }
        preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.host-aware-partitioning=" + hostAware));
        if (clustermode != null) {
            if (clustermode.startsWith("tcpip:")) {
                String tcpipmembers = clustermode.substring(6);
                preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.tcpip-members=" + tcpipmembers));
                preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.discovery-mode=tcpip"));
            } else if (clustermode.startsWith("multicast:")) {
                String[] hostPort = clustermode.split(":");
                if (hostPort.length == 3) {
                    preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.multicast-group=" + hostPort[1]));
                    preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.multicast-port=" + hostPort[2]));
                    preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.discovery-mode=multicast"));
                }
            } else if (clustermode.startsWith("domain:")) {
                String[] hostPort = clustermode.split(":");
                if (hostPort.length == 3) {
                    preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.das-public-address=" + hostPort[1]));
                    preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.das-port=" + hostPort[2]));
                    preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.discovery-mode=domain"));
                }
            }
        } else {
            preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.discovery-mode=multicast"));
        }
        if (interfaces != null) {
            preBootCommands.add(new BootCommand("set", "hazelcast-runtime-configuration.interface=" + interfaces));
        }
    }
}
Also used : BootCommand(fish.payara.micro.boot.runtime.BootCommand)

Example 3 with BootCommand

use of fish.payara.micro.boot.runtime.BootCommand in project Payara by payara.

the class PayaraMicroImpl method configureRequestTracingService.

private void configureRequestTracingService() {
    if (enableRequestTracing) {
        preBootCommands.add(new BootCommand("set", "configs.config.server-config.request-tracing-service-configuration.enabled=true"));
        preBootCommands.add(new BootCommand("set", "configs.config.server-config.request-tracing-service-configuration.threshold-unit=" + requestTracingThresholdUnit));
        preBootCommands.add(new BootCommand("set", "configs.config.server-config.request-tracing-service-configuration.threshold-value" + "=" + Long.toString(requestTracingThresholdValue)));
        if (enableRequestTracingAdaptiveSampling) {
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.request-tracing-service-configuration.adaptive-sampling-enabled=" + Boolean.toString(enableRequestTracingAdaptiveSampling)));
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.request-tracing-service-configuration.adaptive-sampling-target-count=" + Integer.toString(requestTracingAdaptiveSamplingTargetCount)));
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.request-tracing-service-configuration.adaptive-sampling-time-value=" + Integer.toString(requestTracingAdaptiveSamplingTimeValue)));
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.request-tracing-service-configuration.adaptive-sampling-time-unit=" + requestTracingAdaptiveSamplingTimeUnit));
        }
    }
}
Also used : BootCommand(fish.payara.micro.boot.runtime.BootCommand)

Example 4 with BootCommand

use of fish.payara.micro.boot.runtime.BootCommand in project Payara by payara.

the class PayaraMicroImpl method configureAccessLogging.

private void configureAccessLogging() {
    if (enableAccessLog) {
        preBootCommands.add(new BootCommand("set", "configs.config.server-config.http-service.access-logging-enabled=true"));
        preBootCommands.add(new BootCommand("set", "configs.config.server-config.http-service.virtual-server.server.access-log=" + userAccessLogDirectory));
        preBootCommands.add(new BootCommand("set", "configs.config.server-config.http-service.virtual-server.server.access-logging-enabled=true"));
        if (enableAccessLogFormat) {
            preBootCommands.add(new BootCommand("set", "configs.config.server-config.http-service.access-log.format=" + accessLogFormat));
        }
    }
}
Also used : BootCommand(fish.payara.micro.boot.runtime.BootCommand)

Example 5 with BootCommand

use of fish.payara.micro.boot.runtime.BootCommand in project Payara by payara.

the class PayaraMicroImpl method configurePhoneHome.

private void configurePhoneHome() {
    if (disablePhoneHome == true) {
        LOGGER.info("Disabled Phone Home");
        preBootCommands.add(new BootCommand("set", "configs.config.server-config.phone-home-runtime-configuration.enabled=false"));
    }
}
Also used : BootCommand(fish.payara.micro.boot.runtime.BootCommand)

Aggregations

BootCommand (fish.payara.micro.boot.runtime.BootCommand)5 BindException (java.net.BindException)1 GlassFishException (org.glassfish.embeddable.GlassFishException)1