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


Java Health.Builder方法代码示例

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


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

示例1: appendProviderDetails

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
private void appendProviderDetails(Health.Builder builder, String name, Processor processor) {
    final Health.Builder sub = new Health.Builder(Status.UP);
    if (processor != null) {
        sub
                .withDetail("key", processor.getKey())
                .withDetail("name", processor.getName())
                .withDetail("class", processor.getClass().getName())
                ;
    } else {
        sub.outOfService();
        if (requiredProvidersHealthCheckProperties.isFailOnMissing() &&
                requiredProvidersHealthCheckProperties.getFailIfMissing().getOrDefault(name, true)) {
            builder.down();
        }
    }
    builder.withDetail(name, sub.build());
}
 
开发者ID:redlink-gmbh,项目名称:smarti,代码行数:18,代码来源:RequiredProvidersHealthCheck.java

示例2: doHealthCheck

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    log.debug("Initializing JavaMail health indicator");
    try {
        javaMailSender.getSession().getTransport().connect(javaMailSender.getHost(),
                javaMailSender.getPort(),
                javaMailSender.getUsername(),
                javaMailSender.getPassword());

        builder.up();

    } catch (MessagingException e) {
        log.debug("Cannot connect to e-mail server. Error: {}", e.getMessage());
        builder.down(e);
    }
}
 
开发者ID:VHAINNOVATIONS,项目名称:BCDS,代码行数:17,代码来源:JavaMailHealthIndicator.java

示例3: doHealthCheck

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    try {
        GetServerInfoResponse serverInfo = client.getServerInfo();
        List<App> apps = client.getApps().getApps();
        builder.up()
                .withDetail("services", apps)
                .withDetail("name", serverInfo.getName())
                .withDetail("leader", serverInfo.getLeader())
                .withDetail("http_port", serverInfo.getHttp_config().getHttp_port())
                .withDetail("https_port", serverInfo.getHttp_config().getHttps_port())
                .withDetail("hostname", serverInfo.getMarathon_config().getHostname())
                .withDetail("local_port_min", serverInfo.getMarathon_config().getLocal_port_min())
                .withDetail("local_port_max", serverInfo.getMarathon_config().getLocal_port_max());
    }
    catch (Exception e) {
        builder.down(e);
    }
}
 
开发者ID:aatarasoff,项目名称:spring-cloud-marathon,代码行数:20,代码来源:MarathonHealthIndicator.java

示例4: doHealthCheck

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
  boolean isDown = false;
  for (HealthTrackable provider : providers) {
    builder.withDetail(provider.getClass().getSimpleName(), provider.getHealthTracker().getHealthView());
    isDown = isDown || !provider.getHealthTracker().isProviderHealthy();
  }

  if (isDown) {
    if (previousHealthCheckIsUp.getAndSet(false)) {
      log.warn("Server is now UNHEALTHY");
    }
    builder.down();
  } else {
    if (!previousHealthCheckIsUp.getAndSet(true)) {
      log.info("Server is now HEALTHY. Hooray!");
    }
    builder.up();
  }
}
 
开发者ID:spinnaker,项目名称:fiat,代码行数:21,代码来源:ResourceProvidersHealthIndicator.java

示例5: doHealthCheck

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    try {
        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);
    }
}
 
开发者ID:fabric8io,项目名称:spring-cloud-kubernetes,代码行数:22,代码来源:KubernetesHealthIndicator.java

示例6: taskHealthIndicator

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Bean
public HealthIndicator taskHealthIndicator() {
    return new AbstractHealthIndicator() {
        @Override
        protected void doHealthCheck(Health.Builder builder) throws Exception {
            if (correctNumberOfInstances()) {
                builder.up();
            } else {
                builder.down();
            }
            builder.withDetail("mesos.resources.count", instanceCount.getCount());
            builder.withDetail("instances", stateRepository.allTaskInfos().size());

            for (Protos.TaskState taskState : Protos.TaskState.values()) {
                Map<String, Protos.TaskStatus> state = getTasksForState(taskState);
                builder.withDetail(taskState.name(), state.size());
            }
        }
    };
}
 
开发者ID:ContainerSolutions,项目名称:mesosframework,代码行数:21,代码来源:TaskActuatorConfiguration.java

示例7: doHealthCheck

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

    switch (clusterHealth.getStatus()) {
        case "green":
        case "yellow":
            builder.up();
            break;
        case "red":
        default:
            builder.down();
            break;
    }
    builder.withDetail("clusterName", clusterHealth.getClusterName());
    builder.withDetail("numberOfNodes", clusterHealth.getNumberOfNodes());
}
 
开发者ID:luminis-ams,项目名称:elastic-rest-spring-wrapper,代码行数:18,代码来源:ElasticHealthIndicator.java

示例8: doHealthCheck

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    if (camelContext == null) {
        builder.unknown();
    } else {
        builder.withDetail("version", camelContext.getVersion());
        builder.withDetail("contextStatus", camelContext.getStatus().name());
        if (camelContext.getStatus().isStarted()) {
            builder.up();
        } else if (camelContext.getStatus().isStopped()) {
            builder.down();
        } else {
            builder.unknown();
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:CamelHealthIndicator.java

示例9: doHealthCheck

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    if (hiatusEndpoint.isPaused()) {
        builder.outOfService();
    } else {
        builder.up();
    }
    builder.withDetail(HiatusEndpoint.FIELD_NAME_PAUSED, hiatusEndpoint.isPaused())
            .withDetail(HiatusEndpoint.FIELD_NAME_COUNT, hiatusEndpoint.getCount());
}
 
开发者ID:jihor,项目名称:hiatus-spring-boot,代码行数:11,代码来源:HiatusHealthIndicator.java

示例10: doHealthCheck

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

    if (hasConnection()) {
        builder.up();
    } else {
        builder.down();
    }
}
 
开发者ID:experoinc,项目名称:spring-boot-graph-day,代码行数:11,代码来源:JanusGraphHealthIndicator.java

示例11: doHealthCheck

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
    List<String> loadedPlugins = new ArrayList<>();
    pluginService.getSupportedPlatforms().forEach(e -> loadedPlugins.add(e.id));
    builder.withDetail(INSTALLED_PLUGINS_KEY, loadedPlugins);
    builder.withDetail(RUNNING_TRANSFORMATIONS_KEY,
        getTransformationInfoForState(TransformationState.TRANSFORMING));
    builder.withDetail(ERRORED_TRANSFORMATIONS_KEY,
        getTransformationInfoForState(TransformationState.ERROR));
    builder.up().build();
}
 
开发者ID:StuPro-TOSCAna,项目名称:TOSCAna,代码行数:12,代码来源:TransformerHealthIndicator.java

示例12: health

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Override
public Health health() {
    /*
    Perform a series of checks:
    - Servers must be up (0 < delay < 1000 and State == GOOD)
    - Servers must have the latest version
    - Servers must have a valid RCON password (non-null)
     */
    Map<String, Object> details = new LinkedHashMap<>();
    List<GameServer> unresponsive = gameServerService.findUnhealthyServers();
    if (!unresponsive.isEmpty()) {
        details.put("unresponsive", unresponsive.stream()
            .map(GameServer::toString)
            .collect(Collectors.toList()));
    }
    List<GameServer> outdated = gameServerService.findOutdatedServers();
    if (!outdated.isEmpty()) {
        details.put("outdated", outdated.stream()
            .map(GameServer::toString)
            .collect(Collectors.toList()));
    }
    List<GameServer> missingRcon = gameServerService.findServersWithoutRcon();
    if (!missingRcon.isEmpty()) {
        details.put("missingRcon", missingRcon.stream()
            .map(GameServer::toString)
            .collect(Collectors.toList()));
    }
    Health.Builder builder;
    if (details.isEmpty()) {
        builder = Health.up();
        gameServerService.getSummary().forEach(builder::withDetail);
    } else {
        builder = Health.outOfService();
        details.forEach(builder::withDetail);
    }
    return builder.build();
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:38,代码来源:GameServerHealthIndicator.java

示例13: health

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Override
public Health health() {
    int count = 0;
    int ready = 0;
    Map<String, Object> details = new LinkedHashMap<>();
    for (Map.Entry<Bot, IDiscordClient> entry : clientRegistry.getClients().entrySet()) {
        count++;
        Map<String, Object> bot = new LinkedHashMap<>();
        IDiscordClient client = entry.getValue();
        if (client.isReady()) {
            ready++;
            bot.put("status", "UP");
            bot.put("id", client.getOurUser().getStringID());
            bot.put("name", client.getOurUser().getName());
            bot.put("shards", client.getShardCount());
            bot.put("guilds", client.getGuilds().size());
            bot.put("channels", client.getChannels().size());
            bot.put("users", client.getUsers().size());
            bot.put("roles", client.getRoles().size());
        } else if (client.isLoggedIn()) {
            bot.put("status", "OUT_OF_SERVICE");
        } else {
            bot.put("status", "DOWN");
        }
        details.put(entry.getKey().getName(), bot);
    }
    Health.Builder builder = count == 0 ? Health.unknown() : (count == ready ? Health.up() : Health.outOfService());
    details.put("count", count);
    details.put("ready", ready);
    details.forEach(builder::withDetail);
    return builder.build();
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:33,代码来源:BotHealthIndicator.java

示例14: health

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Override
public Health health() {
    Map<String, Map<String, Object>> caches = cacheManager.getCacheNames().stream()
        .map(name -> (GuavaCache) cacheManager.getCache(name))
        .map(cache -> buildStats(cache.getName(), cache.getNativeCache()))
        .collect(Collectors.toMap(stats -> (String) stats.get("name"), stats -> stats));
    Health.Builder builder = Health.up()
        .withDetail("count", caches.size());
    caches.forEach(builder::withDetail);
    return builder.build();
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:12,代码来源:CacheHealthIndicator.java

示例15: doHealthCheck

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Health.Builder builder) throws Exception {
	CacheStats stats = this.cache.stats();
	builder.up().withDetail("evictionCount", stats.evictionCount());
	builder.up().withDetail("hitRate", stats.hitRate());
	builder.up().withDetail("missRate", stats.missRate());
	builder.up().withDetail("hitCount", stats.hitCount());
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-dataflow-metrics-collector,代码行数:9,代码来源:CaffeineHealthIndicator.java


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