Skip to content

Commit

Permalink
[WFCORE-6728] New reload-enhanced operation allowing us to reload to …
Browse files Browse the repository at this point in the history
…a new stability level

This is not available at all stability levels, and has its own RBAC settings
  • Loading branch information
kabir committed Mar 21, 2024
1 parent 2d71776 commit 149ecb2
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 27 deletions.
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";
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 @@ -2003,7 +2003,7 @@ public void handleClose() {
// if the connection loss was triggered by an instruction to restart/reload
// then we don't disconnect yet
if(parsedCmd.getFormat() != null) {
if(Util.RELOAD.equals(parsedCmd.getOperationName())) {
if(Util.RELOAD.equals(parsedCmd.getOperationName()) || Util.RELOAD_ENHANCED.equals(parsedCmd.getOperationName())) {
// do nothing
} else if(Util.SHUTDOWN.equals(parsedCmd.getOperationName())) {
if(CommandFormat.INSTANCE.equals(parsedCmd.getFormat())
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
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 @@ -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);
}
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 @@ -15,7 +15,6 @@
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
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.SUCCESS;
import static org.jboss.as.controller.logging.ControllerLogger.MGMT_OP_LOGGER;
import static org.jboss.as.controller.logging.ControllerLogger.ROOT_LOGGER;
Expand All @@ -42,6 +41,7 @@
import org.jboss.as.controller.client.OperationMessageHandler;
import org.jboss.as.controller.client.OperationResponse;
import org.jboss.as.controller.client.impl.ModelControllerProtocol;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.controller.logging.ControllerLogger;
import org.jboss.as.controller.remote.IdentityAddressProtocolUtil.PropagatedIdentity;
import org.jboss.as.protocol.StreamUtils;
Expand Down Expand Up @@ -69,7 +69,7 @@
* @author <a href="mailto:[email protected]">Darran Lofthouse</a>
*/
public class TransactionalProtocolOperationHandler implements ManagementRequestHandlerFactory {
private static final Set<String> PREPARED_RESPONSE_OPERATIONS = Set.of(RELOAD);
private static final Set<String> PREPARED_RESPONSE_OPERATIONS = ModelDescriptionConstants.RELOAD_OPERATIONS;

private final ModelController controller;
private final ManagementChannelAssociation channelAssociation;
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,8 +78,15 @@ public synchronized void start(final StartContext context) throws StartException

//Moved to AbstractControllerService.start()
//processState.setStarting();
final Bootstrap.Configuration configuration = this.configuration;
final ServerEnvironment serverEnvironment = configuration.getServerEnvironment();
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().recalculateForReload(runningModeControl);
final ProductConfig config = serverEnvironment.getProductConfig();
final String prettyVersion = config.getPrettyVersionString();
ServerLogger.AS_ROOT_LOGGER.serverStarting(prettyVersion);
Expand Down
23 changes: 23 additions & 0 deletions server/src/main/java/org/jboss/as/server/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ public Configuration(final ServerEnvironment serverEnvironment) {
this.startTime = serverEnvironment.getStartTime();
}

private Configuration(final Configuration original, ServerEnvironment serverEnvironment) {
this.serverEnvironment = serverEnvironment;
this.runningModeControl = original.runningModeControl;
this.extensionRegistry = original.extensionRegistry;
this.capabilityRegistry = original.capabilityRegistry;
this.auditLogger = original.auditLogger;
this.authorizer = original.authorizer;
this.securityIdentitySupplier = original.securityIdentitySupplier;
this.moduleLoader = original.moduleLoader;
this.configurationPersisterFactory = original.configurationPersisterFactory;
this.startTime = original.startTime;
}

/**
* Get the server environment.
*
Expand Down Expand Up @@ -235,6 +248,16 @@ public synchronized void setConfigurationPersisterFactory(final ConfigurationPer
public long getStartTime() {
return startTime;
}

Configuration recalculateForReload(RunningModeControl runningModeControl) {
if (runningModeControl.isReloaded()) {
ServerEnvironment recalculatedServerEnvironment = serverEnvironment.recalculateForReload(runningModeControl);
if (recalculatedServerEnvironment != serverEnvironment) {
return new Configuration(this, recalculatedServerEnvironment);
}
}
return this;
}
}

/** A factory for the {@link ExtensibleConfigurationPersister} to be used by this server */
Expand Down
Loading

0 comments on commit 149ecb2

Please sign in to comment.