use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvClustersDeleteActions method datalakeClustersDeleteAction.
@Bean(name = "DATALAKE_CLUSTERS_DELETE_STARTED_STATE")
public Action<?, ?> datalakeClustersDeleteAction() {
return new AbstractEnvClustersDeleteAction<>(EnvDeleteEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
EnvironmentStatus environmentStatus = EnvironmentStatus.DATALAKE_CLUSTERS_DELETE_IN_PROGRESS;
ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_DATALAKE_CLUSTERS_DELETION_STARTED;
EnvClustersDeleteState envClustersDeleteState = EnvClustersDeleteState.DATALAKE_CLUSTERS_DELETE_STARTED_STATE;
String logDeleteState = "Data Lake clusters";
EnvironmentDeletionDto envDto = commonUpdateEnvironmentAndNotify(context, payload, environmentStatus, resourceEvent, envClustersDeleteState, logDeleteState);
sendEvent(context, DELETE_DATALAKE_CLUSTERS_EVENT.selector(), envDto);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvDeleteActions method networkDeleteAction.
@Bean(name = "NETWORK_DELETE_STARTED_STATE")
public Action<?, ?> networkDeleteAction() {
return new AbstractEnvDeleteAction<>(EnvDeleteEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.NETWORK_DELETE_IN_PROGRESS, ResourceEvent.ENVIRONMENT_NETWORK_DELETION_STARTED, EnvDeleteState.NETWORK_DELETE_STARTED_STATE);
EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(envDto).withForceDelete(payload.isForceDelete()).withId(payload.getResourceId()).build();
sendEvent(context, DELETE_NETWORK_EVENT.selector(), environmentDeletionDto);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvDeleteActions method freeipaDeleteAction.
@Bean(name = "FREEIPA_DELETE_STARTED_STATE")
public Action<?, ?> freeipaDeleteAction() {
return new AbstractEnvDeleteAction<>(EnvDeleteEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.FREEIPA_DELETE_IN_PROGRESS, ResourceEvent.ENVIRONMENT_FREEIPA_DELETION_STARTED, EnvDeleteState.FREEIPA_DELETE_STARTED_STATE);
EnvironmentDeletionDto environmentDeletionDto = EnvironmentDeletionDto.builder().withEnvironmentDto(envDto).withForceDelete(payload.isForceDelete()).withId(payload.getResourceId()).build();
sendEvent(context, DELETE_FREEIPA_EVENT.selector(), environmentDeletionDto);
}
};
}
use of com.sequenceiq.flow.core.CommonContext 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.flow.core.CommonContext 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