本文整理汇总了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();
}
}
示例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));
}
}
}
}
示例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");
}
}
示例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));
}
示例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();
}
}
示例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());
}
示例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();
}
示例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());
}
}
示例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();
}
}
示例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();
}
}
}