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


Java Builder.up方法代码示例

本文整理汇总了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));
        }
    };
}
 
开发者ID:jkazama,项目名称:sample-boot-hibernate,代码行数:17,代码来源:ApplicationConfig.java

示例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));
			}
		}
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-commons,代码行数:20,代码来源:RefreshScopeHealthIndicator.java

示例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();
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-netflix,代码行数:26,代码来源:HystrixHealthIndicator.java

示例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");
}
  }
 
开发者ID:spring-cloud,项目名称:spring-cloud-config,代码行数:17,代码来源:ConfigServerHealthIndicator.java

示例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();
    }
}
 
开发者ID:spring-io,项目名称:sagan,代码行数:17,代码来源:ElasticsearchHealthIndicator.java

示例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));
        }
    };
}
 
开发者ID:jkazama,项目名称:sample-boot-micro,代码行数:16,代码来源:MicroAppConfig.java

示例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();
    }
}
 
开发者ID:nikos,项目名称:springboot-security-mongodb,代码行数:11,代码来源:CustomHealthIndicator.java

示例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));
}
 
开发者ID:camunda,项目名称:camunda-bpm-spring-boot-starter,代码行数:11,代码来源:JobExecutorHealthIndicator.java

示例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();
  }
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:12,代码来源:DaraHealthIndicator.java

示例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());
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:15,代码来源:ElasticsearchHealthIndicator.java

示例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();      
}
 
开发者ID:dzhw,项目名称:metadatamanagement,代码行数:12,代码来源:MessageBrokerHealthIndicator.java

示例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();
    }
}
 
开发者ID:vmantek,项目名称:chimera,代码行数:54,代码来源:Q2DeploymentsHealthIndicator.java

示例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();
        }
    }
}
 
开发者ID:julian-eggers,项目名称:spring-rabbitmq-actuator,代码行数:46,代码来源:RabbitQueueCheckHealthIndicator.java


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