Search in sources :

Example 6 with EnvironmentStatus

use of com.sequenceiq.environment.environment.EnvironmentStatus in project cloudbreak by hortonworks.

the class EnvClustersDeleteActions method datahubClustersDeleteAction.

@Bean(name = "DATAHUB_CLUSTERS_DELETE_STARTED_STATE")
public Action<?, ?> datahubClustersDeleteAction() {
    return new AbstractEnvClustersDeleteAction<>(EnvDeleteEvent.class) {

        @Override
        protected void doExecute(CommonContext context, EnvDeleteEvent payload, Map<Object, Object> variables) {
            EnvironmentStatus environmentStatus = EnvironmentStatus.DATAHUB_CLUSTERS_DELETE_IN_PROGRESS;
            ResourceEvent resourceEvent = ResourceEvent.ENVIRONMENT_DATAHUB_CLUSTERS_DELETION_STARTED;
            EnvClustersDeleteState envClustersDeleteState = EnvClustersDeleteState.DATAHUB_CLUSTERS_DELETE_STARTED_STATE;
            String logDeleteState = "Data Hub clusters";
            EnvironmentDeletionDto envDto = commonUpdateEnvironmentAndNotify(context, payload, environmentStatus, resourceEvent, envClustersDeleteState, logDeleteState);
            sendEvent(context, DELETE_DATAHUB_CLUSTERS_EVENT.selector(), envDto);
        }
    };
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) EnvDeleteEvent(com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent) CommonContext(com.sequenceiq.flow.core.CommonContext) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) Map(java.util.Map) EnvironmentDeletionDto(com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto) Bean(org.springframework.context.annotation.Bean)

Example 7 with EnvironmentStatus

use of com.sequenceiq.environment.environment.EnvironmentStatus in project cloudbreak by hortonworks.

the class EnvironmentSyncServiceTest method testGetStatusByFreeipaWhenFreeipaNotAttached.

@Test
void testGetStatusByFreeipaWhenFreeipaNotAttached() {
    Environment environment = new Environment();
    environment.setResourceCrn("crn");
    environment.setCreateFreeIpa(false);
    when(freeIpaService.internalDescribe(environment.getResourceCrn(), "cloudera")).thenReturn(Optional.empty());
    EnvironmentStatus actual = underTest.getStatusByFreeipa(environment);
    Assertions.assertEquals(EnvironmentStatus.AVAILABLE, actual);
}
Also used : EnvironmentStatus(com.sequenceiq.environment.environment.EnvironmentStatus) Environment(com.sequenceiq.environment.environment.domain.Environment) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with EnvironmentStatus

use of com.sequenceiq.environment.environment.EnvironmentStatus 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 9 with EnvironmentStatus

use of com.sequenceiq.environment.environment.EnvironmentStatus 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 10 with EnvironmentStatus

use of com.sequenceiq.environment.environment.EnvironmentStatus 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)

Aggregations

EnvironmentStatus (com.sequenceiq.environment.environment.EnvironmentStatus)16 CommonContext (com.sequenceiq.flow.core.CommonContext)12 Map (java.util.Map)12 Bean (org.springframework.context.annotation.Bean)12 ResourceEvent (com.sequenceiq.cloudbreak.event.ResourceEvent)11 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)10 EnvironmentStartDto (com.sequenceiq.environment.environment.dto.EnvironmentStartDto)4 EnvStartEvent (com.sequenceiq.environment.environment.flow.start.event.EnvStartEvent)4 Environment (com.sequenceiq.environment.environment.domain.Environment)3 EnvStopEvent (com.sequenceiq.environment.environment.flow.stop.event.EnvStopEvent)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)2 EnvironmentLoadBalancerDto (com.sequenceiq.environment.environment.dto.EnvironmentLoadBalancerDto)2 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)2 LoadBalancerUpdateEvent (com.sequenceiq.environment.environment.flow.loadbalancer.event.LoadBalancerUpdateEvent)2 Test (org.junit.jupiter.api.Test)2 UpgradeCcmFailedEvent (com.sequenceiq.environment.environment.flow.upgrade.ccm.event.UpgradeCcmFailedEvent)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1