use of com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent in project cloudbreak by hortonworks.
the class EnvStopActions method stopDatalake.
@Bean(name = "STOP_DATALAKE_STATE")
public Action<?, ?> stopDatalake() {
return new AbstractEnvStopAction<>(EnvStopEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvStopEvent payload, Map<Object, Object> variables) {
EnvironmentStatus environmentStatus = EnvironmentStatus.STOP_DATALAKE_STARTED;
ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_STOP_DATALAKE_STARTED;
EnvStopState envStopState = EnvStopState.STOP_DATALAKE_STATE;
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, envStopState);
sendEvent(context, EnvStopHandlerSelectors.STOP_DATALAKE_HANDLER_EVENT.selector(), envDto);
}
};
}
use of com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent in project cloudbreak by hortonworks.
the class StopDatahubHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
datahubPollerService.stopAttachedDatahubClusters(environmentDto.getId(), environmentDto.getResourceCrn());
EnvStopEvent envStopEvent = EnvStopEvent.EnvStopEventBuilder.anEnvStopEvent().withSelector(EnvStopStateSelectors.ENV_STOP_DATALAKE_EVENT.selector()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(envStopEvent, environmentDtoEvent.getHeaders());
} catch (Exception e) {
EnvStopFailedEvent failedEvent = new EnvStopFailedEvent(environmentDto, e, EnvironmentStatus.STOP_DATAHUB_FAILED);
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
}
}
use of com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent in project cloudbreak by hortonworks.
the class StopDatalakeHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
sdxPollerService.stopAttachedDatalakeClusters(environmentDto.getId(), environmentDto.getName());
EnvStopEvent envStopEvent = EnvStopEvent.EnvStopEventBuilder.anEnvStopEvent().withSelector(EnvStopStateSelectors.ENV_STOP_FREEIPA_EVENT.selector()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(envStopEvent, environmentDtoEvent.getHeaders());
} catch (Exception e) {
EnvStopFailedEvent failedEvent = new EnvStopFailedEvent(environmentDto, e, EnvironmentStatus.STOP_DATALAKE_FAILED);
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
}
}
use of com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent in project cloudbreak by hortonworks.
the class StopFreeIpaHandler method accept.
@Override
public void accept(Event<EnvironmentDto> environmentDtoEvent) {
EnvironmentDto environmentDto = environmentDtoEvent.getData();
try {
if (Strings.isNullOrEmpty(environmentDto.getParentEnvironmentCrn())) {
freeIpaService.describe(environmentDto.getResourceCrn()).ifPresentOrElse(freeIpa -> {
if (freeIpa.getStatus() == null) {
throw new FreeIpaOperationFailedException("FreeIPA status is unpredictable, env stop will be interrupted.");
} else if (freeIpa.getStatus().isStoppedPhase() || freeIpa.getStatus().isStopInProgressPhase()) {
LOGGER.info("Stop has already been triggered continuing without new stop trigger. FreeIPA status: {}", freeIpa.getStatus());
} else if (!freeIpa.getStatus().isStoppable()) {
throw new FreeIpaOperationFailedException("FreeIPA is not in a stoppable state! Current state is: " + freeIpa.getStatus().name());
} else {
LOGGER.info("FreeIPA will be stopped.");
freeIpaPollerService.stopAttachedFreeipaInstances(environmentDto.getId(), environmentDto.getResourceCrn());
}
}, () -> LOGGER.info("FreeIPA cannot be found by environment crn"));
}
EnvStopEvent envStopEvent = EnvStopEvent.EnvStopEventBuilder.anEnvStopEvent().withSelector(EnvStopStateSelectors.FINISH_ENV_STOP_EVENT.selector()).withResourceId(environmentDto.getId()).withResourceName(environmentDto.getName()).build();
eventSender().sendEvent(envStopEvent, environmentDtoEvent.getHeaders());
} catch (Exception e) {
LOGGER.warn("Failed to stop Freeipa.", e);
EnvStopFailedEvent failedEvent = new EnvStopFailedEvent(environmentDto, e, EnvironmentStatus.STOP_FREEIPA_FAILED);
eventSender().sendEvent(failedEvent, environmentDtoEvent.getHeaders());
}
}
use of com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent in project cloudbreak by hortonworks.
the class EnvStopActions method stopFreeipa.
@Bean(name = "STOP_FREEIPA_STATE")
public Action<?, ?> stopFreeipa() {
return new AbstractEnvStopAction<>(EnvStopEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvStopEvent payload, Map<Object, Object> variables) {
EnvironmentStatus environmentStatus = EnvironmentStatus.STOP_FREEIPA_STARTED;
ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_STOP_FREEIPA_STARTED;
EnvStopState envStopState = EnvStopState.STOP_FREEIPA_STATE;
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, envStopState);
sendEvent(context, EnvStopHandlerSelectors.STOP_FREEIPA_HANDLER_EVENT.selector(), envDto);
}
};
}
Aggregations