use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest in project cloudbreak by hortonworks.
the class InstanceGroupV2RequestToHostGroupRequestConverter method convert.
@Override
public HostGroupRequest convert(InstanceGroupV2Request instanceGroupV2Request) {
HostGroupRequest hostGroupRequest = new HostGroupRequest();
hostGroupRequest.setName(instanceGroupV2Request.getGroup());
hostGroupRequest.setRecipeNames(instanceGroupV2Request.getRecipeNames());
hostGroupRequest.setRecipes(Collections.emptySet());
ConstraintJson constraintJson = new ConstraintJson();
constraintJson.setHostCount(instanceGroupV2Request.getNodeCount());
constraintJson.setInstanceGroupName(instanceGroupV2Request.getGroup());
hostGroupRequest.setConstraint(constraintJson);
hostGroupRequest.setRecipeIds(Collections.emptySet());
hostGroupRequest.setRecoveryMode(instanceGroupV2Request.getRecoveryMode());
return hostGroupRequest;
}
use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest 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.api.model.HostGroupRequest in project cloudbreak by hortonworks.
the class ClusterCommonService method recreateCluster.
private void recreateCluster(Long stackId, UpdateClusterJson updateJson) {
IdentityUser user = authenticatedUserService.getCbUser();
Set<HostGroup> hostGroups = new HashSet<>();
for (HostGroupRequest json : updateJson.getHostgroups()) {
HostGroup hostGroup = conversionService.convert(json, HostGroup.class);
hostGroup = hostGroupDecorator.decorate(hostGroup, json, user, stackId, false, false);
hostGroups.add(hostGroup);
}
AmbariStackDetailsJson stackDetails = updateJson.getAmbariStackDetails();
StackRepoDetails stackRepoDetails = null;
if (stackDetails != null) {
stackRepoDetails = conversionService.convert(stackDetails, StackRepoDetails.class);
}
clusterService.recreate(stackId, updateJson.getBlueprintId(), hostGroups, updateJson.getValidateBlueprint(), stackRepoDetails, updateJson.getKerberosPassword(), updateJson.getKerberosPrincipal());
}
use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest in project cloudbreak by hortonworks.
the class InstanceGroupV2RequestToHostGroupRequestConverterTest method convert.
@Test
public void convert() {
// WHEN
HostGroupRequest result = underTest.convert(getSource());
// THEN
assertAllFieldsNotNull(result);
Assert.assertEquals("master", result.getName());
Assert.assertEquals(2, result.getRecipeNames().size());
Assert.assertEquals(0, result.getRecipes().size());
Assert.assertEquals(RecoveryMode.MANUAL, result.getRecoveryMode());
Assert.assertEquals(4, result.getConstraint().getHostCount().intValue());
Assert.assertEquals("master", result.getConstraint().getInstanceGroupName());
}
use of com.sequenceiq.cloudbreak.api.model.HostGroupRequest in project cloudbreak by hortonworks.
the class StackV2RequestToStackRequestConverter method convertClusterRequest.
private void convertClusterRequest(StackV2Request source, StackRequest stackRequest) {
if (source.getCluster() != null) {
stackRequest.setClusterRequest(conversionService.convert(source.getCluster(), ClusterRequest.class));
for (InstanceGroupV2Request instanceGroupV2Request : source.getInstanceGroups()) {
HostGroupRequest convert = conversionService.convert(instanceGroupV2Request, HostGroupRequest.class);
stackRequest.getClusterRequest().getHostGroups().add(convert);
}
stackRequest.getClusterRequest().setName(source.getGeneral().getName());
}
}
Aggregations