当前位置: 首页>>代码示例>>Java>>正文


Java Builder.withDetail方法代码示例

本文整理汇总了Java中org.springframework.boot.actuate.health.Health.Builder.withDetail方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.withDetail方法的具体用法?Java Builder.withDetail怎么用?Java Builder.withDetail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.boot.actuate.health.Health.Builder的用法示例。


在下文中一共展示了Builder.withDetail方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: health

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
public Health health() {

	try {

		VaultHealth vaultHealthResponse = vaultOperations.opsForSys().health();

		Builder healthBuilder = getHealthBuilder(vaultHealthResponse);

		if (StringUtils.hasText(vaultHealthResponse.getVersion())) {
			healthBuilder = healthBuilder.withDetail("version",
					vaultHealthResponse.getVersion());
		}

		return healthBuilder.build();
	}
	catch (Exception e) {
		return Health.down(e).build();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-vault,代码行数:21,代码来源:VaultHealthIndicator.java

示例2: doHealthCheck

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
	Map<String, Exception> errors = new HashMap<>(this.scope.getIfAvailable().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));
			}
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:20,代码来源:RefreshScopeHealthIndicator.java

示例3: doHealthCheck

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@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");
}
  }
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:17,代码来源:ConfigServerHealthIndicator.java

示例4: doHealthCheck

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
	builder.withDetail("location",
			this.mailSender.getHost() + ":" + this.mailSender.getPort());
	this.mailSender.testConnection();
	builder.up();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:MailHealthIndicator.java

示例5: doHealthCheck

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@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));
}
 
开发者ID:camunda,项目名称:camunda-bpm-spring-boot-starter,代码行数:11,代码来源:JobExecutorHealthIndicator.java

示例6: doHealthCheck

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
  
  //check dara health
  if (this.daraService.isDaraHealthy()) {
    builder.up();
    builder.withDetail("location", this.daraService.getApiEndpoint());
  } else {
    builder.down();
  }
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:12,代码来源:DaraHealthIndicator.java

示例7: doHealthCheck

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
  JestResult result = jestClient.execute(new Stats.Builder().addIndex("_all").build());
  JsonObject map = result.getJsonObject();

  if (result.isSucceeded()) {
    builder.up();
    fillStatsForIndex(map, builder);
  } else {
    builder.down();
  }
  builder.withDetail("Number of Update Queue Items", 
      elasticsearchUpdateQueueItemRepository.count());
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:15,代码来源:ElasticsearchHealthIndicator.java

示例8: doHealthCheck

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
  if (env.acceptsProfiles(Constants.SPRING_PROFILE_LOCAL)) {
    builder.withDetail("Message Broker", "Simple (local)");
  } else {
    builder.withDetail("Message Broker", "CloudAMQP (RabbitMQ)");
  }
  builder.withDetail("Active Websocket Sessions", activeWebSocketSessionRepository.count());
  messagingTemplate.convertAndSend("/topic", "Ping");
  builder.up();      
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:12,代码来源:MessageBrokerHealthIndicator.java

示例9: fillStatsForIndex

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
private void fillStatsForIndex(String indexName, JsonObject map, Builder builder) {

        JsonObject indexStats = map.getAsJsonObject("indices").getAsJsonObject(indexName);
        if (indexStats != null) {
            JsonObject primaries = indexStats.getAsJsonObject("primaries");
            builder.withDetail(indexName + "." + "docs_count",
                    primaries.getAsJsonObject("docs").get("count").getAsString());
            builder.withDetail(indexName + "." + "docs_deleted",
                    primaries.getAsJsonObject("docs").get("deleted").getAsString());
            builder.withDetail(indexName + "." + "store_size",
                    primaries.getAsJsonObject("store").get("size_in_bytes").getAsString());
            builder.withDetail(indexName + "." + "query_total",
                    primaries.getAsJsonObject("search").get("query_total").getAsString());
        }
    }
 
开发者ID:spring-io,项目名称:sagan,代码行数:16,代码来源:ElasticsearchHealthIndicator.java

示例10: doHealthCheck

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception
{
    final MBeanServer server = getMBeanServer();

    if (server != null)
    {
        final ObjectName on = new ObjectName("Q2:type=qbean,service=*");
        final Set<ObjectName> names = server.queryNames(on, null);
        final Stream<ObjectName> s = names.stream();

        final long muxInTransitCount = getMuxInTransitCount(server, names);
        final long tmInTransitCount = getTmInTransitCount(server, names);

        builder.withDetail("mux.in-transit", String.valueOf(muxInTransitCount));
        builder.withDetail("tm.in-transit", String.valueOf(tmInTransitCount));
        builder.withDetail("in-transit", String.valueOf(Math.max(muxInTransitCount, tmInTransitCount)));

        if (s.allMatch(name -> getStatus(server, name) == QBean.STARTED))
        {
            builder.up();
        }
        else if (s.anyMatch(name -> getStatus(server, name) == QBean.FAILED))
        {
            long cnt = s.filter(name -> getStatus(server, name) == QBean.FAILED).count();

            Set<String> objs = s.filter(name -> getStatus(server, name) == QBean.FAILED)
                .map(ObjectName::getCanonicalName)
                .collect(Collectors.toSet());

            String failedServices = StringUtils.collectionToCommaDelimitedString(objs);
            builder.withDetail("failed-count", String.valueOf(cnt));
            builder.withDetail("failed-services", failedServices);
            builder.status("failed");
        }
        else if (s.allMatch(name -> getStatus(server, name) == QBean.DESTROYED))
        {
            builder.outOfService();
        }
        else if (s.allMatch(name -> getStatus(server, name) == QBean.STOPPED))
        {
            builder.down();
        }
        else
        {
            builder.unknown();
        }
    }
    else
    {
        builder.unknown();
    }
}
 
开发者ID:vmantek,项目名称:chimera,代码行数:54,代码来源:Q2DeploymentsHealthIndicator.java

示例11: doHealthCheck

import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception
{
    builder.up();

    for (QueueCheck queueCheck : queueChecks)
    {
        try
        {
            RabbitQueueProperties queueProperties = propertiesManager.request(queueCheck.getQueue());
            String queueName = queueCheck.getQueue().getName();
            int currentMessageCount = queueProperties.getMessageCount();
            int maxMessageCount = queueCheck.getMaxMessageCount();
            int currentConsumerCount = queueProperties.getConsumerCount();
            int minConsumerCount = queueCheck.getMinConsumerCount();

            Map<String, Object> details = new LinkedHashMap<String, Object>();
            details.put("status", Status.UP.getCode());
            details.put("currentMessageCount", Integer.valueOf(currentMessageCount));
            details.put("maxMessageCount", Integer.valueOf(maxMessageCount));
            details.put("currentConsumerCount", Integer.valueOf(currentConsumerCount));
            details.put("minConsumerCount", Integer.valueOf(minConsumerCount));
            builder.withDetail(queueName, details);

            if (currentMessageCount > maxMessageCount)
            {
                builder.down();
                details.put("status", Status.DOWN.getCode());
                log.warn(queueName + ": Too many messages ready (Current: " + currentMessageCount + ", " + "Max-Messages: " + queueCheck.getMaxMessageCount() + ")");
            }

            if (currentConsumerCount < minConsumerCount)
            {
                builder.down();
                details.put("status", Status.DOWN.getCode());
                log.warn(queueName + ": Not enough consumers active (Current: " + currentConsumerCount + ", " + "Min-Consumers: " + queueCheck.getMinConsumerCount() + ")");
            }
        }
        catch (Exception e)
        {
            log.error(e.getMessage(), e);
            builder.down();
        }
    }
}
 
开发者ID:julian-eggers,项目名称:spring-rabbitmq-actuator,代码行数:46,代码来源:RabbitQueueCheckHealthIndicator.java


注:本文中的org.springframework.boot.actuate.health.Health.Builder.withDetail方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。