Search in sources :

Example 11 with StepStatus

use of com.emc.storageos.workflow.Workflow.StepStatus in project coprhd-controller by CoprHD.

the class WorkflowService method getOrchestrationIdStartTime.

/**
 * Attempts to intuit the start time for a provisioning operation from the orchestrationId.
 * This may be either a step in an outer workflow, or a task. The Workflow itself is not used
 * because when retrying for a workflow lock, a new workflow is created every time.
 *
 * @param workflow
 *            Workflow
 * @return start time in seconds
 */
private Long getOrchestrationIdStartTime(Workflow workflow) {
    Long timeInSeconds = 0L;
    String orchestrationId = workflow._orchTaskId;
    if (workflow._nested) {
        String parentPath = getZKStep2WorkflowPath(orchestrationId);
        try {
            if (_dataManager.checkExists(parentPath) != null) {
                parentPath = (String) _dataManager.getData(parentPath, false);
                // Load the Workflow state from ZK
                if (parentPath != null) {
                    Workflow parentWorkflow = (Workflow) _dataManager.getData(parentPath, false);
                    parentWorkflow = loadWorkflow(parentWorkflow);
                    // Get the StepStatus for our step.
                    StepStatus status = parentWorkflow.getStepStatus(orchestrationId);
                    if (status != null && status.startTime != null) {
                        timeInSeconds = status.startTime.getTime() / MILLISECONDS_IN_SECOND;
                    }
                }
            }
        } catch (Exception ex) {
            _log.error("An error occurred", ex);
        }
    }
    if (timeInSeconds == 0) {
        // See if there is a task with this id.
        List<Task> tasks = TaskUtils.findTasksForRequestId(_dbClient, orchestrationId);
        for (Task task : tasks) {
            timeInSeconds = task.getStartTime().getTimeInMillis() / MILLISECONDS_IN_SECOND;
        }
    }
    if (timeInSeconds == 0) {
        // Last resort - current time
        timeInSeconds = System.currentTimeMillis() / MILLISECONDS_IN_SECOND;
    }
    return timeInSeconds;
}
Also used : Task(com.emc.storageos.db.client.model.Task) StepStatus(com.emc.storageos.workflow.Workflow.StepStatus) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) LockRetryException(com.emc.storageos.locking.LockRetryException)

Aggregations

StepStatus (com.emc.storageos.workflow.Workflow.StepStatus)11 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)4 LockRetryException (com.emc.storageos.locking.LockRetryException)4 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)4 ControllerException (com.emc.storageos.volumecontroller.ControllerException)4 Step (com.emc.storageos.workflow.Workflow.Step)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Task (com.emc.storageos.db.client.model.Task)2 URI (java.net.URI)2 HashSet (java.util.HashSet)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 DataObject (com.emc.storageos.db.client.model.DataObject)1 ServiceCoded (com.emc.storageos.svcs.errorhandling.model.ServiceCoded)1 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)1 StepState (com.emc.storageos.workflow.Workflow.StepState)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1