use of com.sequenceiq.datalake.flow.detach.event.SdxStartDetachRecoveryEvent in project cloudbreak by hortonworks.
the class SdxDetachRecoveryActions method sdxDetachRecoveryAction.
@Bean(name = "SDX_DETACH_RECOVERY_STATE")
public Action<?, ?> sdxDetachRecoveryAction() {
return new AbstractSdxAction<>(SdxStartDetachRecoveryEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxStartDetachRecoveryEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxStartDetachRecoveryEvent payload, Map<Object, Object> variables) throws Exception {
SdxCluster clusterToReattach = sdxService.getById(payload.getResourceId());
clusterToReattach = sdxAttachService.reattachDetachedSdxCluster(clusterToReattach);
LOGGER.info("Successfully restored detached SDX with ID {}.", clusterToReattach.getId());
sendEvent(context, SDX_DETACH_RECOVERY_SUCCESS_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(SdxStartDetachRecoveryEvent payload, Optional<SdxContext> flowContext, Exception e) {
LOGGER.error("Failed to recover from detach of SDX with ID {}.", payload.getResourceId());
return SdxDetachRecoveryFailedEvent.from(payload, e);
}
};
}
Aggregations