use of com.sequenceiq.datalake.flow.delete.event.RdsDeletionWaitRequest in project cloudbreak by hortonworks.
the class RdsDeletionHandler method doAccept.
@Override
protected Selectable doAccept(HandlerEvent<RdsDeletionWaitRequest> event) {
RdsDeletionWaitRequest rdsWaitRequest = event.getData();
Long sdxId = rdsWaitRequest.getResourceId();
String userId = rdsWaitRequest.getUserId();
Selectable response;
try {
sdxClusterRepository.findById(sdxId).ifPresent(sdxCluster -> {
if (sdxCluster.hasExternalDatabase() && StringUtils.isNotEmpty(sdxCluster.getDatabaseCrn())) {
LOGGER.debug("start polling database termination for sdx: {}", sdxId);
databaseService.terminate(sdxCluster, rdsWaitRequest.isForced());
} else {
LOGGER.debug("skipping deletion of database for sdx: {}", sdxId);
}
setDeletedStatus(sdxCluster);
});
response = new RdsDeletionSuccessEvent(sdxId, userId);
} catch (UserBreakException userBreakException) {
LOGGER.error("Database polling exited before timeout. Cause: ", userBreakException);
response = new SdxDeletionFailedEvent(sdxId, userId, userBreakException, rdsWaitRequest.isForced());
} catch (PollerStoppedException pollerStoppedException) {
LOGGER.error("Database poller stopped for sdx: {}", sdxId, pollerStoppedException);
response = new SdxDeletionFailedEvent(sdxId, userId, new PollerStoppedException("Database deletion timed out after " + durationInMinutes + " minutes"), rdsWaitRequest.isForced());
} catch (PollerException exception) {
LOGGER.error("Database polling failed for sdx: {}", sdxId, exception);
response = new SdxDeletionFailedEvent(sdxId, userId, exception, rdsWaitRequest.isForced());
} catch (Exception anotherException) {
LOGGER.error("Something wrong happened in sdx database deletion wait phase", anotherException);
response = new SdxDeletionFailedEvent(sdxId, userId, anotherException, rdsWaitRequest.isForced());
}
return response;
}
Aggregations