Search in sources :

Example 1 with EnvStackConfigUpdatesFailedEvent

use of com.sequenceiq.environment.environment.flow.config.update.event.EnvStackConfigUpdatesFailedEvent in project cloudbreak by hortonworks.

the class EnvStackConfigUpdatesActions method failedAction.

@Bean(name = "STACK_CONFIG_UPDATES_FAILED_STATE")
public Action<?, ?> failedAction() {
    return new AbstractEnvStackConfigUpdatesAction<>(EnvStackConfigUpdatesFailedEvent.class) {

        @Override
        protected void doExecute(CommonContext context, EnvStackConfigUpdatesFailedEvent payload, Map<Object, Object> variables) {
            LOGGER.warn(String.format("Failed to update environments stack configs '%s'. Status: '%s'.", payload.getEnvironmentDto(), payload.getEnvironmentStatus()), payload.getException());
            EnvironmentDto environmentDto = environmentStatusUpdateService.updateFailedEnvironmentStatusAndNotify(context, payload, getCurrentStatus(payload.getResourceId()), ResourceEvent.ENVIRONMENT_STACK_CONFIGS_UPDATE_FAILED, EnvStackConfigUpdatesState.STACK_CONFIG_UPDATES_FAILED_STATE);
            metricService.incrementMetricCounter(MetricType.ENV_STACK_CONFIG_UPDATE_FAILED, environmentDto, payload.getException());
            sendEvent(context, HANDLE_FAILED_ENV_STACK_CONIFG_UPDATES_EVENT.event(), payload);
        }
    };
}
Also used : EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) EnvStackConfigUpdatesFailedEvent(com.sequenceiq.environment.environment.flow.config.update.event.EnvStackConfigUpdatesFailedEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 2 with EnvStackConfigUpdatesFailedEvent

use of com.sequenceiq.environment.environment.flow.config.update.event.EnvStackConfigUpdatesFailedEvent in project cloudbreak by hortonworks.

the class StackConfigUpdatesHandler method accept.

@Override
public void accept(Event<EnvironmentDto> event) {
    try {
        stackPollerService.updateStackConfigurations(event.getData().getResourceId(), event.getData().getResourceCrn(), event.getHeaders().get(FlowConstants.FLOW_ID));
        EnvStackConfigUpdatesEvent envStackConfigUpdatesEvent = EnvStackConfigUpdatesEventBuilder.anEnvStackConfigUpdatesEvent().withSelector(EnvStackConfigUpdatesStateSelectors.FINISH_ENV_STACK_CONFIG_UPDATES_EVENT.selector()).withResourceId(event.getData().getResourceId()).build();
        eventSender().sendEvent(envStackConfigUpdatesEvent, event.getHeaders());
    } catch (Exception e) {
        eventSender().sendEvent(new EnvStackConfigUpdatesFailedEvent(event.getData(), e, null), event.getHeaders());
    }
}
Also used : EnvStackConfigUpdatesFailedEvent(com.sequenceiq.environment.environment.flow.config.update.event.EnvStackConfigUpdatesFailedEvent) EnvStackConfigUpdatesEvent(com.sequenceiq.environment.environment.flow.config.update.event.EnvStackConfigUpdatesEvent)

Aggregations

EnvStackConfigUpdatesFailedEvent (com.sequenceiq.environment.environment.flow.config.update.event.EnvStackConfigUpdatesFailedEvent)2 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)1 EnvStackConfigUpdatesEvent (com.sequenceiq.environment.environment.flow.config.update.event.EnvStackConfigUpdatesEvent)1 CommonContext (com.sequenceiq.flow.core.CommonContext)1 Map (java.util.Map)1 Bean (org.springframework.context.annotation.Bean)1