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;
}
Aggregations