Search in sources :

Example 1 with DatabaseAvailabilityType

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType in project cloudbreak by hortonworks.

the class DatabaseAvailabilityTypeToExternalDatabaseRequestConverter method convert.

public DatabaseRequest convert(DatabaseAvailabilityType source) {
    DatabaseRequest databaseRequest = new DatabaseRequest();
    databaseRequest.setAvailabilityType(source);
    return databaseRequest;
}
Also used : DatabaseRequest(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseRequest)

Example 2 with DatabaseAvailabilityType

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType in project cloudbreak by hortonworks.

the class StartExternalDatabaseHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<StartExternalDatabaseRequest> event) {
    LOGGER.debug("In StartExternalDatabaseHandler.doAccept");
    StartExternalDatabaseRequest request = event.getData();
    Stack stack = stackService.getById(request.getResourceId());
    DatabaseAvailabilityType externalDatabase = ObjectUtils.defaultIfNull(stack.getExternalDatabaseCreationType(), DatabaseAvailabilityType.NONE);
    LOGGER.debug("External database: {} for stack {}", externalDatabase.name(), stack.getName());
    LOGGER.debug("Getting environment CRN for stack {}", stack.getName());
    DetailedEnvironmentResponse environment = environmentClientService.getByCrn(stack.getEnvironmentCrn());
    Selectable result;
    try {
        if (StackType.WORKLOAD != stack.getType()) {
            LOGGER.debug("External database start in Cloudbreak service is required for WORKLOAD stacks only.");
            result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
        } else if (externalDatabase.isEmbedded()) {
            LOGGER.info("External database for stack {} is not requested. Start is not possible.", stack.getName());
            result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
        } else if (!externalDatabaseConfig.isExternalDatabasePauseSupportedFor(CloudPlatform.valueOf(environment.getCloudPlatform()))) {
            LOGGER.debug("External database pause is not supported for '{}' cloud platform.", environment.getCloudPlatform());
            result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), null);
        } else {
            LOGGER.debug("Updating stack {} status from {} to {}", stack.getName(), stack.getStatus().name(), DetailedStackStatus.EXTERNAL_DATABASE_START_IN_PROGRESS.name());
            stackUpdaterService.updateStatus(stack.getId(), DetailedStackStatus.EXTERNAL_DATABASE_START_IN_PROGRESS, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_START_COMMANCED, "External database start in progress");
            startService.startDatabase(stack.getCluster(), externalDatabase, environment);
            LOGGER.debug("Updating stack {} status from {} to {}", stack.getName(), stack.getStatus().name(), DetailedStackStatus.EXTERNAL_DATABASE_START_FINISHED.name());
            stackUpdaterService.updateStatus(stack.getId(), DetailedStackStatus.EXTERNAL_DATABASE_START_FINISHED, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_START_FINISHED, "External database start finished");
            result = new StartExternalDatabaseResult(stack.getId(), EXTERNAL_DATABASE_STARTED_EVENT.event(), stack.getName(), stack.getCluster().getDatabaseServerCrn());
        }
    } catch (UserBreakException e) {
        LOGGER.error("Database 'start' polling exited before timeout. Cause: ", e);
        result = startFailedEvent(stack, e);
    } catch (PollerStoppedException e) {
        LOGGER.error(String.format("Database 'start' poller stopped for stack: %s", stack.getName()), e);
        result = startFailedEvent(stack, e);
    } catch (PollerException e) {
        LOGGER.error(String.format("Database 'start' polling failed for stack: %s", stack.getName()), e);
        result = startFailedEvent(stack, e);
    }
    return result;
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) StartExternalDatabaseResult(com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StartExternalDatabaseResult) PollerException(com.dyngr.exception.PollerException) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) StartExternalDatabaseRequest(com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StartExternalDatabaseRequest) PollerStoppedException(com.dyngr.exception.PollerStoppedException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) DatabaseAvailabilityType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)

Example 3 with DatabaseAvailabilityType

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType in project cloudbreak by hortonworks.

the class EmbeddedDatabaseService method isEmbeddedDatabaseOnAttachedDiskEnabled.

public boolean isEmbeddedDatabaseOnAttachedDiskEnabled(Stack stack, Cluster cluster) {
    DatabaseAvailabilityType externalDatabase = ObjectUtils.defaultIfNull(stack.getExternalDatabaseCreationType(), DatabaseAvailabilityType.NONE);
    String databaseCrn = cluster == null ? "" : cluster.getDatabaseServerCrn();
    return DatabaseAvailabilityType.NONE == externalDatabase && StringUtils.isEmpty(databaseCrn) && cloudParameterCache.isVolumeAttachmentSupported(stack.cloudPlatform());
}
Also used : DatabaseAvailabilityType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)

Example 4 with DatabaseAvailabilityType

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType 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 5 with DatabaseAvailabilityType

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType in project cloudbreak by hortonworks.

the class ExternalDatabaseToDatabaseResponseConverterTest method convert.

@ParameterizedTest
@EnumSource(DatabaseAvailabilityType.class)
void convert(DatabaseAvailabilityType source) {
    String databaseEngineVersion = "13";
    DatabaseResponse result = underTest.convert(source, databaseEngineVersion);
    assertThat(result.getAvailabilityType()).isEqualTo(source);
    assertThat(result.getDatabaseEngineVersion()).isEqualTo(databaseEngineVersion);
}
Also used : DatabaseResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseResponse) EnumSource(org.junit.jupiter.params.provider.EnumSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)9 DatabaseAvailabilityType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseAvailabilityType)6 PollerException (com.dyngr.exception.PollerException)4 PollerStoppedException (com.dyngr.exception.PollerStoppedException)4 UserBreakException (com.dyngr.exception.UserBreakException)4 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)4 DatabaseResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.database.DatabaseResponse)4 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)4 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)4 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)4 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 EnumSource (org.junit.jupiter.params.provider.EnumSource)3 DatabaseRequest (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.database.DatabaseRequest)2 CreateExternalDatabaseRequest (com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.CreateExternalDatabaseRequest)1 CreateExternalDatabaseResult (com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.CreateExternalDatabaseResult)1 StartExternalDatabaseRequest (com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StartExternalDatabaseRequest)1 StartExternalDatabaseResult (com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StartExternalDatabaseResult)1 StopExternalDatabaseRequest (com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StopExternalDatabaseRequest)1 StopExternalDatabaseResult (com.sequenceiq.cloudbreak.reactor.api.event.externaldatabase.StopExternalDatabaseResult)1