Search in sources :

Example 21 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class ResizeRecoveryService method validateRecovery.

@Override
public SdxRecoverableResponse validateRecovery(SdxCluster sdxCluster, SdxRecoveryRequest request) {
    if (!entitlementService.isDatalakeResizeRecoveryEnabled(ThreadBasedUserCrnProvider.getAccountId())) {
        return new SdxRecoverableResponse("Resize Recovery entitlement not enabled", RecoveryStatus.NON_RECOVERABLE);
    }
    SdxStatusEntity actualStatusForSdx = sdxStatusService.getActualStatusForSdx(sdxCluster);
    DatalakeStatusEnum status = actualStatusForSdx.getStatus();
    String statusReason = actualStatusForSdx.getStatusReason();
    if (getOldCluster(sdxCluster).isPresent()) {
        return validateRecoveryResizedClusterPresent(sdxCluster, status, statusReason);
    }
    return validateRecoveryOnlyOriginalCluster(sdxCluster, status, statusReason);
}
Also used : DatalakeStatusEnum(com.sequenceiq.datalake.entity.DatalakeStatusEnum) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) SdxRecoverableResponse(com.sequenceiq.sdx.api.model.SdxRecoverableResponse)

Example 22 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class SdxClusterStatusCheckerJob method syncSdxStatus.

private void syncSdxStatus(JobExecutionContext context) {
    getCluster().ifPresent(sdx -> {
        StackStatusV4Response stack = cloudbreakInternalCrnClient.withInternalCrn().autoscaleEndpoint().getStatusByCrn(getRemoteResourceCrn());
        updateCertExpirationStateIfDifferent(sdx, stack);
        SdxStatusEntity sdxStatus = sdxStatusService.getActualStatusForSdx(sdx);
        DatalakeStatusEnum originalStatus = sdxStatus.getStatus();
        DatalakeStatusEnum updatedStatus = updateStatusIfNecessary(stack, sdx, sdxStatus);
        if (!Objects.equals(originalStatus, updatedStatus)) {
            logStateChange(originalStatus, updatedStatus);
            updateSyncScheduleIfNecessary(updatedStatus, sdx, context);
        }
    });
}
Also used : DatalakeStatusEnum(com.sequenceiq.datalake.entity.DatalakeStatusEnum) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) StackStatusV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)

Example 23 with SdxStatusEntity

use of com.sequenceiq.datalake.entity.SdxStatusEntity in project cloudbreak by hortonworks.

the class ResizeRecoveryService method validateRecovery.

public SdxRecoverableResponse validateRecovery(SdxCluster sdxCluster) {
    Optional<FlowLog> flowLogOptional = flow2Handler.getFirstStateLogfromLatestFlow(sdxCluster.getId());
    if (flowLogOptional.isEmpty()) {
        return new SdxRecoverableResponse("No recent actions on this cluster", RecoveryStatus.NON_RECOVERABLE);
    }
    if (entitlementService.isDatalakeResizeRecoveryEnabled(ThreadBasedUserCrnProvider.getAccountId())) {
        if (!DatalakeResizeFlowEventChainFactory.class.getSimpleName().equals(flowChainLogService.getFlowChainType(flowLogOptional.get().getFlowChainId()))) {
            return new SdxRecoverableResponse("No recent resize operation", RecoveryStatus.NON_RECOVERABLE);
        }
    } else {
        return new SdxRecoverableResponse("Resize Recovery entitlement not enabled", RecoveryStatus.NON_RECOVERABLE);
    }
    SdxStatusEntity actualStatusForSdx = sdxStatusService.getActualStatusForSdx(sdxCluster);
    switch(actualStatusForSdx.getStatus()) {
        case STOP_FAILED:
            return new SdxRecoverableResponse("Resize can be recovered from a failed stop", RecoveryStatus.RECOVERABLE);
        case PROVISIONING_FAILED:
            return new SdxRecoverableResponse("Failed to provision, recovery will restart original data lake, and delete the new one", RecoveryStatus.RECOVERABLE);
        case DATALAKE_RESTORE_FAILED:
            return new SdxRecoverableResponse("Failed to restore backup to new data lake, recovery will restart original data lake, and delete the new one", RecoveryStatus.RECOVERABLE);
        case DELETE_FAILED:
            return new SdxRecoverableResponse("Failed to delete original data lake, not a recoverable error", RecoveryStatus.NON_RECOVERABLE);
        default:
            return new SdxRecoverableResponse("Resize can not be recovered from this point", RecoveryStatus.NON_RECOVERABLE);
    }
}
Also used : FlowLog(com.sequenceiq.flow.domain.FlowLog) SdxStatusEntity(com.sequenceiq.datalake.entity.SdxStatusEntity) SdxRecoverableResponse(com.sequenceiq.sdx.api.model.SdxRecoverableResponse)

Aggregations

SdxStatusEntity (com.sequenceiq.datalake.entity.SdxStatusEntity)23 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)9 Test (org.junit.jupiter.api.Test)9 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)3 SdxClusterResponse (com.sequenceiq.sdx.api.model.SdxClusterResponse)3 StackStatusV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackStatusV4Response)2 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)2 CDPStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent)2 DatalakeStatusEnum (com.sequenceiq.datalake.entity.DatalakeStatusEnum)2 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)2 SdxRecoverableResponse (com.sequenceiq.sdx.api.model.SdxRecoverableResponse)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)1 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)1 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)1 FlowLog (com.sequenceiq.flow.domain.FlowLog)1 AllocateDatabaseServerV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.AllocateDatabaseServerV4Request)1 SslConfigV4Request (com.sequenceiq.redbeams.api.endpoint.v4.databaseserver.requests.SslConfigV4Request)1