use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class ClusterHostServiceRunner method collectUpscaleCandidates.
private Map<String, String> collectUpscaleCandidates(Long clusterId, Map<String, Integer> hostGroupWithAdjustment) {
Map<String, String> hostNames = new HashMap<>();
for (Map.Entry<String, Integer> entry : hostGroupWithAdjustment.entrySet()) {
String hostGroupName = entry.getKey();
Integer adjustment = entry.getValue();
HostGroup hostGroup = hostGroupService.findHostGroupInClusterByName(clusterId, hostGroupName).orElseThrow(NotFoundException.notFound("hostgroup", hostGroupName));
if (hostGroup.getInstanceGroup() != null) {
Long instanceGroupId = hostGroup.getInstanceGroup().getId();
instanceMetaDataService.findUnusedHostsInInstanceGroup(instanceGroupId).stream().filter(instanceMetaData -> instanceMetaData.getDiscoveryFQDN() != null).sorted(Comparator.comparing(InstanceMetaData::getStartDate)).limit(adjustment.longValue()).forEach(im -> hostNames.put(im.getDiscoveryFQDN(), im.getPrivateIp()));
}
}
return hostNames;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class GrainPropertiesService method addCloudIdentityRolesForHosts.
private GrainProperties addCloudIdentityRolesForHosts(Cluster cluster, Set<Node> nodes) {
Set<InstanceMetaData> instanceMetaDataSet = instanceMetaDataService.getAllInstanceMetadataByStackId(cluster.getStack().getId());
GrainProperties propertiesForIdentityRoles = new GrainProperties();
Set<String> hostNames = nodes.stream().map(Node::getHostname).collect(toSet());
for (InstanceMetaData instanceMetaData : instanceMetaDataSet) {
if (hostNames.contains(instanceMetaData.getDiscoveryFQDN())) {
setCloudIdentityRoles(propertiesForIdentityRoles, instanceMetaData);
}
}
return propertiesForIdentityRoles.getProperties().isEmpty() ? null : propertiesForIdentityRoles;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class AmbariClusterResetService method resetCluster.
public void resetCluster(Long stackId) throws CloudbreakOrchestratorException {
Stack stack = stackService.getByIdWithListsInTransaction(stackId);
InstanceMetaData gatewayInstance = stack.getPrimaryGatewayInstance();
GatewayConfig gatewayConfig = gatewayConfigService.getGatewayConfig(stack, gatewayInstance, stack.getCluster().hasGateway());
Set<String> gatewayFQDN = Collections.singleton(gatewayInstance.getDiscoveryFQDN());
ExitCriteriaModel exitCriteriaModel = clusterDeletionBasedModel(stack.getId(), stack.getCluster().getId());
hostOrchestrator.resetClusterManager(gatewayConfig, gatewayFQDN, stackUtil.collectNodes(stack), exitCriteriaModel);
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class ClusterBuilderService method loadInstanceMetadataForHostGroups.
private Map<HostGroup, List<InstanceMetaData>> loadInstanceMetadataForHostGroups(Iterable<HostGroup> hostGroups) {
Map<HostGroup, List<InstanceMetaData>> instanceMetaDataByHostGroup = new HashMap<>();
for (HostGroup hostGroup : hostGroups) {
Long instanceGroupId = hostGroup.getInstanceGroup().getId();
List<InstanceMetaData> metas = instanceMetaDataService.findAliveInstancesInInstanceGroup(instanceGroupId);
instanceMetaDataByHostGroup.put(hostGroup, metas);
}
return instanceMetaDataByHostGroup;
}
use of com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData in project cloudbreak by hortonworks.
the class ClusterRepairFlowEventChainFactory method downscaleEvent.
private StackEvent downscaleEvent(boolean singlePrimaryGW, ClusterRepairTriggerEvent event, Map<String, Set<String>> groupsWithHostNames) {
Set<InstanceMetaData> instanceMetaData = instanceMetaDataService.getAllInstanceMetadataWithoutInstanceGroupByStackId(event.getStackId());
Map<String, Set<Long>> groupsWithPrivateIds = new HashMap<>();
Map<String, Integer> groupsWithAdjustment = new HashMap<>();
for (Entry<String, Set<String>> groupWithHostNames : groupsWithHostNames.entrySet()) {
Set<String> hostNames = groupWithHostNames.getValue();
String group = groupWithHostNames.getKey();
Set<Long> privateIdsForHostNames = stackService.getPrivateIdsForHostNames(instanceMetaData, hostNames);
groupsWithPrivateIds.put(group, privateIdsForHostNames);
int size = hostNames != null ? hostNames.size() : 0;
groupsWithAdjustment.put(group, size);
}
LOGGER.info("Downscale groups with adjustments: {}", groupsWithAdjustment);
LOGGER.info("Downscale groups with privateIds: {}", groupsWithPrivateIds);
if (!singlePrimaryGW) {
LOGGER.info("Full downscale for the following: {}", groupsWithHostNames);
return new ClusterAndStackDownscaleTriggerEvent(FlowChainTriggers.FULL_DOWNSCALE_TRIGGER_EVENT, event.getResourceId(), groupsWithAdjustment, groupsWithPrivateIds, groupsWithHostNames, ScalingType.DOWNSCALE_TOGETHER, event.accepted(), new ClusterDownscaleDetails(true, true));
} else {
LOGGER.info("Stack downscale for the following: {}", groupsWithHostNames);
return new StackDownscaleTriggerEvent(STACK_DOWNSCALE_EVENT.event(), event.getResourceId(), groupsWithAdjustment, groupsWithPrivateIds, groupsWithHostNames, event.getTriggeredStackVariant(), event.accepted()).setRepair();
}
}
Aggregations