Search in sources :

Example 41 with InstanceMetaData

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

the class ComponentLocatorServiceTest method createHostGroup.

private HostGroup createHostGroup(String name, String hostname) {
    HostGroup hg = new HostGroup();
    hg.setName(name);
    Constraint constraint = new Constraint();
    hg.setConstraint(constraint);
    InstanceGroup ig = new InstanceGroup();
    constraint.setInstanceGroup(ig);
    InstanceMetaData im = new InstanceMetaData();
    im.setDiscoveryFQDN(hostname);
    ig.setInstanceMetaData(ImmutableSet.of(im));
    return hg;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) Constraint(com.sequenceiq.cloudbreak.domain.Constraint) HostGroup(com.sequenceiq.cloudbreak.domain.HostGroup) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup)

Example 42 with InstanceMetaData

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

the class CandidateUnhealthyInstancesSelectorTest method shouldSelectInstancesWithUnknownStatus.

@Test
public void shouldSelectInstancesWithUnknownStatus() throws CloudbreakSecuritySetupException {
    Map<String, String> hostStatuses = new HashMap<>();
    hostStatuses.put("ip-10-0-0-1.ec2.internal", "HEALTHY");
    hostStatuses.put("ip-10-0-0-2.ec2.internal", "UNKNOWN");
    hostStatuses.put("ip-10-0-0-3.ec2.internal", "HEALTHY");
    hostStatuses.put("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.InstanceMetaData) HashMap(java.util.HashMap) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Test(org.junit.Test)

Example 43 with InstanceMetaData

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

the class CandidateUnhealthyInstancesSelectorTest method shouldRemoveNonCoreGroupNodes.

@Test
public void shouldRemoveNonCoreGroupNodes() throws CloudbreakSecuritySetupException {
    Map<String, String> hostStatuses = new HashMap<>();
    hostStatuses.put("ip-10-0-0-1.ec2.internal", "HEALTHY");
    hostStatuses.put("ip-10-0-0-2.ec2.internal", "UNKNOWN");
    hostStatuses.put("ip-10-0-0-3.ec2.internal", "UNKNOWN");
    hostStatuses.put("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(2, candidateUnhealthyInstances.size());
    assertTrue(candidateUnhealthyInstances.contains(imd1));
    assertTrue(candidateUnhealthyInstances.contains(imd2));
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData) HashMap(java.util.HashMap) InstanceGroup(com.sequenceiq.cloudbreak.domain.InstanceGroup) Test(org.junit.Test)

Example 44 with InstanceMetaData

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

the class CandidateUnhealthyInstancesSelectorTest method setupInstanceMetaData.

private InstanceMetaData setupInstanceMetaData(Long stackId, String privateIp, InstanceGroup group) {
    InstanceMetaData imd1 = mock(InstanceMetaData.class);
    when(imd1.getInstanceGroup()).thenReturn(group);
    when(instanceMetaDataRepository.findHostInStack(stackId, privateIp)).thenReturn(imd1);
    return imd1;
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData)

Example 45 with InstanceMetaData

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

the class StackRepairServiceTest method setupInstanceMetadata.

private void setupInstanceMetadata(Long stackId, String instanceId, String privateIp) {
    InstanceMetaData imd1 = mock(InstanceMetaData.class);
    when(imd1.getDiscoveryFQDN()).thenReturn(privateIp);
    when(instanceMetaDataRepository.findByInstanceId(stackId, instanceId)).thenReturn(imd1);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.InstanceMetaData)

Aggregations

InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)71 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)24 Stack (com.sequenceiq.cloudbreak.domain.Stack)23 ArrayList (java.util.ArrayList)18 HashSet (java.util.HashSet)17 Map (java.util.Map)16 HostMetadata (com.sequenceiq.cloudbreak.domain.HostMetadata)14 Test (org.junit.Test)14 HashMap (java.util.HashMap)13 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)12 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)12 HostGroup (com.sequenceiq.cloudbreak.domain.HostGroup)11 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)9 CloudbreakException (com.sequenceiq.cloudbreak.service.CloudbreakException)9 List (java.util.List)9 Set (java.util.Set)9 Inject (javax.inject.Inject)8 CloudContext (com.sequenceiq.cloudbreak.cloud.context.CloudContext)7 CloudCredential (com.sequenceiq.cloudbreak.cloud.model.CloudCredential)7 Matchers.anyString (org.mockito.Matchers.anyString)7