use of com.sequenceiq.datalake.flow.dr.backup.event.DatalakeBackupSuccessEvent 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;
}
use of com.sequenceiq.datalake.flow.dr.backup.event.DatalakeBackupSuccessEvent in project cloudbreak by hortonworks.
the class DatalakeBackupActions method finishedBackupAction.
@Bean(name = "DATALAKE_BACKUP_FINISHED_STATE")
public Action<?, ?> finishedBackupAction() {
return new AbstractSdxAction<>(DatalakeBackupSuccessEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatalakeBackupSuccessEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, DatalakeBackupSuccessEvent payload, Map<Object, Object> variables) {
LOGGER.info("Sdx backup is finalized with sdx id: {}", payload.getResourceId());
sendEvent(context, DATALAKE_DATABASE_BACKUP_FINALIZED_EVENT.event(), payload);
SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.RUNNING, ResourceEvent.DATALAKE_BACKUP_FINISHED, "Datalake backup finished, Datalake is running", payload.getResourceId());
eventSenderService.sendEventAndNotification(sdxCluster, context.getFlowTriggerUserCrn(), ResourceEvent.DATALAKE_BACKUP_FINISHED);
metricService.incrementMetricCounter(MetricType.SDX_BACKUP_FINISHED, sdxCluster);
}
@Override
protected Object getFailurePayload(DatalakeBackupSuccessEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return DatalakeDatabaseBackupFailedEvent.from(payload, ex);
}
};
}
Aggregations