use of org.glassfish.internal.api.Target in project Payara by payara.
the class GetProtocol method execute.
@Override
public void execute(AdminCommandContext context) {
ActionReport report = context.getActionReport();
// Check that a configuration can be found
if (targetUtil.getConfig(target) == null) {
report.failure(logger, MessageFormat.format(logger.getResourceBundle().getString(LogFacade.UNKNOWN_CONFIG), target));
return;
}
Config config = targetUtil.getConfig(target);
// Check that a matching listener can be found
List<Protocol> protocols = config.getNetworkConfig().getProtocols().getProtocol();
Optional<Protocol> optionalProtocol = protocols.stream().filter(protocol -> protocol.getName().equals(protocolName)).findFirst();
if (!optionalProtocol.isPresent()) {
report.failure(logger, MessageFormat.format(logger.getResourceBundle().getString(LogFacade.UNKNOWN_PROTOCOL), protocolName, target));
return;
}
Protocol protocol = optionalProtocol.get();
// Write message body
report.appendMessage(String.format("Name: %s\n", protocol.getName()));
// Write HTTP config options
report.appendMessage("\nHTTP:\n");
report.appendMessage(String.format("Server Name: %s\n", protocol.getHttp().getServerName()));
report.appendMessage(String.format("Max Connections: %s seconds\n", protocol.getHttp().getMaxConnections()));
report.appendMessage(String.format("Default Virtual Server: %s\n", protocol.getHttp().getDefaultVirtualServer()));
report.appendMessage(String.format("Server Header: %s\n", protocol.getHttp().getServerHeader()));
report.appendMessage(String.format("X-Powered-By: %s\n", protocol.getHttp().getXpoweredBy()));
if (verbose) {
report.appendMessage(String.format("Request Timeout: %s seconds\n", protocol.getHttp().getRequestTimeoutSeconds()));
report.appendMessage(String.format("Timeout: %s seconds\n", protocol.getHttp().getTimeoutSeconds()));
report.appendMessage(String.format("DNS Lookup Enabled: %s\n", protocol.getHttp().getDnsLookupEnabled()));
report.appendMessage(String.format("X Frame Options: %s\n", protocol.getHttp().getXframeOptions()));
}
// Write HTTP/2 config options
report.appendMessage("\nHTTP/2:\n");
report.appendMessage(String.format("Enabled: %s\n", protocol.getHttp().getHttp2Enabled()));
if (Boolean.parseBoolean(protocol.getHttp().getHttp2Enabled())) {
report.appendMessage(String.format("Push Enabled: %s\n", protocol.getHttp().getHttp2PushEnabled()));
report.appendMessage(String.format("Cipher Check: %s\n", !Boolean.parseBoolean(protocol.getHttp().getHttp2DisableCipherCheck())));
if (verbose) {
report.appendMessage(String.format("Max Concurrent Streams: %s\n", protocol.getHttp().getHttp2MaxConcurrentStreams()));
report.appendMessage(String.format("Initial Window Size: %s bytes\n", protocol.getHttp().getHttp2InitialWindowSizeInBytes()));
report.appendMessage(String.format("Max Frame Payload Size: %s bytes\n", protocol.getHttp().getHttp2MaxFramePayloadSizeInBytes()));
report.appendMessage(String.format("Max Header List Size: %s bytes\n", protocol.getHttp().getHttp2MaxHeaderListSizeInBytes()));
report.appendMessage(String.format("Streams High Water Mark: %s\n", protocol.getHttp().getHttp2StreamsHighWaterMark()));
report.appendMessage(String.format("Clean Percentage: %s\n", protocol.getHttp().getHttp2CleanPercentage()));
report.appendMessage(String.format("Clean Frequency Check: %s\n", protocol.getHttp().getHttp2CleanFrequencyCheck()));
}
}
// Write the variables as properties
Properties properties = new Properties();
properties.put("name", protocol.getName());
properties.put("serverName", protocol.getHttp().getServerName() == null ? "null" : protocol.getHttp().getServerName());
properties.put("maxConnections", protocol.getHttp().getMaxConnections());
properties.put("defaultVirtualServer", protocol.getHttp().getDefaultVirtualServer());
properties.put("serverHeader", protocol.getHttp().getServerHeader());
properties.put("xPoweredBy", protocol.getHttp().getXpoweredBy());
properties.put("requestTimeoutSeconds", protocol.getHttp().getRequestTimeoutSeconds());
properties.put("timeoutSeconds", protocol.getHttp().getTimeoutSeconds());
properties.put("dnsLookupEnabled", protocol.getHttp().getDnsLookupEnabled());
properties.put("xFrameOptions", protocol.getHttp().getXframeOptions());
properties.put("http2Enabled", protocol.getHttp().getHttp2Enabled());
properties.put("http2MaxConcurrentStreams", protocol.getHttp().getHttp2MaxConcurrentStreams());
properties.put("http2InitialWindowSizeInBytes", protocol.getHttp().getHttp2InitialWindowSizeInBytes());
properties.put("http2MaxFramePayloadSizeInBytes", protocol.getHttp().getHttp2MaxFramePayloadSizeInBytes());
properties.put("http2MaxHeaderListSizeInBytes", protocol.getHttp().getHttp2MaxHeaderListSizeInBytes());
properties.put("http2StreamsHighWaterMark", protocol.getHttp().getHttp2StreamsHighWaterMark());
properties.put("http2CleanPercentage", protocol.getHttp().getHttp2CleanPercentage());
properties.put("http2CleanFrequencyCheck", protocol.getHttp().getHttp2CleanFrequencyCheck());
properties.put("http2DisableCipherCheck", protocol.getHttp().getHttp2DisableCipherCheck());
properties.put("http2PushEnabled", protocol.getHttp().getHttp2PushEnabled());
report.setExtraProperties(properties);
}
use of org.glassfish.internal.api.Target in project Payara by payara.
the class ListProtocols 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) {
Target targetUtil = services.getService(Target.class);
Config newConfig = targetUtil.getConfig(target);
if (newConfig != null) {
config = newConfig;
}
final ActionReport report = context.getActionReport();
List<Protocol> list = config.getNetworkConfig().getProtocols().getProtocol();
for (Protocol protocol : list) {
report.getTopMessagePart().addChild().setMessage(protocol.getName());
}
report.setActionExitCode(ActionReport.ExitCode.SUCCESS);
}
use of org.glassfish.internal.api.Target in project Payara by payara.
the class ConnectorDeployer method deleteResourceRef.
private void deleteResourceRef(String jndiName, String target) throws TransactionFailure {
if (target.equals(DOMAIN)) {
return;
}
if (domain.getConfigNamed(target) != null) {
return;
}
Server server = configBeansUtilities.getServerNamed(target);
if (server != null) {
if (server.isResourceRefExists(jndiName)) {
// delete ResourceRef for Server
server.deleteResourceRef(jndiName);
}
} else {
Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
if (cluster.isResourceRefExists(jndiName)) {
// delete ResourceRef of Cluster
cluster.deleteResourceRef(jndiName);
// delete ResourceRef for all instances of Cluster
Target tgt = habitat.getService(Target.class);
List<Server> instances = tgt.getInstances(target);
for (Server svr : instances) {
if (svr.isResourceRefExists(jndiName)) {
svr.deleteResourceRef(jndiName);
}
}
}
}
}
}
use of org.glassfish.internal.api.Target in project Payara by payara.
the class SetHealthCheckServiceConfiguration method execute.
@Override
public void execute(AdminCommandContext context) {
report = context.getActionReport();
if (report.getExtraProperties() == null) {
report.setExtraProperties(new Properties());
}
targetConfig = targetUtil.getConfig(target);
serviceType = parseServiceType(serviceName);
if (serviceType == null) {
String values = Arrays.asList(CheckerType.values()).stream().map(type -> type.name().toLowerCase().replace('_', '-')).collect(Collectors.joining(", "));
report.setMessage("No such service: " + serviceName + ".\nChoose one of: " + values + ".\nThe name can also be given in short form consisting only of the first letters of each word.");
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
// update the service to unify the way it is printed later on
serviceName = serviceType.name().toLowerCase().replace('_', '-');
BaseHealthCheck<?, ?> service = getService();
if (service == null) {
report.appendMessage(strings.getLocalString("healthcheck.service.configure.status.error", "Service with name {0} could not be found.", serviceName));
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
return;
}
updateServiceConfiguration(service);
}
use of org.glassfish.internal.api.Target in project Payara by payara.
the class ResourceUtil method createResourceRef.
public void createResourceRef(String jndiName, String enabled, String target) throws TransactionFailure {
if (target.equals(DOMAIN)) {
return;
}
Config config = domain.getConfigNamed(target);
if (config != null) {
if (!config.isResourceRefExists(jndiName)) {
config.createResourceRef(enabled, jndiName);
}
// return;
}
Server server = configBeansUtilities.getServerNamed(target);
if (server != null) {
if (!server.isResourceRefExists(jndiName)) {
// create new ResourceRef as a child of Server
server.createResourceRef(enabled, jndiName);
}
} else {
Cluster cluster = domain.getClusterNamed(target);
if (cluster != null) {
if (!cluster.isResourceRefExists(jndiName)) {
// create new ResourceRef as a child of Cluster
cluster.createResourceRef(enabled, jndiName);
// create new ResourceRef for all instances of Cluster
Target tgt = targetProvider.get();
List<Server> instances = tgt.getInstances(target);
for (Server svr : instances) {
if (!svr.isResourceRefExists(jndiName)) {
svr.createResourceRef(enabled, jndiName);
}
}
}
}
}
}
Aggregations