use of com.sequenceiq.redbeams.flow.redbeams.provision.AbstractRedbeamsProvisionAction 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.provision.AbstractRedbeamsProvisionAction in project cloudbreak by hortonworks.
the class RedbeamsProvisionActions method updateDatabaseServerRegistration.
@Bean(name = "UPDATE_DATABASE_SERVER_REGISTRATION_STATE")
public Action<?, ?> updateDatabaseServerRegistration() {
return new AbstractRedbeamsProvisionAction<>(AllocateDatabaseServerSuccess.class) {
@Override
protected void doExecute(RedbeamsContext context, AllocateDatabaseServerSuccess payload, Map<Object, Object> variables) {
dbStackStatusUpdater.updateStatus(payload.getResourceId(), DetailedDBStackStatus.PROVISIONED);
List<CloudResourceStatus> dbResourcesList = dbResourceService.getAllAsCloudResourceStatus(payload.getResourceId());
sendEvent(context, new UpdateDatabaseServerRegistrationRequest(context.getCloudContext(), context.getCloudCredential(), context.getDatabaseStack(), ResourceLists.transform(dbResourcesList)));
}
};
}
Aggregations