Search in sources :

Example 16 with CommonContext

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

Example 17 with CommonContext

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

Example 18 with CommonContext

use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.

the class EnvStartActions method startFreeipa.

@Bean(name = "START_FREEIPA_STATE")
public Action<?, ?> startFreeipa() {
    return new AbstractEnvStartAction<>(EnvStartEvent.class) {

        @Override
        protected void doExecute(CommonContext context, EnvStartEvent payload, Map<Object, Object> variables) {
            EnvironmentStatus environmentStatus = EnvironmentStatus.START_FREEIPA_STARTED;
            ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_START_FREEIPA_STARTED;
            EnvStartState envStartState = EnvStartState.START_FREEIPA_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_FREEIPA_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 19 with CommonContext

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

Example 20 with CommonContext

use of com.sequenceiq.flow.core.CommonContext in project cloudbreak by hortonworks.

the class UpgradeCcmActions method upgradeCcmInFreeIpaAction.

@Bean(name = "UPGRADE_CCM_FREEIPA_STATE")
public Action<?, ?> upgradeCcmInFreeIpaAction() {
    return new AbstractUpgradeCcmAction<>(UpgradeCcmEvent.class) {

        @Override
        protected void doExecute(CommonContext context, UpgradeCcmEvent payload, Map<Object, Object> variables) {
            EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, EnvironmentStatus.UPGRADE_CCM_ON_FREEIPA_IN_PROGRESS, ResourceEvent.ENVIRONMENT_UPGRADE_CCM_ON_FREEIPA_STARTED, UpgradeCcmState.UPGRADE_CCM_FREEIPA_STATE);
            sendEvent(context, UPGRADE_CCM_FREEIPA_HANDLER.selector(), envDto);
        }
    };
}
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)

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