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);
}
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);
}
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());
}
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;
}
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));
}
Aggregations