Search in sources :

Example 1 with SdxDatabaseRestoreStatusResponse

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

the class SdxBackupRestoreService method getDatabaseRestoreStatus.

public SdxDatabaseRestoreStatusResponse getDatabaseRestoreStatus(SdxCluster sdxCluster, String operationId) {
    MDCBuilder.buildMdcContext(sdxCluster);
    SdxOperation drStatus = getDatabaseDrStatus(sdxCluster, operationId, SdxOperationType.RESTORE);
    return new SdxDatabaseRestoreStatusResponse(convertSdxDatabaseDrStatus(drStatus.getStatus()), drStatus.getStatusReason());
}
Also used : SdxOperation(com.sequenceiq.datalake.entity.operation.SdxOperation) SdxDatabaseRestoreStatusResponse(com.sequenceiq.sdx.api.model.SdxDatabaseRestoreStatusResponse)

Example 2 with SdxDatabaseRestoreStatusResponse

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

the class DatalakeRestoreActions method datalakeFullResoreInProgress.

@Bean(name = "DATALAKE_FULL_RESTORE_IN_PROGRESS_STATE")
public Action<?, ?> datalakeFullResoreInProgress() {
    return new AbstractSdxAction<>(SdxEvent.class) {

        @Override
        protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxEvent payload) {
            return SdxContext.from(flowParameters, payload);
        }

        @Override
        protected void doExecute(SdxContext context, SdxEvent payload, Map<Object, Object> variables) {
            LOGGER.info("Full datalake restore is in progress for {} ", payload.getResourceId());
            String operationId = (String) variables.get(OPERATION_ID);
            String restoreId = (String) variables.get(RESTORE_ID);
            SdxCluster sdxCluster = sdxService.getById(payload.getResourceId());
            SdxDatabaseRestoreStatusResponse restoreStatusResponse = sdxBackupRestoreService.getDatabaseRestoreStatus(sdxCluster, operationId);
            if (restoreStatusResponse.getStatus().equals(DatalakeDatabaseDrStatus.INPROGRESS)) {
                sdxBackupRestoreService.updateDatabaseStatusEntry(operationId, SdxOperationStatus.SUCCEEDED, null);
            }
            sendEvent(context, DatalakeFullRestoreWaitRequest.from(context, restoreId));
        }

        @Override
        protected Object getFailurePayload(SdxEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return DatalakeRestoreFailedEvent.from(flowContext, payload, ex);
        }
    };
}
Also used : FlowParameters(com.sequenceiq.flow.core.FlowParameters) AbstractSdxAction(com.sequenceiq.datalake.service.AbstractSdxAction) Optional(java.util.Optional) StateContext(org.springframework.statemachine.StateContext) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) SdxEvent(com.sequenceiq.datalake.flow.SdxEvent) SdxDatabaseRestoreStatusResponse(com.sequenceiq.sdx.api.model.SdxDatabaseRestoreStatusResponse) Map(java.util.Map) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Bean(org.springframework.context.annotation.Bean)

Aggregations

SdxDatabaseRestoreStatusResponse (com.sequenceiq.sdx.api.model.SdxDatabaseRestoreStatusResponse)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 SdxOperation (com.sequenceiq.datalake.entity.operation.SdxOperation)1 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 SdxEvent (com.sequenceiq.datalake.flow.SdxEvent)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)1 FlowParameters (com.sequenceiq.flow.core.FlowParameters)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Bean (org.springframework.context.annotation.Bean)1 StateContext (org.springframework.statemachine.StateContext)1