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.");
}
}
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);
}
}
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;
}
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);
}
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;
}
Aggregations