Search in sources :

Example 6 with HostGroupRequest

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;
}
Also used : HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) ConstraintJson(com.sequenceiq.cloudbreak.api.model.ConstraintJson)

Example 7 with 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;
}
Also used : Constraint(com.sequenceiq.cloudbreak.domain.Constraint) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) HashSet(java.util.HashSet) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 8 with HostGroupRequest

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());
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) AmbariStackDetailsJson(com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) HashSet(java.util.HashSet)

Example 9 with HostGroupRequest

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());
}
Also used : HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) Test(org.junit.Test) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)

Example 10 with HostGroupRequest

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());
    }
}
Also used : InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) ClusterRequest(com.sequenceiq.cloudbreak.api.model.ClusterRequest) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest)

Aggregations

HostGroupRequest (com.sequenceiq.cloudbreak.api.model.HostGroupRequest)13 HashSet (java.util.HashSet)7 ConstraintJson (com.sequenceiq.cloudbreak.api.model.ConstraintJson)5 ClusterRequest (com.sequenceiq.cloudbreak.api.model.ClusterRequest)4 HostGroup (com.sequenceiq.it.cloudbreak.HostGroup)4 ClusterV1Endpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.ClusterV1Endpoint)3 KerberosRequest (com.sequenceiq.cloudbreak.api.model.KerberosRequest)3 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)3 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)3 Set (java.util.Set)3 Parameters (org.testng.annotations.Parameters)3 Test (org.testng.annotations.Test)3 InstanceGroupV2Request (com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request)2 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 AmbariStackDetailsJson (com.sequenceiq.cloudbreak.api.model.AmbariStackDetailsJson)1 GatewayJson (com.sequenceiq.cloudbreak.api.model.GatewayJson)1 UpdateClusterJson (com.sequenceiq.cloudbreak.api.model.UpdateClusterJson)1 CloudVmMetaDataStatus (com.sequenceiq.cloudbreak.cloud.model.CloudVmMetaDataStatus)1 StackRepoDetails (com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails)1 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)1