use of com.sequenceiq.datalake.flow.stop.event.RdsStopSuccessEvent in project cloudbreak by hortonworks.
the class RdsStopHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<RdsWaitingToStopRequest> event) {
RdsWaitingToStopRequest rdsWaitRequest = event.getData();
Long sdxId = rdsWaitRequest.getResourceId();
String userId = rdsWaitRequest.getUserId();
Selectable response;
try {
sdxClusterRepository.findById(sdxId).ifPresent(sdxCluster -> {
if (databasePauseSupportService.isDatabasePauseSupported(sdxCluster)) {
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.EXTERNAL_DATABASE_STOP_IN_PROGRESS, "External database stop in progress", sdxCluster);
LOGGER.debug("stop polling database stop for sdx: {}", sdxId);
databaseService.stop(sdxCluster);
} else {
LOGGER.debug("skipping stop of database for sdx: {}", sdxId);
}
sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.EXTERNAL_DATABASE_STOPPED, "External database stopped", sdxCluster);
});
response = new RdsStopSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Database polling exited before timeout. Cause: ", userBreakException);
response = new SdxStopFailedEvent(sdxId, userId, userBreakException);
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Database poller stopped for sdx: {}", sdxId, pollerStoppedException);
response = new SdxStopFailedEvent(sdxId, userId, new PollerStoppedException("Database stop timed out after " + durationInMinutes + " minutes"));
} catch (PollerException exception) {
LOGGER.error("Database polling failed for sdx: {}", sdxId, exception);
response = new SdxStopFailedEvent(sdxId, userId, exception);
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in sdx database stop wait phase", anotherException);
response = new SdxStopFailedEvent(sdxId, userId, anotherException);
}
return response;
}
Aggregations