use of com.sequenceiq.datalake.service.sdx.status.DatalakeStatusUpdateException in project cloudbreak by hortonworks.
the class SdxCreateActions method failedAction.
@Bean(name = "SDX_CREATION_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractSdxAction<>(SdxCreateFailedEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxCreateFailedEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxCreateFailedEvent payload, Map<Object, Object> variables) throws Exception {
Exception exception = payload.getException();
String statusReason = "Datalake creation failed";
String errorMessage = webApplicationExceptionMessageExtractor.getErrorMessage(exception);
if (StringUtils.hasText(errorMessage)) {
statusReason = statusReason + ". " + errorMessage;
} else if (exception.getMessage() != null) {
statusReason = statusReason + ". " + exception.getMessage();
}
LOGGER.error(statusReason, exception);
try {
SdxCluster sdxCluster = sdxStatusService.setStatusForDatalakeAndNotify(DatalakeStatusEnum.PROVISIONING_FAILED, statusReason, payload.getResourceId());
metricService.incrementMetricCounter(MetricType.SDX_CREATION_FAILED, sdxCluster);
eventSenderService.notifyEvent(context, ResourceEvent.SDX_CLUSTER_CREATION_FAILED);
} catch (NotFoundException notFoundException) {
LOGGER.info("Can not set status to SDX_CREATION_FAILED because data lake was not found");
} catch (DatalakeStatusUpdateException datalakeStatusUpdateException) {
LOGGER.info("Status update for data lake failed (possible reason: ongoing parallel deletion flow): {}", exception.getMessage());
}
Flow flow = getFlow(context.getFlowParameters().getFlowId());
flow.setFlowFailed(payload.getException());
sendEvent(context, SDX_CREATE_FAILED_HANDLED_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(SdxCreateFailedEvent payload, Optional<SdxContext> flowContext, Exception ex) {
return null;
}
};
}
Aggregations