Search in sources :

Example 51 with CommonContext

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

the class LoadBalancerUpdateActions method stackLoadBalancerUpdate.

@Bean(name = "STACK_UPDATE_STATE")
public Action<?, ?> stackLoadBalancerUpdate() {
    return new AbstractLoadBalancerUpdateAction<>(LoadBalancerUpdateEvent.class) {

        @Override
        protected void doExecute(CommonContext context, LoadBalancerUpdateEvent payload, Map<Object, Object> variables) {
            EnvironmentStatus environmentStatus = EnvironmentStatus.LOAD_BALANCER_STACK_UPDATE_STARTED;
            ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_LOAD_BALANCER_STACK_UPDATE_STARTED;
            LoadBalancerUpdateState loadBalancerUpdateState = LoadBalancerUpdateState.STACK_UPDATE_STATE;
            EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, loadBalancerUpdateState);
            EnvironmentLoadBalancerDto environmentLoadBalancerDto = EnvironmentLoadBalancerDto.builder().withId(envDto.getId()).withEnvironmentDto(payload.getEnvironmentDto()).withEndpointAccessGateway(payload.getEndpointAccessGateway()).withEndpointGatewaySubnetIds(payload.getSubnetIds()).build();
            sendEvent(context, LoadBalancerUpdateHandlerSelectors.STACK_UPDATE_HANDLER_EVENT.selector(), environmentLoadBalancerDto);
        }
    };
}
Also used : EnvironmentLoadBalancerDto(com.sequenceiq.environment.environment.dto.EnvironmentLoadBalancerDto) EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) LoadBalancerUpdateEvent(com.sequenceiq.environment.environment.flow.loadbalancer.event.LoadBalancerUpdateEvent) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 52 with CommonContext

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

the class LoadBalancerUpdateActions method environmentLoadBalancerUpdate.

@Bean(name = "ENVIRONMENT_UPDATE_STATE")
public Action<?, ?> environmentLoadBalancerUpdate() {
    return new AbstractLoadBalancerUpdateAction<>(LoadBalancerUpdateEvent.class) {

        @Override
        protected void doExecute(CommonContext context, LoadBalancerUpdateEvent payload, Map<Object, Object> variables) {
            EnvironmentStatus environmentStatus = EnvironmentStatus.LOAD_BALANCER_ENV_UPDATE_STARTED;
            ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_LOAD_BALANCER_ENV_UPDATE_STARTED;
            LoadBalancerUpdateState loadBalancerUpdateState = LoadBalancerUpdateState.ENVIRONMENT_UPDATE_STATE;
            EnvironmentDto envDto = environmentStatusUpdateService.updateEnvironmentStatusAndNotify(context, payload, environmentStatus, resourceEvent, loadBalancerUpdateState);
            EnvironmentLoadBalancerDto environmentLoadBalancerDto = EnvironmentLoadBalancerDto.builder().withId(envDto.getId()).withEnvironmentDto(payload.getEnvironmentDto()).withEndpointAccessGateway(payload.getEndpointAccessGateway()).withEndpointGatewaySubnetIds(payload.getSubnetIds()).build();
            sendEvent(context, LoadBalancerUpdateHandlerSelectors.ENVIRONMENT_UPDATE_HANDLER_EVENT.selector(), environmentLoadBalancerDto);
        }
    };
}
Also used : EnvironmentLoadBalancerDto(com.sequenceiq.environment.environment.dto.EnvironmentLoadBalancerDto) EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) LoadBalancerUpdateEvent(com.sequenceiq.environment.environment.flow.loadbalancer.event.LoadBalancerUpdateEvent) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 53 with CommonContext

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

the class LoadBalancerUpdateActions method failedAction.

@Bean(name = "LOAD_BALANCER_UPDATE_FAILED_STATE")
public Action<?, ?> failedAction() {
    return new AbstractLoadBalancerUpdateAction<>(LoadBalancerUpdateFailedEvent.class) {

        @Override
        protected void doExecute(CommonContext context, LoadBalancerUpdateFailedEvent payload, Map<Object, Object> variables) {
            LOGGER.warn(String.format("Failed to update load balancer on environment '%s'. Status: '%s'.", payload.getEnvironmentDto(), payload.getEnvironmentStatus()), payload.getException());
            EnvironmentDto environmentDto = environmentStatusUpdateService.updateFailedEnvironmentStatusAndNotify(context, payload, payload.getEnvironmentStatus(), convertStatus(payload.getEnvironmentStatus()), LoadBalancerUpdateState.LOAD_BALANCER_UPDATE_FAILED_STATE);
            metricService.incrementMetricCounter(MetricType.ENV_LOAD_BALANCER_UPDATE_FAILED, environmentDto, payload.getException());
            sendEvent(context, HANDLED_FAILED_LOAD_BALANCER_UPDATE_EVENT.event(), payload);
        }
    };
}
Also used : LoadBalancerUpdateFailedEvent(com.sequenceiq.environment.environment.flow.loadbalancer.event.LoadBalancerUpdateFailedEvent) EnvironmentDto(com.sequenceiq.environment.environment.dto.EnvironmentDto) CommonContext(com.sequenceiq.flow.core.CommonContext) Map(java.util.Map) Bean(org.springframework.context.annotation.Bean)

Example 54 with CommonContext

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

the class UpgradeCcmActions method upgradeCcmUpdateTunnelAction.

@Bean(name = "UPGRADE_CCM_TUNNEL_UPDATE_STATE")
public Action<?, ?> upgradeCcmUpdateTunnelAction() {
    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_TUNNEL_UPDATE_IN_PROGRESS, ResourceEvent.ENVIRONMENT_UPGRADE_CCM_TUNNEL_UPDATE_STARTED, UpgradeCcmState.UPGRADE_CCM_TUNNEL_UPDATE_STATE);
            sendEvent(context, UPGRADE_CCM_TUNNEL_UPDATE_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)

Example 55 with CommonContext

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

the class UpgradeCcmActions method upgradeCcmInDataLakeAction.

@Bean(name = "UPGRADE_CCM_DATALAKE_STATE")
public Action<?, ?> upgradeCcmInDataLakeAction() {
    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_DATALAKE_IN_PROGRESS, ResourceEvent.ENVIRONMENT_UPGRADE_CCM_ON_DATALAKE_STARTED, UpgradeCcmState.UPGRADE_CCM_DATALAKE_STATE);
            sendEvent(context, UPGRADE_CCM_DATALAKE_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