Search in sources :

Example 51 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.

the class ServiceTestUtils method createBlueprint.

public static Blueprint createBlueprint(String owner, String account) {
    Blueprint blueprint = new Blueprint();
    blueprint.setId(1L);
    blueprint.setAmbariName("test-blueprint");
    blueprint.setBlueprintText("dummyText");
    blueprint.setHostGroupCount(3);
    blueprint.setDescription("test blueprint");
    blueprint.setName("multi-node-hdfs-yarn");
    blueprint.setOwner(owner);
    blueprint.setAccount(account);
    blueprint.setPublicInAccount(true);
    return blueprint;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint)

Example 52 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.

the class BlueprintLoaderServiceTest method createBlueprint.

public static Blueprint createBlueprint(ResourceStatus resourceStatus, int index) {
    Blueprint blueprint = new Blueprint();
    blueprint.setId(Long.valueOf(index));
    blueprint.setAmbariName("test-validation" + index);
    blueprint.setBlueprintText(JSON + index);
    blueprint.setHostGroupCount(3);
    blueprint.setStatus(resourceStatus);
    blueprint.setDescription("test validation" + index);
    blueprint.setName("multi-node-hdfs-yarn" + index);
    blueprint.setOwner(LUCKY_MAN);
    blueprint.setAccount(LOTTERY_WINNERS);
    blueprint.setPublicInAccount(true);
    return blueprint;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint)

Example 53 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.

the class BlueprintLoaderServiceTest method generateDatabaseData.

private Set<Blueprint> generateDatabaseData(int cacheSize) {
    Set<Blueprint> databaseData = new HashSet<>();
    for (int i = 0; i < cacheSize; i++) {
        Blueprint blueprint = createBlueprint(DEFAULT, i);
        databaseData.add(blueprint);
    }
    return databaseData;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HashSet(java.util.HashSet)

Example 54 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.

the class AmbariDecommissionerTest method testVerifyNodeCountWithValidationException.

@Test
public void testVerifyNodeCountWithValidationException() throws CloudbreakSecuritySetupException {
    thrown.expect(NotEnoughNodeException.class);
    String hostGroupName = "hostGroupName";
    String hostname = "hostname";
    String ipAddress = "192.18.256.1";
    int gatewayPort = 1234;
    String ambariName = "ambari-name";
    Map<String, List<String>> blueprintMap = new HashMap<>();
    blueprintMap.put(hostGroupName, Collections.singletonList("DATANODE"));
    Blueprint blueprint = new Blueprint();
    blueprint.setName(ambariName);
    blueprint.setAmbariName(ambariName);
    Cluster cluster = new Cluster();
    cluster.setAmbariIp(ipAddress);
    cluster.setBlueprint(blueprint);
    Stack stack = new Stack();
    stack.setGatewayPort(gatewayPort);
    stack.setId(100L);
    HostGroup hostGroup = new HostGroup();
    hostGroup.setName(hostGroupName);
    hostGroup.setHostMetadata(Collections.singleton(getHostMetadata(0L)));
    AmbariClient ambariClient = mock(AmbariClient.class);
    HttpClientConfig config = new HttpClientConfig(ipAddress);
    when(tlsSecurityService.buildTLSClientConfigForPrimaryGateway(stack.getId(), cluster.getAmbariIp())).thenReturn(config);
    when(ambariClientProvider.getAmbariClient(config, stack.getGatewayPort(), cluster)).thenReturn(ambariClient);
    when(hostGroupService.getByClusterAndHostName(cluster, hostname)).thenReturn(hostGroup);
    when(ambariClient.getBlueprintMap(ambariName)).thenReturn(blueprintMap);
    when(configurationService.getConfiguration(ambariClient, hostGroupName)).thenReturn(Collections.singletonMap(ConfigParam.DFS_REPLICATION.key(), "3"));
    thrown.expect(NotEnoughNodeException.class);
    thrown.expectMessage("There is not enough node to downscale. Check the replication factor and the ApplicationMaster occupation.");
    underTest.verifyNodeCount(stack, cluster, hostname);
}
Also used : HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) List(java.util.List) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Stack(com.sequenceiq.cloudbreak.domain.Stack) AmbariClient(com.sequenceiq.ambari.client.AmbariClient) Test(org.junit.Test)

Example 55 with Blueprint

use of com.sequenceiq.cloudbreak.domain.Blueprint in project cloudbreak by hortonworks.

the class UpdateAmbariRequestToUpdateClusterRequestConverter method convert.

@Override
public UpdateClusterJson convert(ReinstallRequestV2 source) {
    UpdateClusterJson updateStackJson = new UpdateClusterJson();
    updateStackJson.setValidateBlueprint(true);
    updateStackJson.setKerberosPassword(source.getKerberosPassword());
    updateStackJson.setKerberosPrincipal(source.getKerberosPrincipal());
    Blueprint blueprint = blueprintRepository.findOneByName(source.getBlueprintName(), source.getAccount());
    if (blueprint != null) {
        updateStackJson.setBlueprintId(blueprint.getId());
        updateStackJson.setAmbariStackDetails(source.getAmbariStackDetails());
        Set<HostGroupRequest> hostgroups = new HashSet<>();
        for (InstanceGroupV2Request instanceGroupV2Request : source.getInstanceGroups()) {
            HostGroupRequest hostGroupRequest = new HostGroupRequest();
            hostGroupRequest.setRecoveryMode(instanceGroupV2Request.getRecoveryMode());
            hostGroupRequest.setRecipeNames(instanceGroupV2Request.getRecipeNames());
            hostGroupRequest.setName(instanceGroupV2Request.getGroup());
            ConstraintJson constraintJson = new ConstraintJson();
            constraintJson.setHostCount(instanceGroupV2Request.getNodeCount());
            constraintJson.setInstanceGroupName(instanceGroupV2Request.getGroup());
            hostGroupRequest.setConstraint(constraintJson);
            hostgroups.add(hostGroupRequest);
        }
        updateStackJson.setHostgroups(hostgroups);
    } else {
        throw new BadRequestException(String.format("Blueprint '%s' not available", source.getBlueprintName()));
    }
    return updateStackJson;
}
Also used : InstanceGroupV2Request(com.sequenceiq.cloudbreak.api.model.v2.InstanceGroupV2Request) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HostGroupRequest(com.sequenceiq.cloudbreak.api.model.HostGroupRequest) BadRequestException(com.sequenceiq.cloudbreak.controller.BadRequestException) ConstraintJson(com.sequenceiq.cloudbreak.api.model.ConstraintJson) UpdateClusterJson(com.sequenceiq.cloudbreak.api.model.UpdateClusterJson) HashSet(java.util.HashSet)

Aggregations

Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)71 Test (org.junit.Test)29 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)27 JsonNode (com.fasterxml.jackson.databind.JsonNode)25 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)22 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)22 Stack (com.sequenceiq.cloudbreak.domain.Stack)16 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)8 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 HashSet (java.util.HashSet)8 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)7 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)6 List (java.util.List)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)4 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 AmbariClient (com.sequenceiq.ambari.client.AmbariClient)4 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)4 BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)4