use of com.sequenceiq.datalake.flow.delete.event.RdsDeletionSuccessEvent 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;
}
use of com.sequenceiq.datalake.flow.delete.event.RdsDeletionSuccessEvent in project cloudbreak by hortonworks.
the class SdxDeleteActions method finishedAction.
@Bean(name = "SDX_DELETION_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractSdxAction<>(RdsDeletionSuccessEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, RdsDeletionSuccessEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, RdsDeletionSuccessEvent payload, Map<Object, Object> variables) throws Exception {
Long datalakeId = payload.getResourceId();
LOGGER.info("Datalake delete finalized: {}", datalakeId);
SdxCluster sdxCluster = sdxService.getById(datalakeId);
if (sdxCluster != null) {
metricService.incrementMetricCounter(MetricType.SDX_DELETION_FINISHED, sdxCluster);
}
eventSenderService.notifyEvent(context, ResourceEvent.SDX_CLUSTER_DELETION_FINISHED);
sendEvent(context, SDX_DELETE_FINALIZED_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(RdsDeletionSuccessEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return null;
}
};
}
Aggregations