Skip to content

Commit

Permalink
Merge pull request #6225 from ehsavoie/WFCORE-7035
Browse files Browse the repository at this point in the history
[WFCORE-7035]: YAML extension doesn't support ParallelBoot.
  • Loading branch information
bstansberry authored Dec 13, 2024
2 parents 288c84d + 2e11a98 commit 9ca5454
Show file tree
Hide file tree
Showing 24 changed files with 945 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,10 @@ final boolean isRollingBack() {
@Override
public final void reloadRequired() {
if (processState.isReloadSupported()) {
if(isBooting()) {
MGMT_OP_LOGGER.debug("Server is booting so we didn't set the reload required flag");
return;
}
activeStep.setRestartStamp(processState.setReloadRequired());
activeStep.response.get(RESPONSE_HEADERS, OPERATION_REQUIRES_RELOAD).set(true);
getManagementModel().getCapabilityRegistry().capabilityReloadRequired(activeStep.address,
Expand All @@ -1237,6 +1241,9 @@ public final void reloadRequired() {

@Override
public final void restartRequired() {
if (isBooting()) {
return;
}
activeStep.setRestartStamp(processState.setRestartRequired());
activeStep.response.get(RESPONSE_HEADERS, OPERATION_REQUIRES_RESTART).set(true);
getManagementModel().getCapabilityRegistry().capabilityRestartRequired(activeStep.address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,7 @@ boolean boot(final List<ModelNode> bootList, final OperationMessageHandler handl
// stop
break;
} else {
if(parsedOp.handler instanceof ParallelBootOperationStepHandler &&
((ParallelBootOperationStepHandler)parsedOp.handler).getParsedBootOp().getChildOperations().size() != parsedOp.getChildOperations().size()) {
if(parsedOp.isBootHandlerUpdateNeeded()) {
ParallelBootOperationStepHandler updatedHandler = new ParallelBootOperationStepHandler(executorService, managementModel.get().getRootResourceRegistration(), processState, this, operationID, extraValidationStepHandler);
for(ModelNode childOp : parsedOp.getChildOperations()) {
updatedHandler.addSubsystemOperation(new ParsedBootOp(childOp));
Expand Down
13 changes: 13 additions & 0 deletions controller/src/main/java/org/jboss/as/controller/ParsedBootOp.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ParsedBootOp {
public final OperationStepHandler handler;
public final ModelNode response;
private List<ModelNode> childOperations;
private boolean bootHandlerUpdateNeeded = false;

ParsedBootOp(final ModelNode operation) {
this(operation, null, new ModelNode());
Expand Down Expand Up @@ -84,6 +85,18 @@ public PathAddress getAddress() {
return address;
}

public boolean isBootHandlerUpdateNeeded() {
return this.handler instanceof ParallelBootOperationStepHandler && bootHandlerUpdateNeeded;
}

/**
* Setting this will force the ParallelBootOperationStepHandler handdler to be updated on boot.
*/
public void bootHandlerUpdateNeeded() {
this.bootHandlerUpdateNeeded = true;
}


@Override
public String toString() {
return "ParsedBootOp{" + "operation=" + operation + ", operationName=" + operationName + ", address=" + address + ", handler=" + handler + ", response=" + response + ", childOperations=" + childOperations + '}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3805,4 +3805,8 @@ OperationFailedRuntimeException capabilityAlreadyRegisteredInContext(String capa

@Message(id = 516, value = "Parameter %s specifies an invalid module name: %s")
OperationFailedException invalidModuleNameParameter(String parameterName, String moduleName);

@LogMessage(level = WARN)
@Message(id = 517, value = "There are multiple Parallel Boot Operations.")
void multipleParallelBootOperation();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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.REMOVE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.URL;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
Expand Down Expand Up @@ -45,6 +46,7 @@
import org.jboss.as.controller.MapAttributeDefinition;
import org.jboss.as.controller.ObjectMapAttributeDefinition;
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
import org.jboss.as.controller.ParallelBootOperationStepHandler;
import org.jboss.as.controller.ParsedBootOp;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.RunningMode;
Expand Down Expand Up @@ -160,11 +162,20 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist
}
MGMT_OP_LOGGER.debug("We are applying YAML files to the configuration");
Map<PathAddress, ParsedBootOp> xmlOperations = new HashMap<>();
boolean paralleBoot = false;
for (ParsedBootOp op : postExtensionOps) {
if (op.getChildOperations().isEmpty()) {
List<ModelNode> childOperations = op.getChildOperations();
if (childOperations.isEmpty()) {
xmlOperations.put(op.getAddress(), op);
} else {
for (ModelNode childOp : op.getChildOperations()) {
if (op.handler instanceof ParallelBootOperationStepHandler) {
if (!paralleBoot) {
paralleBoot = true;
} else {
MGMT_OP_LOGGER.multipleParallelBootOperation();
}
}
for (ModelNode childOp : childOperations) {
ParsedBootOp subOp = new ParsedBootOp(childOp, null);
xmlOperations.put(subOp.getAddress(), subOp);
}
Expand All @@ -176,10 +187,44 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist
for (Map.Entry<String, Object> deployment : deployments.entrySet()) {
processUnmanagedDeployments(rootRegistration, deployment, xmlOperations, postExtensionOps);
}
List<ParsedBootOp> reorderedList = new ArrayList<>(postExtensionOps.size());
//We need to find the parallel boot operation becaue it might have changed due to deletion of resource so we can't use the initial one.
ParsedBootOp parallelBootOp = null;
if (paralleBoot) {
for (ParsedBootOp op : postExtensionOps) {
if (op.handler instanceof ParallelBootOperationStepHandler) {
if (parallelBootOp == null) {
parallelBootOp = op;
parallelBootOp.bootHandlerUpdateNeeded();
break;
}
}
}
}
for (ParsedBootOp op : postExtensionOps) {
// ModelControllerImpl doesn't include subsystem ops directly in the postExtensionsOps param in parallel boot.
// So, if postExtensionOps contains a subsystem op, it's because we've created it from YAML.
if (parallelBootOp != null && isSubsystemOperation(op)) {
//The new operations created from the YAML are added to the parallel boot operation enclosing all the subsystem operations
parallelBootOp.addChildOperation(op);
} else if (op.handler instanceof ParallelBootOperationStepHandler) {
//The parallel boot operation is added to the list
reorderedList.add(parallelBootOp);
} else {
//The new operations created from the YAML are added to the list of operations (if they haven't already be added in a subsystem enclosing operation).
reorderedList.add(op);
}
}
postExtensionOps.clear();
postExtensionOps.addAll(reorderedList);
this.configs.clear();
needReload = true;
}

private boolean isSubsystemOperation(ParsedBootOp op) {
return op.getAddress().size() > 0 && SUBSYSTEM.equals(op.getAddress().getElement(0).getKey());
}

@SuppressWarnings("unchecked")
private void processResource(PathAddress parentAddress, Map<String, Object> yaml, ImmutableManagementResourceRegistration rootRegistration, ImmutableManagementResourceRegistration resourceRegistration, Map<PathAddress, ParsedBootOp> xmlOperations, List<ParsedBootOp> postExtensionOps, boolean placeHolder) {
for (String name : yaml.keySet()) {
Expand Down Expand Up @@ -424,7 +469,7 @@ private void processAttributes(PathAddress address, ImmutableManagementResourceR
}
}
for (AttributeDefinition def : operationEntry.getOperationDefinition().getParameters()) {
if (def != null && ! attributeNames.contains(def.getName())) {
if (def != null && !attributeNames.contains(def.getName())) {
if (!def.isResourceOnly()) {
attributes.add(def);
}
Expand Down
Loading

0 comments on commit 9ca5454

Please sign in to comment.