Search in sources :

Example 31 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class WorkflowService method rollbackChildWorkflow.

/**
 * This call will rollback a child workflow given the parent's workflow URI and the step-id
 * of the parent step which is the child workflow's orchestration task id.
 * <p>
 * The idea is that if step of a parent workflow creates a child workflow, which completes successfully, but then a later step in the
 * parent workflow fails, initiating rollback, we need an easy way to rollback the entire child workflow in the rollback method of the
 * step that created the child workflow.
 * <p>
 * So this method should only be called from a parent workflow's rollback method for the step that initiated the child workflow. In
 * order to be eligible to be rolled back, the child workflow must have completed successfully. It will be completely rolled back (i.e.
 * all steps in the child workflow) will be rolled back.
 *
 * @param parentURI
 * @param childOrchestrationTaskId
 * @param stepId
 */
public void rollbackChildWorkflow(URI parentURI, String childOrchestrationTaskId, String stepId) {
    Workflow parentWorkflow = loadWorkflowFromUri(parentURI);
    if (parentWorkflow == null) {
        _log.info("Could not locate parent workflow %s (%s), possibly it was already deleted");
        ServiceCoded coded = WorkflowException.exceptions.workflowNotFound(parentURI.toString());
        WorkflowStepCompleter.stepFailed(stepId, coded);
    }
    for (URI childURI : parentWorkflow._childWorkflows) {
        Workflow childWorkflow = loadWorkflowFromUri(childURI);
        if (childWorkflow == null) {
            _log.info("Could not locate child workflow %s (%s), possibly it was already deleted");
            WorkflowStepCompleter.stepSucceded(stepId);
            return;
        }
        // exist.
        if (!NullColumnValueGetter.isNullValue(childWorkflow.getOrchTaskId()) && childWorkflow.getOrchTaskId().equals(childOrchestrationTaskId)) {
            // Rolling back the specified workflow.
            rollbackInnerWorkflow(childWorkflow, stepId);
            return;
        }
    }
    // Didn't find a Workflow to rollback.
    WorkflowStepCompleter.stepSucceded(stepId);
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) URI(java.net.URI)

Example 32 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class WorkflowTest method stepStoreData.

/**
 * Saves al forms of workflow step data.
 * @param stepId -- this step
 */
public void stepStoreData(String stepId) {
    try {
        URI workflowURI = workflowService.getWorkflowFromStepId(stepId).getWorkflowURI();
        workflowService.storeStepData(workflowURI.toString(), "workflow-data");
        workflowService.storeStepData(stepId, "step-data");
        workflowService.storeStepData(stepId, "keya", "keya-data");
        workflowService.storeStepData(stepId, "keyb", "keyb-data");
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (Exception ex) {
        log.error("Exception in stepSaveData: ", ex.getMessage(), ex);
        ServiceCoded coded = WorkflowException.errors.unforeseen();
        WorkflowStepCompleter.stepFailed(stepId, coded);
    }
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 33 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class WorkflowTest method deeplastnop.

public void deeplastnop(int level, int step, String stepId) {
    WorkflowStepCompleter.stepExecuting(stepId);
    if (sleepMillis > 0) {
        try {
            Thread.sleep(sleepMillis);
        } catch (Exception ex) {
        // no action
        }
    }
    if (hasInjectedFailure(level, step)) {
        log.info("Injecting failure in step: " + genMsg(level, step, "deeplastnop"));
        ServiceCoded coded = WorkflowException.errors.unforeseen();
        WorkflowStepCompleter.stepFailed(stepId, coded);
    } else {
        WorkflowStepCompleter.stepSucceded(stepId);
    }
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 34 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class WorkflowTest method nop.

public void nop(int level, int step, String stepId) {
    WorkflowStepCompleter.stepExecuting(stepId);
    if (sleepMillis > 0) {
        try {
            Thread.sleep(sleepMillis);
        } catch (Exception ex) {
        // no action
        }
    }
    if (hasInjectedFailure(level, step)) {
        log.info("Injecting failure in step: " + genMsg(level, step, "nop"));
        ServiceCoded coded = WorkflowException.errors.unforeseen();
        WorkflowStepCompleter.stepFailed(stepId, coded);
    } else {
        WorkflowStepCompleter.stepSucceded(stepId);
    }
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 35 with ServiceCoded

use of com.emc.storageos.svcs.errorhandling.model.ServiceCoded in project coprhd-controller by CoprHD.

the class WorkflowTest method stepLoadData.

/**
 * Verifies all forms of workflow step data.
 * @param storerStepId -- step of storing routine
 * @param stepId -- this step
 */
public void stepLoadData(String storerStepId, String stepId) {
    try {
        URI workflowURI = workflowService.getWorkflowFromStepId(stepId).getWorkflowURI();
        String workflowData = (String) workflowService.loadStepData(workflowURI.toString());
        Assert.assertEquals("workflow-data", workflowData);
        String stepData = (String) workflowService.loadStepData(storerStepId);
        Assert.assertEquals("step-data", stepData);
        ;
        String keyaData = (String) workflowService.loadStepData(storerStepId, "keya");
        Assert.assertEquals("keya-data", keyaData);
        String keybData = (String) workflowService.loadStepData(storerStepId, "keyb");
        Assert.assertEquals("keyb-data", keybData);
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (Exception ex) {
        log.error("Exception in stepLoadData: ", ex.getMessage(), ex);
        ServiceCoded coded = WorkflowException.errors.unforeseen();
        WorkflowStepCompleter.stepFailed(stepId, coded);
    }
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)94 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)48 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)44 URI (java.net.URI)41 Volume (com.emc.storageos.db.client.model.Volume)31 ControllerException (com.emc.storageos.volumecontroller.ControllerException)27 NamedURI (com.emc.storageos.db.client.model.NamedURI)26 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)22 WorkflowException (com.emc.storageos.workflow.WorkflowException)22 ArrayList (java.util.ArrayList)22 BlockObject (com.emc.storageos.db.client.model.BlockObject)18 Operation (com.emc.storageos.db.client.model.Operation)17 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)17 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)16 TaskCompleter (com.emc.storageos.volumecontroller.TaskCompleter)15 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)14 HashMap (java.util.HashMap)14 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)13 URISyntaxException (java.net.URISyntaxException)13 Host (com.emc.storageos.db.client.model.Host)12