List of usage examples for org.springframework.boot.actuate.health Health.Builder down
public static Builder down(Exception ex)
From source file:io.fabric8.spring.cloud.kubernetes.KubernetesHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { try {//from w w w . j av a 2 s.c o m Pod current = utils.currentPod().get(); if (current != null) { builder.up().withDetail("inside", true) .withDetail("namespace", current.getMetadata().getNamespace()) .withDetail("podName", current.getMetadata().getName()) .withDetail("podIp", current.getStatus().getPodIP()) .withDetail("serviceAccount", current.getSpec().getServiceAccountName()) .withDetail("nodeName", current.getSpec().getNodeName()) .withDetail("hostIp", current.getStatus().getHostIP()); } else { builder.up().withDetail("inside", false); } } catch (Exception e) { builder.down(e); } }
From source file:org.springframework.boot.actuate.health.AbstractHealthIndicator.java
@Override public final Health health() { Health.Builder builder = new Health.Builder(); try {/*from w w w . java 2 s. co m*/ doHealthCheck(builder); } catch (Exception ex) { if (this.logger.isWarnEnabled()) { String message = this.healthCheckFailedMessage.apply(ex); this.logger.warn(StringUtils.hasText(message) ? message : DEFAULT_MESSAGE, ex); } builder.down(ex); } return builder.build(); }
From source file:org.springframework.cloud.client.discovery.health.DiscoveryClientHealthIndicator.java
@Override public Health health() { Health.Builder builder = new Health.Builder(); if (this.discoveryInitialized.get()) { try {/*w w w .j a va 2 s . c o m*/ List<String> services = this.discoveryClient.getServices(); String description = (this.properties.isIncludeDescription()) ? this.discoveryClient.description() : ""; builder.status(new Status("UP", description)).withDetail("services", services); } catch (Exception e) { log.error("Error", e); builder.down(e); } } else { builder.status(new Status(Status.UNKNOWN.getCode(), "Discovery Client not initialized")); } return builder.build(); }
From source file:org.springframework.cloud.config.server.config.ConfigServerHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { builder.up();/*from w w w . j av a 2 s . c o m*/ List<Map<String, Object>> details = new ArrayList<>(); for (String name : this.repositories.keySet()) { Repository repository = this.repositories.get(name); String application = (repository.getName() == null) ? name : repository.getName(); String profiles = repository.getProfiles(); try { Environment environment = this.environmentRepository.findOne(application, profiles, repository.getLabel()); HashMap<String, Object> detail = new HashMap<>(); detail.put("name", environment.getName()); detail.put("label", environment.getLabel()); if (environment.getProfiles() != null && environment.getProfiles().length > 0) { detail.put("profiles", Arrays.asList(environment.getProfiles())); } if (!CollectionUtils.isEmpty(environment.getPropertySources())) { List<String> sources = new ArrayList<>(); for (PropertySource source : environment.getPropertySources()) { sources.add(source.getName()); } detail.put("sources", sources); } details.add(detail); } catch (Exception e) { logger.debug("Could not read repository: " + application, e); HashMap<String, String> map = new HashMap<>(); map.put("application", application); map.put("profiles", profiles); builder.withDetail("repository", map); builder.down(e); return; } } builder.withDetail("repositories", details); }
From source file:org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryHealthIndicator.java
@Override protected void doHealthCheck(Health.Builder builder) throws Exception { try {//from w ww . j a va2 s. com Iterable<ServiceInstance<ZookeeperInstance>> allInstances = new ZookeeperServiceInstances( this.serviceDiscovery, this.zookeeperDependencies, this.zookeeperDiscoveryProperties); builder.up().withDetail("services", allInstances); } catch (Exception e) { log.error("Error", e); builder.down(e); } }