use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class ClusterUpscaleFlowService method updateMetadata.
private int updateMetadata(StackView stackView, String hostGroupName) {
LOGGER.info("Start update metadata");
HostGroup hostGroup = hostGroupService.getByClusterIdAndName(stackView.getClusterView().getId(), hostGroupName);
Set<HostMetadata> hostMetadata = hostGroupService.findEmptyHostMetadataInHostGroup(hostGroup.getId());
updateFailedHostMetaData(hostMetadata);
int failedHosts = 0;
for (HostMetadata hostMeta : hostMetadata) {
if (hostGroup.getConstraint().getInstanceGroup() != null) {
stackService.updateMetaDataStatus(stackView.getId(), hostMeta.getHostName(), InstanceStatus.REGISTERED);
}
hostGroupService.updateHostMetaDataStatus(hostMeta.getId(), HostMetadataState.HEALTHY);
if (hostMeta.getHostMetadataState() == HostMetadataState.UNHEALTHY) {
failedHosts++;
}
}
return failedHosts;
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class StackRepairServiceTest method setupHostMetadata.
private void setupHostMetadata(Long clusterId, String privateIp, String hostGroupName) {
HostMetadata hmd1 = mock(HostMetadata.class);
HostGroup hg1 = mock(HostGroup.class);
when(hg1.getName()).thenReturn(hostGroupName);
when(hmd1.getHostGroup()).thenReturn(hg1);
when(hostMetadataRepository.findHostInClusterByName(clusterId, privateIp)).thenReturn(hmd1);
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class StackToStackV2RequestConverter method collectInformationsFromActualHostgroup.
private InstanceGroupV2Request collectInformationsFromActualHostgroup(Stack source, InstanceGroup instanceGroup, InstanceGroupV2Request instanceGroupV2Request) {
HostGroup actualHostgroup = null;
for (HostGroup hostGroup : source.getCluster().getHostGroups()) {
if (hostGroup.getName().equals(instanceGroup.getGroupName())) {
actualHostgroup = hostGroup;
}
}
if (actualHostgroup != null) {
instanceGroupV2Request.setRecoveryMode(actualHostgroup.getRecoveryMode());
instanceGroupV2Request.setRecipeNames(new HashSet<>());
for (Recipe recipe : actualHostgroup.getRecipes()) {
instanceGroupV2Request.getRecipeNames().add(recipe.getName());
}
}
return instanceGroupV2Request;
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class StackValidationRequestToStackValidationConverter method convertHostGroupsFromJson.
private Set<HostGroup> convertHostGroupsFromJson(Collection<InstanceGroup> instanceGroups, Iterable<HostGroupRequest> hostGroupsJsons) {
Set<HostGroup> hostGroups = new HashSet<>();
for (HostGroupRequest json : hostGroupsJsons) {
HostGroup hostGroup = new HostGroup();
hostGroup.setName(json.getName());
Constraint constraint = getConversionService().convert(json.getConstraint(), Constraint.class);
String instanceGroupName = json.getConstraint().getInstanceGroupName();
if (instanceGroupName != null) {
InstanceGroup instanceGroup = instanceGroups.stream().filter(instanceGroup1 -> instanceGroup1.getGroupName().equals(instanceGroupName)).findFirst().get();
if (instanceGroup == null) {
throw new BadRequestException(String.format("Cannot find instance group named '%s' in instance group list", instanceGroupName));
}
constraint.setInstanceGroup(instanceGroup);
}
hostGroup.setConstraint(constraint);
hostGroups.add(hostGroup);
}
return hostGroups;
}
use of com.sequenceiq.cloudbreak.domain.HostGroup in project cloudbreak by hortonworks.
the class HostGroupDecorator method getDetailsFromExistingHostGroup.
private HostGroup getDetailsFromExistingHostGroup(Constraint constraint, HostGroup subject, String instanceGroupName, Collection<HostGroup> hostGroups) {
Optional<HostGroup> hostGroupOptional = hostGroups.stream().filter(input -> input.getConstraint().getInstanceGroup().getGroupName().equals(instanceGroupName)).findFirst();
if (hostGroupOptional.isPresent()) {
HostGroup hostGroup = hostGroupOptional.get();
Integer instanceGroupNodeCount = hostGroup.getConstraint().getInstanceGroup().getNodeCount();
if (constraint.getHostCount() > instanceGroupNodeCount) {
throw new BadRequestException(String.format("The 'hostCount' of host group '%s' constraint could not be more than '%s'!", subject.getName(), instanceGroupNodeCount));
}
hostGroup.getConstraint().setHostCount(constraint.getHostCount());
hostGroup.setName(subject.getName());
return hostGroup;
} else {
throw new BadRequestException(String.format("Invalid 'instanceGroupName'! Could not find instance group with name: '%s'", instanceGroupName));
}
}
Aggregations