use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationService method getOperationProgressByResourceCrn.
public OperationView getOperationProgressByResourceCrn(String resourceCrn, boolean detailed) {
OperationView stackOperationView = new OperationView();
try {
OperationResource operationResource = OperationResource.fromCrn(Crn.safeFromString(resourceCrn));
Optional<OperationFlowsView> operationFlowsViewOpt = flowService.getLastFlowOperationByResourceCrn(resourceCrn);
if (operationFlowsViewOpt.isPresent()) {
OperationFlowsView operationFlowsView = operationFlowsViewOpt.get();
OperationType operationType = operationFlowsView.getOperationType();
if (OperationType.PROVISION.equals(operationType)) {
stackOperationView = handleProvisionOperation(resourceCrn, operationResource, operationFlowsView, detailed);
} else {
stackOperationView = operationDetailsPopulator.createOperationView(operationFlowsView, operationResource);
}
}
} catch (Exception e) {
LOGGER.debug(String.format("Could not fetch remote database details for stack with crn %s", resourceCrn), e);
}
return stackOperationView;
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationService method handleProvisionOperation.
private OperationView handleProvisionOperation(String resourceCrn, OperationResource operationResource, OperationFlowsView operationFlowsView, boolean detailed) {
OperationView stackOperationView;
stackOperationView = operationDetailsPopulator.createOperationView(operationFlowsView, operationResource, List.of(CloudConfigValidationFlowConfig.class, KerberosConfigValidationFlowConfig.class, ExternalDatabaseCreationFlowConfig.class, StackCreationFlowConfig.class, ClusterCreationFlowConfig.class));
if (detailed && !OperationResource.DATALAKE.equals(operationResource)) {
Stack stack = stackOperations.getStackByCrn(resourceCrn);
DatabaseAvailabilityType databaseAvailabilityType = stack.getExternalDatabaseCreationType();
Map<OperationResource, OperationCondition> conditionMap = new HashMap<>();
Map<OperationResource, OperationView> subOperations = new HashMap<>();
if (!DatabaseAvailabilityType.NONE.equals(databaseAvailabilityType)) {
conditionMap.put(OperationResource.REMOTEDB, OperationCondition.REQUIRED);
subOperations.put(OperationResource.REMOTEDB, databaseService.getRemoteDatabaseOperationProgress(stack, detailed).orElse(null));
} else {
conditionMap.put(OperationResource.REMOTEDB, OperationCondition.NONE);
}
stackOperationView.setSubOperationConditions(conditionMap);
stackOperationView.setSubOperations(subOperations);
}
return stackOperationView;
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class SdxPollerProviderTest method getOperationViewWithStatus.
private OperationView getOperationViewWithStatus(OperationProgressStatus status) {
OperationView operationView = new OperationView();
operationView.setProgressStatus(status);
return operationView;
}
use of com.sequenceiq.flow.api.model.operation.OperationView 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()) {
return operationDetailsPopulator.createOperationView(operationFlowsViewOpt.get(), OperationResource.REMOTEDB);
}
return response;
}
use of com.sequenceiq.flow.api.model.operation.OperationView in project cloudbreak by hortonworks.
the class OperationServiceTest method testGetOperationProgressByResourceCrnWithDatalake.
@Test
public void testGetOperationProgressByResourceCrnWithDatalake() {
// GIVEN
ProvisionFlowEventChainFactory provisionFlowEventChainFactory = new ProvisionFlowEventChainFactory();
FlowTriggerEventQueue eventQueue = provisionFlowEventChainFactory.createFlowTriggerEventQueue(new StackEvent(null, null));
given(flowService.getLastFlowOperationByResourceCrn(anyString())).willReturn(Optional.of(operationFlowsView));
given(operationFlowsView.getOperationType()).willReturn(OperationType.PROVISION);
given(operationDetailsPopulator.createOperationView(operationFlowsView, OperationResource.DATALAKE, EXPECTED_TYPE_LIST)).willReturn(operationView);
// WHEN
OperationView result = underTest.getOperationProgressByResourceCrn(TEST_DATALAKE_CRN, true);
// THEN
assertEquals(operationView, result);
verify(operationDetailsPopulator, times(1)).createOperationView(operationFlowsView, OperationResource.DATALAKE, EXPECTED_TYPE_LIST);
// Checks that the number of provision flows are the same as in the operation check
assertEquals(eventQueue.getQueue().size(), EXPECTED_TYPE_LIST.size());
}
Aggregations