Search in sources :

Example 56 with CommonContext

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;
            }
        }
    };
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) UpgradeCcmFailedEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 57 with CommonContext

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);
        }
    };
}
Also used : UpgradeCcmEvent(com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 58 with CommonContext

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);
        }
    };
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) EnvStartEvent(com.sequenceiq.environment.environment.flow.start.event.EnvStartEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) Map(java.util.Map) EnvironmentStartDto(com.sequenceiq.environment.environment.dto.EnvironmentStartDto) Bean(org.springframework.context.annotation.Bean)

Example 59 with CommonContext

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);
        }
    };
}
Also used : EnvStartFailedEvent(com.sequenceiq.environment.environment.flow.start.event.EnvStartFailedEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 60 with CommonContext

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);
        }
    };
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) EnvStartEvent(com.sequenceiq.environment.environment.flow.start.event.EnvStartEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) Map(java.util.Map) EnvironmentStartDto(com.sequenceiq.environment.environment.dto.EnvironmentStartDto) Bean(org.springframework.context.annotation.Bean)

Aggregations

CommonContext (com.sequenceiq.flow.core.CommonContext)84 Map (java.util.Map)83 Bean (org.springframework.context.annotation.Bean)83 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)46 DiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.diagnostics.event.DiagnosticsCollectionEvent)13 DiagnosticsCollectionEvent (com.sequenceiq.freeipa.flow.freeipa.diagnostics.event.DiagnosticsCollectionEvent)13 EnvironmentStatus (com.sequenceiq.environment.environment.EnvironmentStatus)12 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)12 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)12 ResourceEvent (com.sequenceiq.cloudbreak.event.ResourceEvent)11 EnvCreationEvent (com.sequenceiq.environment.environment.flow.creation.event.EnvCreationEvent)7 EnvCreationFailureEvent (com.sequenceiq.environment.environment.flow.creation.event.EnvCreationFailureEvent)7 CmDiagnosticsCollectionEvent (com.sequenceiq.cloudbreak.core.flow2.cmdiagnostics.event.CmDiagnosticsCollectionEvent)6 UpgradeCcmEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmEvent)6 ResourceCrnPayload (com.sequenceiq.cloudbreak.common.event.ResourceCrnPayload)5 Environment (com.sequenceiq.environment.environment.domain.Environment)4 EnvironmentStartDto (com.sequenceiq.environment.environment.dto.EnvironmentStartDto)4 EnvStartEvent (com.sequenceiq.environment.environment.flow.start.event.EnvStartEvent)4 DiagnosticParameters (com.sequenceiq.common.model.diagnostics.DiagnosticParameters)3 EnvStopEvent (com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent)3