use of com.emc.storageos.db.client.model.WorkflowStep in project coprhd-controller by CoprHD.
the class ControllerWorkflowCleanupHandler method completeWorkflow.
private void completeWorkflow(URI workflowId) {
URIQueryResultList stepURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getWorkflowWorkflowStepConstraint(workflowId), stepURIs);
for (URI stepURI : stepURIs) {
WorkflowStep step = dbClient.queryObject(WorkflowStep.class, stepURI);
String state = step.getState();
List<String> activeStepStates = Arrays.asList(StepState.CREATED.toString(), StepState.BLOCKED.toString(), StepState.QUEUED.toString(), StepState.EXECUTING.toString());
if (activeStepStates.contains(state)) {
WorkflowException ex = WorkflowException.exceptions.workflowTerminatedForFailover(workflowId.toString());
log.info("Terminate workflow step {}", step.getId());
WorkflowService.completerStepErrorWithoutRollback(step.getStepId(), ex);
}
}
}
use of com.emc.storageos.db.client.model.WorkflowStep in project coprhd-controller by CoprHD.
the class WorkflowService method getParentWorkflow.
/**
* Gets the parent workflow for the passed workflow.
*
* @param workflow A reference to the workflow
*
* @return The parent workflow or null for a top-level workflow.
*/
private Workflow getParentWorkflow(Workflow workflow) {
Workflow parentWorkflow = null;
if (workflow != null) {
List<WorkflowStep> wfSteps = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, WorkflowStep.class, AlternateIdConstraint.Factory.getWorkflowStepByStepId(workflow.getOrchTaskId()));
if (!wfSteps.isEmpty()) {
// There should only be a single workflow step that has a step id that is equal
// to the orchestration task id for a workflow. The workflow for that step is
// the parent workflow for the passed workflow.
URI parentWorkflowURI = wfSteps.get(0).getWorkflowId();
parentWorkflow = queryResource(parentWorkflowURI);
}
}
return parentWorkflow;
}
use of com.emc.storageos.db.client.model.WorkflowStep in project coprhd-controller by CoprHD.
the class FilePolicyWorkflowCompleter method getWorkFlowSteps.
public List<WorkflowStep> getWorkFlowSteps(DbClient dbClient, URI workFlowId) {
List<WorkflowStep> workFlowSteps = new ArrayList<WorkflowStep>();
if (workFlowId != null) {
URIQueryResultList stepURIs = new URIQueryResultList();
dbClient.queryByConstraint(ContainmentConstraint.Factory.getWorkflowWorkflowStepConstraint(workFlowId), stepURIs);
Iterator<URI> iter = stepURIs.iterator();
while (iter.hasNext()) {
URI workflowStepURI = iter.next();
WorkflowStep step = dbClient.queryObject(WorkflowStep.class, workflowStepURI);
workFlowSteps.add(step);
}
}
return workFlowSteps;
}
use of com.emc.storageos.db.client.model.WorkflowStep in project coprhd-controller by CoprHD.
the class FilePolicyWorkflowCompleter method getWorkFlowFailedSteps.
public int getWorkFlowFailedSteps(DbClient dbClient, URI workFlowId, StringBuffer strErrorMsg) {
int numStepsFailed = 0;
List<WorkflowStep> workFlowSteps = getWorkFlowSteps(dbClient, workFlowId);
if (workFlowSteps != null && !workFlowSteps.isEmpty()) {
strErrorMsg.append("The following workflow step(s) failed :");
for (WorkflowStep workFlowStep : workFlowSteps) {
if (workFlowStep.getState() != null && workFlowStep.getState().equalsIgnoreCase("error")) {
numStepsFailed++;
strErrorMsg.append(workFlowStep.getDescription());
}
}
}
return numStepsFailed;
}
use of com.emc.storageos.db.client.model.WorkflowStep in project coprhd-controller by CoprHD.
the class WorkflowTest method test02_one_wf_three_steps_simple.
@Test
public /**
* This tests a single level, three step workflow that passes.
*/
void test02_one_wf_three_steps_simple() {
// Expected results for this test case
final String[] testSuccessSteps = { "L0S1 sub", "L0S2 sub", "L0S3 sub" };
final String[] testErrorSteps = {};
final String[] testCancelledSteps = {};
final String[] testSuspendedSteps = {};
final String testname = new Object() {
}.getClass().getEnclosingMethod().getName();
printLog(testname + " started");
// Don't cause in failures
workflowService.setSuspendClassMethodTestOnly(null);
workflowService.setSuspendOnErrorTestOnly(true);
injectedFailures.clear();
String taskId = UUID.randomUUID().toString();
generate3StepWF(0, 1, taskId);
WorkflowState state = waitOnWorkflowComplete(taskId);
printLog("Top level workflow state: " + state);
Map<String, WorkflowStep> stepMap = readWorkflowFromDb(taskId);
assertTrue(state == WorkflowState.SUCCESS);
validateStepStates(stepMap, testSuccessSteps, testErrorSteps, testCancelledSteps, testSuspendedSteps);
printLog(testname + " completed");
}
Aggregations