better naming for switch step sub-tasks
diff --git a/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowStepResolution.java b/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowStepResolution.java
index cbcff72..e356ee1 100644
--- a/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowStepResolution.java
+++ b/core/src/main/java/org/apache/brooklyn/core/workflow/WorkflowStepResolution.java
@@ -30,6 +30,7 @@
import org.apache.brooklyn.api.objs.BrooklynObject;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.entity.EntityAdjuncts.EntityAdjunctProxyable;
+import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
import org.apache.brooklyn.core.mgmt.internal.AbstractManagementContext;
import org.apache.brooklyn.core.objs.BrooklynObjectInternal;
import org.apache.brooklyn.core.resolve.jackson.BeanWithTypeUtils;
@@ -228,7 +229,8 @@
def = converter.call();
} else {
// run in a task context if we can, to facilitate conversion and type lookup
- def = Entities.submit(entity, Tasks.create("convert steps", converter)).getUnchecked();
+ def = Entities.submit(entity,
+ Tasks.builder().displayName("convert steps").body(converter).tag(BrooklynTaskTags.TRANSIENT_TASK_TAG).build()).getUnchecked();
}
if (def instanceof WorkflowStepDefinition.WorkflowStepDefinitionWithSpecialDeserialization) {
diff --git a/core/src/main/java/org/apache/brooklyn/core/workflow/steps/flow/SwitchWorkflowStep.java b/core/src/main/java/org/apache/brooklyn/core/workflow/steps/flow/SwitchWorkflowStep.java
index 42598bf..a1e7831 100644
--- a/core/src/main/java/org/apache/brooklyn/core/workflow/steps/flow/SwitchWorkflowStep.java
+++ b/core/src/main/java/org/apache/brooklyn/core/workflow/steps/flow/SwitchWorkflowStep.java
@@ -100,35 +100,44 @@
for (int i = 0; i<stepsResolved.size(); i++) {
// go through steps, find first that matches
+ String potentialTaskName = Tasks.current().getDisplayName()+"-"+(i+1);
+
WorkflowStepDefinition subStep = stepsResolved.get(i);
+ String name = subStep.getName();
+ if (Strings.isBlank(name)) {
+ subStep.setName(potentialTaskName);
+ name = subStep.getName();
+ potentialTaskName = null;
+ }
WorkflowStepInstanceExecutionContext subStepContext = new WorkflowStepInstanceExecutionContext(
/** use same step index */ context.getStepIndex(), subStep, context.getWorkflowExectionContext());
- // might want to record sub-step context somewhere; but for now we don't
-
- String potentialTaskName = Tasks.current().getDisplayName()+"-"+(i+1);
+ // sub-step context gets recorded in selectedStepContext,
+ // and promoted and used by the UI
DslPredicates.DslPredicate condition = subStep.getConditionResolved(subStepContext);
if (condition!=null) {
- if (log.isTraceEnabled()) log.trace("Considering condition " + condition + " for " + potentialTaskName);
+ if (log.isTraceEnabled()) log.trace("Considering condition " + condition + " for " + name);
boolean conditionMet = DslPredicates.evaluateDslPredicateWithBrooklynObjectContext(condition, valueResolved, subStepContext.getEntity());
- if (log.isTraceEnabled()) log.trace("Considered condition " + condition + " for " + potentialTaskName + ": " + conditionMet);
+ if (log.isTraceEnabled()) log.trace("Considered condition " + condition + " for " + name + ": " + conditionMet);
if (!conditionMet) continue;
}
setStepState(context, true, subStep, subStepContext); // persist this, so when we resume we can pick up the same one
- Task<?> handlerI = subStep.newTaskAsSubTask(subStepContext,
- potentialTaskName, BrooklynTaskTags.tagForWorkflowSubStep(context, i));
+ // provide some details of other step
+ name = subStepContext.getName();
+ context.noteOtherMetadata("Switch match", "Case "+(i+1)+(Strings.isNonBlank(name) && Strings.isNonBlank(potentialTaskName) ? ": "+name : ""));
- log.debug("Switch matched at substep "+i+", running " + potentialTaskName + " '" + subStep.computeName(subStepContext, false)+"' in task "+handlerI.getId());
+ Task<?> handlerI = subStep.newTaskAsSubTask(subStepContext,
+ null, BrooklynTaskTags.tagForWorkflowSubStep(context, i));
+
+ log.debug("Switch matched at substep "+i+", running " + (potentialTaskName!=null ? potentialTaskName : "case") + " '" + subStep.computeName(subStepContext, false)+"' in task "+handlerI.getId());
Object result = DynamicTasks.queue(handlerI).getUnchecked();
context.next = WorkflowReplayUtils.getNext(subStepContext, subStep, context, this);
- // provide some details of other step
- context.noteOtherMetadata("Switch match", "Case "+(i+1)+": "+Strings.firstNonBlank(subStepContext.getName(), subStepContext.getWorkflowStepReference()));
context.otherMetadata.putAll(subStepContext.otherMetadata);
return result;