use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class ClouderaManagerSetupService method prepareTemplate.
@Override
public String prepareTemplate(Map<HostGroup, List<InstanceMetaData>> instanceMetaDataByHostGroup, TemplatePreparationObject templatePreparationObject, String sdxContext, String sdxCrn, KerberosConfig kerberosConfig) {
Long clusterId = stack.getCluster().getId();
try {
Set<InstanceMetaData> instances = instanceMetaDataByHostGroup.values().stream().flatMap(Collection::stream).collect(Collectors.toSet());
waitForHosts(instances);
String sdxContextName = Optional.ofNullable(sdxContext).map(this::setupRemoteDataContext).orElse(null);
ClouderaManagerRepo clouderaManagerRepoDetails = clusterComponentProvider.getClouderaManagerRepoDetails(clusterId);
ApiClusterTemplate apiClusterTemplate = getCmTemplate(templatePreparationObject, sdxContextName, instanceMetaDataByHostGroup, clouderaManagerRepoDetails, clusterId);
return getExtendedBlueprintText(apiClusterTemplate);
} catch (CancellationException cancellationException) {
throw cancellationException;
} catch (Exception e) {
throw mapException(e);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class ClouderaHostGroupAssociationBuilder method buildHostGroupAssociation.
private List<Map<String, String>> buildHostGroupAssociation(List<InstanceMetaData> instanceMetadataList) {
List<Map<String, String>> hostInfoForHostGroup = new ArrayList<>();
for (InstanceMetaData metaData : instanceMetadataList) {
Map<String, String> hostInfo = new HashMap<>();
hostInfo.put(ClusterHostAttributes.FQDN, metaData.getDiscoveryFQDN());
NullUtil.putIfPresent(hostInfo, ClusterHostAttributes.RACK_ID, metaData.getRackId());
hostInfoForHostGroup.add(hostInfo);
}
return hostInfoForHostGroup;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class StackCreatorService method prepareInstanceMetaDataSubnetAndAvailabilityZoneAndRackId.
private void prepareInstanceMetaDataSubnetAndAvailabilityZoneAndRackId(String stackSubnetId, String stackAz, InstanceGroup instanceGroup) {
for (InstanceMetaData instanceMetaData : instanceGroup.getAllInstanceMetaData()) {
if (Strings.isNullOrEmpty(instanceMetaData.getSubnetId()) && Strings.isNullOrEmpty(instanceMetaData.getAvailabilityZone())) {
instanceMetaData.setSubnetId(stackSubnetId);
instanceMetaData.setAvailabilityZone(stackAz);
}
instanceMetaData.setRackId(multiAzCalculatorService.determineRackId(instanceMetaData.getSubnetId(), instanceMetaData.getAvailabilityZone()));
}
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class StackCreatorService method fillInstanceMetadata.
@VisibleForTesting
void fillInstanceMetadata(DetailedEnvironmentResponse environment, Stack stack) {
long privateIdNumber = 0;
Map<String, String> subnetAzPairs = multiAzCalculatorService.prepareSubnetAzMap(environment);
String stackSubnetId = getStackSubnetIdIfExists(stack);
String stackAz = stackSubnetId == null ? null : subnetAzPairs.get(stackSubnetId);
for (InstanceGroup instanceGroup : sortInstanceGroups(stack)) {
for (InstanceMetaData instanceMetaData : instanceGroup.getAllInstanceMetaData()) {
instanceMetaData.setPrivateId(privateIdNumber++);
instanceMetaData.setInstanceStatus(InstanceStatus.REQUESTED);
}
multiAzCalculatorService.calculateByRoundRobin(subnetAzPairs, instanceGroup);
prepareInstanceMetaDataSubnetAndAvailabilityZoneAndRackId(stackSubnetId, stackAz, instanceGroup);
}
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class VmStatusCheckerConclusionStep method checkCMForInstanceStatuses.
private Conclusion checkCMForInstanceStatuses(ClusterApi connector, Set<InstanceMetaData> runningInstances, Long clusterId) {
ExtendedHostStatuses extendedHostStatuses = connector.clusterStatusService().getExtendedHostStatuses(runtimeVersionService.getRuntimeVersion(clusterId));
Map<HostName, Set<HealthCheck>> hostStatuses = extendedHostStatuses.getHostsHealth();
Map<String, String> unhealthyHosts = hostStatuses.keySet().stream().filter(hostName -> !extendedHostStatuses.isHostHealthy(hostName)).collect(Collectors.toMap(StringType::value, extendedHostStatuses::statusReasonForHost));
Set<String> noReportHosts = runningInstances.stream().map(InstanceMetaData::getDiscoveryFQDN).filter(Objects::nonNull).filter(discoveryFQDN -> !hostStatuses.containsKey(hostName(discoveryFQDN))).collect(toSet());
if (!unhealthyHosts.isEmpty() || !noReportHosts.isEmpty()) {
String conclusion = String.format("Unhealthy and/or unknown VMs found based on CM status. Unhealthy VMs: %s, unknown VMs: %s. " + "Please check the instances on your cloud provider for further details.", unhealthyHosts, noReportHosts);
String details = String.format("Unhealthy and/or unknown VMs found based on CM status. Unhealthy VMs: %s, unknown VMs: %s", unhealthyHosts, noReportHosts);
LOGGER.warn(details);
return failed(conclusion, details);
} else {
return succeeded();
}
}
Aggregations