use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class UpgradeCcmActions method failedAction.
@Bean(name = "UPGRADE_CCM_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractUpgradeCcmAction<>(UpgradeCcmFailedEvent.class) {
@Override
protected void doExecute(CommonContext context, UpgradeCcmFailedEvent payload, Map<Object, Object> variables) {
LOGGER.error(String.format("Failed to upgrade CCM in environment '%s'. Status: '%s'.", payload.getEnvironmentDto(), payload.getEnvironmentStatus()), payload.getException());
EnvironmentDto environmentDto = environmentStatusUpdateService.updateFailedEnvironmentStatusAndNotify(context, payload, payload.getEnvironmentStatus(), convertStatus(payload.getEnvironmentStatus()), UpgradeCcmState.UPGRADE_CCM_FAILED_STATE);
metricService.incrementMetricCounter(MetricType.ENV_UPGRADE_CCM_FAILED, environmentDto, payload.getException());
sendEvent(context, HANDLED_FAILED_UPGRADE_CCM_EVENT.event(), payload);
}
private ResourceEvent convertStatus(EnvironmentStatus status) {
switch(status) {
case UPGRADE_CCM_VALIDATION_FAILED:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_VALIDATION_FAILED;
case UPGRADE_CCM_TUNNEL_UPDATE_FAILED:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_TUNNEL_UPDATE_FAILED;
case UPGRADE_CCM_ON_FREEIPA_FAILED:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_ON_FREEIPA_FAILED;
case UPGRADE_CCM_ON_DATALAKE_FAILED:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_ON_DATALAKE_FAILED;
case UPGRADE_CCM_ON_DATAHUB_FAILED:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_ON_DATAHUB_FAILED;
default:
return ResourceEvent.ENVIRONMENT_UPGRADE_CCM_FAILED;
}
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class UpgradeCcmActions method finishedAction.
@Bean(name = "UPGRADE_CCM_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractUpgradeCcmAction<>(UpgradeCcmEvent.class) {
@Override
protected void doExecute(CommonContext context, UpgradeCcmEvent payload, Map<Object, Object> variables) {
EnvironmentDto environmentDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.AVAILABLE, ResourceEvent.ENVIRONMENT_UPGRADE_CCM_FINISHED, UpgradeCcmState.UPGRADE_CCM_FINISHED_STATE);
metricService.incrementMetricCounter(MetricType.ENV_UPGRADE_CCM_FINISHED, environmentDto);
sendEvent(context, FINALIZE_UPGRADE_CCM_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvStartActions method synchronizeUsers.
@Bean(name = "SYNCHRONIZE_USERS_STATE")
public Action<?, ?> synchronizeUsers() {
return new AbstractEnvStartAction<>(EnvStartEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvStartEvent payload, Map<Object, Object> variables) {
EnvironmentStatus environmentStatus = EnvironmentStatus.START_SYNCHRONIZE_USERS_STARTED;
ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_START_SYNCHRONIZE_USERS_STARTED;
EnvStartState envStartState = EnvStartState.SYNCHRONIZE_USERS_STATE;
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, envStartState);
EnvironmentStartDto environmentStartDto = EnvironmentStartDto.builder().withDataHubStart(payload.getDataHubStartAction()).withEnvironmentDto(envDto).withId(envDto.getId()).build();
sendEvent(context, EnvStartHandlerSelectors.SYNCHRONIZE_USERS_HANDLER_EVENT.selector(), environmentStartDto);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvStartActions method failedAction.
@Bean(name = "ENV_START_FAILED_STATE")
public Action<?, ?> failedAction() {
return new AbstractEnvStartAction<>(EnvStartFailedEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvStartFailedEvent payload, Map<Object, Object> variables) {
LOGGER.warn(String.format("Failed to start environment '%s'. Status: '%s'.", payload.getEnvironmentDto(), payload.getEnvironmentStatus()), payload.getException());
EnvironmentDto environmentDto = environmentStatusUpdateService.updateFailedEnvironmentStatusAndNotify(context, payload, payload.getEnvironmentStatus(), convertStatus(payload.getEnvironmentStatus()), EnvStartState.ENV_START_FAILED_STATE);
metricService.incrementMetricCounter(MetricType.ENV_START_FAILED, environmentDto, payload.getException());
sendEvent(context, HANDLED_FAILED_ENV_START_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.
the class EnvStartActions method startDatalake.
@Bean(name = "START_DATALAKE_STATE")
public Action<?, ?> startDatalake() {
return new AbstractEnvStartAction<>(EnvStartEvent.class) {
@Override
protected void doExecute(CommonContext context, EnvStartEvent payload, Map<Object, Object> variables) {
EnvironmentStatus environmentStatus = EnvironmentStatus.START_DATALAKE_STARTED;
ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_START_DATALAKE_STARTED;
EnvStartState envStartState = EnvStartState.START_DATALAKE_STATE;
EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, envStartState);
EnvironmentStartDto environmentStartDto = EnvironmentStartDto.builder().withDataHubStart(payload.getDataHubStartAction()).withEnvironmentDto(envDto).withId(envDto.getId()).build();
sendEvent(context, EnvStartHandlerSelectors.START_DATALAKE_HANDLER_EVENT.selector(), environmentStartDto);
}
};
}
Aggregations