Search in sources :

Example 21 with Blueprint

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

the class AmbariDecommissionerTest method testVerifyNodeCountWithReplicationFactory.

@Test
public void testVerifyNodeCountWithReplicationFactory() throws CloudbreakSecuritySetupException {
    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(Sets.newHashSet(getHostMetadata(0L), getHostMetadata(1L), getHostMetadata(2L), getHostMetadata(3L)));
    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"));
    underTest.verifyNodeCount(stack, cluster, hostname);
    verify(configurationService, times(1)).getConfiguration(ambariClient, hostGroupName);
}
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 22 with Blueprint

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

the class AmbariClusterServiceTest method setup.

@Before
public void setup() throws CloudbreakException {
    Cluster cluster = new Cluster();
    cluster.setId(1L);
    cluster.setBlueprint(new Blueprint());
    cluster.getBlueprint().setId(1L);
    Stack stack = new Stack();
    stack.setOrchestrator(new Orchestrator());
    stack.setCluster(cluster);
    when(clusterRepository.findById(any(Long.class))).thenReturn(cluster);
    when(stackService.getByIdWithLists(any(Long.class))).thenReturn(stack);
    when(orchestratorTypeResolver.resolveType(any(Orchestrator.class))).thenReturn(OrchestratorType.HOST);
    when(orchestratorTypeResolver.resolveType(anyString())).thenReturn(OrchestratorType.HOST);
    when(clusterComponentConfigProvider.getHDPRepo(any(Long.class))).thenReturn(new StackRepoDetails());
    when(clusterComponentConfigProvider.store(any(ClusterComponent.class))).thenAnswer(invocation -> invocation.getArgumentAt(0, ClusterComponent.class));
    when(clusterComponentConfigProvider.getComponent(any(Long.class), any(ComponentType.class))).thenReturn(new ClusterComponent());
    when(blueprintService.get(any(Long.class))).thenReturn(cluster.getBlueprint());
}
Also used : ComponentType(com.sequenceiq.cloudbreak.common.type.ComponentType) StackRepoDetails(com.sequenceiq.cloudbreak.cloud.model.component.StackRepoDetails) ClusterComponent(com.sequenceiq.cloudbreak.domain.ClusterComponent) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) Stack(com.sequenceiq.cloudbreak.domain.Stack) Before(org.junit.Before)

Example 23 with Blueprint

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

the class AmbariClusterStatusUpdaterTest method createStack.

private Stack createStack(Status stackStatus, Status clusterStatus) {
    Stack stack = createStack(stackStatus);
    Cluster cluster = new Cluster();
    cluster.setAmbariIp("10.0.0.1");
    cluster.setId(TEST_CLUSTER_ID);
    cluster.setStatus(clusterStatus);
    Blueprint blueprint = new Blueprint();
    blueprint.setAmbariName(TEST_BLUEPRINT);
    cluster.setBlueprint(blueprint);
    stack.setCluster(cluster);
    return stack;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 24 with Blueprint

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

the class BlueprintLoaderService method updateDefaultBlueprints.

private Set<Blueprint> updateDefaultBlueprints(IdentityUser user, Iterable<Blueprint> blueprints) {
    Set<Blueprint> resultList = new HashSet<>();
    LOGGER.info("Updating default blueprints which are contains text modifications.");
    Map<String, Blueprint> defaultBlueprints = defaultBlueprintCache.defaultBlueprints();
    for (Blueprint blueprintFromDatabase : blueprints) {
        Blueprint newBlueprint = defaultBlueprints.get(blueprintFromDatabase.getName());
        if (defaultBlueprintExistInTheCache(newBlueprint) && (defaultBlueprintContainsNewTexts(blueprintFromDatabase, newBlueprint) || defaultBlueprintContainsNewDescription(blueprintFromDatabase, newBlueprint))) {
            LOGGER.info("Default Blueprint '{}' needs to modify for the '{}' user because the validation text changed.", blueprintFromDatabase.getName(), user.getUserId());
            resultList.add(prepateBlueprint(user, blueprintFromDatabase, newBlueprint));
        }
    }
    LOGGER.info("Finished to Update default blueprints which are contains text modifications.");
    return resultList;
}
Also used : Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) HashSet(java.util.HashSet)

Example 25 with Blueprint

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

the class BlueprintLoaderService method getResultSetFromUpdateAndOriginalBlueprints.

private Iterable<Blueprint> getResultSetFromUpdateAndOriginalBlueprints(Iterable<Blueprint> blueprints, Iterable<Blueprint> blueprintsWhichAreMissing) {
    LOGGER.info("Updating blueprints which should be modified.");
    Iterable<Blueprint> savedBlueprints = blueprintRepository.save(blueprintsWhichAreMissing);
    LOGGER.info("Finished to update blueprints which should be modified.");
    Map<String, Blueprint> resultBlueprints = new HashMap<>();
    for (Blueprint blueprint : blueprints) {
        resultBlueprints.put(blueprint.getName(), blueprint);
    }
    for (Blueprint savedBlueprint : savedBlueprints) {
        resultBlueprints.put(savedBlueprint.getName(), savedBlueprint);
    }
    return resultBlueprints.values();
}
Also used : HashMap(java.util.HashMap) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint)

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