Search in sources :

Example 76 with HostGroup

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);
    }
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) JsonNode(com.fasterxml.jackson.databind.JsonNode) IOException(java.io.IOException)

Example 77 with HostGroup

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;
}
Also used : HashMap(java.util.HashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Port(com.sequenceiq.cloudbreak.api.model.Port) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) JsonNode(com.fasterxml.jackson.databind.JsonNode) CloudbreakApiException(com.sequenceiq.cloudbreak.controller.CloudbreakApiException) IOException(java.io.IOException) InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) StackServiceComponentDescriptor(com.sequenceiq.cloudbreak.blueprint.validation.StackServiceComponentDescriptor)

Example 78 with HostGroup

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;
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup)

Example 79 with 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;
}
Also used : HashMap(java.util.HashMap) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) List(java.util.List)

Example 80 with HostGroup

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);
}
Also used : Constraint(com.sequenceiq.cloudbreak.domain.Constraint) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup)

Aggregations

HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)94 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)33 Test (org.junit.Test)33 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)31 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)29 HashSet (java.util.HashSet)22 JsonNode (com.fasterxml.jackson.databind.JsonNode)20 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)20 List (java.util.List)20 HashMap (java.util.HashMap)19 Stack (com.sequenceiq.cloudbreak.domain.Stack)18 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)16 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)15 Map (java.util.Map)14 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)13 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)12 Constraint (com.sequenceiq.cloudbreak.domain.Constraint)11 ArrayList (java.util.ArrayList)11 Set (java.util.Set)11 Inject (javax.inject.Inject)11