下面列出了怎么用org.springframework.boot.actuate.info.Info.Builder的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void contribute(Builder builder) {
try {
Pod current = this.utils.currentPod().get();
Map<String, Object> details = new HashMap<>();
if (current != null) {
details.put("inside", true);
details.put("namespace", current.getMetadata().getNamespace());
details.put("podName", current.getMetadata().getName());
details.put("podIp", current.getStatus().getPodIP());
details.put("serviceAccount", current.getSpec().getServiceAccountName());
details.put("nodeName", current.getSpec().getNodeName());
details.put("hostIp", current.getStatus().getHostIP());
}
else {
details.put("inside", false);
}
builder.withDetail("kubernetes", details);
}
catch (Exception e) {
LOG.warn("Failed to get pod details", e);
}
}
@Override
public void contribute(Builder builder) {
long tacoCount = tacoRepo.count();
Map<String, Object> tacoMap = new HashMap<String, Object>();
tacoMap.put("count", tacoCount);
builder.withDetail("taco-stats", tacoMap);
}
@Override
public void contribute(Builder builder) {
long tacoCount = tacoRepo.count();
Map<String, Object> tacoMap = new HashMap<String, Object>();
tacoMap.put("count", tacoCount);
builder.withDetail("taco-stats", tacoMap);
}
@Override
public void contribute(Builder builder) {
long tacoCount = tacoRepo.count();
Map<String, Object> tacoMap = new HashMap<String, Object>();
tacoMap.put("count", tacoCount);
builder.withDetail("taco-stats", tacoMap);
}
@Override
public void contribute(Builder builder) {
long tacoCount = tacoRepo.count();
Map<String, Object> tacoMap = new HashMap<String, Object>();
tacoMap.put("count", tacoCount);
builder.withDetail("taco-stats", tacoMap);
}
@Override
public void contribute(Builder builder) {
Map<String, Object> details = new HashMap<>();
Optional<Leader> leader = leadershipController.getLocalLeader();
if (leader.isPresent()) {
Leader l = leader.get();
details.put("leaderId", l.getId());
details.put("role", l.getRole());
details.put("isLeader", l.isCandidate(candidate));
}
else {
details.put("leaderId", "Unknown");
}
builder.withDetail("leaderElection", details);
}
/**
* Provides information about the internal status and operations of the
* archiver. Can be triggered by calling to <code>/info</code>
*/
@Override
public void contribute(Builder builder) {
if (!enabled) {
return;
}
builder.withDetail("reports archiver", archiveHistory).build();
}
/**
* Info about the server that can be retrieved using the
* http://<host>:<port>/info request
*/
@Override
public void contribute(Builder builder) {
Map<String, Integer> metadataDetails = new HashMap<>();
metadataDetails.put("existing executions", (int) metadataRepository.count());
metadataDetails.put("active executions", (int) executionRepository.count());
builder.withDetail("execution summary controller", metadataDetails);
}
/**
* Info about the server that can be retrieved using the
* http://<host>:<port>/info request
*/
@Override
public void contribute(Builder builder) {
final Map<String, Integer> metadataDetails = new HashMap<>();
metadataDetails.put("enabled", enabled ? 1 : 0);
if (enabled) {
metadataDetails.put("active executions", (int) accessTimePerExecution.size());
}
builder.withDetail("access time updater controller", metadataDetails);
}
/**
* Info about the server that can be retrieved using the
* http://<host>:<port>/info request
*/
@Override
public void contribute(Builder builder) {
Map<String, String> pluginDetails = new HashMap<>();
List<Plugin> plugins = pluginManager.getPlugins(Plugin.class);
pluginDetails.put("number of plugins", plugins.size() + "");
pluginDetails.put("plugins", plugins.stream().map(p -> p.getName()).collect(Collectors.toList()).toString());
builder.withDetail("plugin controller", pluginDetails).build();
}