use of com.sequenceiq.cloudbreak.common.event.ResourceCrnPayload in project cloudbreak by hortonworks.
the class EnvStopActions method finishedAction.
@Bean(name = "ENV_STOP_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractEnvStopAction<>(ResourceCrnPayload.class) {
@Override
protected void doExecute(CommonContext context, ResourceCrnPayload payload, Map<Object, Object> variables) {
EnvironmentDto environmentDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.ENV_STOPPED, ResourceEvent.ENVIRONMENT_STOPPED, EnvStopState.ENV_STOP_FINISHED_STATE);
metricService.incrementMetricCounter(MetricType.ENV_STOP_FINISHED, environmentDto);
LOGGER.info("Flow entered into ENV_STOP_FINISHED_STATE");
sendEvent(context, FINALIZE_ENV_STOP_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.cloudbreak.common.event.ResourceCrnPayload in project cloudbreak by hortonworks.
the class EnvStartActions method finishedAction.
@Bean(name = "ENV_START_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractEnvStartAction<>(ResourceCrnPayload.class) {
@Override
protected void doExecute(CommonContext context, ResourceCrnPayload payload, Map<Object, Object> variables) {
EnvironmentDto environmentDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.AVAILABLE, ResourceEvent.ENVIRONMENT_STARTED, EnvStartState.ENV_START_FINISHED_STATE);
metricService.incrementMetricCounter(MetricType.ENV_START_FINISHED, environmentDto);
LOGGER.info("Flow entered into ENV_START_FINISHED_STATE");
sendEvent(context, FINALIZE_ENV_START_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.cloudbreak.common.event.ResourceCrnPayload in project cloudbreak by hortonworks.
the class LoadBalancerUpdateActions method finishedAction.
@Bean(name = "LOAD_BALANCER_UPDATE_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractLoadBalancerUpdateAction<>(ResourceCrnPayload.class) {
@Override
protected void doExecute(CommonContext context, ResourceCrnPayload payload, Map<Object, Object> variables) {
EnvironmentDto environmentDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.AVAILABLE, ResourceEvent.ENVIRONMENT_LOAD_BALANCER_UPDATE_FINISHED, LoadBalancerUpdateState.LOAD_BALANCER_UPDATE_FINISHED_STATE);
metricService.incrementMetricCounter(MetricType.ENV_LOAD_BALANCER_UPDATE_FINISHED, environmentDto);
LOGGER.info("Flow entered into LOAD_BALANCER_UPDATE_FINISHED_STATE");
sendEvent(context, FINALIZE_LOAD_BALANCER_UPDATE_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.cloudbreak.common.event.ResourceCrnPayload in project cloudbreak by hortonworks.
the class EnvDeleteActions method finishedAction.
@Bean(name = "ENV_DELETE_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractEnvDeleteAction<>(ResourceCrnPayload.class) {
@Override
protected void doExecute(CommonContext context, ResourceCrnPayload payload, Map<Object, Object> variables) {
environmentService.findEnvironmentById(payload.getResourceId()).ifPresentOrElse(env -> {
String originalName = env.getName();
env.setName(generateArchiveName(env.getName()));
env.setDeletionTimestamp(new Date().getTime());
env.setStatus(EnvironmentStatus.ARCHIVED);
env.setStatusReason(null);
env.setArchived(true);
env.setProxyConfig(null);
Environment result = environmentService.save(env);
EnvironmentDto environmentDto = environmentService.getEnvironmentDto(result);
SimpleEnvironmentResponse simpleResponse = environmentResponseConverter.dtoToSimpleResponse(environmentDto, true, true);
simpleResponse.setName(originalName);
metricService.incrementMetricCounter(MetricType.ENV_DELETION_FINISHED, environmentDto);
eventService.sendEventAndNotificationWithPayload(environmentDto, context.getFlowTriggerUserCrn(), ResourceEvent.ENVIRONMENT_DELETION_FINISHED, simpleResponse);
}, () -> LOGGER.error("Cannot finish the delete flow because the environment does not exist: {}. " + "But the flow will continue, how can this happen?", payload.getResourceId()));
LOGGER.info("Flow entered into ENV_DELETE_FINISHED_STATE");
sendEvent(context, FINALIZE_ENV_DELETE_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.cloudbreak.common.event.ResourceCrnPayload in project cloudbreak by hortonworks.
the class EnvStackConfigUpdatesActions method finishedAction.
@Bean(name = "STACK_CONFIG_UPDATES_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractEnvStackConfigUpdatesAction<>(ResourceCrnPayload.class) {
@Override
protected void doExecute(CommonContext context, ResourceCrnPayload payload, Map<Object, Object> variables) {
EnvironmentDto environmentDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, getCurrentStatus(payload.getResourceId()), ResourceEvent.ENVIRONMENT_STACK_CONFIGS_UPDATE_FINISHED, EnvStackConfigUpdatesState.STACK_CONFIG_UPDATES_FINISHED_STATE);
metricService.incrementMetricCounter(MetricType.ENV_STACK_CONFIG_UPDATE_FINISHED, environmentDto);
LOGGER.info("Flow entered into STACK_CONFIG_UPDATES_FINISHED_STATE");
sendEvent(context, FINALIZE_ENV_STACK_CONIFG_UPDATES_EVENT.event(), payload);
}
};
}
Aggregations