Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFCORE-6731] Expose supported stability levels via the management API #5917

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
21 changes: 15 additions & 6 deletions server/src/main/java/org/jboss/as/server/ServerEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,16 @@ public ServerEnvironment(final String hostControllerName, final Properties props
final boolean startGracefully, final String gitRepository, final String gitBranch, final String gitAuthConfiguration,
final String supplementalConfiguration) {
assert props != null;
assert productConfig != null;
ConfigurationFile.InteractionPolicy configInteractionPolicy = configurationInteractionPolicy;
this.startSuspended = startSuspended;
this.startGracefully = startGracefully;

this.launchType = launchType;
this.standalone = launchType != LaunchType.DOMAIN;

this.productConfig = productConfig;

this.initialRunningMode = initialRunningMode == null ? RunningMode.NORMAL : initialRunningMode;
this.runningModeControl = new RunningModeControl(this.initialRunningMode);
this.startTime = startTime;
Expand Down Expand Up @@ -366,7 +369,7 @@ public ServerEnvironment(final String hostControllerName, final Properties props
domainBaseDir = null;
domainConfigurationDir = null;
repository = null;
this.stability = productConfig.getDefaultStability();
this.stability = this.productConfig.getDefaultStability();
WildFlySecurityManager.setPropertyPrivileged(ServerEnvironment.JBOSS_PERSIST_SERVER_CONFIG, "false");
} else {

Expand Down Expand Up @@ -523,11 +526,13 @@ public ServerEnvironment(final String hostControllerName, final Properties props
}

this.stability = getEnumProperty(props, ProcessEnvironment.STABILITY, productConfig.getDefaultStability());
checkStabilityIsValidForInstallation(productConfig, this.stability);
if (!productConfig.getStabilitySet().contains(this.stability)) {
throw ServerLogger.ROOT_LOGGER.unsupportedStability(this.stability, productConfig.getProductName());
}
}
boolean allowExecutor = true;
String maxThreads = WildFlySecurityManager.getPropertyPrivileged(BOOTSTRAP_MAX_THREADS, null);
if (maxThreads != null && maxThreads.length() > 0) {
if (maxThreads != null && !maxThreads.isEmpty()) {
try {
//noinspection ResultOfMethodCallIgnored
Integer.decode(maxThreads);
Expand All @@ -547,7 +552,6 @@ public ServerEnvironment(final String hostControllerName, final Properties props
throw ServerLogger.ROOT_LOGGER.couldNotObtainServerUuidFile(ex, filePath);
}
this.serverUUID = uuid;
this.productConfig = productConfig;

// Keep a copy of the original properties
this.primordialProperties = new Properties();
Expand Down Expand Up @@ -675,7 +679,7 @@ private Path[] findSupplementalConfigurationFiles(final Path serverConfiguration
if (error) {
throw ServerLogger.ROOT_LOGGER.unableToFindYaml(joiner.toString());
}
return yamlPaths.toArray(new Path[yamlPaths.size()]);
return yamlPaths.toArray(new Path[0]);
}

void resetProvidedProperties() {
Expand Down Expand Up @@ -1015,6 +1019,11 @@ public Stability getStability() {
return this.stability;
}

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

/**
* Gets whether this server is an independently managed server, not managed as part of a managed domain.
*
Expand Down Expand Up @@ -1104,7 +1113,7 @@ public static int getBootstrapMaxThreads() {
int cpuCount = ProcessorInfo.availableProcessors();
int defaultThreads = cpuCount * 2;
String maxThreads = WildFlySecurityManager.getPropertyPrivileged(BOOTSTRAP_MAX_THREADS, null);
if (maxThreads != null && maxThreads.length() > 0) {
if (maxThreads != null && !maxThreads.isEmpty()) {
try {
int max = Integer.decode(maxThreads);
defaultThreads = Math.max(max, 1);
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 @@ -17,6 +17,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 @@ -98,7 +99,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 void getBannerFile(Module module) throws IOException {
Expand Down