use of com.sequenceiq.flow.api.model.operation.OperationFlowsView in project cloudbreak by hortonworks.
the class OperationService method getOperationProgressByResourceCrn.
public OperationView getOperationProgressByResourceCrn(String resourceCrn, boolean detailed) {
OperationView response = new OperationView();
Optional<OperationFlowsView> operationFlowsViewOpt = flowService.getLastFlowOperationByResourceCrn(resourceCrn);
if (operationFlowsViewOpt.isPresent()) {
OperationFlowsView operationFlowsView = operationFlowsViewOpt.get();
OperationType operationType = operationFlowsView.getOperationType();
response = operationDetailsPopulator.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
if (OperationType.PROVISION.equals(operationType)) {
if (detailed) {
handleProvisionOperation(resourceCrn, response, detailed);
} else {
LOGGER.debug("Skipping detailed environment provision operation response");
}
}
}
return response;
}
use of com.sequenceiq.flow.api.model.operation.OperationFlowsView in project cloudbreak by hortonworks.
the class OperationService method getOperationProgressByResourceCrn.
public OperationView getOperationProgressByResourceCrn(String resourceCrn, boolean detailed) {
OperationView sdxOperationView = new OperationView();
Optional<OperationFlowsView> operationFlowsViewOpt = flowService.getLastFlowOperationByResourceCrn(resourceCrn);
if (operationFlowsViewOpt.isPresent()) {
OperationFlowsView operationFlowsView = operationFlowsViewOpt.get();
OperationType operationType = operationFlowsView.getOperationType();
sdxOperationView = operationDetailsPopulator.createOperationView(operationFlowsView, OperationResource.DATALAKE);
if (OperationType.PROVISION.equals(operationType)) {
if (detailed) {
handleProvisionOperation(resourceCrn, sdxOperationView, detailed);
} else {
LOGGER.debug("Skipping detailed SDX provision operation response");
}
}
}
return sdxOperationView;
}
use of com.sequenceiq.flow.api.model.operation.OperationFlowsView in project cloudbreak by hortonworks.
the class OperationDetailsPopulatorTest method testCreateOperationViewWithoutFlows.
@Test
public void testCreateOperationViewWithoutFlows() {
// GIVEN
OperationFlowsView operationFlowsView = createOperationFlowsView(new HashMap<>());
// WHEN
OperationView operationView = underTest.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
// THEN
assertEquals(DEFAULT_PROGRESS, operationView.getProgress());
assertEquals(OperationProgressStatus.UNKNOWN, operationView.getProgressStatus());
}
use of com.sequenceiq.flow.api.model.operation.OperationFlowsView in project cloudbreak by hortonworks.
the class OperationDetailsPopulatorTest method testCreateOperationView.
@Test
public void testCreateOperationView() {
// GIVEN
Map<String, FlowProgressResponse> flowProgressResponseMap = new HashMap<>();
flowProgressResponseMap.put(DUMMY_CLASS, createFlowProgressResponse("SUCCESSFUL", true).get());
OperationFlowsView operationFlowsView = createOperationFlowsView(flowProgressResponseMap);
// WHEN
OperationView operationView = underTest.createOperationView(operationFlowsView, OperationResource.ENVIRONMENT);
// THEN
assertEquals(MAX_PROGRESS, operationView.getProgress());
assertEquals(OperationProgressStatus.FINISHED, operationView.getProgressStatus());
}
use of com.sequenceiq.flow.api.model.operation.OperationFlowsView in project cloudbreak by hortonworks.
the class FlowOperationStatisticsService method createOperationResponse.
public Optional<OperationFlowsView> createOperationResponse(String resourceCrn, List<FlowLog> flowLogs) {
Double avgProgressTime = 0.0d;
OperationType operationType;
if (flowLogs.isEmpty()) {
operationType = OperationType.UNKNOWN;
} else {
FlowLog flowLog = flowLogs.get(0);
operationType = flowLog.getOperationType();
if (!operationType.equals(OperationType.UNKNOWN)) {
PayloadContext payloadContext = payloadContextProvider.getPayloadContext(flowLog.getResourceId());
avgProgressTime = getExpectedAverageTimeForOperation(operationType, payloadContext.getCloudPlatform());
}
}
Map<String, List<FlowLog>> flowLogsPerType = flowLogs.stream().filter(fl -> fl.getFlowType() != null).collect(groupingBy(fl -> fl.getFlowType().getName()));
Map<String, FlowProgressResponse> response = new HashMap<>();
Map<Long, String> createdMap = new TreeMap<>();
Integer progressFromHistory = DEFAULT_PROGRESS;
for (Map.Entry<String, List<FlowLog>> entry : flowLogsPerType.entrySet()) {
FlowProgressResponse progressResponse = flowProgressResponseConverter.convert(entry.getValue(), resourceCrn);
response.put(entry.getKey(), progressResponse);
createdMap.put(progressResponse.getCreated(), entry.getKey());
}
List<String> typeOrderList = new ArrayList<>(createdMap.values());
if (!createdMap.isEmpty()) {
Long operationCreated = createdMap.keySet().stream().mapToLong(v -> v).min().getAsLong();
progressFromHistory = getProgressFromHistory(avgProgressTime, operationCreated);
}
if (CollectionUtils.isEmpty(response.entrySet())) {
LOGGER.debug("Not found any historical flow data for requested resource (crn: {})", resourceCrn);
return Optional.empty();
}
return Optional.of(OperationFlowsView.Builder.newBuilder().withOperationType(operationType).withFlowTypeProgressMap(response).withTypeOrderList(typeOrderList).withProgressFromHistory(progressFromHistory).build());
}
Aggregations