Search in sources :

Example 1 with DatalakeFullRestoreInProgressEvent

use of com.sequenceiq.datalake.flow.dr.restore.event.DatalakeFullRestoreInProgressEvent in project cloudbreak by hortonworks.

the class DatalakeDatabaseRestoreWaitHandler method doAccept.

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