Search in sources :

Example 91 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class ClouderaManagerClusterCommissionServiceTest method testCollectHostsToCommission.

@Test
public void testCollectHostsToCommission() {
    HostGroup hostGroup = mock(HostGroup.class);
    Set<String> hostnames = mock(Set.class);
    underTest.collectHostsToCommission(hostGroup, hostnames);
    verify(clouderaManagerCommissioner).collectHostsToCommission(stack, hostGroup, hostnames, apiClient);
}
Also used : HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Test(org.junit.Test)

Example 92 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class ClouderaManagerClusterDecommissionServiceTest method testCollectDownscaleCandidates.

@Test
public void testCollectDownscaleCandidates() {
    HostGroup hostGroup = new HostGroup();
    Integer scalingAdjustment = 1;
    Set<InstanceMetaData> instanceMetadatas = new HashSet<>();
    InstanceMetaData instanceMetaData1 = new InstanceMetaData();
    instanceMetaData1.setDiscoveryFQDN("host1");
    instanceMetaData1.setPrivateId(1L);
    instanceMetadatas.add(instanceMetaData1);
    InstanceMetaData instanceMetaData2 = new InstanceMetaData();
    instanceMetaData2.setDiscoveryFQDN("host2");
    instanceMetaData2.setPrivateId(2L);
    instanceMetadatas.add(instanceMetaData2);
    when(clouderaManagerDecomissioner.collectDownscaleCandidates(v31Client, stack, hostGroup, scalingAdjustment, instanceMetadatas)).thenReturn(instanceMetadatas);
    Set<InstanceMetaData> actual = underTest.collectDownscaleCandidates(hostGroup, scalingAdjustment, instanceMetadatas);
    assertEquals(instanceMetadatas, actual);
    verify(clouderaManagerDecomissioner).collectDownscaleCandidates(v31Client, stack, hostGroup, scalingAdjustment, instanceMetadatas);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 93 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class ClouderaManagerCommissionerTest method testCollectHostsToCommissionAllFound.

@Test
public void testCollectHostsToCommissionAllFound() throws ApiException {
    Set<String> hostNames = createHostnames(3);
    ApiHostList apiHostList = createGoodHealthApiHostList(hostNames);
    mockListClusterHosts(apiHostList);
    HostGroup hostGroup = createHostGroup(hostNames);
    Map<String, InstanceMetaData> result = underTest.collectHostsToCommission(getStack(), hostGroup, hostNames, client);
    assertEquals(3, result.size());
    assertEquals(hostNames, result.keySet());
}
Also used : ApiHostList(com.cloudera.api.swagger.model.ApiHostList) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Test(org.junit.jupiter.api.Test)

Example 94 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class ClusterUpscaleFlowService method updateMetadata.

private int updateMetadata(StackView stackView, Set<String> hostGroups, boolean repair) {
    LOGGER.info("Start update metadata");
    int failedInstances = 0;
    for (String hostGroup : hostGroups) {
        Optional<HostGroup> hostGroupOptional = hostGroupService.getByClusterIdAndName(stackView.getClusterView().getId(), hostGroup);
        if (hostGroupOptional.isPresent()) {
            InstanceGroup instanceGroup = hostGroupOptional.get().getInstanceGroup();
            Set<InstanceMetaData> notDeletedInstanceMetaDataSet = instanceGroup.getNotDeletedAndNotZombieInstanceMetaDataSet();
            failedInstances += updateMissingHostsMetaDatas(notDeletedInstanceMetaDataSet, instanceGroup, repair);
        }
    }
    return failedInstances;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)

Example 95 with HostGroup

use of com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup in project cloudbreak by hortonworks.

the class StackPreTerminationHandler method accept.

@Override
public void accept(Event<StackPreTerminationRequest> requestEvent) {
    StackPreTerminationRequest request = requestEvent.getData();
    Stack stack = stackService.getByIdWithListsInTransaction(request.getResourceId());
    try {
        Cluster cluster = stack.getCluster();
        if (cluster != null) {
            Set<HostGroup> hostGroupsWithRecipes = hostGroupService.getByClusterWithRecipes(cluster.getId());
            telemetryAgentService.stopTelemetryAgent(stack);
            recipeEngine.executePreTerminationRecipes(stack, hostGroupsWithRecipes, request.getForced());
            preTerminationStateExecutor.runPreTerminationTasks(stack);
        }
    } catch (Exception ex) {
        LOGGER.info("Pre-termination failed: {}", ex.getMessage(), ex);
    }
    Selectable result = new StackPreTerminationSuccess(stack.getId());
    eventBus.notify(result.selector(), new Event<>(requestEvent.getHeaders(), result));
}
Also used : StackPreTerminationRequest(com.sequenceiq.cloudbreak.reactor.api.event.recipe.StackPreTerminationRequest) Selectable(com.sequenceiq.cloudbreak.common.event.Selectable) StackPreTerminationSuccess(com.sequenceiq.cloudbreak.reactor.api.event.recipe.StackPreTerminationSuccess) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) HostGroup(com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack)

Aggregations

HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)132 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)66 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)60 HashSet (java.util.HashSet)55 Test (org.junit.jupiter.api.Test)52 List (java.util.List)50 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)43 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)37 Map (java.util.Map)37 Set (java.util.Set)37 Collectors (java.util.stream.Collectors)35 HostGroupService (com.sequenceiq.cloudbreak.service.hostgroup.HostGroupService)25 Optional (java.util.Optional)25 ArrayList (java.util.ArrayList)24 StackService (com.sequenceiq.cloudbreak.service.stack.StackService)22 InstanceStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus)21 ClusterApiConnectors (com.sequenceiq.cloudbreak.service.cluster.ClusterApiConnectors)21 HashMap (java.util.HashMap)19 Logger (org.slf4j.Logger)19 LoggerFactory (org.slf4j.LoggerFactory)19