use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvCreationActions method failedAction.
@Bean(name = "ENV_CREATION_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractEnvironmentCreationAction<>(EnvCreationFailureEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvCreationFailureEvent payload, Map<Object, Object> variables) {
Exception exception = payload.getException();
LOGGER.debug("Failed to create environment {} with payload {}", exception, payload);
environmentService.findEnvironmentById(payload.getResourceId()).ifPresentOrElse(environment -> {
environment.setStatusReason(exception.getMessage());
environment.setStatus(EnvironmentStatus.CREATE_FAILED);
environmentService.save(environment);
EnvironmentDto environmentDto = environmentService.getEnvironmentDto(environment);
metricService.incrementMetricCounter(MetricType.ENV_CREATION_FAILED, environmentDto, exception);
eventService.sendEventAndNotification(environmentDto, context.getFlowTriggerUserCrn(), ENVIRONMENT_CREATION_FAILED);
}, () -> LOGGER.error("Cannot finish the creation of env, because the environment does not exist: {}. " + "But the flow will continue, how can this happen?", payload.getResourceId()));
LOGGER.info("Flow entered into ENV_CREATION_FAILED_STATE");
sendEvent(context, HANDLED_FAILED_ENV_CREATION_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvDeleteActions method umsResourceDeleteAction.
@Bean(name = "UMS_RESOURCE_DELETE_STARTED_STATE")
public Action<?, ?> umsResourceDeleteAction() {
return new AbstractEnvDeleteAction<>(EnvDeleteEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.UMS_RESOURCE_DELETE_IN_PROGRESS, ResourceEvent.ENVIRONMENT_UMS_RESOURCE_DELETION_STARTED, EnvDeleteState.UMS_RESOURCE_DELETE_STARTED_STATE);
EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(envDto).withForceDelete(payload.isForceDelete()).withId(payload.getResourceId()).build();
sendEvent(context, DELETE_UMS_RESOURCE_EVENT.selector(), environmentDeletionDto);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvDeleteActions method rdbmsDeleteAction.
@Bean(name = "RDBMS_DELETE_STARTED_STATE")
public Action<?, ?> rdbmsDeleteAction() {
return new AbstractEnvDeleteAction<>(EnvDeleteEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.RDBMS_DELETE_IN_PROGRESS, ResourceEvent.ENVIRONMENT_DATABASE_DELETION_STARTED, EnvDeleteState.RDBMS_DELETE_STARTED_STATE);
EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(envDto).withForceDelete(payload.isForceDelete()).withId(payload.getResourceId()).build();
sendEvent(context, DELETE_RDBMS_EVENT.selector(), environmentDeletionDto);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvDeleteActions method resourceEncryptionDeleteAction.
@Bean(name = "ENVIRONMENT_RESOURCE_ENCRYPTION_DELETE_STARTED_STATE")
public Action<?, ?> resourceEncryptionDeleteAction() {
return new AbstractEnvDeleteAction<>(EnvDeleteEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.ENVIRONMENT_RESOURCE_ENCRYPTION_DELETE_IN_PROGRESS, ResourceEvent.ENVIRONMENT_RESOURCE_ENCRYPTION_DELETION_STARTED, EnvDeleteState.ENVIRONMENT_RESOURCE_ENCRYPTION_DELETE_STARTED_STATE);
EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(envDto).withForceDelete(payload.isForceDelete()).withId(payload.getResourceId()).build();
sendEvent(context, DELETE_ENVIRONMENT_RESOURCE_ENCRYPTION_EVENT.selector(), environmentDeletionDto);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvDeleteActions method idbmmsDeleteAction.
@Bean(name = "IDBROKER_MAPPINGS_DELETE_STARTED_STATE")
public Action<?, ?> idbmmsDeleteAction() {
return new AbstractEnvDeleteAction<>(EnvDeleteEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.IDBROKER_MAPPINGS_DELETE_IN_PROGRESS, ResourceEvent.ENVIRONMENT_IDBROKER_MAPPINGS_DELETION_STARTED, EnvDeleteState.IDBROKER_MAPPINGS_DELETE_STARTED_STATE);
EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(envDto).withForceDelete(payload.isForceDelete()).withId(payload.getResourceId()).build();
sendEvent(context, DELETE_IDBROKER_MAPPINGS_EVENT.selector(), environmentDeletionDto);
}
};
}
Aggregations