Search in sources :

Example 6 with HostName

use of com.sequenceiq.cloudbreak.cloud.model.HostName in project cloudbreak by hortonworks.

the class CandidateUnhealthyInstancesSelectorTest method shouldRemoveNonCoreGroupNodes.

@Test
public void shouldRemoveNonCoreGroupNodes() {
    Map<HostName, String> hostStatuses = new HashMap<>();
    hostStatuses.put(hostName("ip-10-0-0-1.ec2.internal"), "HEALTHY");
    hostStatuses.put(hostName("ip-10-0-0-2.ec2.internal"), "UNKNOWN");
    hostStatuses.put(hostName("ip-10-0-0-3.ec2.internal"), "UNKNOWN");
    hostStatuses.put(hostName("ip-10-0-0-4.ec2.internal"), "UNKNOWN");
    when(clusterService.getHostStatuses(stack.getId())).thenReturn(hostStatuses);
    InstanceGroup slaveGroup = setupInstanceGroup(InstanceGroupType.CORE);
    InstanceGroup gatewayGroup = setupInstanceGroup(InstanceGroupType.GATEWAY);
    InstanceMetaData imd1 = setupInstanceMetaData(stack.getId(), "ip-10-0-0-2.ec2.internal", slaveGroup);
    InstanceMetaData imd2 = setupInstanceMetaData(stack.getId(), "ip-10-0-0-4.ec2.internal", slaveGroup);
    setupInstanceMetaData(stack.getId(), "ip-10-0-0-3.ec2.internal", gatewayGroup);
    Set<InstanceMetaData> candidateUnhealthyInstances = undertest.selectCandidateUnhealthyInstances(stack.getId());
    assertEquals(2L, candidateUnhealthyInstances.size());
    assertTrue(candidateUnhealthyInstances.contains(imd1));
    assertTrue(candidateUnhealthyInstances.contains(imd2));
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HashMap(java.util.HashMap) HostName(com.sequenceiq.cloudbreak.cloud.model.HostName) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.Test)

Example 7 with HostName

use of com.sequenceiq.cloudbreak.cloud.model.HostName in project cloudbreak by hortonworks.

the class CandidateUnhealthyInstancesSelectorTest method shouldSelectInstancesWithUnknownStatus.

@Test
public void shouldSelectInstancesWithUnknownStatus() {
    Map<HostName, String> hostStatuses = new HashMap<>();
    hostStatuses.put(hostName("ip-10-0-0-1.ec2.internal"), "HEALTHY");
    hostStatuses.put(hostName("ip-10-0-0-2.ec2.internal"), "UNKNOWN");
    hostStatuses.put(hostName("ip-10-0-0-3.ec2.internal"), "HEALTHY");
    hostStatuses.put(hostName("ip-10-0-0-4.ec2.internal"), "UNKNOWN");
    when(clusterService.getHostStatuses(stack.getId())).thenReturn(hostStatuses);
    InstanceGroup slaveGroup = setupInstanceGroup(InstanceGroupType.CORE);
    InstanceMetaData imd1 = setupInstanceMetaData(stack.getId(), "ip-10-0-0-2.ec2.internal", slaveGroup);
    InstanceMetaData imd2 = setupInstanceMetaData(stack.getId(), "ip-10-0-0-4.ec2.internal", slaveGroup);
    Set<InstanceMetaData> candidateUnhealthyInstances = undertest.selectCandidateUnhealthyInstances(stack.getId());
    assertEquals(2, candidateUnhealthyInstances.size());
    assertTrue(candidateUnhealthyInstances.contains(imd1));
    assertTrue(candidateUnhealthyInstances.contains(imd2));
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) HashMap(java.util.HashMap) HostName(com.sequenceiq.cloudbreak.cloud.model.HostName) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Test(org.junit.Test)

Aggregations

HostName (com.sequenceiq.cloudbreak.cloud.model.HostName)7 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)5 Set (java.util.Set)5 ExtendedHostStatuses (com.sequenceiq.cloudbreak.cluster.status.ExtendedHostStatuses)4 ClusterApi (com.sequenceiq.cloudbreak.cluster.api.ClusterApi)3 HealthCheck (com.sequenceiq.cloudbreak.common.type.HealthCheck)3 HashMap (java.util.HashMap)3 HostName.hostName (com.sequenceiq.cloudbreak.cloud.model.HostName.hostName)2 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)2 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Collectors.toSet (java.util.stream.Collectors.toSet)2 Inject (javax.inject.Inject)2 Test (org.junit.Test)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Component (org.springframework.stereotype.Component)2 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)1