Search in sources :

Example 1 with WorkflowStep

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);
        }
    }
}
Also used : WorkflowStep(com.emc.storageos.db.client.model.WorkflowStep) WorkflowException(com.emc.storageos.workflow.WorkflowException) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 2 with WorkflowStep

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;
}
Also used : WorkflowStep(com.emc.storageos.db.client.model.WorkflowStep) Workflow(com.emc.storageos.db.client.model.Workflow) URI(java.net.URI)

Example 3 with WorkflowStep

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;
}
Also used : WorkflowStep(com.emc.storageos.db.client.model.WorkflowStep) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 4 with WorkflowStep

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;
}
Also used : WorkflowStep(com.emc.storageos.db.client.model.WorkflowStep) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint)

Example 5 with WorkflowStep

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");
}
Also used : WorkflowStep(com.emc.storageos.db.client.model.WorkflowStep) DataObject(com.emc.storageos.db.client.model.DataObject) Test(org.junit.Test)

Aggregations

WorkflowStep (com.emc.storageos.db.client.model.WorkflowStep)28 DataObject (com.emc.storageos.db.client.model.DataObject)16 Test (org.junit.Test)16 URI (java.net.URI)7 Operation (com.emc.storageos.db.client.model.Operation)6 Task (com.emc.storageos.db.client.model.Task)6 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 Workflow (com.emc.storageos.db.client.model.Workflow)5 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)3 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 WorkflowStepData (com.emc.storageos.db.client.model.WorkflowStepData)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)1 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 Joiner (com.emc.storageos.db.joiner.Joiner)1 StepList (com.emc.storageos.model.workflow.StepList)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1