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);
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations