use of com.netflix.appinfo.InstanceInfo.InstanceStatus in project SimianArmy by Netflix.
the class DiscoveryASGInstanceValidator method isActiveInstance.
/**
* Returns true if the instance is registered in Eureka/Discovery.
* @param instanceId the instance id
* @return true if the instance is active, false otherwise
*/
private boolean isActiveInstance(String instanceId) {
Validate.notNull(instanceId);
LOGGER.debug(String.format("Checking if instance %s is active", instanceId));
List<InstanceInfo> instanceInfos = discoveryClient.getInstancesById(instanceId);
for (InstanceInfo info : instanceInfos) {
InstanceStatus status = info.getStatus();
if (status == InstanceStatus.UP || status == InstanceStatus.STARTING) {
LOGGER.debug(String.format("Instance %s is active in Discovery.", instanceId));
return true;
}
}
LOGGER.debug(String.format("Instance %s is not active in Discovery.", instanceId));
return false;
}
use of com.netflix.appinfo.InstanceInfo.InstanceStatus in project spring-cloud-netflix by spring-cloud.
the class EurekaHealthCheckHandlerTests method testEurekaIgnored.
@Test
public void testEurekaIgnored() throws Exception {
initialize(EurekaDownHealthConfiguration.class);
InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UP);
assertEquals(InstanceStatus.UP, status);
}
use of com.netflix.appinfo.InstanceInfo.InstanceStatus in project spring-cloud-netflix by spring-cloud.
the class EurekaHealthCheckHandlerTests method testDown.
@Test
public void testDown() throws Exception {
initialize(UpHealthConfiguration.class, DownHealthConfiguration.class);
InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UNKNOWN);
assertEquals(InstanceStatus.DOWN, status);
}
use of com.netflix.appinfo.InstanceInfo.InstanceStatus in project spring-cloud-netflix by spring-cloud.
the class EurekaHealthCheckHandlerTests method testUnknown.
@Test
public void testUnknown() throws Exception {
initialize(FatalHealthConfiguration.class);
InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UNKNOWN);
assertEquals(InstanceStatus.UNKNOWN, status);
}
use of com.netflix.appinfo.InstanceInfo.InstanceStatus in project spring-cloud-netflix by spring-cloud.
the class EurekaHealthCheckHandlerTests method testAllUp.
@Test
public void testAllUp() throws Exception {
initialize(UpHealthConfiguration.class);
InstanceStatus status = healthCheckHandler.getStatus(InstanceStatus.UNKNOWN);
assertEquals(InstanceStatus.UP, status);
}
Aggregations