use of com.sequenceiq.datalake.flow.detach.event.SdxDetachFailedEvent in project cloudbreak by hortonworks.
the class SdxDetachActions method sdxAttachNewClusterFailedAction.
@Bean(name = "SDX_ATTACH_NEW_CLUSTER_FAILED_STATE")
public Action<?, ?> sdxAttachNewClusterFailedAction() {
return new AbstractSdxAction<>(SdxDetachFailedEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxDetachFailedEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxDetachFailedEvent payload, Map<Object, Object> variables) throws Exception {
SdxCluster clusterToReattach = (SdxCluster) variables.get(DETACHED_SDX);
clusterToReattach = sdxAttachService.reattachDetachedSdxCluster(clusterToReattach);
LOGGER.info("Successfully restored detached SDX with ID {}.", clusterToReattach.getId());
sendEvent(context, SDX_DETACH_FAILED_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(SdxDetachFailedEvent payload, Optional<SdxContext> flowContext, Exception e) {
LOGGER.error("Failed to recover from detach of SDX with ID {}.", payload.getResourceId());
return payload;
}
};
}
use of com.sequenceiq.datalake.flow.detach.event.SdxDetachFailedEvent in project cloudbreak by hortonworks.
the class SdxDetachActions method sdxDetachExternalDBFailedAction.
@Bean(name = "SDX_DETACH_EXTERNAL_DB_FAILED_STATE")
public Action<?, ?> sdxDetachExternalDBFailedAction() {
return new AbstractSdxAction<>(SdxDetachFailedEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxDetachFailedEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxDetachFailedEvent payload, Map<Object, Object> variables) {
if (!((boolean) variables.get(IS_DETACH_DURING_RECOVERY))) {
SdxCluster detached = (SdxCluster) variables.get(DETACHED_SDX);
LOGGER.error("Failed to detach external DB of SDX with ID: {}. Attempting to restore it.", detached.getId());
String detachedName = detached.getClusterName();
SdxCluster reattached = sdxAttachService.reattachCluster(detached);
sdxAttachService.reattachStack(reattached, detachedName);
LOGGER.info("Successfully restored detached SDX with ID {} which failed to detach its external database.", reattached.getId());
}
sendEvent(context, SDX_DETACH_FAILED_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(SdxDetachFailedEvent payload, Optional<SdxContext> flowContext, Exception e) {
LOGGER.error("Failed to reattach SDX with ID {} which failed to detach its external database.", payload.getResourceId());
return payload;
}
};
}
use of com.sequenceiq.datalake.flow.detach.event.SdxDetachFailedEvent in project cloudbreak by hortonworks.
the class SdxDetachActions method sdxDetachStackFailedAction.
@Bean(name = "SDX_DETACH_STACK_FAILED_STATE")
public Action<?, ?> sdxDetachStackFailedAction() {
return new AbstractSdxAction<>(SdxDetachFailedEvent.class) {
@Override
protected SdxContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, SdxDetachFailedEvent payload) {
return SdxContext.from(flowParameters, payload);
}
@Override
protected void doExecute(SdxContext context, SdxDetachFailedEvent payload, Map<Object, Object> variables) {
if (!((boolean) variables.get(IS_DETACH_DURING_RECOVERY))) {
SdxCluster clusterToReattach = (SdxCluster) variables.get(DETACHED_SDX);
LOGGER.error("Failed to detach stack of SDX with ID: {}. Attempting to restore it.", clusterToReattach.getId());
clusterToReattach = sdxAttachService.reattachCluster(clusterToReattach);
LOGGER.info("Successfully restored detached SDX with ID {} which failed to detach its stack.", clusterToReattach.getId());
}
sendEvent(context, SDX_DETACH_FAILED_EVENT.event(), payload);
}
@Override
protected Object getFailurePayload(SdxDetachFailedEvent payload, Optional<SdxContext> flowContext, Exception e) {
LOGGER.error("Failed to reattach SDX with ID {} which failed to detach its stack.", payload.getResourceId());
return payload;
}
};
}
Aggregations