本文整理汇总了Java中org.springframework.boot.actuate.info.Info.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java Info.Builder方法的具体用法?Java Info.Builder怎么用?Java Info.Builder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.boot.actuate.info.Info
的用法示例。
在下文中一共展示了Info.Builder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldAddBuildInfoToBuilder
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Test
public void shouldAddBuildInfoToBuilder() throws Exception {
DmBuildInfo dmBuildInfo = new DmBuildInfo("name","env","project");
Info.Builder builder = new Info.Builder();
dmBuildInfo.contribute(builder);
Map<String,Object> buildInfo = new HashMap<>();
buildInfo.put("environment", "env");
buildInfo.put("project", "project");
buildInfo.put("name", "name");
buildInfo.put("version", "unknown");
buildInfo.put("date", "unknown");
buildInfo.put("commit", "unknown");
buildInfo.put("extra", Collections.EMPTY_MAP);
Map<String,Object> map = new HashMap<>();
map.put("buildInfo",buildInfo);
Info info = builder.build();
assertThat(info.getDetails(), CoreMatchers.equalTo(map));
}
示例2: shouldAddBuildInfoToBuilderNullBuildInfo
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Test
public void shouldAddBuildInfoToBuilderNullBuildInfo() throws Exception {
DmBuildInfo dmBuildInfo = new DmBuildInfo("name","env","project",null);
Info.Builder builder = new Info.Builder();
dmBuildInfo.contribute(builder);
Map<String,Object> buildInfo = new HashMap<>();
buildInfo.put("environment", "env");
buildInfo.put("project", "project");
buildInfo.put("name", "name");
buildInfo.put("version", "unknown");
buildInfo.put("date", "unknown");
buildInfo.put("commit", "unknown");
buildInfo.put("extra", Collections.EMPTY_MAP);
Map<String,Object> map = new HashMap<>();
map.put("buildInfo",buildInfo);
Info info = builder.build();
assertThat(info.getDetails(), CoreMatchers.equalTo(map));
}
示例3: shouldAddBuildInfoToBuilderIncludesBuildNumber
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Test
public void shouldAddBuildInfoToBuilderIncludesBuildNumber() throws Exception {
DmBuildInfo dmBuildInfo = new DmBuildInfo("name","env","project",BUILD_INFO_WITH_BUILD_NO);
Info.Builder builder = new Info.Builder();
dmBuildInfo.contribute(builder);
Map<String,Object> buildInfo = new HashMap<>();
buildInfo.put("environment", "env");
buildInfo.put("project", "project");
buildInfo.put("name", "name");
buildInfo.put("version", "1.0-42");
buildInfo.put("date", "today");
buildInfo.put("commit", "aaaaaaa");
buildInfo.put("extra", Collections.EMPTY_MAP);
Map<String,Object> map = new HashMap<>();
map.put("buildInfo",buildInfo);
Info info = builder.build();
assertThat(info.getDetails(), CoreMatchers.equalTo(map));
}
示例4: contribute
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Override
public void contribute(Info.Builder builder) {
Map<String, String> asgNames = new HashMap<String, String>();
asgNames.put("author-dispatcher", envValues.getAutoScaleGroupNameForAuthorDispatcher());
asgNames.put("publish", envValues.getAutoScaleGroupNameForPublish());
asgNames.put("publish-dispatcher", envValues.getAutoScaleGroupNameForPublishDispatcher());
builder.withDetail("auto-scaling-group-names", asgNames);
Map<String, String> authorInfo = new HashMap<String, String>();
authorInfo.put("elastic-load-balancer-name", envValues.getElasticLoadBalancerNameForAuthor());
authorInfo.put("elastic-load-balancer-dns", envValues.getElasticLoadBalancerAuthorDns());
builder.withDetail("author", authorInfo);
builder.withDetail("alarm-notification-topic-arn", envValues.getTopicArn());
}
示例5: contribute
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Override
public void contribute(Info.Builder builder) {
InetAddress ip = null;
Map<String, String> hostMap = new HashMap<>();
try {
ip = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
hostMap.put("ipAddress", ip.getHostAddress());
hostMap.put("hostname", ip.getHostName());
builder.withDetail("appHostInfo", hostMap);
hostMap = new HashMap<>();
CommandResult commandResult = this.mongoTemplate.executeCommand("{ serverStatus: 1 }");
hostMap.put("hostname", commandResult.getString("host"));
builder.withDetail("mongoDbHostInfo", hostMap);
}
示例6: contribute
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Override
public void contribute(Info.Builder builder) {
Map<String, Object> details = new LinkedHashMap<>();
metadataProvider.get().getConfiguration().getEnv().getBoms().forEach((k, v) -> {
if (v.getMappings() != null && !v.getMappings().isEmpty()) {
Map<String, Object> bom = new LinkedHashMap<>();
v.getMappings().forEach(it -> {
String requirement = "Spring Boot " + it.determineVersionRangeRequirement();
bom.put(it.getVersion(), requirement);
});
details.put(k, bom);
}
});
if (!details.isEmpty()) {
builder.withDetail("bom-ranges", details);
}
}
示例7: contribute
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Override
public void contribute(Info.Builder builder) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("environment",environment);
map.put("project", project);
map.put("name", name);
map.put("version", version + (EMPTY.equals(build) ? "" : "-" + build));
map.put("commit", commit);
map.put("date", date);
map.put("extra",new HashMap<>());
builder.withDetail("buildInfo",map);
}
示例8: testContribute
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Test
public void testContribute() {
// Setup for "auto-scaling-group-names".
String autoScaleGroupNameForAuthorDispatcher = "autoScaleGroupNameForAuthorDispatcher";
String autoScaleGroupNameForPublish = "autoScaleGroupNameForPublish";
String autoScaleGroupNameForPublishDispatcher = "autoScaleGroupNameForPublishDispatcher";
when(envValues.getAutoScaleGroupNameForAuthorDispatcher()).thenReturn(autoScaleGroupNameForAuthorDispatcher);
when(envValues.getAutoScaleGroupNameForPublish()).thenReturn(autoScaleGroupNameForPublish);
when(envValues.getAutoScaleGroupNameForPublishDispatcher()).thenReturn(autoScaleGroupNameForPublishDispatcher);
// Setup for "author".
String elasticLoadBalancerNameForAuthor = "elasticLoadBalancerNameForAuthor";
String elasticLoadBalancerAuthorDns = "elasticLoadBalancerAuthorDns";
when(envValues.getElasticLoadBalancerNameForAuthor()).thenReturn(elasticLoadBalancerNameForAuthor);
when(envValues.getElasticLoadBalancerAuthorDns()).thenReturn(elasticLoadBalancerAuthorDns);
// Setup for "alarm-notification-topic-arn"
String topicArn = "topicArn";
when(envValues.getTopicArn()).thenReturn(topicArn);
Info.Builder builder = new Info.Builder();
infoActuator.contribute(builder);
// Validate "auto-scaling-group-names".
Map<String, Object> info = builder.build().getDetails();
Map<String, String> asgNames = (Map<String, String>) info.get("auto-scaling-group-names");
assertThat(asgNames.get("author-dispatcher"), equalTo(autoScaleGroupNameForAuthorDispatcher));
assertThat(asgNames.get("publish"), equalTo(autoScaleGroupNameForPublish));
assertThat(asgNames.get("publish-dispatcher"), equalTo(autoScaleGroupNameForPublishDispatcher));
// Validate "author"
Map<String, String> authorInfo = (Map<String, String>) info.get("author");
assertThat(authorInfo.get("elastic-load-balancer-name"), equalTo(elasticLoadBalancerNameForAuthor));
assertThat(authorInfo.get("elastic-load-balancer-dns"), equalTo(elasticLoadBalancerAuthorDns));
// Validate "alarm-notification-topic-arn"
assertThat(info.get("alarm-notification-topic-arn"), equalTo(topicArn));
}
示例9: contributeUsedSkillCount
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
private void contributeUsedSkillCount(List<User> users, Info.Builder builder) {
int usedSkillCount = (int) users.stream()
.flatMap(p -> p.getSkillsExcludeHidden().stream())
.map(UserSkill::getName)
.distinct()
.count();
builder.withDetail("skills_used", usedSkillCount);
}
示例10: contributeUserSkills
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
private void contributeUserSkills(List<User> users, Info.Builder builder) {
IntSummaryStatistics stats = users.stream().mapToInt(u -> u.getSkillsExcludeHidden().size()).summaryStatistics();
Map<String, Double> details = new HashMap<>();
details.put("total", (double) stats.getSum());
details.put("min", (double) stats.getMin());
details.put("max", (double) stats.getMax());
details.put("average", stats.getAverage());
builder.withDetail("personal_skills", details);
}
示例11: contribute
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Override
public void contribute(Info.Builder builder) {
List<User> users = UserRepository.findAll();
contributeUserCount(builder);
contributeSkillCount(builder);
contributeUsedSkillCount(users, builder);
contributeHiddenSkillCount(builder);
contributeUserSkills(users, builder);
}
示例12: mergeDetailsFrom
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
synchronized void mergeDetailsFrom(ActorInfoContributorReference actorInfoContributorReference)
{
Info.Builder builder = new Info.Builder();
actorInfoContributorReference.getInfoContributor().contribute(builder);
Map<String, Object> whereToPutDetails = details;
for (Function<ActorInfoContributorReference, String> handler: detailLevelHandlers)
{
String key = handler.apply(actorInfoContributorReference);
whereToPutDetails.putIfAbsent(key, new HashMap<String, Object>());
//noinspection unchecked
whereToPutDetails = (Map<String, Object>) whereToPutDetails.get(key);
}
whereToPutDetails.putAll(builder.build().getDetails());
}
示例13: contribute
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Override
public void contribute(final Info.Builder builder)
{
populateActorInfoContainerWhileRemovingExpiredReferences();
Map<String, Object> details = actorInfoDetailsContainer.getDetailsSnapshot();
if (!details.isEmpty())
{
builder.withDetail("actors", details);
}
}
示例14: contribute
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Override
public void contribute(final Info.Builder builder)
{
builder.withDetail("constructorInjectedValue", constructorInjectedValue)
.withDetail("fieldInjectedValue", fieldInjectedValue);
super.contribute(builder);
}
示例15: contribute
import org.springframework.boot.actuate.info.Info; //导入方法依赖的package包/类
@Override
public void contribute(Info.Builder builder) {
final Map<String, OAuth2LoginDetails> oauth2Details =
settingsRepository.findOne("default").getoAuth2LoginDetails();
final Map<String, AuthProviderInfo> providers = providersMap.values()
.stream()
.filter(p -> !p.isConfigDynamic() || (null != oauth2Details && oauth2Details.containsKey(p.getName())))
.collect(Collectors
.toMap(OAuthProvider::getName,
p -> new AuthProviderInfo(p.getButton(), p.buildPath(getAuthBasePath()))));
builder.withDetail("auth_extensions", providers);
//@formatter:on
}