use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class AmbariDecommissioner method verifyNodeCount.
public void verifyNodeCount(@Nonnull Stack stack, @Nonnull Cluster cluster, @Nonnull String hostName) {
requireNonNull(stack);
requireNonNull(cluster);
requireNonNull(hostName);
HttpClientConfig clientConfig = tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), cluster.getAmbariIp());
AmbariClient ambariClient = ambariClientProvider.getAmbariClient(clientConfig, stack.getGatewayPort(), cluster);
String ambariName = cluster.getBlueprint().getAmbariName();
HostGroup hostGroup = hostGroupService.getByClusterAndHostName(cluster, hostName);
int replication = getReplicationFactor(ambariClient.getBlueprintMap(ambariName), hostGroup, ambariClient);
int hostSize = 1;
int reservedInstances = hostGroup.getHostMetadata().size() - hostSize;
verifyNodeCount(replication, hostSize, hostSize, reservedInstances);
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class AmbariDecommissioner method collectHostMetadata.
private Map<String, HostMetadata> collectHostMetadata(Cluster cluster, String hostGroupName, Collection<String> hostNames) {
HostGroup hostGroup = hostGroupService.getByClusterIdAndName(cluster.getId(), hostGroupName);
Set<HostMetadata> hostsInHostGroup = hostGroup.getHostMetadata();
Map<String, HostMetadata> hostMetadatas = hostsInHostGroup.stream().filter(hostMetadata -> hostNames.contains(hostMetadata.getHostName())).collect(Collectors.toMap(HostMetadata::getHostName, hostMetadata -> hostMetadata));
return hostMetadatas;
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class ClusterTerminationService method deleteClusterHostGroupsWithItsMetadata.
private void deleteClusterHostGroupsWithItsMetadata(Cluster cluster) {
Set<HostGroup> hostGroups = hostGroupRepository.findHostGroupsInCluster(cluster.getId());
Collection<Constraint> constraintsToDelete = new LinkedList<>();
for (HostGroup hg : hostGroups) {
hg.getRecipes().clear();
Constraint constraint = hg.getConstraint();
if (constraint != null) {
constraintsToDelete.add(constraint);
}
}
hostGroupRepository.delete(hostGroups);
constraintRepository.delete(constraintsToDelete);
cluster.getHostGroups().clear();
cluster.getContainers().clear();
clusterRepository.save(cluster);
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class OrchestratorRecipeExecutor method uploadRecipes.
public void uploadRecipes(Stack stack, Collection<HostGroup> hostGroups) throws CloudbreakException {
HostOrchestrator hostOrchestrator = hostOrchestratorResolver.get(stack.getOrchestrator().getType());
Map<String, List<RecipeModel>> recipeMap = hostGroups.stream().filter(hg -> !hg.getRecipes().isEmpty()).collect(Collectors.toMap(HostGroup::getName, h -> convert(h.getRecipes())));
List<GatewayConfig> allGatewayConfigs = gatewayConfigService.getAllGatewayConfigs(stack);
recipesEvent(stack.getId(), stack.getStatus(), recipeMap);
try {
hostOrchestrator.uploadRecipes(allGatewayConfigs, recipeMap, clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId()));
} catch (CloudbreakOrchestratorFailedException e) {
throw new CloudbreakException(e);
}
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class HostGroupAssociationBuilder method buildHostGroupAssociations.
public Map<String, List<Map<String, String>>> buildHostGroupAssociations(Iterable<HostGroup> hostGroups) {
Map<String, List<Map<String, String>>> hostGroupMappings = new HashMap<>();
LOGGER.info("Computing host - hostGroup mappings based on hostGroup - instanceGroup associations");
for (HostGroup hostGroup : hostGroups) {
List<Map<String, String>> hostInfoForHostGroup = new ArrayList<>();
if (hostGroup.getConstraint().getInstanceGroup() != null) {
Map<String, String> topologyMapping = getTopologyMapping(hostGroup);
Long instanceGroupId = hostGroup.getConstraint().getInstanceGroup().getId();
List<InstanceMetaData> metas = instanceMetadataRepository.findAliveInstancesInInstanceGroup(instanceGroupId);
if (metas.isEmpty()) {
for (HostMetadata hostMetadata : hostGroup.getHostMetadata()) {
Map<String, String> hostInfo = new HashMap<>();
hostInfo.put(FQDN, hostMetadata.getHostName());
hostInfoForHostGroup.add(hostInfo);
}
} else {
for (InstanceMetaData meta : metas) {
Map<String, String> hostInfo = new HashMap<>();
hostInfo.put(FQDN, meta.getDiscoveryFQDN());
String localityIndicator = meta.getLocalityIndicator();
if (localityIndicator != null) {
if (topologyMapping.isEmpty()) {
// Azure
if (localityIndicator.startsWith("/")) {
hostInfo.put("rack", meta.getLocalityIndicator());
// Openstack
} else {
hostInfo.put("rack", '/' + meta.getLocalityIndicator());
}
// With topology mapping
} else {
hostInfo.put("hypervisor", meta.getLocalityIndicator());
hostInfo.put("rack", topologyMapping.get(meta.getLocalityIndicator()));
}
}
hostInfoForHostGroup.add(hostInfo);
}
}
} else {
for (HostMetadata hostMetadata : hostGroup.getHostMetadata()) {
Map<String, String> hostInfo = new HashMap<>();
hostInfo.put(FQDN, hostMetadata.getHostName());
hostInfoForHostGroup.add(hostInfo);
}
}
hostGroupMappings.put(hostGroup.getName(), hostInfoForHostGroup);
}
LOGGER.info("Computed host-hostGroup associations: {}", hostGroupMappings);
return hostGroupMappings;
}
Aggregations