本文整理汇总了Java中org.springframework.boot.actuate.health.Health.Builder.up方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.up方法的具体用法?Java Builder.up怎么用?Java Builder.up使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.boot.actuate.health.Health.Builder
的用法示例。
在下文中一共展示了Builder.up方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dayIndicator
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
/** 営業日チェック */
@Bean
@ConditionalOnBean(BusinessDayHandler.class)
HealthIndicator dayIndicator(final Timestamper time, final BusinessDayHandler day) {
return new AbstractHealthIndicator() {
@Override
protected void doHealthCheck(Builder builder) throws Exception {
builder.up();
builder.withDetail("day", day.day())
.withDetail("dayMinus1", day.day(-1))
.withDetail("dayPlus1", day.day(1))
.withDetail("dayPlus2", day.day(2))
.withDetail("dayPlus3", day.day(3));
}
};
}
示例2: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
Map<String, Exception> errors = new HashMap<>(this.scope.getIfAvailable().getErrors());
errors.putAll(this.rebinder.getErrors());
if (errors.isEmpty()) {
builder.up();
}
else {
builder.down();
if (errors.size() == 1) {
builder.withException(errors.values().iterator().next());
}
else {
for (String name : errors.keySet()) {
builder.withDetail(name, errors.get(name));
}
}
}
}
示例3: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
List<String> openCircuitBreakers = new ArrayList<>();
// Collect all open circuit breakers from Hystrix
for (HystrixCommandMetrics metrics : HystrixCommandMetrics.getInstances()) {
HystrixCircuitBreaker circuitBreaker = HystrixCircuitBreaker.Factory
.getInstance(metrics.getCommandKey());
if (circuitBreaker != null && circuitBreaker.isOpen()) {
openCircuitBreakers.add(metrics.getCommandGroup().name() + "::"
+ metrics.getCommandKey().name());
}
}
// If there is at least one open circuit report OUT_OF_SERVICE adding the command
// group
// and key name
if (!openCircuitBreakers.isEmpty()) {
builder.status(CIRCUIT_OPEN).withDetail("openCircuitBreakers",
openCircuitBreakers);
}
else {
builder.up();
}
}
示例4: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
PropertySource<?> propertySource = getPropertySource();
builder.up();
if (propertySource instanceof CompositePropertySource) {
List<String> sources = new ArrayList<>();
for (PropertySource<?> ps : ((CompositePropertySource) propertySource).getPropertySources()) {
sources.add(ps.getName());
}
builder.withDetail("propertySources", sources);
} else if (propertySource!=null) {
builder.withDetail("propertySources", propertySource.toString());
} else {
builder.unknown().withDetail("error", "no property sources located");
}
}
示例5: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
JestResult result = jestClient.execute(new Stats.Builder().addIndex(this.indices).build());
JsonObject map = result.getJsonObject();
if (result.isSucceeded()) {
builder.up();
for (String indexName : this.indices) {
fillStatsForIndex(indexName, map, builder);
}
}
else {
builder.down();
}
}
示例6: dayIndicator
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
/** 営業日チェック */
@Bean
HealthIndicator dayIndicator(final Timestamper time, final BusinessDayHandler day) {
return new AbstractHealthIndicator() {
@Override
protected void doHealthCheck(Builder builder) throws Exception {
builder.up();
builder.withDetail("day", day.day())
.withDetail("dayMinus1", day.day(-1))
.withDetail("dayPlus1", day.day(1))
.withDetail("dayPlus2", day.day(2))
.withDetail("dayPlus3", day.day(3));
}
};
}
示例7: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
int errorCode = new Random().nextInt(2);
log.info("*************************** errorCode: {}", errorCode);
if (errorCode != 0) {
builder.down().withDetail("errorCode", errorCode).build();
} else {
builder.up();
}
}
示例8: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
builder.withDetail("location",
this.mailSender.getHost() + ":" + this.mailSender.getPort());
this.mailSender.testConnection();
builder.up();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:8,代码来源:MailHealthIndicator.java
示例9: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
boolean active = jobExecutor.isActive();
if (active) {
builder = builder.up();
} else {
builder = builder.down();
}
builder.withDetail("jobExecutor", Details.from(jobExecutor));
}
示例10: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
//check dara health
if (this.daraService.isDaraHealthy()) {
builder.up();
builder.withDetail("location", this.daraService.getApiEndpoint());
} else {
builder.down();
}
}
示例11: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
JestResult result = jestClient.execute(new Stats.Builder().addIndex("_all").build());
JsonObject map = result.getJsonObject();
if (result.isSucceeded()) {
builder.up();
fillStatsForIndex(map, builder);
} else {
builder.down();
}
builder.withDetail("Number of Update Queue Items",
elasticsearchUpdateQueueItemRepository.count());
}
示例12: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
if (env.acceptsProfiles(Constants.SPRING_PROFILE_LOCAL)) {
builder.withDetail("Message Broker", "Simple (local)");
} else {
builder.withDetail("Message Broker", "CloudAMQP (RabbitMQ)");
}
builder.withDetail("Active Websocket Sessions", activeWebSocketSessionRepository.count());
messagingTemplate.convertAndSend("/topic", "Ping");
builder.up();
}
示例13: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception
{
final MBeanServer server = getMBeanServer();
if (server != null)
{
final ObjectName on = new ObjectName("Q2:type=qbean,service=*");
final Set<ObjectName> names = server.queryNames(on, null);
final Stream<ObjectName> s = names.stream();
final long muxInTransitCount = getMuxInTransitCount(server, names);
final long tmInTransitCount = getTmInTransitCount(server, names);
builder.withDetail("mux.in-transit", String.valueOf(muxInTransitCount));
builder.withDetail("tm.in-transit", String.valueOf(tmInTransitCount));
builder.withDetail("in-transit", String.valueOf(Math.max(muxInTransitCount, tmInTransitCount)));
if (s.allMatch(name -> getStatus(server, name) == QBean.STARTED))
{
builder.up();
}
else if (s.anyMatch(name -> getStatus(server, name) == QBean.FAILED))
{
long cnt = s.filter(name -> getStatus(server, name) == QBean.FAILED).count();
Set<String> objs = s.filter(name -> getStatus(server, name) == QBean.FAILED)
.map(ObjectName::getCanonicalName)
.collect(Collectors.toSet());
String failedServices = StringUtils.collectionToCommaDelimitedString(objs);
builder.withDetail("failed-count", String.valueOf(cnt));
builder.withDetail("failed-services", failedServices);
builder.status("failed");
}
else if (s.allMatch(name -> getStatus(server, name) == QBean.DESTROYED))
{
builder.outOfService();
}
else if (s.allMatch(name -> getStatus(server, name) == QBean.STOPPED))
{
builder.down();
}
else
{
builder.unknown();
}
}
else
{
builder.unknown();
}
}
示例14: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入方法依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception
{
builder.up();
for (QueueCheck queueCheck : queueChecks)
{
try
{
RabbitQueueProperties queueProperties = propertiesManager.request(queueCheck.getQueue());
String queueName = queueCheck.getQueue().getName();
int currentMessageCount = queueProperties.getMessageCount();
int maxMessageCount = queueCheck.getMaxMessageCount();
int currentConsumerCount = queueProperties.getConsumerCount();
int minConsumerCount = queueCheck.getMinConsumerCount();
Map<String, Object> details = new LinkedHashMap<String, Object>();
details.put("status", Status.UP.getCode());
details.put("currentMessageCount", Integer.valueOf(currentMessageCount));
details.put("maxMessageCount", Integer.valueOf(maxMessageCount));
details.put("currentConsumerCount", Integer.valueOf(currentConsumerCount));
details.put("minConsumerCount", Integer.valueOf(minConsumerCount));
builder.withDetail(queueName, details);
if (currentMessageCount > maxMessageCount)
{
builder.down();
details.put("status", Status.DOWN.getCode());
log.warn(queueName + ": Too many messages ready (Current: " + currentMessageCount + ", " + "Max-Messages: " + queueCheck.getMaxMessageCount() + ")");
}
if (currentConsumerCount < minConsumerCount)
{
builder.down();
details.put("status", Status.DOWN.getCode());
log.warn(queueName + ": Not enough consumers active (Current: " + currentConsumerCount + ", " + "Min-Consumers: " + queueCheck.getMinConsumerCount() + ")");
}
}
catch (Exception e)
{
log.error(e.getMessage(), e);
builder.down();
}
}
}