use of com.sequenceiq.flow.core.Flow in project cloudbreak by hortonworks.
the class DatalakeRecoveryBringupActions method datalakeRecoveryBringupFailedAction.
@Bean(name = "RECOVERY_BRINGUP_FAILED_STATE")
public Action<?, ?> datalakeRecoveryBringupFailedAction() {
return new AbstractDatalakeRecoveryBringupAction<>(DatalakeRecoverySetupNewInstancesFailedEvent.class) {
@Override
protected DatalakeRecoveryBringupContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, DatalakeRecoverySetupNewInstancesFailedEvent payload) {
Exception exception = payload.getException();
Long stackId = payload.getResourceId();
Flow flow = getFlow(flowParameters.getFlowId());
StackView stackView = stackService.getViewByIdWithoutAuth(stackId);
MDCBuilder.buildMdcContext(stackView);
flow.setFlowFailed(exception);
LOGGER.error("Datalake recovery failed for stack with id: {}", stackId, exception);
return DatalakeRecoveryBringupContext.from(flowParameters, payload);
}
@Override
protected void doExecute(DatalakeRecoveryBringupContext context, DatalakeRecoverySetupNewInstancesFailedEvent payload, Map<Object, Object> variables) {
datalakeRecoveryBringupStatusService.handleDatalakeRecoveryBringupFailure(context.getStackId(), payload.getException().getMessage(), payload.getDetailedStatus());
sendEvent(context, RECOVERY_BRINGUP_FAIL_HANDLED_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.flow.core.Flow in project cloudbreak by hortonworks.
the class ClusterUpgradeActions method clusterUpgradeFailedAction.
@Bean(name = "CLUSTER_UPGRADE_FAILED_STATE")
public Action<?, ?> clusterUpgradeFailedAction() {
return new AbstractClusterUpgradeAction<>(ClusterUpgradeFailedEvent.class) {
@Value("${cb.upgrade.failure.sync.sdx.enabled}")
private boolean syncAfterFailureEnabled;
@Override
protected ClusterUpgradeContext createFlowContext(FlowParameters flowParameters, StateContext<FlowState, FlowEvent> stateContext, ClusterUpgradeFailedEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
Stack stack = stackService.getById(payload.getResourceId());
MDCBuilder.buildMdcContext(stack);
flow.setFlowFailed(payload.getException());
return ClusterUpgradeContext.from(flowParameters, payload);
}
@Override
protected void doExecute(ClusterUpgradeContext context, ClusterUpgradeFailedEvent payload, Map<Object, Object> variables) {
clusterUpgradeService.handleUpgradeClusterFailure(context.getStackId(), payload.getException().getMessage(), payload.getDetailedStatus());
if (syncAfterFailureEnabled) {
LOGGER.debug("Starting syncing parcel and CM version from CM to DB.");
try {
Set<Image> candidateImages = new HashSet<>();
Optional.ofNullable(getCurrentImage(variables)).ifPresent(si -> candidateImages.add(si.getImage()));
Optional.ofNullable(getTargetImage(variables)).ifPresent(si -> candidateImages.add(si.getImage()));
ClusterUpgradeFailedCmSyncRequest cmSyncRequest = new ClusterUpgradeFailedCmSyncRequest(payload.getResourceId(), payload.getException(), payload.getDetailedStatus(), candidateImages);
sendEvent(context, cmSyncRequest);
} catch (Exception e) {
LOGGER.warn("Error starting syncing CM version to DB, syncing skipped: ", e);
sendEvent(context, new ClusterUpgradeFailHandledRequest(payload.getResourceId(), payload.getException(), payload.getDetailedStatus()));
}
} else {
LOGGER.debug("Syncing from CM to DB is not enabled.");
sendEvent(context, new ClusterUpgradeFailHandledRequest(payload.getResourceId(), payload.getException(), payload.getDetailedStatus()));
}
}
@Override
protected Object getFailurePayload(ClusterUpgradeFailedEvent payload, Optional<ClusterUpgradeContext> flowContext, Exception ex) {
return null;
}
};
}
use of com.sequenceiq.flow.core.Flow in project cloudbreak by hortonworks.
the class ExternalDatabaseStopActions method externalDatabaseStopFailureAction.
@Bean(name = "EXTERNAL_DATABASE_STOP_FAILED_STATE")
public Action<?, ?> externalDatabaseStopFailureAction() {
return new AbstractExternalDatabaseStopAction<>(StopExternalDatabaseFailed.class) {
@Override
protected void doExecute(ExternalDatabaseContext context, StopExternalDatabaseFailed payload, Map<Object, Object> variables) {
stackUpdaterService.updateStatus(context.getStack().getId(), DetailedStackStatus.EXTERNAL_DATABASE_STOP_FAILED, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_STOP_FAILED, payload.getException().getMessage());
getMetricService().incrementMetricCounter(MetricType.EXTERNAL_DATABASE_STOP_FAILED, context.getStack());
sendEvent(context);
}
@Override
protected Selectable createRequest(ExternalDatabaseContext context) {
return new StackEvent(ExternalDatabaseStopEvent.EXTERNAL_DATABASE_STOP_FAILURE_HANDLED_EVENT.event(), context.getStack().getId());
}
@Override
protected void beforeReturnFlowContext(FlowParameters flowParameters, StateContext<ExternalDatabaseStopState, ExternalDatabaseStopEvent> stateContext, StopExternalDatabaseFailed payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
super.beforeReturnFlowContext(flowParameters, stateContext, payload);
}
};
}
use of com.sequenceiq.flow.core.Flow in project cloudbreak by hortonworks.
the class ExternalDatabaseTerminationActions method externalDatabaseTerminationFailureAction.
@Bean(name = "EXTERNAL_DATABASE_TERMINATION_FAILED_STATE")
public Action<?, ?> externalDatabaseTerminationFailureAction() {
return new AbstractExternalDatabaseTerminationAction<>(TerminateExternalDatabaseFailed.class) {
@Override
protected void doExecute(ExternalDatabaseContext context, TerminateExternalDatabaseFailed payload, Map<Object, Object> variables) {
stackUpdaterService.updateStatus(context.getStack().getId(), DetailedStackStatus.DELETE_FAILED, ResourceEvent.CLUSTER_EXTERNAL_DATABASE_DELETION_FAILED, payload.getException().getMessage());
getMetricService().incrementMetricCounter(MetricType.EXTERNAL_DATABASE_TERMINATION_FAILED, context.getStack());
sendEvent(context);
}
@Override
protected Selectable createRequest(ExternalDatabaseContext context) {
return new StackEvent(ExternalDatabaseTerminationEvent.EXTERNAL_DATABASE_TERMINATION_FAILURE_HANDLED_EVENT.event(), context.getStack().getId());
}
@Override
protected void beforeReturnFlowContext(FlowParameters flowParameters, StateContext<ExternalDatabaseTerminationState, ExternalDatabaseTerminationEvent> stateContext, TerminateExternalDatabaseFailed payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
super.beforeReturnFlowContext(flowParameters, stateContext, payload);
}
};
}
use of com.sequenceiq.flow.core.Flow in project cloudbreak by hortonworks.
the class CloudConfigValidationActions method cloudConfigValidationFailureAction.
@Bean(name = "VALIDATE_CLOUD_CONFIG_FAILED_STATE")
public Action<?, ?> cloudConfigValidationFailureAction() {
return new AbstractStackFailureAction<CloudConfigValidationState, CloudConfigValidationEvent>() {
@Override
protected StackFailureContext createFlowContext(FlowParameters flowParameters, StateContext<CloudConfigValidationState, CloudConfigValidationEvent> stateContext, StackFailureEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
StackView stackView = stackViewService.findById(payload.getResourceId()).get();
MDCBuilder.buildMdcContext(stackView);
flow.setFlowFailed(payload.getException());
return new StackFailureContext(flowParameters, stackView);
}
@Override
protected void doExecute(StackFailureContext context, StackFailureEvent payload, Map<Object, Object> variables) {
String statusReason = payload.getException().getMessage();
stackUpdaterService.updateStatusAndSendEventWithArgs(context.getStackView().getId(), DetailedStackStatus.PROVISION_FAILED, ResourceEvent.CLOUD_CONFIG_VALIDATION_FAILED, statusReason, statusReason);
sendEvent(context);
}
@Override
protected Selectable createRequest(StackFailureContext context) {
return new StackEvent(CloudConfigValidationEvent.VALIDATE_CLOUD_CONFIG_FAILURE_HANDLED_EVENT.selector(), context.getStackView().getId());
}
};
}
Aggregations