Skip to content

Commit 2e11a98

Browse files
committed
[WFCORE-7035]: YAML extension doesn't support ParallelBoot.
* Adding YAML subsystem operations to the ParallelOperationHandler. * Adding more tests to cover that use-case. Jira: https://issues.redhat.com/browse/WFCORE-7035 Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
1 parent 435779c commit 2e11a98

File tree

23 files changed

+938
-6
lines changed

23 files changed

+938
-6
lines changed

controller/src/main/java/org/jboss/as/controller/ModelControllerImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,7 @@ boolean boot(final List<ModelNode> bootList, final OperationMessageHandler handl
533533
// stop
534534
break;
535535
} else {
536-
if(parsedOp.handler instanceof ParallelBootOperationStepHandler &&
537-
((ParallelBootOperationStepHandler)parsedOp.handler).getParsedBootOp().getChildOperations().size() != parsedOp.getChildOperations().size()) {
536+
if(parsedOp.isBootHandlerUpdateNeeded()) {
538537
ParallelBootOperationStepHandler updatedHandler = new ParallelBootOperationStepHandler(executorService, managementModel.get().getRootResourceRegistration(), processState, this, operationID, extraValidationStepHandler);
539538
for(ModelNode childOp : parsedOp.getChildOperations()) {
540539
updatedHandler.addSubsystemOperation(new ParsedBootOp(childOp));

controller/src/main/java/org/jboss/as/controller/ParsedBootOp.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class ParsedBootOp {
3030
public final OperationStepHandler handler;
3131
public final ModelNode response;
3232
private List<ModelNode> childOperations;
33+
private boolean bootHandlerUpdateNeeded = false;
3334

3435
ParsedBootOp(final ModelNode operation) {
3536
this(operation, null, new ModelNode());
@@ -84,6 +85,18 @@ public PathAddress getAddress() {
8485
return address;
8586
}
8687

88+
public boolean isBootHandlerUpdateNeeded() {
89+
return this.handler instanceof ParallelBootOperationStepHandler && bootHandlerUpdateNeeded;
90+
}
91+
92+
/**
93+
* Setting this will force the ParallelBootOperationStepHandler handdler to be updated on boot.
94+
*/
95+
public void bootHandlerUpdateNeeded() {
96+
this.bootHandlerUpdateNeeded = true;
97+
}
98+
99+
87100
@Override
88101
public String toString() {
89102
return "ParsedBootOp{" + "operation=" + operation + ", operationName=" + operationName + ", address=" + address + ", handler=" + handler + ", response=" + response + ", childOperations=" + childOperations + '}';

controller/src/main/java/org/jboss/as/controller/logging/ControllerLogger.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3805,4 +3805,8 @@ OperationFailedRuntimeException capabilityAlreadyRegisteredInContext(String capa
38053805

38063806
@Message(id = 516, value = "Parameter %s specifies an invalid module name: %s")
38073807
OperationFailedException invalidModuleNameParameter(String parameterName, String moduleName);
3808+
3809+
@LogMessage(level = WARN)
3810+
@Message(id = 517, value = "There are multiple Parallel Boot Operations.")
3811+
void multipleParallelBootOperation();
38083812
}

controller/src/main/java/org/jboss/as/controller/persistence/yaml/YamlConfigurationExtension.java

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
1616
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
1717
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE;
18+
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
1819
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.UNDEFINE_ATTRIBUTE_OPERATION;
1920
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.URL;
2021
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
@@ -45,6 +46,7 @@
4546
import org.jboss.as.controller.MapAttributeDefinition;
4647
import org.jboss.as.controller.ObjectMapAttributeDefinition;
4748
import org.jboss.as.controller.ObjectTypeAttributeDefinition;
49+
import org.jboss.as.controller.ParallelBootOperationStepHandler;
4850
import org.jboss.as.controller.ParsedBootOp;
4951
import org.jboss.as.controller.PathAddress;
5052
import org.jboss.as.controller.RunningMode;
@@ -160,11 +162,20 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist
160162
}
161163
MGMT_OP_LOGGER.debug("We are applying YAML files to the configuration");
162164
Map<PathAddress, ParsedBootOp> xmlOperations = new HashMap<>();
165+
boolean paralleBoot = false;
163166
for (ParsedBootOp op : postExtensionOps) {
164-
if (op.getChildOperations().isEmpty()) {
167+
List<ModelNode> childOperations = op.getChildOperations();
168+
if (childOperations.isEmpty()) {
165169
xmlOperations.put(op.getAddress(), op);
166170
} else {
167-
for (ModelNode childOp : op.getChildOperations()) {
171+
if (op.handler instanceof ParallelBootOperationStepHandler) {
172+
if (!paralleBoot) {
173+
paralleBoot = true;
174+
} else {
175+
MGMT_OP_LOGGER.multipleParallelBootOperation();
176+
}
177+
}
178+
for (ModelNode childOp : childOperations) {
168179
ParsedBootOp subOp = new ParsedBootOp(childOp, null);
169180
xmlOperations.put(subOp.getAddress(), subOp);
170181
}
@@ -176,10 +187,44 @@ public void processOperations(ImmutableManagementResourceRegistration rootRegist
176187
for (Map.Entry<String, Object> deployment : deployments.entrySet()) {
177188
processUnmanagedDeployments(rootRegistration, deployment, xmlOperations, postExtensionOps);
178189
}
190+
List<ParsedBootOp> reorderedList = new ArrayList<>(postExtensionOps.size());
191+
//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.
192+
ParsedBootOp parallelBootOp = null;
193+
if (paralleBoot) {
194+
for (ParsedBootOp op : postExtensionOps) {
195+
if (op.handler instanceof ParallelBootOperationStepHandler) {
196+
if (parallelBootOp == null) {
197+
parallelBootOp = op;
198+
parallelBootOp.bootHandlerUpdateNeeded();
199+
break;
200+
}
201+
}
202+
}
203+
}
204+
for (ParsedBootOp op : postExtensionOps) {
205+
// ModelControllerImpl doesn't include subsystem ops directly in the postExtensionsOps param in parallel boot.
206+
// So, if postExtensionOps contains a subsystem op, it's because we've created it from YAML.
207+
if (parallelBootOp != null && isSubsystemOperation(op)) {
208+
//The new operations created from the YAML are added to the parallel boot operation enclosing all the subsystem operations
209+
parallelBootOp.addChildOperation(op);
210+
} else if (op.handler instanceof ParallelBootOperationStepHandler) {
211+
//The parallel boot operation is added to the list
212+
reorderedList.add(parallelBootOp);
213+
} else {
214+
//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).
215+
reorderedList.add(op);
216+
}
217+
}
218+
postExtensionOps.clear();
219+
postExtensionOps.addAll(reorderedList);
179220
this.configs.clear();
180221
needReload = true;
181222
}
182223

224+
private boolean isSubsystemOperation(ParsedBootOp op) {
225+
return op.getAddress().size() > 0 && SUBSYSTEM.equals(op.getAddress().getElement(0).getKey());
226+
}
227+
183228
@SuppressWarnings("unchecked")
184229
private void processResource(PathAddress parentAddress, Map<String, Object> yaml, ImmutableManagementResourceRegistration rootRegistration, ImmutableManagementResourceRegistration resourceRegistration, Map<PathAddress, ParsedBootOp> xmlOperations, List<ParsedBootOp> postExtensionOps, boolean placeHolder) {
185230
for (String name : yaml.keySet()) {
@@ -424,7 +469,7 @@ private void processAttributes(PathAddress address, ImmutableManagementResourceR
424469
}
425470
}
426471
for (AttributeDefinition def : operationEntry.getOperationDefinition().getParameters()) {
427-
if (def != null && ! attributeNames.contains(def.getName())) {
472+
if (def != null && !attributeNames.contains(def.getName())) {
428473
if (!def.isResourceOnly()) {
429474
attributes.add(def);
430475
}

0 commit comments

Comments
 (0)