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