Search in sources :

Example 36 with FAILED

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.FAILED in project cloudbreak by hortonworks.

the class StackToStackV4ResponseConverter method getTags.

private TagsV4Response getTags(Json tag) {
    try {
        if (tag != null && tag.getValue() != null) {
            StackTags stackTag = tag.get(StackTags.class);
            return stackTagsToTagsV4ResponseConverter.convert(stackTag);
        }
    } catch (Exception e) {
        LOGGER.info("Failed to convert dynamic tags.", e);
    }
    TagsV4Response response = new TagsV4Response();
    response.setApplication(new HashMap<>());
    response.setDefaults(new HashMap<>());
    response.setUserDefined(new HashMap<>());
    return response;
}
Also used : StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags) TagsV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.tags.TagsV4Response) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Example 37 with FAILED

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.FAILED in project cloudbreak by hortonworks.

the class StackV4RequestToStackConverter method getTags.

private Json getTags(StackV4Request source, DetailedEnvironmentResponse environment) {
    try {
        TagsV4Request tags = source.getTags();
        if (tags == null) {
            Map<String, String> userDefined = environment == null || environment.getTags() == null ? new HashMap<>() : environment.getTags().getUserDefined();
            return new Json(new StackTags(userDefined, new HashMap<>(), new HashMap<>()));
        }
        Map<String, String> userDefined = new HashMap<>();
        if (environment != null && environment.getTags() != null && environment.getTags().getUserDefined() != null && !environment.getTags().getUserDefined().isEmpty()) {
            userDefined = environment.getTags().getUserDefined();
        }
        CDPTagMergeRequest request = CDPTagMergeRequest.Builder.builder().withPlatform(source.getCloudPlatform().name()).withRequestTags(tags.getUserDefined() != null ? tags.getUserDefined() : Maps.newHashMap()).withEnvironmentTags(userDefined).build();
        return new Json(new StackTags(costTagging.mergeTags(request), tags.getApplication(), new HashMap<>()));
    } catch (Exception e) {
        throw new BadRequestException("Failed to convert dynamic tags. " + e.getMessage(), e);
    }
}
Also used : StackTags(com.sequenceiq.cloudbreak.cloud.model.StackTags) CDPTagMergeRequest(com.sequenceiq.cloudbreak.tag.request.CDPTagMergeRequest) HashMap(java.util.HashMap) TagsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.TagsV4Request) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Json(com.sequenceiq.cloudbreak.common.json.Json) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) IOException(java.io.IOException)

Example 38 with FAILED

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.FAILED in project cloudbreak by hortonworks.

the class ClusterOperationService method updateNewHealthyNodes.

private void updateNewHealthyNodes(Cluster cluster, Set<String> newHealthyNodes) throws TransactionExecutionException {
    if (!newHealthyNodes.isEmpty()) {
        Map<String, Optional<String>> hostNamesWithReason = newHealthyNodes.stream().collect(Collectors.toMap(host -> host, host -> Optional.empty()));
        Set<InstanceStatus> expectedStates = EnumSet.of(SERVICES_UNHEALTHY, SERVICES_RUNNING, DECOMMISSION_FAILED, FAILED);
        InstanceStatus newState = SERVICES_HEALTHY;
        ResourceEvent clusterEvent = CLUSTER_RECOVERED_NODES_REPORTED_CLUSTER_EVENT;
        updateChangedHosts(cluster, hostNamesWithReason, expectedStates, newState, clusterEvent, Optional.empty());
    }
}
Also used : ComponentType(com.sequenceiq.cloudbreak.common.type.ComponentType) SERVICES_RUNNING(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.SERVICES_RUNNING) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Resource(com.sequenceiq.cloudbreak.domain.Resource) AVAILABLE(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.AVAILABLE) HostGroupAdjustmentV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.HostGroupAdjustmentV4Request) SERVICES_UNHEALTHY(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.SERVICES_UNHEALTHY) LoggerFactory(org.slf4j.LoggerFactory) UserNamePasswordV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.UserNamePasswordV4Request) Math.abs(java.lang.Math.abs) Measure(com.sequenceiq.cloudbreak.aspect.Measure) ClusterService(com.sequenceiq.cloudbreak.service.cluster.ClusterService) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException) StringUtils(org.apache.commons.lang3.StringUtils) StatusRequest(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.StatusRequest) CloudbreakMessagesService(com.sequenceiq.cloudbreak.message.CloudbreakMessagesService) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) CloudbreakEventService(com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakEventService) Map(java.util.Map) CLUSTER_AUTORECOVERY_REQUESTED_CLUSTER_EVENT(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_AUTORECOVERY_REQUESTED_CLUSTER_EVENT) StackUpdater(com.sequenceiq.cloudbreak.service.StackUpdater) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) EnumSet(java.util.EnumSet) RecoveryMode(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.RecoveryMode) CLUSTER_RECOVERED_NODES_REPORTED_CLUSTER_EVENT(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_RECOVERED_NODES_REPORTED_CLUSTER_EVENT) CertificatesRotationV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.CertificatesRotationV4Request) ResourceAttributeUtil(com.sequenceiq.cloudbreak.cluster.util.ResourceAttributeUtil) SERVICES_HEALTHY(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.SERVICES_HEALTHY) FileSystemConfigService(com.sequenceiq.cloudbreak.service.filesystem.FileSystemConfigService) Collection(java.util.Collection) CLUSTER_STOP_IGNORED(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_STOP_IGNORED) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) Status(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) Collectors(java.util.stream.Collectors) ClouderaManagerRepo(com.sequenceiq.cloudbreak.cloud.model.ClouderaManagerRepo) Sets(com.google.common.collect.Sets) List(java.util.List) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) Optional(java.util.Optional) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) CLUSTER_FAILED_NODES_REPORTED_HOST_EVENT(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_FAILED_NODES_REPORTED_HOST_EVENT) START_IN_PROGRESS(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.START_IN_PROGRESS) CMRepositoryVersionUtil(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil) ReactorFlowManager(com.sequenceiq.cloudbreak.core.flow2.service.ReactorFlowManager) HashMap(java.util.HashMap) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ResourceService(com.sequenceiq.cloudbreak.service.resource.ResourceService) StackStopRestrictionService(com.sequenceiq.cloudbreak.service.stack.StackStopRestrictionService) Service(org.springframework.stereotype.Service) FlowIdentifier(com.sequenceiq.flow.api.model.FlowIdentifier) FAILED(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.FAILED) InstanceMetaDataService(com.sequenceiq.cloudbreak.service.stack.InstanceMetaDataService) ResourceType(com.sequenceiq.common.api.type.ResourceType) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) DECOMMISSION_FAILED(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.DECOMMISSION_FAILED) Logger(org.slf4j.Logger) Benchmark.measure(com.sequenceiq.cloudbreak.util.Benchmark.measure) BlueprintValidator(com.sequenceiq.cloudbreak.template.validation.BlueprintValidator) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent) IOException(java.io.IOException) CLUSTER_AUTORECOVERY_REQUESTED_HOST_EVENT(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_AUTORECOVERY_REQUESTED_HOST_EVENT) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) CLUSTER_FAILED_NODES_REPORTED_CLUSTER_EVENT(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_FAILED_NODES_REPORTED_CLUSTER_EVENT) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) NotAllowedStatusUpdate(com.sequenceiq.cloudbreak.util.NotAllowedStatusUpdate) User(com.sequenceiq.cloudbreak.workspace.model.User) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CLUSTER_START_IGNORED(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_START_IGNORED) BlueprintService(com.sequenceiq.cloudbreak.service.blueprint.BlueprintService) UsageLoggingUtil(com.sequenceiq.cloudbreak.util.UsageLoggingUtil) BlueprintValidatorFactory(com.sequenceiq.cloudbreak.service.blueprint.BlueprintValidatorFactory) STOPPED(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.STOPPED) Collections(java.util.Collections) StopRestrictionReason(com.sequenceiq.cloudbreak.domain.StopRestrictionReason) Optional(java.util.Optional) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) ResourceEvent(com.sequenceiq.cloudbreak.event.ResourceEvent)

Example 39 with FAILED

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.FAILED in project cloudbreak by hortonworks.

the class StopStartUpscaleCommissionViaCMHandler method doAccept.

@Override
protected Selectable doAccept(HandlerEvent<StopStartUpscaleCommissionViaCMRequest> event) {
    StopStartUpscaleCommissionViaCMRequest request = event.getData();
    LOGGER.info("StopStartUpscaleCommissionViaCMHandler for: {}, {}", event.getData().getResourceId(), event);
    LOGGER.debug("StartedInstancesToCommission: {}, servicesNotRunningInstancesToCommission: {}", request.getStartedInstancesToCommission(), request.getServicesNotRunningInstancesToCommission());
    List<InstanceMetaData> allInstancesToCommission = new LinkedList<>();
    allInstancesToCommission.addAll(request.getStartedInstancesToCommission());
    allInstancesToCommission.addAll(request.getServicesNotRunningInstancesToCommission());
    try {
        Stack stack = stackService.getByIdWithLists(request.getResourceId());
        Cluster cluster = stack.getCluster();
        flowMessageService.fireEventAndLog(stack.getId(), UPDATE_IN_PROGRESS.name(), CLUSTER_SCALING_STOPSTART_UPSCALE_WAITING_HOSTSTART, String.valueOf(allInstancesToCommission.size()));
        ClusterSetupService clusterSetupService = clusterApiConnectors.getConnector(stack).clusterSetupService();
        clusterSetupService.waitForHostsHealthy(new HashSet<>(allInstancesToCommission));
        flowMessageService.fireEventAndLog(stack.getId(), UPDATE_IN_PROGRESS.name(), CLUSTER_SCALING_STOPSTART_UPSCALE_CMHOSTSSTARTED, String.valueOf(allInstancesToCommission.size()));
        ClusterCommissionService clusterCommissionService = clusterApiConnectors.getConnector(stack).clusterCommissionService();
        Set<String> hostNames = allInstancesToCommission.stream().map(i -> i.getDiscoveryFQDN()).collect(Collectors.toSet());
        LOGGER.debug("HostNames to recommission: count={}, hostNames={}", hostNames.size(), hostNames);
        HostGroup hostGroup = hostGroupService.getByClusterIdAndName(cluster.getId(), request.getHostGroupName()).orElseThrow(NotFoundException.notFound("hostgroup", request.getHostGroupName()));
        Map<String, InstanceMetaData> hostsToRecommission = clusterCommissionService.collectHostsToCommission(hostGroup, hostNames);
        List<String> missingHostsInCm = Collections.emptyList();
        if (hostNames.size() != hostsToRecommission.size()) {
            missingHostsInCm = hostNames.stream().filter(h -> !hostsToRecommission.containsKey(h)).collect(Collectors.toList());
            LOGGER.info("Found fewer instances in CM to commission, as compared to initial ask. foundCount={}, initialCount={}, missingHostsInCm={}", hostsToRecommission.size(), hostNames.size(), missingHostsInCm);
        }
        // TODO CB-15132: Eventually ensure CM, relevant services (YARN RM) are in a functional state - or fail/delay the operation
        // TODO CB-15132: Potentially poll nodes for success. Don't fail the entire operation if a single node fails to commission.
        // What would need to happen to the CM command in this case? (Can only work in the presence of a co-operative CM API call.
        // Alternately this could go straight to the service)
        Set<String> recommissionedHostnames = Collections.emptySet();
        if (hostsToRecommission.size() > 0) {
            recommissionedHostnames = clusterCommissionService.recommissionClusterNodes(hostsToRecommission);
        // TODO CB-15132: Maybe wait for services to start / force CM sync.
        }
        List<String> allMissingRecommissionHostnames = null;
        if (missingHostsInCm.size() > 0) {
            allMissingRecommissionHostnames = new LinkedList<>(missingHostsInCm);
        }
        if (hostsToRecommission.size() != recommissionedHostnames.size()) {
            Set<String> finalRecommissionedHostnames = recommissionedHostnames;
            List<String> additionalMissingRecommissionHostnames = hostsToRecommission.keySet().stream().filter(h -> !finalRecommissionedHostnames.contains(h)).collect(Collectors.toList());
            LOGGER.info("Recommissioned fewer instances than requested. recommissionedCount={}, expectedCount={}, initialCount={}, notRecommissioned=[{}]", recommissionedHostnames.size(), hostsToRecommission.size(), hostNames.size(), additionalMissingRecommissionHostnames);
            if (allMissingRecommissionHostnames == null) {
                allMissingRecommissionHostnames = new LinkedList<>();
            }
            allMissingRecommissionHostnames.addAll(additionalMissingRecommissionHostnames);
        }
        return new StopStartUpscaleCommissionViaCMResult(request, recommissionedHostnames, allMissingRecommissionHostnames);
    } catch (Exception e) {
        // TODO CB-15132: This can be improved based on where and when the Exception occurred to potentially rollback certain aspects.
        // ClusterClientInitException is one which is explicitly thrown.
        String message = "Failed while attempting to commission nodes via CM";
        LOGGER.error(message);
        return new StopStartUpscaleCommissionViaCMResult(message, e, request);
    }
}
Also used : ClusterSetupService(com.sequenceiq.cloudbreak.cluster.api.ClusterSetupService) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) LoggerFactory(org.slf4j.LoggerFactory) EventSelectorUtil(com.sequenceiq.flow.event.EventSelectorUtil) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) HostGroupService(com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService) CLUSTER_SCALING_STOPSTART_UPSCALE_CMHOSTSSTARTED(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_SCALING_STOPSTART_UPSCALE_CMHOSTSSTARTED) StopStartUpscaleCommissionViaCMResult(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.StopStartUpscaleCommissionViaCMResult) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ExceptionCatcherEventHandler(com.sequenceiq.flow.reactor.api.handler.ExceptionCatcherEventHandler) UPDATE_IN_PROGRESS(com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.UPDATE_IN_PROGRESS) Event(reactor.bus.Event) CloudbreakFlowMessageService(com.sequenceiq.cloudbreak.core.flow2.stack.CloudbreakFlowMessageService) Map(java.util.Map) ClusterSetupService(com.sequenceiq.cloudbreak.cluster.api.ClusterSetupService) CLUSTER_SCALING_STOPSTART_UPSCALE_WAITING_HOSTSTART(com.sequenceiq.cloudbreak.event.ResourceEvent.CLUSTER_SCALING_STOPSTART_UPSCALE_WAITING_HOSTSTART) LinkedList(java.util.LinkedList) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) Logger(org.slf4j.Logger) Set(java.util.Set) HandlerEvent(com.sequenceiq.flow.reactor.api.handler.HandlerEvent) StopStartUpscaleCommissionViaCMRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.StopStartUpscaleCommissionViaCMRequest) Collectors(java.util.stream.Collectors) ClusterCommissionService(com.sequenceiq.cloudbreak.cluster.api.ClusterCommissionService) List(java.util.List) Component(org.springframework.stereotype.Component) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ClusterApiConnectors(com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors) Collections(java.util.Collections) StackService(com.sequenceiq.cloudbreak.service.stack.StackService) StopStartUpscaleCommissionViaCMResult(com.sequenceiq.cloudbreak.reactor.api.event.orchestration.StopStartUpscaleCommissionViaCMResult) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) LinkedList(java.util.LinkedList) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) StopStartUpscaleCommissionViaCMRequest(com.sequenceiq.cloudbreak.reactor.api.event.cluster.StopStartUpscaleCommissionViaCMRequest) ClusterCommissionService(com.sequenceiq.cloudbreak.cluster.api.ClusterCommissionService)

Example 40 with FAILED

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus.FAILED in project cloudbreak by hortonworks.

the class MetadataSetupService method saveLoadBalancerMetadata.

public void saveLoadBalancerMetadata(Stack stack, Iterable<CloudLoadBalancerMetadata> cloudLoadBalancerMetadataList) {
    try {
        LOGGER.info("Save load balancer metadata for stack: {}", stack.getName());
        Set<LoadBalancer> allLoadBalancerMetadata = loadBalancerPersistenceService.findByStackId(stack.getId());
        for (CloudLoadBalancerMetadata cloudLoadBalancerMetadata : cloudLoadBalancerMetadataList) {
            LoadBalancer loadBalancerEntry = createLoadBalancerMetadataIfAbsent(allLoadBalancerMetadata, stack, cloudLoadBalancerMetadata.getType());
            loadBalancerEntry.setDns(cloudLoadBalancerMetadata.getCloudDns());
            loadBalancerEntry.setHostedZoneId(cloudLoadBalancerMetadata.getHostedZoneId());
            loadBalancerEntry.setIp(cloudLoadBalancerMetadata.getIp());
            loadBalancerEntry.setType(cloudLoadBalancerMetadata.getType());
            String endpoint = loadBalancerConfigService.generateLoadBalancerEndpoint(stack);
            List<StackIdView> byEnvironmentCrnAndStackType = stackService.getByEnvironmentCrnAndStackType(stack.getEnvironmentCrn(), StackType.DATALAKE);
            List<StackStatus> stoppedDatalakes = byEnvironmentCrnAndStackType.stream().map(s -> stackStatusService.findFirstByStackIdOrderByCreatedDesc(s.getId())).filter(Optional::isPresent).map(Optional::get).filter(status -> status.getStatus().isStopState()).collect(Collectors.toList());
            if (!stoppedDatalakes.isEmpty()) {
                /* Starts to check for a situation where we are resizing a datalake that did not previously have loadbalancers
                        so that we can use the same endpoint name for a seamless transistion
                     */
                LOGGER.info("Using old datalake endpoint name for resized datalake: {}, env: {}", stack.getName(), stack.getEnvironmentCrn());
                if (stoppedDatalakes.size() > 1) {
                    String ids = stoppedDatalakes.stream().map(stackStatus -> stackStatus.getStack().getId()).map(Object::toString).collect(Collectors.joining(","));
                    LOGGER.warn("more than one datalake found to resize from: {}", ids);
                }
                Long oldId = stoppedDatalakes.get(0).getStack().getId();
                Set<LoadBalancer> oldLoadbalancers = loadBalancerPersistenceService.findByStackId(oldId);
                if (oldLoadbalancers.isEmpty()) {
                    Stack oldStack = stackService.getByIdWithGatewayInTransaction(oldId);
                    if (stack.getDisplayName().equals(oldStack.getDisplayName())) {
                        endpoint = oldStack.getPrimaryGatewayInstance().getShortHostname();
                    }
                }
            }
            LOGGER.info("Saving load balancer endpoint as: {}", endpoint);
            loadBalancerEntry.setEndpoint(endpoint);
            loadBalancerEntry.setProviderConfig(loadBalancerConfigConverter.convertLoadBalancer(stack.getCloudPlatform(), cloudLoadBalancerMetadata));
            loadBalancerPersistenceService.save(loadBalancerEntry);
            Set<TargetGroup> targetGroups = targetGroupPersistenceService.findByLoadBalancerId(loadBalancerEntry.getId());
            for (TargetGroup targetGroup : targetGroups) {
                targetGroup.setProviderConfig(loadBalancerConfigConverter.convertTargetGroup(stack.getCloudPlatform(), cloudLoadBalancerMetadata, targetGroup));
                targetGroupPersistenceService.save(targetGroup);
            }
        }
    } catch (Exception ex) {
        throw new CloudbreakServiceException("Load balancer metadata collection failed", ex);
    }
}
Also used : 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) Optional(java.util.Optional) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) StackIdView(com.sequenceiq.cloudbreak.domain.projection.StackIdView) TransactionRuntimeExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionRuntimeExecutionException) TransactionExecutionException(com.sequenceiq.cloudbreak.common.service.TransactionService.TransactionExecutionException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudLoadBalancerMetadata(com.sequenceiq.cloudbreak.cloud.model.CloudLoadBalancerMetadata) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup)

Aggregations

Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)20 List (java.util.List)19 Set (java.util.Set)18 Inject (javax.inject.Inject)18 Optional (java.util.Optional)17 Logger (org.slf4j.Logger)17 LoggerFactory (org.slf4j.LoggerFactory)17 Map (java.util.Map)16 Collectors (java.util.stream.Collectors)15 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)14 HashSet (java.util.HashSet)13 Status (com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status)11 Collection (java.util.Collection)11 Collections (java.util.Collections)11 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)9 ResourceEvent (com.sequenceiq.cloudbreak.event.ResourceEvent)9 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)8 VolumeSetAttributes (com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes)8 ResourceAttributeUtil (com.sequenceiq.cloudbreak.cluster.util.ResourceAttributeUtil)8 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)8