Skip to content

Commit

Permalink
[WFCORE-7035]: WIP
Browse files Browse the repository at this point in the history
Trying to get Brian's comment into account.

Signed-off-by: Emmanuel Hugonnet <[email protected]>
  • Loading branch information
ehsavoie committed Dec 10, 2024
1 parent 41b3b80 commit 4f1149a
Show file tree
Hide file tree
Showing 20 changed files with 716 additions and 15 deletions.
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
16 changes: 16 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,21 @@ public PathAddress getAddress() {
return address;
}

public boolean isBootHandlerUpdateNeeded() {
return this.handler instanceof ParallelBootOperationStepHandler
&& (
bootHandlerUpdateNeeded
|| ((ParallelBootOperationStepHandler) this.handler).getParsedBootOp().getChildOperations().size() != getChildOperations().size());
}

/**
* 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 @@ -168,23 +169,22 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist
xmlOperations.put(op.getAddress(), op);
} else {
if (op.handler instanceof ParallelBootOperationStepHandler) {
/* We need to createa new ParsedBootOp so that the handler number of childOperations is different from the number of childOperation of the handler and thus the handler will be properly updated.
* @see ModelCOntrollerImpl.boot(final List<ModelNode> bootList, final OperationMessageHandler handler, final OperationTransactionControl control,
/* We need to force the ParallelBootOperationStepHandler to be updated during the boot ( around line 536)
* @see ModelControllerImpl.boot(final List<ModelNode> bootList, final OperationMessageHandler handler, final OperationTransactionControl control,
* final boolean rollbackOnRuntimeFailure, MutableRootResourceRegistrationProvider parallelBootRootResourceRegistrationProvider,
* final boolean skipModelValidation, final boolean partialModel, final ConfigurationExtension configExtension)
*/
parallelBootOp = new ParsedBootOp(op, op.handler);
for (ModelNode childOp : childOperations) {
ParsedBootOp subOp = new ParsedBootOp(childOp, null);
xmlOperations.put(subOp.getAddress(), subOp);
parallelBootOp.addChildOperation(subOp);
}
} else {
for (ModelNode childOp : childOperations) {
ParsedBootOp subOp = new ParsedBootOp(childOp, null);
xmlOperations.put(subOp.getAddress(), subOp);
if (parallelBootOp == null) {
parallelBootOp = op;
parallelBootOp.bootHandlerUpdateNeeded();
} else {
MGMT_OP_LOGGER.multipleParallelBootOperation();
}
}
for (ModelNode childOp : childOperations) {
ParsedBootOp subOp = new ParsedBootOp(childOp, null);
xmlOperations.put(subOp.getAddress(), subOp);
}
}
}
for (Map<String, Object> config : configs) {
Expand All @@ -195,7 +195,7 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist
}
List<ParsedBootOp> reorderedList = new ArrayList<>(postExtensionOps.size());
for (ParsedBootOp op : postExtensionOps) {
if (parallelBootOp != null && op.getAddress().size() > 0 && "subsystem".equals(op.getAddress().getElement(0).getKey())) {
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) {
Expand All @@ -212,6 +212,9 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist
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
Loading

0 comments on commit 4f1149a

Please sign in to comment.