use of com.sequenceiq.datalake.flow.dr.restore.event.DatalakeDatabaseRestoreFailedEvent 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;
}
use of com.sequenceiq.datalake.flow.dr.restore.event.DatalakeDatabaseRestoreFailedEvent in project cloudbreak by hortonworks.
the class DatalakeRestoreActions method databaseRestoreFailed.
@Bean(name = "DATALAKE_DATABASE_RESTORE_FAILED_STATE")
public Action<?, ?> databaseRestoreFailed() {
return new AbstractSdxAction<>(DatalakeDatabaseRestoreFailedEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatalakeDatabaseRestoreFailedEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, DatalakeDatabaseRestoreFailedEvent payload, Map<Object, Object> variables) {
Exception exception = payload.getException();
LOGGER.error("Datalake database restore could not be started for datalake with id: {}", payload.getResourceId(), exception);
String operationId = (String) variables.get(OPERATION_ID);
sdxBackupRestoreService.updateDatabaseStatusEntry(operationId, SdxOperationStatus.FAILED, exception.getLocalizedMessage());
Flow flow = getFlow(context.getFlowParameters().getFlowId());
flow.setFlowFailed(payload.getException());
sendEvent(context, DATALAKE_DATABASE_RESTORE_FAILURE_HANDLED_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(DatalakeDatabaseRestoreFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return DatalakeDatabaseRestoreFailedEvent.from(payload, ex);
}
};
}
Aggregations