-
Notifications
You must be signed in to change notification settings - Fork 465
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-6815][Community] Added reload-enhanced operation to reload a domain to a certain stability #5992
Merged
Merged
[WFCORE-6815][Community] Added reload-enhanced operation to reload a domain to a certain stability #5992
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
243c63e
[WFCORE-6815] Add reload-enhanced operation to Host Controllers
yersan f0774e0
[WFCORE-6815] Tests cases to verify the stability after reloading the…
yersan b825731
[WFCORE-6815] Move Domain Mode stability test case outside of the Dom…
yersan 30e96b4
[WFCORE-6815] Verify the domain reloaded to the original stability wh…
yersan c1859c9
[WFCORE-6815] Fix conflicts introduced by reload parameters usage
yersan 172c712
[WFCORE-6815] Remove restart-servers attribute from reload-enhanced m…
yersan 59589cb
[WFCORE-6815] Fix checkstyle errors
yersan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
import org.jboss.as.controller.SimpleAttributeDefinitionBuilder; | ||
import org.jboss.as.controller.SimpleOperationDefinition; | ||
import org.jboss.as.controller.SimpleOperationDefinitionBuilder; | ||
import org.jboss.as.controller.access.management.SensitiveTargetAccessConstraintDefinition; | ||
import org.jboss.as.controller.descriptions.DefaultOperationDescriptionProvider; | ||
import org.jboss.as.controller.descriptions.DescriptionProvider; | ||
import org.jboss.as.controller.descriptions.ModelDescriptionConstants; | ||
|
@@ -24,10 +25,12 @@ | |
import org.jboss.as.controller.registry.OperationEntry; | ||
import org.jboss.as.domain.controller.LocalHostControllerInfo; | ||
import org.jboss.as.host.controller.HostControllerEnvironment; | ||
import org.jboss.as.host.controller.HostEnvironmentAwareProcessReloadHandler; | ||
import org.jboss.as.host.controller.HostModelUtil; | ||
import org.jboss.as.host.controller.HostRunningModeControl; | ||
import org.jboss.as.host.controller.RestartMode; | ||
import org.jboss.as.host.controller.logging.HostControllerLogger; | ||
import org.jboss.as.version.Stability; | ||
import org.jboss.dmr.ModelNode; | ||
import org.jboss.dmr.ModelType; | ||
import org.jboss.msc.service.ServiceName; | ||
|
@@ -36,10 +39,10 @@ | |
* | ||
* @author <a href="[email protected]">Kabir Khan</a> | ||
*/ | ||
public class HostProcessReloadHandler extends ProcessReloadHandler<HostRunningModeControl>{ | ||
public class HostProcessReloadHandler extends HostEnvironmentAwareProcessReloadHandler { | ||
|
||
private static final AttributeDefinition RESTART_SERVERS = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.RESTART_SERVERS, ModelType.BOOLEAN, true) | ||
.setDefaultValue(ModelNode.TRUE).build(); | ||
.setDefaultValue(ModelNode.TRUE).build(); | ||
|
||
private static final AttributeDefinition USE_CURRENT_DOMAIN_CONFIG = new SimpleAttributeDefinitionBuilder(ModelDescriptionConstants.USE_CURRENT_DOMAIN_CONFIG, ModelType.BOOLEAN, true) | ||
.setAlternatives(ModelDescriptionConstants.DOMAIN_CONFIG) | ||
|
@@ -60,27 +63,40 @@ public class HostProcessReloadHandler extends ProcessReloadHandler<HostRunningMo | |
.build(); | ||
|
||
|
||
private static final AttributeDefinition[] MASTER_ATTRIBUTES = new AttributeDefinition[] {ADMIN_ONLY, RESTART_SERVERS, USE_CURRENT_DOMAIN_CONFIG, USE_CURRENT_HOST_CONFIG, DOMAIN_CONFIG, HOST_CONFIG}; | ||
private static final AttributeDefinition[] PRIMARY_HC_ATTRIBUTES = new AttributeDefinition[] {ADMIN_ONLY, RESTART_SERVERS, USE_CURRENT_DOMAIN_CONFIG, USE_CURRENT_HOST_CONFIG, DOMAIN_CONFIG, HOST_CONFIG}; | ||
|
||
private static final AttributeDefinition[] SLAVE_ATTRIBUTES = new AttributeDefinition[] {ADMIN_ONLY, RESTART_SERVERS, USE_CURRENT_HOST_CONFIG, HOST_CONFIG}; | ||
private static final AttributeDefinition[] SECONDARY_HC_ATTRIBUTES = new AttributeDefinition[] {ADMIN_ONLY, RESTART_SERVERS, USE_CURRENT_HOST_CONFIG, HOST_CONFIG}; | ||
|
||
private static final AttributeDefinition[] ENHANCED_PRIMARY_HC_ATTRIBUTES = new AttributeDefinition[] {ADMIN_ONLY, USE_CURRENT_DOMAIN_CONFIG, USE_CURRENT_HOST_CONFIG, DOMAIN_CONFIG, HOST_CONFIG, STABILITY}; | ||
|
||
private static final AttributeDefinition[] ENHANCED_SECONDARY_HC_ATTRIBUTES = new AttributeDefinition[] {ADMIN_ONLY, USE_CURRENT_HOST_CONFIG, HOST_CONFIG, STABILITY}; | ||
|
||
private final HostControllerEnvironment environment; | ||
private final LocalHostControllerInfo hostControllerInfo; | ||
private final ProcessType processType; | ||
|
||
public static OperationDefinition getDefinition(final LocalHostControllerInfo hostControllerInfo) { | ||
return new DeferredParametersOperationDefinitionBuilder(hostControllerInfo, OPERATION_NAME, HostModelUtil.getResourceDescriptionResolver()) | ||
.setParameters(hostControllerInfo.isMasterDomainController() ? MASTER_ATTRIBUTES : SLAVE_ATTRIBUTES) | ||
.withFlag(OperationEntry.Flag.HOST_CONTROLLER_ONLY) | ||
.setRuntimeOnly() | ||
.build(); | ||
.setParameters(hostControllerInfo.isMasterDomainController() ? PRIMARY_HC_ATTRIBUTES : SECONDARY_HC_ATTRIBUTES) | ||
.withFlag(OperationEntry.Flag.HOST_CONTROLLER_ONLY) | ||
.setRuntimeOnly() | ||
.build(); | ||
} | ||
|
||
public static OperationDefinition getEnhancedDefinition(final LocalHostControllerInfo hostControllerInfo) { | ||
return new DeferredParametersOperationDefinitionBuilder(hostControllerInfo, ENHANCED_OPERATION_NAME, HostModelUtil.getResourceDescriptionResolver(), ENHANCED_PRIMARY_HC_ATTRIBUTES, ENHANCED_SECONDARY_HC_ATTRIBUTES, Stability.COMMUNITY) | ||
.setStability(Stability.COMMUNITY) | ||
.setAccessConstraints(SensitiveTargetAccessConstraintDefinition.RELOAD_ENHANCED) | ||
.setParameters(hostControllerInfo.isMasterDomainController() ? ENHANCED_PRIMARY_HC_ATTRIBUTES : ENHANCED_SECONDARY_HC_ATTRIBUTES) | ||
.withFlag(OperationEntry.Flag.HOST_CONTROLLER_ONLY) | ||
.setRuntimeOnly() | ||
.build(); | ||
} | ||
|
||
public HostProcessReloadHandler(final ServiceName rootService, final HostRunningModeControl runningModeControl, | ||
final ControlledProcessState processState, final HostControllerEnvironment environment, | ||
final LocalHostControllerInfo hostControllerInfo) { | ||
super(rootService, runningModeControl, processState); | ||
super(rootService, runningModeControl, processState, environment); | ||
this.processType = environment.getProcessType(); | ||
this.environment = environment; | ||
this.hostControllerInfo = hostControllerInfo; | ||
|
@@ -102,6 +118,14 @@ public void execute(OperationContext context, ModelNode operation) throws Operat | |
|
||
@Override | ||
protected ProcessReloadHandler.ReloadContext<HostRunningModeControl> initializeReloadContext(final OperationContext context, final ModelNode operation) throws OperationFailedException { | ||
final Stability stability; | ||
if (operation.hasDefined(STABILITY.getName())) { | ||
String val = STABILITY.resolveModelAttribute(context, operation).asString(); | ||
stability = Stability.fromString(val); | ||
environment.checkStabilityIsValidForInstallation(stability); | ||
} else { | ||
stability = null; | ||
} | ||
final boolean adminOnly = ADMIN_ONLY.resolveModelAttribute(context, operation).asBoolean(false); | ||
final boolean restartServers = RESTART_SERVERS.resolveModelAttribute(context, operation).asBoolean(true); | ||
final boolean useCurrentHostConfig = USE_CURRENT_HOST_CONFIG.resolveModelAttribute(context, operation).asBoolean(true); | ||
|
@@ -124,7 +148,7 @@ protected ProcessReloadHandler.ReloadContext<HostRunningModeControl> initializeR | |
throw HostControllerLogger.ROOT_LOGGER.domainConfigForReloadNotFound(hostConfig); | ||
} | ||
|
||
return new ReloadContext<HostRunningModeControl>() { | ||
return new ReloadContext<>() { | ||
|
||
@Override | ||
public void reloadInitiated(HostRunningModeControl runningModeControl) { | ||
|
@@ -140,24 +164,42 @@ public void doReload(HostRunningModeControl runningModeControl) { | |
runningModeControl.setNewDomainBootFileName(domainConfig); | ||
runningModeControl.setNewBootFileName(hostConfig); | ||
runningModeControl.setReloadHostName(hostName); | ||
if (stability != null) { | ||
updateHostEnvironmentStability(stability); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* The host controller info does not know if it is master or not until later in the bootup process | ||
* The host controller info does not know if it is master or not until later in the booting process | ||
*/ | ||
private static class DeferredParametersOperationDefinitionBuilder extends SimpleOperationDefinitionBuilder { | ||
private final LocalHostControllerInfo hostControllerInfo; | ||
private final AttributeDefinition[] primaryHcAttr; | ||
private final AttributeDefinition[] secondaryHcAttr; | ||
private final Stability stability; | ||
|
||
public DeferredParametersOperationDefinitionBuilder(LocalHostControllerInfo hostControllerInfo, String name, ResourceDescriptionResolver resolver) { | ||
super(name, resolver); | ||
this.hostControllerInfo = hostControllerInfo; | ||
this.primaryHcAttr = PRIMARY_HC_ATTRIBUTES; | ||
this.secondaryHcAttr = SECONDARY_HC_ATTRIBUTES; | ||
this.stability = Stability.DEFAULT; | ||
} | ||
|
||
public DeferredParametersOperationDefinitionBuilder(LocalHostControllerInfo hostControllerInfo, String name, ResourceDescriptionResolver resolver, AttributeDefinition[] primaryHcAttr, AttributeDefinition[] secondaryHcAttr, Stability stability) { | ||
super(name, resolver); | ||
this.hostControllerInfo = hostControllerInfo; | ||
this.primaryHcAttr = primaryHcAttr; | ||
this.secondaryHcAttr = secondaryHcAttr; | ||
this.stability = stability; | ||
} | ||
|
||
@Override | ||
public SimpleOperationDefinition internalBuild(final ResourceDescriptionResolver resolver, final ResourceDescriptionResolver attributeResolver) { | ||
return new SimpleOperationDefinition(new SimpleOperationDefinitionBuilder(name, resolver) | ||
.setStability(stability) | ||
.setAttributeResolver(attributeResolver) | ||
.setParameters(parameters) | ||
.withFlags(flags)) { | ||
|
@@ -166,8 +208,8 @@ public DescriptionProvider getDescriptionProvider() { | |
return new DescriptionProvider() { | ||
@Override | ||
public ModelNode getModelDescription(Locale locale) { | ||
AttributeDefinition[] params = hostControllerInfo.isMasterDomainController() ? MASTER_ATTRIBUTES : SLAVE_ATTRIBUTES; | ||
return new DefaultOperationDescriptionProvider(getName(), resolver, attributeResolver, replyType, replyValueType, replyAllowNull, deprecationData, replyParameters, params, accessConstraints).getModelDescription(locale); | ||
AttributeDefinition[] params = hostControllerInfo.isMasterDomainController() ? primaryHcAttr : secondaryHcAttr; | ||
return new DefaultOperationDescriptionProvider(getName(), resolver, attributeResolver, replyType, replyValueType, replyAllowNull, deprecationData, replyParameters, params, accessConstraints, stability).getModelDescription(locale); | ||
} | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really important, but I think it would be clearer if both the calls to this constructor had the same format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing @kabir
What do you mean about having the same format?
I understand that what you suggested is to remove the overloaded DeferredParametersOperationDefinitionBuilder constructor, so both
getEnhancedDefinition
andgetDefinition
use the same number of arguments to improve the code readability and make it more clear, correct?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far, just updated it to assert that closing the snapshot indeed reloaded the host controller to the original stability level