Search in sources :

Example 1 with DatalakeFullBackupInProgressEvent

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

the class DatalakeDatabaseBackupWaitHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<DatalakeDatabaseBackupWaitRequest> event) {
    DatalakeDatabaseBackupWaitRequest request = event.getData();
    Long sdxId = request.getResourceId();
    String userId = request.getUserId();
    Selectable response;
    try {
        LOGGER.info("Start polling datalake database backup  for id: {}", sdxId);
        PollingConfig pollingConfig = new PollingConfig(sleepTimeInSec, TimeUnit.SECONDS, durationInMinutes, TimeUnit.MINUTES);
        sdxBackupRestoreService.waitCloudbreakFlow(sdxId, pollingConfig, "Database backup");
        response = new DatalakeFullBackupInProgressEvent(sdxId, userId, request.getOperationId());
    } catch (UserBreakException userBreakException) {
        LOGGER.info("Database backup polling exited before timeout. Cause: ", userBreakException);
        sdxBackupRestoreService.updateDatabaseStatusEntry(event.getData().getOperationId(), SdxOperationStatus.FAILED, userBreakException.getLocalizedMessage());
        response = new DatalakeDatabaseBackupFailedEvent(sdxId, userId, userBreakException);
    } catch (PollerStoppedException pollerStoppedException) {
        LOGGER.info("Database backup poller stopped for cluster: {}", sdxId);
        sdxBackupRestoreService.updateDatabaseStatusEntry(event.getData().getOperationId(), SdxOperationStatus.FAILED, pollerStoppedException.getLocalizedMessage());
        response = new DatalakeDatabaseBackupFailedEvent(sdxId, userId, new PollerStoppedException("Database backup timed out after " + durationInMinutes + " minutes"));
    } catch (PollerException exception) {
        LOGGER.info("Database backup polling failed for cluster: {}", sdxId);
        sdxBackupRestoreService.updateDatabaseStatusEntry(event.getData().getOperationId(), SdxOperationStatus.FAILED, exception.getLocalizedMessage());
        response = new DatalakeDatabaseBackupFailedEvent(sdxId, userId, exception);
    }
    return response;
}
Also used : DatalakeDatabaseBackupWaitRequest(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeDatabaseBackupWaitRequest) UserBreakException(com.dyngr.exception.UserBreakException) DatalakeFullBackupInProgressEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeFullBackupInProgressEvent) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) DatalakeDatabaseBackupFailedEvent(com.sequenceiq.datalake.flow.dr.backup.event.DatalakeDatabaseBackupFailedEvent) PollerException(com.dyngr.exception.PollerException) PollingConfig(com.sequenceiq.datalake.service.sdx.PollingConfig) PollerStoppedException(com.dyngr.exception.PollerStoppedException)

Aggregations

PollerException (com.dyngr.exception.PollerException)1 PollerStoppedException (com.dyngr.exception.PollerStoppedException)1 UserBreakException (com.dyngr.exception.UserBreakException)1 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)1 DatalakeDatabaseBackupFailedEvent (com.sequenceiq.datalake.flow.dr.backup.event.DatalakeDatabaseBackupFailedEvent)1 DatalakeDatabaseBackupWaitRequest (com.sequenceiq.datalake.flow.dr.backup.event.DatalakeDatabaseBackupWaitRequest)1 DatalakeFullBackupInProgressEvent (com.sequenceiq.datalake.flow.dr.backup.event.DatalakeFullBackupInProgressEvent)1 PollingConfig (com.sequenceiq.datalake.service.sdx.PollingConfig)1