use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class BlueprintValidator method validateBlueprintForStack.
public void validateBlueprintForStack(Cluster cluster, Blueprint blueprint, Collection<HostGroup> hostGroups, Collection<InstanceGroup> instanceGroups) {
try {
JsonNode hostGroupsNode = getHostGroupNode(blueprint);
validateHostGroups(hostGroupsNode, hostGroups, instanceGroups);
Map<String, HostGroup> hostGroupMap = createHostGroupMap(hostGroups);
Map<String, BlueprintServiceComponent> blueprintServiceComponentMap = Maps.newHashMap();
for (JsonNode hostGroupNode : hostGroupsNode) {
validateHostGroup(hostGroupNode, hostGroupMap, blueprintServiceComponentMap);
}
validateBlueprintServiceComponents(blueprintServiceComponentMap);
validateKnoxWithKerberos(cluster, instanceGroups, blueprintServiceComponentMap);
} catch (IOException e) {
throw new BlueprintValidationException(String.format("Blueprint [%s] can not be parsed from JSON.", blueprint.getId()), e);
}
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class ClusterToClusterResponseConverter method prepareServiceEndpointsMap.
private Map<String, String> prepareServiceEndpointsMap(Cluster cluster, String ambariIp) {
Set<HostGroup> hostGroups = cluster.getHostGroups();
Blueprint blueprint = cluster.getBlueprint();
Map<String, String> result = new HashMap<>();
List<Port> ports = NetworkUtils.getPorts(Optional.empty());
try {
JsonNode hostGroupsNode = blueprintValidator.getHostGroupNode(blueprint);
Map<String, HostGroup> hostGroupMap = blueprintValidator.createHostGroupMap(hostGroups);
for (JsonNode hostGroupNode : hostGroupsNode) {
String hostGroupName = blueprintValidator.getHostGroupName(hostGroupNode);
JsonNode componentsNode = blueprintValidator.getComponentsNode(hostGroupNode);
HostGroup actualHostgroup = hostGroupMap.get(hostGroupName);
String serviceAddress;
if (actualHostgroup.getConstraint().getInstanceGroup() != null) {
InstanceMetaData next = actualHostgroup.getConstraint().getInstanceGroup().getInstanceMetaData().iterator().next();
serviceAddress = next.getPublicIpWrapper();
} else {
serviceAddress = actualHostgroup.getHostMetadata().iterator().next().getHostName();
}
for (JsonNode componentNode : componentsNode) {
String componentName = componentNode.get("name").asText();
StackServiceComponentDescriptor componentDescriptor = stackServiceComponentDescs.get(componentName);
collectServicePorts(result, ports, ambariIp, serviceAddress, componentDescriptor, cluster);
}
}
} catch (Exception ignored) {
return result;
}
return result;
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class HostGroupRequestToHostGroupConverter method convert.
@Override
public HostGroup convert(HostGroupRequest source) {
HostGroup hostGroup = new HostGroup();
hostGroup.setName(source.getName());
hostGroup.setRecoveryMode(source.getRecoveryMode());
return hostGroup;
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class ComponentLocatorService method getComponentLocation.
public Map<String, List<String>> getComponentLocation(Cluster cluster, Collection<String> componentNames) {
Map<String, List<String>> result = new HashMap<>();
for (HostGroup hg : hostGroupService.getByCluster(cluster.getId())) {
Set<String> hgComponents = blueprintProcessorFactory.get(cluster.getBlueprint().getBlueprintText()).getComponentsInHostGroup(hg.getName());
hgComponents.retainAll(componentNames);
List<String> fqdn = hg.getConstraint().getInstanceGroup().getInstanceMetaData().stream().map(InstanceMetaData::getDiscoveryFQDN).collect(Collectors.toList());
for (String service : hgComponents) {
List<String> storedAddresses = result.get(service);
if (storedAddresses == null) {
result.put(service, fqdn);
} else {
storedAddresses.addAll(fqdn);
}
}
}
return result;
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class AmbariClusterService method updateHostCountWithAdjustment.
@Override
public void updateHostCountWithAdjustment(Long clusterId, String hostGroupName, Integer adjustment) {
HostGroup hostGroup = hostGroupService.getByClusterIdAndName(clusterId, hostGroupName);
Constraint constraint = hostGroup.getConstraint();
constraint.setHostCount(constraint.getHostCount() + adjustment);
constraintRepository.save(constraint);
}
Aggregations