Search in sources :

Example 1 with InstanceStatus

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;
}
Also used : InstanceStatus(com.netflix.appinfo.InstanceInfo.InstanceStatus) InstanceInfo(com.netflix.appinfo.InstanceInfo)

Example 2 with InstanceStatus

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);
}
Also used : InstanceStatus(com.netflix.appinfo.InstanceInfo.InstanceStatus) Test(org.junit.Test)

Example 3 with InstanceStatus

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);
}
Also used : InstanceStatus(com.netflix.appinfo.InstanceInfo.InstanceStatus) Test(org.junit.Test)

Example 4 with InstanceStatus

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);
}
Also used : InstanceStatus(com.netflix.appinfo.InstanceInfo.InstanceStatus) Test(org.junit.Test)

Example 5 with InstanceStatus

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);
}
Also used : InstanceStatus(com.netflix.appinfo.InstanceInfo.InstanceStatus) Test(org.junit.Test)

Aggregations

InstanceStatus (com.netflix.appinfo.InstanceInfo.InstanceStatus)19 InstanceInfo (com.netflix.appinfo.InstanceInfo)10 Test (org.junit.Test)5 Lease (com.netflix.eureka.lease.Lease)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 DataCenterInfo (com.netflix.appinfo.DataCenterInfo)1 LeaseInfo (com.netflix.appinfo.LeaseInfo)1 RefreshableInstanceConfig (com.netflix.appinfo.RefreshableInstanceConfig)1 UniqueIdentifier (com.netflix.appinfo.UniqueIdentifier)1 StatusChangeEvent (com.netflix.discovery.StatusChangeEvent)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 DELETE (javax.ws.rs.DELETE)1 Path (javax.ws.rs.Path)1