Skip to content

Commit

Permalink
[WFCORE-6731] Expose supported stability levels via the management API
Browse files Browse the repository at this point in the history
  • Loading branch information
yersan committed Mar 20, 2024
1 parent 2d71776 commit 40e92fa
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.nio.file.StandardOpenOption;
import java.util.Collections;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Stream;

Expand All @@ -30,6 +31,7 @@
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.interfaces.InetAddressUtil;
import org.jboss.as.controller.logging.ControllerLogger;
import org.jboss.as.version.Stability;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;

Expand All @@ -54,6 +56,13 @@ public abstract class ProcessEnvironment implements FeatureRegistry {

public static final String STABILITY = "jboss.stability";

/**
* Returns an unmodifiable set of all the permissible stability levels.
*
* @return a set of stability levels
*/
public abstract Set<Stability> getStabilities();

/**
* Gets an {@link OperationStepHandler} that can read the {@code name} attribute for a processes root resource
* @return the handler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.EnumSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.UUID;

import org.jboss.as.controller.OperationContext;
Expand Down Expand Up @@ -234,6 +235,7 @@ public class HostControllerEnvironment extends ProcessEnvironment {

private final RunningMode initialRunningMode;
private final Stability stability;
private final Set<Stability> stabilities;
private final ProductConfig productConfig;
private final String qualifiedHostName;
private final String hostName;
Expand Down Expand Up @@ -485,6 +487,7 @@ public HostControllerEnvironment(Map<String, String> hostSystemProperties, boole
this.processType = processType;

this.stability = getEnumProperty(hostSystemProperties, STABILITY, this.productConfig.getDefaultStability());
this.stabilities = productConfig.getStabilitySet();
if (!this.productConfig.getStabilitySet().contains(this.stability)) {
throw HostControllerLogger.ROOT_LOGGER.unsupportedStability(this.stability, this.productConfig.getProductName());
}
Expand Down Expand Up @@ -808,6 +811,11 @@ public Stability getStability() {
return this.stability;
}

@Override
public Set<Stability> getStabilities() {
return this.stabilities;
}

@Override
protected boolean isRuntimeSystemPropertyUpdateAllowed(String propertyName, String propertyValue, boolean bootTime) {
// Currently any system-property in host.xml should not be applied to the HC runtime. This method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleListAttributeDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.access.management.AccessConstraintDefinition;
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition;
import org.jboss.as.controller.persistence.ConfigurationFile;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.services.path.PathInfoHandler;
import org.jboss.as.host.controller.HostControllerEnvironment;
import org.jboss.as.version.Stability;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;

Expand Down Expand Up @@ -63,6 +65,11 @@ public class HostEnvironmentResourceDefinition extends SimpleResourceDefinition
private static final AttributeDefinition INITIAL_RUNNING_MODE = createAttributeDefinition("initial-running-mode");
private static final AttributeDefinition QUALIFIED_HOST_NAME = createAttributeDefinition("qualified-host-name");
private static final AttributeDefinition HOST_NAME = createAttributeDefinition("host-name");
private static final AttributeDefinition STABILITY = createAttributeDefinition("stability");
private static final AttributeDefinition PERMISSIBLE_STABILITY_LEVELS = new SimpleListAttributeDefinition.Builder("permissible-stability-levels", STABILITY)
.setStorageRuntime()
.setRuntimeServiceNotRequired()
.build();

private static final AttributeDefinition[] HOST_ENV_ATTRIBUTES = {
PROCESS_CONTROLLER_ADDRESS,
Expand All @@ -86,7 +93,9 @@ public class HostEnvironmentResourceDefinition extends SimpleResourceDefinition
USE_CACHED_DC,
INITIAL_RUNNING_MODE,
QUALIFIED_HOST_NAME,
HOST_NAME
HOST_NAME,
STABILITY,
PERMISSIBLE_STABILITY_LEVELS
};

private final HostEnvironmentReadHandler osh;
Expand Down Expand Up @@ -217,6 +226,12 @@ public void execute(final OperationContext context, final ModelNode operation) t
set(result, environment.getQualifiedHostName());
} else if (equals(name, HOST_NAME)) {
set(result, environment.getHostName());
} else if (equals(name, STABILITY)) {
result.set(environment.getStability().toString());
} else if (equals(name, PERMISSIBLE_STABILITY_LEVELS)) {
for (Stability s : environment.getStabilities()) {
result.add(s.toString());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ host.env.use-cached-dc=Whether this host controller should use cached domain con
host.env.initial-running-mode=The initial running mode of the host, when the Host Controller process was launched. Either NORMAL or ADMIN_ONLY. An ADMIN_ONLY server will start any configured management interfaces and accept management requests, but will not start services used for handling end user requests.
host.env.qualified-host-name=The fully qualified host name detected at startup.
host.env.host-name=The local host name detected at server startup.
host.env.stability=The stability level of the host controller.
host.env.permissible-stability-levels=A list of all the stability levels supported by this host controller.


host.reload=Reloads the Host Controller by shutting down all its services and starting again. The JVM itself is not restarted. Note however that this will lead to a full process restart for any server processes managed by this host controller.
Expand Down
10 changes: 9 additions & 1 deletion server/src/main/java/org/jboss/as/server/ServerEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public ProcessType getProcessType() {
private final boolean startGracefully;
private final GitRepository repository;
private final Stability stability;
private final Set<Stability> stabilities;

public ServerEnvironment(final String hostControllerName, final Properties props, final Map<String, String> env, final String serverConfig,
final ConfigurationFile.InteractionPolicy configInteractionPolicy, final LaunchType launchType,
Expand Down Expand Up @@ -367,6 +368,7 @@ public ServerEnvironment(final String hostControllerName, final Properties props
domainConfigurationDir = null;
repository = null;
this.stability = productConfig.getDefaultStability();
this.stabilities = productConfig.getStabilitySet();
WildFlySecurityManager.setPropertyPrivileged(ServerEnvironment.JBOSS_PERSIST_SERVER_CONFIG, "false");
} else {

Expand Down Expand Up @@ -523,7 +525,8 @@ public ServerEnvironment(final String hostControllerName, final Properties props
}

this.stability = getEnumProperty(props, ProcessEnvironment.STABILITY, productConfig.getDefaultStability());
if (!productConfig.getStabilitySet().contains(this.stability)) {
this.stabilities = productConfig.getStabilitySet();
if (!stabilities.contains(this.stability)) {
throw ServerLogger.ROOT_LOGGER.unsupportedStability(this.stability, productConfig.getProductName());
}
}
Expand Down Expand Up @@ -1017,6 +1020,11 @@ public Stability getStability() {
return this.stability;
}

@Override
public Set<Stability> getStabilities() {
return this.stabilities;
}

/**
* Gets whether this server is an independently managed server, not managed as part of a managed domain.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
import org.jboss.as.controller.OperationStepHandler;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
import org.jboss.as.controller.SimpleListAttributeDefinition;
import org.jboss.as.controller.SimpleResourceDefinition;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.persistence.ConfigurationFile;
import org.jboss.as.controller.registry.AttributeAccess;
import org.jboss.as.controller.registry.ManagementResourceRegistration;
import org.jboss.as.controller.services.path.PathInfoHandler;
import org.jboss.as.server.controller.descriptions.ServerDescriptions;
import org.jboss.as.version.Stability;
import org.jboss.dmr.ModelNode;
import org.jboss.dmr.ModelType;

Expand Down Expand Up @@ -55,10 +57,13 @@ public class ServerEnvironmentResourceDescription extends SimpleResourceDefiniti
public static final AttributeDefinition START_SUSPENDED = SimpleAttributeDefinitionBuilder.create("start-suspended", ModelType.BOOLEAN).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
public static final AttributeDefinition GRACEFUL_STARTUP = SimpleAttributeDefinitionBuilder.create("start-gracefully", ModelType.BOOLEAN).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
static final AttributeDefinition STABILITY = SimpleAttributeDefinitionBuilder.create("stability", ModelType.STRING).setFlags(AttributeAccess.Flag.STORAGE_RUNTIME).build();
static final AttributeDefinition PERMISSIBLE_STABILITY_LEVELS = new SimpleListAttributeDefinition.Builder("permissible-stability-levels", STABILITY)
.setFlags(AttributeAccess.Flag.STORAGE_RUNTIME)
.build();

private static final AttributeDefinition[] SERVER_ENV_ATTRIBUTES = { BASE_DIR, CONFIG_DIR, CONFIG_FILE, CONTENT_DIR, DATA_DIR,
DEPLOY_DIR, EXT_DIRS, HOME_DIR, HOST_NAME, INITIAL_RUNNING_MODE, LAUNCH_TYPE, LOG_DIR, NODE_NAME,
QUALIFIED_HOST_NAME, SERVER_NAME, TEMP_DIR, START_SUSPENDED, GRACEFUL_STARTUP, STABILITY };
QUALIFIED_HOST_NAME, SERVER_NAME, TEMP_DIR, START_SUSPENDED, GRACEFUL_STARTUP, STABILITY, PERMISSIBLE_STABILITY_LEVELS };

private final ServerEnvironmentReadHandler osh;

Expand Down Expand Up @@ -175,6 +180,10 @@ public void execute(final OperationContext context, final ModelNode operation) t
result.set(environment.isStartGracefully());
} else if (equals(name, STABILITY)) {
result.set(environment.getStability().toString());
} else if (equals(name, PERMISSIBLE_STABILITY_LEVELS)) {
for (Stability s : environment.getStabilities()) {
result.add(s.toString());
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ server.suspend-state=The suspend state of the server
server.env.start-suspended=Start the server suspended.
server.env.start-gracefully=Start the server gracefully.
server.env.stability=The stability level of the server.
server.env.permissible-stability-levels=A list of all the stability levels supported by this server.

# Lifecycle operations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.nio.file.Paths;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -94,7 +95,7 @@ private ProductConfig(ModuleLoader loader, ProductConfProps productConfProps, Ma
version = productVersion;
this.consoleSlot = consoleSlot;
this.defaultStability = defaultStability;
this.stabilities = EnumSet.range(maxStability, minStability);
this.stabilities = Collections.unmodifiableSet(EnumSet.range(maxStability, minStability));
}

private static String getProductConf(String home) {
Expand Down

0 comments on commit 40e92fa

Please sign in to comment.