Search in sources :

Example 16 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class NodeStatusService method getMeteringReport.

public RPCResponse<NodeStatusProto.NodeStatusReport> getMeteringReport(Stack stack) {
    MDCBuilder.buildMdcContext(stack);
    LOGGER.debug("Retrieving metering report from the hosts of stack: {}", stack.getResourceCrn());
    try (CdpNodeStatusMonitorClient client = factory.getClient(stack, stack.getPrimaryGatewayInstance())) {
        return client.nodeMeteringReport();
    } catch (CdpNodeStatusMonitorClientException e) {
        throw new CloudbreakServiceException("Could not get metering report from stack.");
    }
}
Also used : CdpNodeStatusMonitorClientException(com.sequenceiq.node.health.client.CdpNodeStatusMonitorClientException) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CdpNodeStatusMonitorClient(com.sequenceiq.node.health.client.CdpNodeStatusMonitorClient)

Example 17 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class ComponentConfigProviderService method getImage.

public Image getImage(Long stackId) throws CloudbreakImageNotFoundException {
    try {
        Component component = getComponent(stackId, ComponentType.IMAGE, ComponentType.IMAGE.name());
        if (component == null) {
            throw new CloudbreakImageNotFoundException(String.format("Image not found: stackId: %d, componentType: %s, name: %s", stackId, ComponentType.IMAGE.name(), ComponentType.IMAGE.name()));
        }
        LOGGER.debug("Image found! stackId: {}, component: {}", stackId, component);
        return component.getAttributes().get(Image.class);
    } catch (IOException e) {
        throw new CloudbreakServiceException("Failed to read image", e);
    }
}
Also used : CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) IOException(java.io.IOException) Component(com.sequenceiq.cloudbreak.domain.stack.Component)

Example 18 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class LoadBalancerConfigService method createLoadBalancers.

public Set<LoadBalancer> createLoadBalancers(Stack stack, DetailedEnvironmentResponse environment, StackV4Request source) {
    LoadBalancerSku sku = getLoadBalancerSku(source);
    boolean azureLoadBalancerDisabled = CloudPlatform.AZURE.toString().equalsIgnoreCase(stack.getCloudPlatform()) && LoadBalancerSku.NONE.equals(sku);
    if (azureLoadBalancerDisabled) {
        Optional<TargetGroup> oozieTargetGroup = setupOozieHATargetGroup(stack, true);
        if (oozieTargetGroup.isPresent()) {
            throw new CloudbreakServiceException("Unsupported setup: Load balancers are disabled, but Oozie HA is configured. " + "Either enable Azure load balancers, or use a non-HA Oozie setup.");
        }
        LOGGER.debug("Azure load balancers have been explicitly disabled.");
        return Collections.emptySet();
    }
    boolean loadBalancerFlagEnabled = source != null && source.isEnableLoadBalancer();
    Set<LoadBalancer> loadBalancers = setupLoadBalancers(stack, environment, false, loadBalancerFlagEnabled, sku);
    if (stack.getCloudPlatform().equalsIgnoreCase(CloudPlatform.AZURE.toString())) {
        configureLoadBalancerAvailabilitySets(stack.getName(), loadBalancers);
        configureLoadBalancerSku(source, loadBalancers);
    }
    return loadBalancers;
}
Also used : LoadBalancerSku(com.sequenceiq.common.api.type.LoadBalancerSku) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer)

Example 19 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class LoadBalancerConfigService method setupKnoxTargetGroup.

private Optional<TargetGroup> setupKnoxTargetGroup(Stack stack, boolean dryRun) {
    TargetGroup knoxTargetGroup = null;
    Set<String> knoxGatewayGroupNames = getKnoxGatewayGroups(stack);
    Set<InstanceGroup> knoxGatewayInstanceGroups = stack.getInstanceGroups().stream().filter(ig -> knoxGatewayGroupNames.contains(ig.getGroupName())).collect(Collectors.toSet());
    if (AZURE.equalsIgnoreCase(stack.getCloudPlatform()) && knoxGatewayInstanceGroups.size() > 1) {
        throw new CloudbreakServiceException("For Azure load balancers, Knox must be defined in a single instance group.");
    } else if (!knoxGatewayInstanceGroups.isEmpty()) {
        LOGGER.info("Knox gateway instance found; enabling Knox load balancer configuration.");
        knoxTargetGroup = new TargetGroup();
        knoxTargetGroup.setType(TargetGroupType.KNOX);
        knoxTargetGroup.setInstanceGroups(knoxGatewayInstanceGroups);
        if (!dryRun) {
            LOGGER.debug("Adding target group to Knox gateway instances groups.");
            TargetGroup finalKnoxTargetGroup = knoxTargetGroup;
            knoxGatewayInstanceGroups.forEach(ig -> ig.addTargetGroup(finalKnoxTargetGroup));
        } else {
            LOGGER.debug("Dry run, skipping instance group/target group linkage.");
        }
    }
    return Optional.ofNullable(knoxTargetGroup);
}
Also used : Arrays(java.util.Arrays) EntitlementService(com.sequenceiq.cloudbreak.auth.altus.EntitlementService) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) OozieRoles(com.sequenceiq.cloudbreak.cmtemplate.configproviders.oozie.OozieRoles) ThreadBasedUserCrnProvider(com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider) LoadBalancer(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.LoadBalancer) ProviderParameterCalculator(com.sequenceiq.cloudbreak.common.mappable.ProviderParameterCalculator) PublicEndpointAccessGateway(com.sequenceiq.common.api.type.PublicEndpointAccessGateway) Map(java.util.Map) DetailedEnvironmentResponse(com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse) SubnetSelector(com.sequenceiq.cloudbreak.converter.v4.environment.network.SubnetSelector) AzureStackV4Parameters(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.parameter.stack.AzureStackV4Parameters) LoadBalancerPersistenceService(com.sequenceiq.cloudbreak.service.stack.LoadBalancerPersistenceService) Set(java.util.Set) LoadBalancerSku(com.sequenceiq.common.api.type.LoadBalancerSku) Collectors(java.util.stream.Collectors) KnoxRoles(com.sequenceiq.cloudbreak.cmtemplate.configproviders.knox.KnoxRoles) Json(com.sequenceiq.cloudbreak.common.json.Json) List(java.util.List) Optional(java.util.Optional) GCP(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.GCP) CmTemplateProcessor(com.sequenceiq.cloudbreak.cmtemplate.CmTemplateProcessor) CLOUDERA_STACK_VERSION_7_2_11(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.CLOUDERA_STACK_VERSION_7_2_11) OOZIE_HTTPS_PORT(com.sequenceiq.cloudbreak.cmtemplate.configproviders.oozie.OozieHAConfigProvider.OOZIE_HTTPS_PORT) NetworkConstants(com.sequenceiq.cloudbreak.common.network.NetworkConstants) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) TargetGroupPortPair(com.sequenceiq.cloudbreak.cloud.model.TargetGroupPortPair) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) Network(com.sequenceiq.cloudbreak.domain.Network) EnvironmentNetworkResponse(com.sequenceiq.environment.api.v1.environment.model.response.EnvironmentNetworkResponse) CloudPlatform(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform) LoadBalancerType(com.sequenceiq.common.api.type.LoadBalancerType) HashSet(java.util.HashSet) Inject(javax.inject.Inject) Value(org.springframework.beans.factory.annotation.Value) AWS(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AWS) Service(org.springframework.stereotype.Service) CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited(com.sequenceiq.cloudbreak.cmtemplate.CMRepositoryVersionUtil.isVersionNewerOrEqualThanLimited) NetworkV4Base(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.NetworkV4Base) Map.entry(java.util.Map.entry) AzureInstanceGroupParameters(com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceGroupParameters) LoadBalancerCreation(com.sequenceiq.common.api.type.LoadBalancerCreation) CloudSubnet(com.sequenceiq.cloudbreak.cloud.model.CloudSubnet) Logger(org.slf4j.Logger) AvailabilitySetNameService(com.sequenceiq.cloudbreak.cloud.model.instance.AvailabilitySetNameService) TargetGroupType(com.sequenceiq.common.api.type.TargetGroupType) InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) StackV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) StackType(com.sequenceiq.cloudbreak.api.endpoint.v4.common.StackType) Preconditions(com.google.common.base.Preconditions) AZURE(com.sequenceiq.cloudbreak.common.mappable.CloudPlatform.AZURE) Collections(java.util.Collections) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException) TargetGroup(com.sequenceiq.cloudbreak.domain.stack.loadbalancer.TargetGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 20 with CloudbreakServiceException

use of com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException in project cloudbreak by hortonworks.

the class ClusterService method updateClusterManagerHostStatus.

private InstanceMetaData updateClusterManagerHostStatus(Set<InstanceMetaData> notTerminatedInstanceMetaDatas) {
    InstanceMetaData cmInstance = notTerminatedInstanceMetaDatas.stream().filter(InstanceMetaData::getClusterManagerServer).findFirst().orElseThrow(() -> new CloudbreakServiceException("Cluster manager inaccessible, and the corresponding instance metadata not found."));
    cmInstance.setInstanceStatus(SERVICES_UNHEALTHY);
    cmInstance.setStatusReason("Cluster manager inaccessible.");
    instanceMetaDataService.save(cmInstance);
    return cmInstance;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) CloudbreakServiceException(com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)

Aggregations

CloudbreakServiceException (com.sequenceiq.cloudbreak.common.exception.CloudbreakServiceException)142 Test (org.junit.jupiter.api.Test)25 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)24 List (java.util.List)20 CancellationException (com.sequenceiq.cloudbreak.cloud.scheduler.CancellationException)18 IOException (java.io.IOException)18 Map (java.util.Map)18 ApiException (com.cloudera.api.swagger.client.ApiException)17 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)16 Collectors (java.util.stream.Collectors)15 Inject (javax.inject.Inject)15 Logger (org.slf4j.Logger)15 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)14 LoggerFactory (org.slf4j.LoggerFactory)14 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)13 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)12 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)12 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)12 Optional (java.util.Optional)12 Set (java.util.Set)12