Search in sources :

Example 16 with SdxRecoverableResponse

use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse 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 17 with SdxRecoverableResponse

use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse in project cloudbreak by hortonworks.

the class SdxUpgradeRecoveryService method validateRecovery.

public SdxRecoverableResponse validateRecovery(SdxCluster sdxCluster) {
    MDCBuilder.buildMdcContext(sdxCluster);
    try {
        String initiatorUserCrn = ThreadBasedUserCrnProvider.getUserCrn();
        RecoveryValidationV4Response response = ThreadBasedUserCrnProvider.doAsInternalActor(() -> stackV4Endpoint.getClusterRecoverableByNameInternal(0L, sdxCluster.getClusterName(), initiatorUserCrn));
        return new SdxRecoverableResponse(response.getReason(), response.getStatus());
    } catch (WebApplicationException e) {
        String exceptionMessage = exceptionMessageExtractor.getErrorMessage(e);
        String message = String.format("Stack recovery validation failed on cluster: [%s]. Message: [%s]", sdxCluster.getClusterName(), exceptionMessage);
        throw new CloudbreakApiException(message, e);
    }
}
Also used : RecoveryValidationV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response) WebApplicationException(javax.ws.rs.WebApplicationException) SdxRecoverableResponse(com.sequenceiq.sdx.api.model.SdxRecoverableResponse) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException)

Example 18 with SdxRecoverableResponse

use of com.sequenceiq.sdx.api.model.SdxRecoverableResponse 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

SdxRecoverableResponse (com.sequenceiq.sdx.api.model.SdxRecoverableResponse)18 Test (org.junit.jupiter.api.Test)6 RecoveryValidationV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.recovery.RecoveryValidationV4Response)5 Test (org.junit.Test)4 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)3 com.cloudera.thunderhead.service.datalakedr.datalakeDRProto (com.cloudera.thunderhead.service.datalakedr.datalakeDRProto)2 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)2 SdxStatusEntity (com.sequenceiq.datalake.entity.SdxStatusEntity)2 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)2 SdxRecoveryResponse (com.sequenceiq.sdx.api.model.SdxRecoveryResponse)2 ArrayList (java.util.ArrayList)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 DatalakeStatusEnum (com.sequenceiq.datalake.entity.DatalakeStatusEnum)1 FlowLog (com.sequenceiq.flow.domain.FlowLog)1 SdxRecoveryRequest (com.sequenceiq.sdx.api.model.SdxRecoveryRequest)1