use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsFailureEvent in project cloudbreak by hortonworks.
the class StopDatabaseServerFailedActionTest method shouldUpdateStatusAndIncrementMetricOnPrepare.
@Test
public void shouldUpdateStatusAndIncrementMetricOnPrepare() {
RedbeamsFailureEvent event = new RedbeamsFailureEvent(RESOURCE_ID, exception);
Optional<DBStack> dbStackOptional = Optional.of(dbStack);
when(dbStackStatusUpdater.updateStatus(RESOURCE_ID, DetailedDBStackStatus.STOP_FAILED, null)).thenReturn(dbStackOptional);
victim.prepareExecution(event, null);
verify(metricService).incrementMetricCounter(MetricType.DB_STOP_FAILED, dbStackOptional);
}
use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsFailureEvent in project cloudbreak by hortonworks.
the class RedbeamsProvisionActions method provisionFailed.
@Bean(name = "REDBEAMS_PROVISION_FAILED_STATE")
public Action<?, ?> provisionFailed() {
return new AbstractRedbeamsProvisionAction<>(RedbeamsFailureEvent.class) {
// A lot here - some of this could go into some sort of failure handler class
// compare to core StackCreationService::handleStackCreationFailure
@Override
protected void prepareExecution(RedbeamsFailureEvent payload, Map<Object, Object> variables) {
Exception failureException = payload.getException();
LOGGER.info("Error during database stack creation flow:", failureException);
if (failureException instanceof CancellationException || ExceptionUtils.getRootCause(failureException) instanceof CancellationException) {
LOGGER.debug("The flow has been cancelled");
} else {
// StackCreationActions / StackCreationService only update status if stack isn't mid-deletion
String errorReason = failureException == null ? "Unknown error" : failureException.getMessage();
Optional<DBStack> dbStack = dbStackStatusUpdater.updateStatus(payload.getResourceId(), DetailedDBStackStatus.PROVISION_FAILED, errorReason);
metricService.incrementMetricCounter(MetricType.DB_PROVISION_FAILED, dbStack);
}
}
@Override
protected RedbeamsContext createFlowContext(FlowParameters flowParameters, StateContext<RedbeamsProvisionState, RedbeamsProvisionEvent> stateContext, RedbeamsFailureEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return super.createFlowContext(flowParameters, stateContext, payload);
}
@Override
protected Selectable createRequest(RedbeamsContext context) {
return new RedbeamsEvent(RedbeamsProvisionEvent.REDBEAMS_PROVISION_FAILURE_HANDLED_EVENT.event(), 0L);
}
};
}
use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsFailureEvent in project cloudbreak by hortonworks.
the class RedbeamsTerminationActions method failedAction.
@Bean(name = "REDBEAMS_TERMINATION_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractRedbeamsTerminationAction<>(RedbeamsFailureEvent.class, false) {
// A lot here - some of this could go into some sort of failure handler class
// compare to core StackCreationService::handleStackCreationFailure
@Override
protected void doExecute(RedbeamsContext context, RedbeamsFailureEvent payload, Map<Object, Object> variables) {
Exception failureException = payload.getException();
LOGGER.info("Error during database stack termination flow:", failureException);
if (failureException instanceof CancellationException || ExceptionUtils.getRootCause(failureException) instanceof CancellationException) {
LOGGER.debug("The flow has been cancelled");
} else {
// StackCreationActions / StackCreationService only update status if stack isn't mid-deletion
String errorReason = failureException == null ? "Unknown error" : failureException.getMessage();
Optional<DBStack> dbStack = dbStackStatusUpdater.updateStatus(payload.getResourceId(), DetailedDBStackStatus.DELETE_FAILED, errorReason);
metricService.incrementMetricCounter(MetricType.DB_TERMINATION_FAILED, dbStack);
}
sendEvent(context, REDBEAMS_TERMINATION_FAILURE_HANDLED_EVENT.event(), payload);
}
@Override
protected RedbeamsContext createFlowContext(FlowParameters flowParameters, StateContext<RedbeamsTerminationState, RedbeamsTerminationEvent> stateContext, RedbeamsFailureEvent payload) {
Flow flow = getFlow(flowParameters.getFlowId());
flow.setFlowFailed(payload.getException());
return super.createFlowContext(flowParameters, stateContext, payload);
}
@Override
protected Object getFailurePayload(RedbeamsFailureEvent payload, Optional<RedbeamsContext> flowContext, Exception ex) {
return payload;
}
};
}
use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsFailureEvent in project cloudbreak by hortonworks.
the class StartDatabaseServerFailedActionTest method shouldUpdateStatusWithUknownErrorAndIncrementMetricOnPrepare.
@Test
public void shouldUpdateStatusWithUknownErrorAndIncrementMetricOnPrepare() {
RedbeamsFailureEvent event = new RedbeamsFailureEvent(RESOURCE_ID, null);
Optional<DBStack> dbStackOptional = Optional.of(dbStack);
when(dbStackStatusUpdater.updateStatus(RESOURCE_ID, DetailedDBStackStatus.START_FAILED, "Unknown error")).thenReturn(dbStackOptional);
victim.prepareExecution(event, null);
verify(metricService).incrementMetricCounter(MetricType.DB_START_FAILED, dbStackOptional);
}
use of com.sequenceiq.redbeams.flow.redbeams.common.RedbeamsFailureEvent in project cloudbreak by hortonworks.
the class StartDatabaseServerFailedActionTest method shouldUpdateStatusAndIncrementMetricOnPrepare.
@Test
public void shouldUpdateStatusAndIncrementMetricOnPrepare() {
RedbeamsFailureEvent event = new RedbeamsFailureEvent(RESOURCE_ID, exception);
Optional<DBStack> dbStackOptional = Optional.of(dbStack);
when(dbStackStatusUpdater.updateStatus(RESOURCE_ID, DetailedDBStackStatus.START_FAILED, null)).thenReturn(dbStackOptional);
victim.prepareExecution(event, null);
verify(metricService).incrementMetricCounter(MetricType.DB_START_FAILED, dbStackOptional);
}
Aggregations