@Test public void testInstanceNotUpInEurekaIsUnhealthy() { for (InstanceStatus status : asList(InstanceStatus.DOWN, InstanceStatus.STARTING, InstanceStatus.OUT_OF_SERVICE, InstanceStatus.UNKNOWN)) { mockStatusInEureka(instance, status); AgentStatus agentStatus = monitor.getStatus(instance.getId()); assertThat(agentStatus.getStatusCode()).isEqualTo(AgentStatusCode.Unhealthy); } }
@Override public AgentStatus getStatus(String agentInstanceId) { AgentInstance agentInstance = agentManagementService.getAgentInstance(agentInstanceId); Pair<InstanceStatus, AgentStatus> current = statusByInstanceId.get(agentInstance.getId()); if (current == null) { return AgentStatus.unhealthy(SOURCE_ID, agentInstance, "Not registered with Eureka", System.currentTimeMillis()); } return current.getRight(); }
EurekaAgentStatusMonitor implements AgentStatusMonitor, EurekaEventListener { @Override public AgentStatus getStatus(String agentInstanceId) { AgentInstance agentInstance = agentManagementService.getAgentInstance(agentInstanceId); Pair<InstanceStatus, AgentStatus> current = statusByInstanceId.get(agentInstance.getId()); if (current == null) { return AgentStatus.unhealthy(SOURCE_ID, agentInstance, "Not registered with Eureka", System.currentTimeMillis()); } return current.getRight(); } }
EurekaAgentStatusMonitor implements AgentStatusMonitor, EurekaEventListener { @Override public AgentStatus getStatus(String agentInstanceId) { AgentInstance agentInstance = agentManagementService.getAgentInstance(agentInstanceId); Pair<InstanceStatus, AgentStatus> current = statusByInstanceId.get(agentInstance.getId()); if (current == null) { return AgentStatus.unhealthy(SOURCE_ID, agentInstance, "Not registered with Eureka", System.currentTimeMillis()); } return current.getRight(); } @Inject  EurekaAgentStatusMonitor(EurekaClient eurekaClient, AgentManagementService agentManagementService, Registry registry); }
EurekaAgentStatusMonitor implements AgentStatusMonitor, EurekaEventListener { @Override public AgentStatus getStatus(String agentInstanceId) { AgentInstance agentInstance = agentManagementService.getAgentInstance(agentInstanceId); Pair<InstanceStatus, AgentStatus> current = statusByInstanceId.get(agentInstance.getId()); if (current == null) { return AgentStatus.unhealthy(SOURCE_ID, agentInstance, "Not registered with Eureka", System.currentTimeMillis()); } return current.getRight(); } @Inject  EurekaAgentStatusMonitor(EurekaClient eurekaClient, AgentManagementService agentManagementService, Registry registry); @Activator void enterActiveMode(); @Override AgentStatus getStatus(String agentInstanceId); @Override boolean isHealthy(String agentInstanceId); @Override Observable<AgentStatus> monitor(); @Override void onEvent(EurekaEvent event); }
EurekaAgentStatusMonitor implements AgentStatusMonitor, EurekaEventListener { @Override public AgentStatus getStatus(String agentInstanceId) { AgentInstance agentInstance = agentManagementService.getAgentInstance(agentInstanceId); Pair<InstanceStatus, AgentStatus> current = statusByInstanceId.get(agentInstance.getId()); if (current == null) { return AgentStatus.unhealthy(SOURCE_ID, agentInstance, "Not registered with Eureka", System.currentTimeMillis()); } return current.getRight(); } @Inject  EurekaAgentStatusMonitor(EurekaClient eurekaClient, AgentManagementService agentManagementService, Registry registry); @Activator void enterActiveMode(); @Override AgentStatus getStatus(String agentInstanceId); @Override boolean isHealthy(String agentInstanceId); @Override Observable<AgentStatus> monitor(); @Override void onEvent(EurekaEvent event);  }