public static Map<String, String> getPEServices() { LOG.info("Load PE service status"); Consul consul = consulInstance(); AgentClient agent = consul.agentClient(); Map<String, Service> services = consul.agentClient().getServices(); Map<String, HealthCheck> checks = agent.getChecks(); Map<String, String> peServices = new HashMap<>(); for(Map.Entry<String, Service> entry : services.entrySet()) { if(entry.getValue().getTags().contains(PE_SERVICE_NAME)) { String serviceId = entry.getValue().getId(); String serviceStatus = "critical"; if(checks.containsKey("service:" + entry.getKey())) { serviceStatus = checks.get("service:" + entry.getKey()).getStatus(); } LOG.info("Service id: " + serviceId + " service status: " + serviceStatus); peServices.put(serviceId, serviceStatus); } } return peServices; }
public ConsulAgentProducer(ConsulEndpoint endpoint, ConsulConfiguration configuration) { super(endpoint, configuration, Consul::agentClient); bind(ConsulAgentActions.CHECKS, wrap(c -> c.getChecks())); bind(ConsulAgentActions.SERVICES, wrap(c -> c.getServices())); bind(ConsulAgentActions.MEMBERS, wrap(c -> c.getMembers())); bind(ConsulAgentActions.AGENT, wrap(c -> c.getAgent())); } }
builder.unknown(); com.orbitz.consul.model.health.HealthCheck check = client.get().agentClient().getChecks().get(checkId); if (check != null) {