Search in sources :

Example 1 with TERMINATED

use of com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.TERMINATED in project cloudbreak by hortonworks.

the class MetadataSetupService method cleanupRequestedInstancesWithoutFQDN.

public void cleanupRequestedInstancesWithoutFQDN(Long stackId, Set<String> instanceGroups) {
    try {
        transactionService.required(() -> {
            for (String instanceGroupName : instanceGroups) {
                Optional<InstanceGroup> ig = instanceGroupService.findOneWithInstanceMetadataByGroupNameInStack(stackId, instanceGroupName);
                if (ig.isPresent()) {
                    List<InstanceMetaData> requestedInstances = instanceMetaDataService.findAllByInstanceGroupAndInstanceStatus(ig.get(), InstanceStatus.REQUESTED);
                    List<InstanceMetaData> requestedInstancesWithoutFQDN = requestedInstances.stream().filter(instanceMetaData -> instanceMetaData.getDiscoveryFQDN() == null).collect(Collectors.toList());
                    LOGGER.info("Set requested instances without FQDN to terminated: {}", requestedInstancesWithoutFQDN);
                    for (InstanceMetaData inst : requestedInstancesWithoutFQDN) {
                        inst.setTerminationDate(clock.getCurrentTimeMillis());
                        inst.setInstanceStatus(InstanceStatus.TERMINATED);
                    }
                    instanceMetaDataService.saveAll(requestedInstances);
                }
            }
        });
    } catch (TransactionExecutionException e) {
        throw new TransactionRuntimeExecutionException(e);
    }
}
Also used : CloudInstanceMetaData(com.sequenceiq.cloudbreak.cloud.model.CloudInstanceMetaData) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) LoggerFactory(org.slf4j.LoggerFactory) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException) InstanceGroupService(com.sequenceiq.cloudbreak.service.stack.InstanceGroupService) ImageService(com.sequenceiq.cloudbreak.service.image.ImageService) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) CloudbreakEventService(com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakEventService) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) Map(java.util.Map) TargetGroupPersistenceService(com.sequenceiq.cloudbreak.service.stack.TargetGroupPersistenceService) UPDATE_FAILED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_FAILED) LoadBalancerPersistenceService(com.sequenceiq.cloudbreak.service.stack.LoadBalancerPersistenceService) InstanceMetadataType(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType) Collection(java.util.Collection) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Json(com.sequenceiq.cloudbreak.common.json.Json) List(java.util.List) STARTED(com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.STARTED) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) Optional(java.util.Optional) CloudVmMetaDataStatus(com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) InstanceLifeCycle(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceLifeCycle) Clock(com.sequenceiq.cloudbreak.common.service.Clock) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) LoadBalancerConfigService(com.sequenceiq.cloudbreak.service.LoadBalancerConfigService) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) Image(com.sequenceiq.cloudbreak.cloud.model.Image) Function(java.util.function.Function) StackStatusService(com.sequenceiq.cloudbreak.service.stackstatus.StackStatusService) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) Inject(javax.inject.Inject) Service(org.springframework.stereotype.Service) LoadBalancerConfigConverter(com.sequenceiq.cloudbreak.service.LoadBalancerConfigConverter) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) TERMINATED(com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.TERMINATED) Logger(org.slf4j.Logger) CloudInstanceMetaData(com.sequenceiq.cloudbreak.cloud.model.CloudInstanceMetaData) STACK_INSTANCE_METADATA_RESTORED(com.sequenceiq.cloudbreak.event.ResourceEvent.STACK_INSTANCE_METADATA_RESTORED) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata) StackIdView(com.sequenceiq.cloudbreak.domain.projection.StackIdView) CREATED(com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.CREATED) StringUtils(org.springframework.util.StringUtils) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)

Aggregations

StackType (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType)1 UPDATE_FAILED (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_FAILED)1 InstanceLifeCycle (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceLifeCycle)1 InstanceMetadataType (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceMetadataType)1 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)1 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)1 CloudInstanceMetaData (com.sequenceiq.cloudbreak.cloud.model.CloudInstanceMetaData)1 CloudLoadBalancerMetadata (com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata)1 CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)1 Image (com.sequenceiq.cloudbreak.cloud.model.Image)1 CREATED (com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.CREATED)1 STARTED (com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.STARTED)1 TERMINATED (com.sequenceiq.cloudbreak.cloud.model.InstanceStatus.TERMINATED)1 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 Clock (com.sequenceiq.cloudbreak.common.service.Clock)1 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)1 TransactionExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException)1 TransactionRuntimeExecutionException (com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException)1