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


Java Health.outOfService方法代码示例

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


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

示例1: 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

示例2: 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

示例3: health

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Health health() {
    // If catalogs are loaded we'll just report up
    final Health.Builder builder = this.catalogsLoaded.get() ? Health.up() : Health.outOfService();

    for (final Map.Entry<String, MetacatCatalogConfig> entry : this.connectorManager.getCatalogs().entrySet()) {
        builder.withDetail(entry.getKey(), entry.getValue().getType());
    }

    return builder.build();
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:15,代码来源:CatalogManager.java

示例4: health

import org.springframework.boot.actuate.health.Health; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Health health() {
    final boolean plugins = this.pluginsLoaded.get();
    final boolean catalogs = this.catalogsLoaded.get();
    final boolean thrift = this.thriftStarted.get();

    final Health.Builder builder = plugins && catalogs && thrift ? Health.up() : Health.outOfService();

    builder.withDetail(PLUGIN_KEY, plugins);
    builder.withDetail(CATALOG_KEY, catalogs);
    builder.withDetail(THRIFT_KEY, thrift);

    return builder.build();
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:18,代码来源:MetacatInitializationService.java


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