use of com.sequenceiq.cloudbreak.domain.Constraint in project cloudbreak by hortonworks.
the class HostGroupDecorator method decorate.
public HostGroup decorate(HostGroup subject, HostGroupRequest hostGroupRequest, IdentityUser user, Long stackId, boolean postRequest, Boolean publicInAccount) {
ConstraintJson constraintJson = hostGroupRequest.getConstraint();
Set<Long> recipeIds = hostGroupRequest.getRecipeIds();
Set<RecipeRequest> recipes = hostGroupRequest.getRecipes();
Set<String> recipeNames = hostGroupRequest.getRecipeNames();
LOGGER.debug("Decorating hostgroup on [{}] request.", postRequest ? "POST" : "PUT");
Constraint constraint = conversionService.convert(constraintJson, Constraint.class);
if (postRequest) {
constraint = decorateConstraint(stackId, user, constraint, constraintJson.getInstanceGroupName(), constraintJson.getConstraintTemplateName());
subject.setConstraint(constraint);
} else {
subject = getHostGroup(stackId, constraint, constraintJson, subject, user);
}
subject.getRecipes().clear();
if (recipeIds != null) {
prepareRecipesByIds(subject, recipeIds);
}
if (recipeNames != null && !recipeNames.isEmpty()) {
prepareRecipesByName(subject, user, recipeNames);
}
if (recipes != null && !recipes.isEmpty()) {
prepareRecipesByRequests(subject, user, recipes, publicInAccount);
}
return subject;
}
use of com.sequenceiq.cloudbreak.domain.Constraint in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method createHostGroup.
private HostGroup createHostGroup(String groupName, InstanceGroup instanceGroup) {
HostGroup group = new HostGroup();
group.setName(groupName);
Constraint constraint = new Constraint();
constraint.setHostCount(instanceGroup.getNodeCount());
constraint.setInstanceGroup(instanceGroup);
group.setConstraint(constraint);
return group;
}
use of com.sequenceiq.cloudbreak.domain.Constraint in project cloudbreak by hortonworks.
the class ComponentLocatorServiceTest method createHostGroup.
private HostGroup createHostGroup(String name, String hostname) {
HostGroup hg = new HostGroup();
hg.setName(name);
Constraint constraint = new Constraint();
hg.setConstraint(constraint);
InstanceGroup ig = new InstanceGroup();
constraint.setInstanceGroup(ig);
InstanceMetaData im = new InstanceMetaData();
im.setDiscoveryFQDN(hostname);
ig.setInstanceMetaData(ImmutableSet.of(im));
return hg;
}
use of com.sequenceiq.cloudbreak.domain.Constraint 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);
}
use of com.sequenceiq.cloudbreak.domain.Constraint in project cloudbreak by hortonworks.
the class HostGroupDecorator method getHostGroup.
private HostGroup getHostGroup(Long stackId, Constraint constraint, ConstraintJson constraintJson, HostGroup subject, IdentityUser user) {
if (constraintJson == null) {
throw new BadRequestException("The constraint field must be set in the reinstall request!");
}
HostGroup result = subject;
String instanceGroupName = constraintJson.getInstanceGroupName();
String constraintTemplateName = constraintJson.getConstraintTemplateName();
Cluster cluster = clusterService.retrieveClusterByStackId(stackId);
Constraint decoratedConstraint = decorateConstraint(stackId, user, constraint, instanceGroupName, constraintTemplateName);
if (!isEmpty(instanceGroupName)) {
result = getHostGroupByInstanceGroupName(decoratedConstraint, subject, cluster, instanceGroupName);
} else if (!isEmpty(constraintTemplateName)) {
subject.setConstraint(constraintRepository.save(constraint));
} else {
throw new BadRequestException("The constraint field must contain the 'constraintTemplateName' or 'instanceGroupName' parameter!");
}
return result;
}
Aggregations