Java Code Examples for org.springframework.boot.actuate.health.Health.Builder#up()
The following examples show how to use
org.springframework.boot.actuate.health.Health.Builder#up() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NacosConfigEndpointTests.java From spring-cloud-alibaba with Apache License 2.0 | 6 votes |
private void checkoutAcmHealthIndicator() { try { Builder builder = new Builder(); NacosConfigHealthIndicator healthIndicator = new NacosConfigHealthIndicator( properties.configServiceInstance()); healthIndicator.doHealthCheck(builder); Builder builder1 = new Builder(); builder1.up(); assertThat(builder.build()).isEqualTo(builder1.build()); } catch (Exception ignore) { } }
Example 2
Source File: RefreshScopeHealthIndicator.java From spring-cloud-commons with Apache License 2.0 | 6 votes |
@Override protected void doHealthCheck(Builder builder) throws Exception { RefreshScope refreshScope = this.scope.getIfAvailable(); if (refreshScope != null) { Map<String, Exception> errors = new HashMap<>(refreshScope.getErrors()); errors.putAll(this.rebinder.getErrors()); if (errors.isEmpty()) { builder.up(); } else { builder.down(); if (errors.size() == 1) { builder.withException(errors.values().iterator().next()); } else { for (String name : errors.keySet()) { builder.withDetail(name, errors.get(name)); } } } } }
Example 3
Source File: ConfigServerHealthIndicator.java From spring-cloud-config with Apache License 2.0 | 6 votes |
@Override protected void doHealthCheck(Builder builder) throws Exception { PropertySource<?> propertySource = getPropertySource(); builder.up(); if (propertySource instanceof CompositePropertySource) { List<String> sources = new ArrayList<>(); for (PropertySource<?> ps : ((CompositePropertySource) propertySource) .getPropertySources()) { sources.add(ps.getName()); } builder.withDetail("propertySources", sources); } else if (propertySource != null) { builder.withDetail("propertySources", propertySource.toString()); } else { builder.unknown().withDetail("error", "no property sources located"); } }
Example 4
Source File: MicroAppConfig.java From sample-boot-micro with MIT License | 5 votes |
/** 営業日チェック */ @Bean HealthIndicator dayIndicator(final Timestamper time, final BusinessDayHandler day) { return new AbstractHealthIndicator() { @Override protected void doHealthCheck(Builder builder) throws Exception { builder.up(); builder.withDetail("day", day.day()) .withDetail("dayMinus1", day.day(-1)) .withDetail("dayPlus1", day.day(1)) .withDetail("dayPlus2", day.day(2)) .withDetail("dayPlus3", day.day(3)); } }; }
Example 5
Source File: MicroAssetConfig.java From sample-boot-micro with MIT License | 5 votes |
/** 営業日チェック */ @Bean HealthIndicator dayIndicator(final Timestamper time, final BusinessDayHandler day) { return new AbstractHealthIndicator() { @Override protected void doHealthCheck(Builder builder) throws Exception { builder.up(); builder.withDetail("day", day.day()) .withDetail("dayMinus1", day.day(-1)) .withDetail("dayPlus1", day.day(1)) .withDetail("dayPlus2", day.day(2)) .withDetail("dayPlus3", day.day(3)); } }; }
Example 6
Source File: ApplicationConfig.java From sample-boot-hibernate with MIT License | 5 votes |
/** 営業日チェック */ @Bean HealthIndicator dayIndicator(Timestamper time, BusinessDayHandler day) { return new AbstractHealthIndicator() { @Override protected void doHealthCheck(Builder builder) throws Exception { builder.up(); builder.withDetail("day", day.day()) .withDetail("dayMinus1", day.day(-1)) .withDetail("dayPlus1", day.day(1)) .withDetail("dayPlus2", day.day(2)) .withDetail("dayPlus3", day.day(3)); } }; }
Example 7
Source File: JobExecutorHealthIndicator.java From camunda-bpm-spring-boot-starter with Apache License 2.0 | 5 votes |
@Override protected void doHealthCheck(Builder builder) throws Exception { boolean active = jobExecutor.isActive(); if (active) { builder = builder.up(); } else { builder = builder.down(); } builder.withDetail("jobExecutor", Details.from(jobExecutor)); }
Example 8
Source File: JobExecutorHealthIndicator.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override protected void doHealthCheck(Builder builder) throws Exception { boolean active = jobExecutor.isActive(); if (active) { builder = builder.up(); } else { builder = builder.down(); } builder.withDetail("jobExecutor", Details.from(jobExecutor)); }
Example 9
Source File: AbstractAdvancedHealthIndicator.java From super-cloudops with Apache License 2.0 | 4 votes |
@Override protected void doHealthCheck(Builder builder) throws Exception { int index = 0; StringBuffer desc = new StringBuffer(); for (String name : this.eventStores.keySet()) { try { EventStore<Partition> store = this.eventStores.get(name); Partition latestPart = store.latest(); if (logger.isDebugEnabled()) logger.debug("Health performance:{}", mapper.writeValueAsString(latestPart)); if (latestPart == null) { builder.up(); return; } // Get partition configuration by current partition. Partition confPart = this.conf.getPartitions().get(name); if (confPart == null) throw new Error("It should not come here. " + name); // Check threshold. long threshold = confPart.getValue(); long curVal = latestPart.getValue(); if (this.compare(curVal, threshold) < 0) { // Trigger event. if (desc.length() > 0) { desc.append("<br/>"); } desc.append(name).append(":").append(formatValue(curVal)).append(" exceed the threshold:") .append(formatValue(confPart.getValue())); } // Meaningful field name prefix. String p = this.compareFieldName(); builder.withDetail("AcqPosition_" + index, name).withDetail("AcqSamples_" + index, latestPart.getSamples()) .withDetail("AcqTime_" + index, latestPart.getFormatTimestamp()) .withDetail(p + "Avg_" + index, formatValue(store.average())) .withDetail(p + "Lgt_" + index, formatValue(store.largest().getValue())) .withDetail(p + "Let_" + index, formatValue(store.least().getValue())) .withDetail(p + "Lat_" + index, formatValue(store.latest().getValue())) .withDetail(p + "Threshold_" + index, formatValue(threshold)); // All the checks are normal. if (desc.length() > 0) { HealthUtil.down(builder, desc.toString()); desc.setLength(0); // Reset. } else { builder.up(); } if (logger.isDebugEnabled()) { logger.debug("Acquisition unhealthy description:{}", desc); } } catch (Exception e) { builder.down(e); logger.error("Advanced health check failed.", e); } finally { // Increase by 1 ++index; } } }