Search in sources :

Example 1 with OperationCondition

use of com.sequenceiq.flow.api.model.operation.OperationCondition 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;
}
Also used : OperationCondition(com.sequenceiq.flow.api.model.operation.OperationCondition) HashMap(java.util.HashMap) OperationView(com.sequenceiq.flow.api.model.operation.OperationView) OperationResource(com.sequenceiq.flow.api.model.operation.OperationResource) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) DatabaseAvailabilityType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)

Example 2 with OperationCondition

use of com.sequenceiq.flow.api.model.operation.OperationCondition in project cloudbreak by hortonworks.

the class OperationService method handleProvisionOperation.

private void handleProvisionOperation(String resourceCrn, OperationView sdxOperationView, boolean detailed) {
    String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
    SdxCluster sdxCluster = sdxService.getByCrn(userCrn, resourceCrn);
    boolean createDb = sdxCluster.isCreateDatabase();
    Map<OperationResource, OperationView> subOperations = new HashMap<>();
    Map<OperationResource, OperationCondition> conditionMap = new HashMap<>();
    conditionMap.put(OperationResource.DATALAKE, OperationCondition.REQUIRED);
    if (createDb) {
        conditionMap.put(OperationResource.REMOTEDB, OperationCondition.REQUIRED);
        try {
            OperationView rdbOperationView = databaseService.getOperationProgressStatus(sdxCluster.getDatabaseCrn(), detailed);
            if (OperationType.PROVISION.equals(rdbOperationView.getOperationType())) {
                subOperations.put(OperationResource.REMOTEDB, rdbOperationView);
            }
        } catch (Exception e) {
            LOGGER.warn("Error during fetching provision progress from remote database API. Skip filling remote database response.", e);
        }
    } else {
        conditionMap.put(OperationResource.REMOTEDB, OperationCondition.NONE);
    }
    sdxOperationView.setSubOperationConditions(conditionMap);
    try {
        OperationView stackOperationProgressView = operationV4Endpoint.getOperationProgressByResourceCrn(resourceCrn, detailed);
        if (OperationType.PROVISION.equals(stackOperationProgressView.getOperationType())) {
            subOperations.put(OperationResource.DATALAKE, stackOperationProgressView);
        }
    } catch (Exception e) {
        LOGGER.warn("Error during fetching provision progress from stack API. Skip filling stack progress response.", e);
    }
    sdxOperationView.setSubOperations(subOperations);
}
Also used : OperationCondition(com.sequenceiq.flow.api.model.operation.OperationCondition) HashMap(java.util.HashMap) OperationView(com.sequenceiq.flow.api.model.operation.OperationView) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) OperationResource(com.sequenceiq.flow.api.model.operation.OperationResource)

Aggregations

OperationCondition (com.sequenceiq.flow.api.model.operation.OperationCondition)2 OperationResource (com.sequenceiq.flow.api.model.operation.OperationResource)2 OperationView (com.sequenceiq.flow.api.model.operation.OperationView)2 HashMap (java.util.HashMap)2 DatabaseAvailabilityType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1