Search in sources :

Example 1 with DatalakeBackupFailedEvent

use of com.sequenceiq.datalake.flow.dr.backup.event.DatalakeBackupFailedEvent in project cloudbreak by hortonworks.

the class DatalakeFullBackupWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeFullBackupWaitRequest> event) {
    DatalakeFullBackupWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling datalake full backup status for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        sdxBackupRestoreService.waitForDatalakeDrBackupToComplete(sdxId, request.getOperationId(), request.getUserId(), pollingConfig, "Full backup");
        response = new DatalakeBackupSuccessEvent(sdxId, userId, request.getOperationId());
    } catch (UserBreakException userBreakException) {
        LOGGER.info("Full backup polling exited before timeout. Cause: ", userBreakException);
        response = new DatalakeBackupFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.info("Full backup poller stopped for cluster: {}", sdxId);
        response = new DatalakeBackupFailedEvent(sdxId, userId, new PollerStoppedException("Datalake backup timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.info("Full backup polling failed for cluster: {}", sdxId);
        response = new DatalakeBackupFailedEvent(sdxId, userId, exception);
    } catch (CloudbreakApiException exception) {
        LOGGER.info("Datalake backup failed. Reason: " + exception.getMessage());
        response = new DatalakeBackupFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : DatalakeBackupFailedEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeBackupFailedEvent) DatalakeFullBackupWaitRequest(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeFullBackupWaitRequest) UserBreakException(com.dyngr.exception.UserBreakException) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) PollerException(com.dyngr.exception.PollerException) DatalakeBackupSuccessEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeBackupSuccessEvent) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) CloudbreakApiException(com.sequenceiq.cloudbreak.exception.CloudbreakApiException) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Example 2 with DatalakeBackupFailedEvent

use of com.sequenceiq.datalake.flow.dr.backup.event.DatalakeBackupFailedEvent in project cloudbreak by hortonworks.

the class DatalakeBackupActions method backupFailed.

@Bean(name = "DATALAKE_BACKUP_FAILED_STATE")
public Action<?, ?> backupFailed() {
    return new AbstractSdxAction<>(DatalakeBackupFailedEvent.class) {

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

        @Override
        protected void doExecute(SdxContext context, DatalakeBackupFailedEvent payload, Map<Object, Object> variables) {
            Exception exception = payload.getException();
            LOGGER.error("Datalake backup failed for datalake with id: {}", payload.getResourceId(), exception);
            SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.RUNNING, ResourceEvent.DATALAKE_BACKUP_FAILED, getFailureReason(variables, exception), payload.getResourceId());
            metricService.incrementMetricCounter(MetricType.SDX_BACKUP_FAILED, sdxCluster);
            Flow flow = getFlow(context.getFlowParameters().getFlowId());
            flow.setFlowFailed(exception);
            eventSenderService.sendEventAndNotification(sdxCluster, context.getFlowTriggerUserCrn(), ResourceEvent.DATALAKE_BACKUP_FAILED, List.of(exception.getMessage()));
            sendEvent(context, DATALAKE_BACKUP_FAILURE_HANDLED_EVENT.event(), payload);
        }

        @Override
        protected Object getFailurePayload(DatalakeBackupFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) {
            return DatalakeDatabaseBackupFailedEvent.from(payload, ex);
        }
    };
}
Also used : DatalakeBackupFailedEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeBackupFailedEvent) 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) Map(java.util.Map) PollerStoppedException(com.dyngr.exception.PollerStoppedException) SdxContext(com.sequenceiq.datalake.flow.SdxContext) Flow(com.sequenceiq.flow.core.Flow) Bean(org.springframework.context.annotation.Bean)

Aggregations

PollerStoppedException (com.dyngr.exception.PollerStoppedException)2 DatalakeBackupFailedEvent (com.sequenceiq.datalake.flow.dr.backup.event.DatalakeBackupFailedEvent)2 PollerException (com.dyngr.exception.PollerException)1 UserBreakException (com.dyngr.exception.UserBreakException)1 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 CloudbreakApiException (com.sequenceiq.cloudbreak.exception.CloudbreakApiException)1 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)1 SdxContext (com.sequenceiq.datalake.flow.SdxContext)1 DatalakeBackupSuccessEvent (com.sequenceiq.datalake.flow.dr.backup.event.DatalakeBackupSuccessEvent)1 DatalakeFullBackupWaitRequest (com.sequenceiq.datalake.flow.dr.backup.event.DatalakeFullBackupWaitRequest)1 AbstractSdxAction (com.sequenceiq.datalake.service.AbstractSdxAction)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)1 Flow (com.sequenceiq.flow.core.Flow)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