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