use of com.sequenceiq.flow.api.model.FlowStateTransitionResponse in project cloudbreak by hortonworks.
the class OperationDetailsPopulatorTest method createFlowProgressResponse.
private Optional<FlowProgressResponse> createFlowProgressResponse(String secondTransitionState, boolean finished) {
FlowProgressResponse response = new FlowProgressResponse();
List<FlowStateTransitionResponse> transitionResponseList = new ArrayList<>();
FlowStateTransitionResponse transitionResponse1 = new FlowStateTransitionResponse();
transitionResponse1.setState("state1");
transitionResponse1.setNextEvent("nextEvent1");
transitionResponse1.setStatus("SUCCESSFUL");
FlowStateTransitionResponse transitionResponse2 = new FlowStateTransitionResponse();
transitionResponse2.setStatus("state2");
transitionResponse2.setNextEvent("nextEvent2");
transitionResponse2.setStatus(secondTransitionState);
transitionResponseList.add(transitionResponse1);
transitionResponseList.add(transitionResponse2);
response.setTransitions(transitionResponseList);
if (finished) {
response.setProgress(MAX_PROGRESS);
response.setFinalized(false);
response.setMaxNumberOfTransitions(transitionResponseList.size());
} else {
response.setProgress(IN_PROGRESS);
response.setFinalized(true);
response.setMaxNumberOfTransitions(transitionResponseList.size() + 1);
}
return Optional.of(response);
}
use of com.sequenceiq.flow.api.model.FlowStateTransitionResponse in project cloudbreak by hortonworks.
the class FlowProgressResponseConverter method createFlowStateTransitions.
private List<FlowStateTransitionResponse> createFlowStateTransitions(List<FlowLog> reversedFlowLogs, Long currentCreatedTime) {
List<FlowStateTransitionResponse> transitions = new ArrayList<>();
for (int flowLogIndex = 0; flowLogIndex < reversedFlowLogs.size(); flowLogIndex++) {
FlowLog fl = reversedFlowLogs.get(flowLogIndex);
Double elapsedTime = null;
if (!fl.getFinalized() && flowLogIndex == reversedFlowLogs.size() - 1) {
elapsedTime = getRoundedTimeInSeconds(currentCreatedTime, new Date().getTime());
} else {
elapsedTime = getRoundedTimeInSeconds(currentCreatedTime, fl.getCreated());
}
currentCreatedTime = fl.getCreated();
transitions.add(convertToFlowTransitionResponse(fl, elapsedTime));
}
return transitions;
}
use of com.sequenceiq.flow.api.model.FlowStateTransitionResponse in project cloudbreak by hortonworks.
the class OperationDetailsPopulator method calculateProgress.
private OperationProgressStatus calculateProgress(List<FlowProgressResponse> provisionFlows) {
FlowProgressResponse lastFlowProgress = provisionFlows.get(provisionFlows.size() - 1);
if (lastFlowProgress.getTransitions() == null) {
return OperationProgressStatus.UNKNOWN;
}
OperationProgressStatus progressStatus = OperationProgressStatus.FINISHED;
boolean hasCancelState = false;
boolean hasFailedStatus = false;
boolean hasPendingStatus = false;
for (FlowStateTransitionResponse fsTransitionResp : lastFlowProgress.getTransitions()) {
if (OperationProgressStatus.CANCELLED.name().equals(fsTransitionResp.getStatus())) {
hasCancelState = true;
} else if (StateStatus.FAILED.name().equals(fsTransitionResp.getStatus())) {
hasFailedStatus = true;
} else if (StateStatus.PENDING.name().equals(fsTransitionResp.getStatus())) {
hasPendingStatus = true;
}
}
if (hasFailedStatus) {
progressStatus = OperationProgressStatus.FAILED;
} else if (hasCancelState) {
progressStatus = OperationProgressStatus.CANCELLED;
} else if (hasPendingStatus) {
progressStatus = OperationProgressStatus.RUNNING;
}
return progressStatus;
}
use of com.sequenceiq.flow.api.model.FlowStateTransitionResponse in project cloudbreak by hortonworks.
the class FlowProgressResponseConverter method convertToFlowTransitionResponse.
private FlowStateTransitionResponse convertToFlowTransitionResponse(FlowLog fl, Double elapsedTime) {
FlowStateTransitionResponse transition = new FlowStateTransitionResponse();
transition.setState(fl.getCurrentState());
transition.setNextEvent(fl.getNextEvent());
transition.setStatus(fl.getStateStatus().name());
transition.setElapsedTimeInSeconds(elapsedTime);
return transition;
}
Aggregations