Skip to content

Commit

Permalink
[WFCORE-6728] Change stability in ExtensionRegistry when reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
kabir committed Mar 21, 2024
1 parent 149ecb2 commit 6c9e814
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -117,7 +118,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 AtomicReference<Stability> stabilityReference = new AtomicReference<>(Stability.DEFAULT);

private Builder(ProcessType processType) {
this.processType = processType;
Expand Down Expand Up @@ -183,12 +184,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 #withStabilityReference(AtomicReference)}.
* @param stability the stability level to use
* @return a reference to this builder
*/
public Builder withStability(Stability stability) {
this.stability = stability;
return withStabilityReference(new AtomicReference<>(stability));
}

/**
* Overrides the default stability level of the extension registry.
* @param stabilityReference an AtomicReference containing the stability level
* @return a reference to this builder
*/
public Builder withStabilityReference(AtomicReference<Stability> stabilityReference) {
this.stabilityReference = stabilityReference;
return this;
}

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

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

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

/**
Expand Down Expand Up @@ -539,7 +550,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 @@ -86,7 +86,7 @@ public synchronized void start(final StartContext context) throws StartException
} else {
configuration = this.configuration;
}
final ServerEnvironment serverEnvironment = configuration.getServerEnvironment().recalculateForReload(runningModeControl);
final ServerEnvironment serverEnvironment = configuration.getServerEnvironment();
final ProductConfig config = serverEnvironment.getProductConfig();
final String prettyVersion = config.getPrettyVersionString();
ServerLogger.AS_ROOT_LOGGER.serverStarting(prettyVersion);
Expand Down
15 changes: 13 additions & 2 deletions server/src/main/java/org/jboss/as/server/Bootstrap.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicReference;

import javax.xml.namespace.QName;

Expand All @@ -23,6 +24,7 @@
import org.jboss.as.server.controller.git.GitConfigurationPersister;
import org.jboss.as.controller.persistence.XmlConfigurationPersister;
import org.jboss.as.server.parsing.StandaloneXml;
import org.jboss.as.version.Stability;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleLoader;
import org.jboss.msc.service.ServiceActivator;
Expand Down Expand Up @@ -78,6 +80,8 @@ final class Configuration {
private final ManagedAuditLogger auditLogger;
private final DelegatingConfigurableAuthorizer authorizer;
private final ManagementSecurityIdentitySupplier securityIdentitySupplier;

private final AtomicReference<Stability> stabilityReference;
private ModuleLoader moduleLoader = Module.getBootModuleLoader();
private ConfigurationPersisterFactory configurationPersisterFactory;
private long startTime;
Expand All @@ -89,9 +93,10 @@ public Configuration(final ServerEnvironment serverEnvironment) {
this.auditLogger = serverEnvironment.createAuditLogger();
this.authorizer = new DelegatingConfigurableAuthorizer();
this.securityIdentitySupplier = new ManagementSecurityIdentitySupplier();
this.stabilityReference = new AtomicReference<>(serverEnvironment.getStability());
this.extensionRegistry = ExtensionRegistry.builder(serverEnvironment.getLaunchType().getProcessType())
.withRunningModeControl(this.runningModeControl)
.withStability(serverEnvironment.getStability())
.withStabilityReference(this.stabilityReference)
.withAuditLogger(this.auditLogger)
.withAuthorizer(this.authorizer)
.withSecurityIdentitySupplier(this.securityIdentitySupplier)
Expand All @@ -101,13 +106,19 @@ public Configuration(final ServerEnvironment serverEnvironment) {
}

private Configuration(final Configuration original, ServerEnvironment serverEnvironment) {
// Updating the server environment here, will update the value
this.serverEnvironment = serverEnvironment;
this.runningModeControl = original.runningModeControl;
this.extensionRegistry = original.extensionRegistry;
this.runningModeControl = original.runningModeControl;
this.capabilityRegistry = original.capabilityRegistry;
this.auditLogger = original.auditLogger;
this.authorizer = original.authorizer;
this.securityIdentitySupplier = original.securityIdentitySupplier;

// The extension registry caches the stability supplier so update its value here
this.stabilityReference = original.stabilityReference;
this.stabilityReference.set(this.serverEnvironment.getStability());

this.moduleLoader = original.moduleLoader;
this.configurationPersisterFactory = original.configurationPersisterFactory;
this.startTime = original.startTime;
Expand Down

0 comments on commit 6c9e814

Please sign in to comment.