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-6728] Utility to reload servers started by testsuite to a desired stability level #5895

Merged
merged 10 commits into from
Mar 23, 2024
Merged
1 change: 1 addition & 0 deletions cli/src/main/java/org/jboss/as/cli/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ public class Util {
public static final String RELEASE_CODENAME = "release-codename";
public static final String RELEASE_VERSION = "release-version";
public static final String RELOAD = "reload";
public static final String RELOAD_ENHANCED = "reload-enhanced";
yersan marked this conversation as resolved.
Show resolved Hide resolved
public static final String REMOVE = "remove";
public static final String REPLY_PROPERTIES = "reply-properties";
public static final String REQUEST_PROPERTIES = "request-properties";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package org.jboss.as.controller;

import org.jboss.as.version.Stability;

/**
* Provides control over the server's current {@link RunningMode}.
*
Expand All @@ -18,6 +20,11 @@ public class RunningModeControl {
private volatile String newBootFileName;
private volatile Boolean suspend;


// Temporary experiment for the testsuite
@Deprecated
yersan marked this conversation as resolved.
Show resolved Hide resolved
private volatile Stability reloadedStability;

public RunningModeControl(final RunningMode initialMode) {
this.runningMode = initialMode;
}
Expand Down Expand Up @@ -81,4 +88,22 @@ public String getAndClearNewBootFileName() {
public void setNewBootFileName(String newBootFileName) {
this.newBootFileName = newBootFileName;
}

/**
* Gets the stability of the reloaded server.
*
* @return the stability of the reloaded server
*/
public Stability getReloadedStability() {
return reloadedStability;
}

/**
* Sets the stability of the reloaded server.
*
* @param reloadedStability the stability of the reloaded server
*/
public void setReloadedStability(Stability reloadedStability) {
this.reloadedStability = reloadedStability;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class SensitivityClassification extends AbstractSensitivity {
public static final SensitivityClassification MODULE_LOADING = new SensitivityClassification("module-loading", false, false, true);
public static final SensitivityClassification PATCHING = new SensitivityClassification("patching", false, false, true);
public static final SensitivityClassification READ_WHOLE_CONFIG = new SensitivityClassification("read-whole-config", false, true, true);
public static final SensitivityClassification RELOAD_ENHANCED = new SensitivityClassification("reload-enhanced", false, false, false);
public static final SensitivityClassification SECURITY_REALM = new SensitivityClassification("security-realm", true, true, true);
public static final SensitivityClassification SECURITY_REALM_REF = new SensitivityClassification("security-realm-ref", true, true, true);
public static final SensitivityClassification SECURITY_DOMAIN = new SensitivityClassification("security-domain", true, true, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class SensitiveTargetAccessConstraintDefinition implements AccessConstrai
public static final SensitiveTargetAccessConstraintDefinition MODULE_LOADING = new SensitiveTargetAccessConstraintDefinition(SensitivityClassification.MODULE_LOADING);
public static final SensitiveTargetAccessConstraintDefinition PATCHING = new SensitiveTargetAccessConstraintDefinition(SensitivityClassification.PATCHING);
public static final SensitiveTargetAccessConstraintDefinition READ_WHOLE_CONFIG = new SensitiveTargetAccessConstraintDefinition(SensitivityClassification.READ_WHOLE_CONFIG);
public static final SensitiveTargetAccessConstraintDefinition RELOAD_ENHANCED = new SensitiveTargetAccessConstraintDefinition(SensitivityClassification.RELOAD_ENHANCED);
public static final SensitiveTargetAccessConstraintDefinition SECURITY_DOMAIN = new SensitiveTargetAccessConstraintDefinition(SensitivityClassification.SECURITY_DOMAIN);
public static final SensitiveTargetAccessConstraintDefinition SECURITY_DOMAIN_REF = new SensitiveTargetAccessConstraintDefinition(SensitivityClassification.SECURITY_DOMAIN_REF);
public static final SensitiveTargetAccessConstraintDefinition SECURITY_REALM = new SensitiveTargetAccessConstraintDefinition(SensitivityClassification.SECURITY_REALM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
package org.jboss.as.controller.descriptions;

import java.util.Set;

/**
* String constants frequently used in model descriptions.
*
Expand Down Expand Up @@ -419,6 +421,7 @@ public class ModelDescriptionConstants {
public static final String RELEASE_CODENAME = "release-codename";
public static final String RELEASE_VERSION = "release-version";
public static final String RELOAD = "reload";
public static final String RELOAD_ENHANCED = "reload-enhanced";
public static final String RELOAD_REQUIRED = "reload-required";
public static final String REMOVE = "remove";
public static final String REMOTE = "remote";
Expand Down Expand Up @@ -614,6 +617,8 @@ public class ModelDescriptionConstants {
public static final String PRIMARY = "primary";
public static final String PERFORM_INSTALLATION = "perform-installation";

public static final Set<String> RELOAD_OPERATIONS = Set.of(RELOAD, RELOAD_ENHANCED);

private ModelDescriptionConstants() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static class Builder {
private JmxAuthorizer authorizer = NO_OP_AUTHORIZER;
private Supplier<SecurityIdentity> securityIdentitySupplier = Functions.constantSupplier(null);
private RuntimeHostControllerInfoAccessor hostControllerInfoAccessor = RuntimeHostControllerInfoAccessor.SERVER;
private Stability stability = Stability.DEFAULT;
private Supplier<Stability> stabilitySupplier = Functions.constantSupplier(Stability.DEFAULT);

private Builder(ProcessType processType) {
this.processType = processType;
Expand Down Expand Up @@ -183,12 +183,22 @@ public Builder withHostControllerInfoAccessor(RuntimeHostControllerInfoAccessor
}

/**
* Overrides the default stability level of the extension registry.
* @param stability a stability level
* Overrides the default stability level of the extension registry. This is a convenience method for
* {@link #withStabilitySupplier(Supplier)}.
* @param stability the stability level to use
* @return a reference to this builder
*/
public Builder withStability(Stability stability) {
this.stability = stability;
return withStabilitySupplier(Functions.constantSupplier(stability));
}

/**
* Overrides the default stability level of the extension registry.
* @param stabilitySupplier a Supplier returning the stability level
* @return a reference to this builder
*/
public Builder withStabilitySupplier(Supplier<Stability> stabilitySupplier) {
kabir marked this conversation as resolved.
Show resolved Hide resolved
this.stabilitySupplier = stabilitySupplier;
return this;
}

Expand All @@ -209,7 +219,7 @@ public ExtensionRegistry build() {
}

private final ProcessType processType;
private final Stability stability;
private final Supplier<Stability> stability;

private SubsystemXmlWriterRegistry writerRegistry;
private volatile PathManager pathManager;
Expand All @@ -233,7 +243,7 @@ private ExtensionRegistry(Builder builder) {
this.authorizer = builder.authorizer;
this.securityIdentitySupplier = builder.securityIdentitySupplier;
this.hostControllerInfoAccessor = builder.hostControllerInfoAccessor;
this.stability = builder.stability;
this.stability = builder.stabilitySupplier;
}

/**
Expand Down Expand Up @@ -539,7 +549,7 @@ public TransformerRegistry getTransformerRegistry() {

@Override
public Stability getStability() {
return this.stability;
return this.stability.get();
}

private abstract class AbstractExtensionParsingContext implements ExtensionParsingContext, AutoCloseable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class ProcessReloadHandler<T extends RunningModeControl> impleme
/**
* The operation name.
*/
protected static final String OPERATION_NAME = "reload";
protected static final String OPERATION_NAME = ModelDescriptionConstants.RELOAD;

protected static final AttributeDefinition ADMIN_ONLY = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.ADMIN_ONLY, ModelType.BOOLEAN, true)
.setDefaultValue(ModelNode.FALSE).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_HEADERS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELOAD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELOAD_OPERATIONS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SHUTDOWN;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;
Expand All @@ -32,6 +32,7 @@
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
Expand Down Expand Up @@ -68,7 +69,12 @@
*/
public class ModelControllerClientOperationHandler implements ManagementRequestHandlerFactory {

private static final Set<String> PREPARED_RESPONSE_OPERATIONS = Set.of(RELOAD, SHUTDOWN);
private static final Set<String> PREPARED_RESPONSE_OPERATIONS;
static {
Set<String> ops = new HashSet<>(RELOAD_OPERATIONS);
ops.add(SHUTDOWN);
PREPARED_RESPONSE_OPERATIONS = Collections.unmodifiableSet(ops);
jamezp marked this conversation as resolved.
Show resolved Hide resolved
}
private final ModelController controller;

private final ManagementChannelAssociation channelAssociation;
Expand Down Expand Up @@ -193,7 +199,7 @@ public void operationPrepared(ModelController.OperationTransaction transaction,
@Override
public void operationPrepared(ModelController.OperationTransaction transaction, final ModelNode preparedResult, OperationContext context) {
transaction.commit();
if (context == null || !RELOAD.equals(operation.get(OP).asString())) { // TODO deal with shutdown as well,
if (context == null || !RELOAD_OPERATIONS.contains(operation.get(OP).asString())) { // TODO deal with shutdown as well,
// the handlers for which have some
// subtleties that need thought
sendResponse(preparedResult);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.nio.file.Files;
import java.util.Deque;
import java.util.Iterator;
import java.util.Set;

import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
Expand All @@ -40,6 +41,7 @@
import org.jboss.as.controller.client.OperationBuilder;
import org.jboss.as.controller.client.OperationMessageHandler;
import org.jboss.as.controller.client.OperationResponse;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.core.security.AccessMechanism;
import org.jboss.dmr.ModelNode;
import org.xnio.IoUtils;
Expand All @@ -61,9 +63,12 @@ class DomainApiGenericOperationHandler implements HttpHandler {

private static final String CLIENT_NAME = "X-Management-Client-Name";

private static final Set<String> PREPARED_RESPONSE_OPERATIONS = ModelDescriptionConstants.RELOAD_OPERATIONS;

private final ModelController modelController;
private final FormParserFactory formParserFactory;


public DomainApiGenericOperationHandler(ModelController modelController) {
this.modelController = modelController;
this.formParserFactory = FormParserFactory.builder().build();
Expand Down Expand Up @@ -203,8 +208,6 @@ private static String stripSuffix(String contentType) {
return contentType;
}

static final String RELOAD = "reload";

/**
* Determine whether the prepared response should be sent, before the operation completed. This is needed in order
* that operations like :reload() can be executed without causing communication failures.
Expand All @@ -217,7 +220,7 @@ private boolean sendPreparedResponse(final ModelNode operation) {
final String op = operation.get(OP).asString();
final int size = address.size();
if (size == 0) {
if (op.equals(RELOAD)) {
if (PREPARED_RESPONSE_OPERATIONS.contains(op)) {
return true;
} else if (op.equals(COMPOSITE)) {
// TODO
Expand All @@ -227,7 +230,7 @@ private boolean sendPreparedResponse(final ModelNode operation) {
}
} else if (size == 1) {
if (address.getLastElement().getKey().equals(HOST)) {
return op.equals(RELOAD);
return PREPARED_RESPONSE_OPERATIONS.contains(op);
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
Expand Down Expand Up @@ -66,7 +67,7 @@
* @author <a href="[email protected]">Kabir Khan</a>
*/
class DomainApiHandler implements HttpHandler {

private static final Set<String> PREPARED_RESPONSE_OPERATIONS = ModelDescriptionConstants.RELOAD_OPERATIONS;
private static final String JSON_PRETTY = "json.pretty";

/**
Expand Down Expand Up @@ -309,6 +310,7 @@ private String unescape(String string) {
}
}


/**
* Determine whether the prepared response should be sent, before the operation completed. This is needed in order
* that operations like :reload() can be executed without causing communication failures.
Expand All @@ -321,7 +323,7 @@ private boolean sendPreparedResponse(final ModelNode operation) {
final String op = operation.get(OP).asString();
final int size = address.size();
if (size == 0) {
if (op.equals("reload")) {
if (PREPARED_RESPONSE_OPERATIONS.contains(op)) {
return true;
} else if (op.equals(COMPOSITE)) {
// TODO
Expand All @@ -331,7 +333,7 @@ private boolean sendPreparedResponse(final ModelNode operation) {
}
} else if (size == 1) {
if (address.getLastElement().getKey().equals(HOST)) {
return op.equals("reload");
return PREPARED_RESPONSE_OPERATIONS.contains(op);
}
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELOAD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;

import org.jboss.as.controller.ModelController;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.client.OperationResponse;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.remote.EarlyResponseSendListener;
import org.jboss.dmr.ModelNode;

Expand All @@ -29,7 +29,7 @@ final class EarlyResponseTransactionControl implements ModelController.Operation

EarlyResponseTransactionControl(ResponseCallback callback, ModelNode operation) {
this.callback = callback;
this.reload = RELOAD.equals(operation.get(OP).asString());
this.reload = ModelDescriptionConstants.RELOAD_OPERATIONS.contains(operation.get(OP).asString());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
final class ApplicationServerService implements Service<AsyncFuture<ServiceContainer>> {

private final List<ServiceActivator> extraServices;
private final Bootstrap.Configuration configuration;
private volatile Bootstrap.Configuration configuration;
private final RunningModeControl runningModeControl;
private final ControlledProcessState processState;
private final SuspendController suspendController;
Expand All @@ -78,7 +78,14 @@ public synchronized void start(final StartContext context) throws StartException

//Moved to AbstractControllerService.start()
//processState.setStarting();
final Bootstrap.Configuration configuration = this.configuration;
final Bootstrap.Configuration configuration;
Bootstrap.Configuration recalculatedConfiguration = this.configuration.recalculateForReload(runningModeControl);
if (recalculatedConfiguration != this.configuration) {
this.configuration = recalculatedConfiguration;
configuration = recalculatedConfiguration;
} else {
configuration = this.configuration;
}
final ServerEnvironment serverEnvironment = configuration.getServerEnvironment();
final ProductConfig config = serverEnvironment.getProductConfig();
final String prettyVersion = config.getPrettyVersionString();
Expand Down
Loading