Search in sources :

Example 1 with ATTRIBUTES

use of com.sequenceiq.cloudbreak.cloud.model.CloudResource.ATTRIBUTES in project cloudbreak by hortonworks.

the class InstanceMetaDataService method getAzFromDiskOrNullIfRepair.

@VisibleForTesting
String getAzFromDiskOrNullIfRepair(Stack stack, boolean repair, String instanceGroup, String hostname) {
    String availabilityZone = null;
    if (repair) {
        ResourceType resourceType = getSupportedReattachableDiskType(stack);
        if (resourceType != null) {
            List<CloudResource> reattachableDiskResources = resourceRetriever.findAllByStatusAndTypeAndStackAndInstanceGroup(CommonStatus.DETACHED, resourceType, stack.getId(), instanceGroup);
            Optional<CloudResource> reattachableDiskResource = reattachableDiskResources.stream().filter(d -> d.getParameter(ATTRIBUTES, VolumeSetAttributes.class).getDiscoveryFQDN().equals(hostname)).findFirst();
            if (reattachableDiskResource.isPresent()) {
                VolumeSetAttributes volumeSetAttributes = reattachableDiskResource.get().getParameter(ATTRIBUTES, VolumeSetAttributes.class);
                availabilityZone = volumeSetAttributes.getAvailabilityZone();
                LOGGER.debug("Found AZ for the {}: {}", resourceType, availabilityZone);
            } else {
                LOGGER.debug("Cannot find {} for {} in instanceGroup of {}", resourceType, hostname, instanceGroup);
            }
        }
    }
    return availabilityZone;
}
Also used : Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ATTRIBUTES(com.sequenceiq.cloudbreak.cloud.model.CloudResource.ATTRIBUTES) InstanceMetaDataRepository(com.sequenceiq.cloudbreak.repository.InstanceMetaDataRepository) Network(com.sequenceiq.cloudbreak.domain.Network) LoggerFactory(org.slf4j.LoggerFactory) CloudInstance(com.sequenceiq.cloudbreak.cloud.model.CloudInstance) ResourceRetriever(com.sequenceiq.cloudbreak.cloud.service.ResourceRetriever) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) Inject(javax.inject.Inject) Strings(com.google.common.base.Strings) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) TransactionService(com.sequenceiq.cloudbreak.common.service.TransactionService) Service(org.springframework.stereotype.Service) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) CommonStatus(com.sequenceiq.common.api.type.CommonStatus) ResourceType(com.sequenceiq.common.api.type.ResourceType) NetworkScaleDetails(com.sequenceiq.cloudbreak.core.flow2.dto.NetworkScaleDetails) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Benchmark.measure(com.sequenceiq.cloudbreak.util.Benchmark.measure) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Collection(java.util.Collection) Set(java.util.Set) PageRequest(org.springframework.data.domain.PageRequest) EnvironmentClientService(com.sequenceiq.cloudbreak.service.environment.EnvironmentClientService) AccessDeniedException(org.springframework.security.access.AccessDeniedException) Page(org.springframework.data.domain.Page) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) Collectors(java.util.stream.Collectors) RegionAwareInternalCrnGeneratorFactory(com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory) Objects(java.util.Objects) Json(com.sequenceiq.cloudbreak.common.json.Json) List(java.util.List) MultiAzCalculatorService(com.sequenceiq.cloudbreak.service.multiaz.MultiAzCalculatorService) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) Group(com.sequenceiq.cloudbreak.cloud.model.Group) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) Optional(java.util.Optional) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) VisibleForTesting(com.google.common.annotations.VisibleForTesting) StackInstanceCount(com.sequenceiq.cloudbreak.domain.projection.StackInstanceCount) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Collections(java.util.Collections) ResourceType(com.sequenceiq.common.api.type.ResourceType) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) VolumeSetAttributes(com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Strings (com.google.common.base.Strings)1 StackType (com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType)1 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)1 RegionAwareInternalCrnGeneratorFactory (com.sequenceiq.cloudbreak.auth.crn.RegionAwareInternalCrnGeneratorFactory)1 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)1 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)1 ATTRIBUTES (com.sequenceiq.cloudbreak.cloud.model.CloudResource.ATTRIBUTES)1 Group (com.sequenceiq.cloudbreak.cloud.model.Group)1 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)1 VolumeSetAttributes (com.sequenceiq.cloudbreak.cloud.model.VolumeSetAttributes)1 ResourceRetriever (com.sequenceiq.cloudbreak.cloud.service.ResourceRetriever)1 CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 CloudPlatform (com.sequenceiq.cloudbreak.common.mappable.CloudPlatform)1 TransactionService (com.sequenceiq.cloudbreak.common.service.TransactionService)1 NetworkScaleDetails (com.sequenceiq.cloudbreak.core.flow2.dto.NetworkScaleDetails)1 Network (com.sequenceiq.cloudbreak.domain.Network)1 StackInstanceCount (com.sequenceiq.cloudbreak.domain.projection.StackInstanceCount)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1