本文整理汇总了Java中org.springframework.boot.actuate.health.Health.Builder类的典型用法代码示例。如果您正苦于以下问题:Java Builder类的具体用法?Java Builder怎么用?Java Builder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Builder类属于org.springframework.boot.actuate.health.Health包,在下文中一共展示了Builder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDoHealthCheckSingleQueueCheckMetricException
import org.springframework.boot.actuate.health.Health.Builder; //导入依赖的package包/类
@Test
public void testDoHealthCheckSingleQueueCheckMetricException() throws Exception
{
Queue queue = generateQueue("test");
healthIndicator.addQueueCheck(queue, 10000, 2);
propertiesManager.request(queue);
PowerMock.expectLastCall().andThrow(new RuntimeException());
PowerMock.replayAll();
Builder builder = new Builder(Status.OUT_OF_SERVICE);
healthIndicator.doHealthCheck(builder);
PowerMock.verifyAll();
Health health = builder.build();
Assert.assertEquals(Status.DOWN, health.getStatus());
Assert.assertNull(health.getDetails().get("test"));
}
开发者ID:julian-eggers,项目名称:spring-rabbitmq-actuator,代码行数:19,代码来源:RabbitQueueCheckHealthIndicatorTest.java
示例2: health
import org.springframework.boot.actuate.health.Health.Builder; //导入依赖的package包/类
@Override
public Health health() {
try {
VaultHealth vaultHealthResponse = vaultOperations.opsForSys().health();
Builder healthBuilder = getHealthBuilder(vaultHealthResponse);
if (StringUtils.hasText(vaultHealthResponse.getVersion())) {
healthBuilder = healthBuilder.withDetail("version",
vaultHealthResponse.getVersion());
}
return healthBuilder.build();
}
catch (Exception e) {
return Health.down(e).build();
}
}
示例3: getHealthBuilder
import org.springframework.boot.actuate.health.Health.Builder; //导入依赖的package包/类
private Builder getHealthBuilder(VaultHealth vaultHealthResponse) {
if (!vaultHealthResponse.isInitialized()) {
return Health.down().withDetail("state", "Vault uninitialized");
}
if (vaultHealthResponse.isSealed()) {
return Health.down().withDetail("state", "Vault sealed");
}
if (vaultHealthResponse.isStandby()) {
return Health.up().withDetail("state", "Vault in standby");
}
return Health.up();
}
示例4: 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));
}
};
}
示例5: 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));
}
}
}
}
示例6: 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();
}
}
示例7: 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");
}
}
示例8: 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();
}
}
示例9: 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));
}
};
}
示例10: 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();
}
}
示例11: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
log.info("Test geolocation service health - start.");
long startTime = System.currentTimeMillis();
Mentor mentor = mentorRepository.findAll().iterator().next();
Point point = mentorUtils.getLocationOfMentor(mentor);
if (point.getLatitude() != 0) {
builder.withDetail("handle", point.toString()).up();
} else {
builder.status("GeocodingError");
}
log.info("Test geolocation service health - end. Duration: " + Long.toString(System.currentTimeMillis() - startTime) + "ms");
}
示例12: doHealthCheck
import org.springframework.boot.actuate.health.Health.Builder; //导入依赖的package包/类
@Override
protected void doHealthCheck(Builder builder) throws Exception {
if (twitter.isAuthenticated()) {
builder.withDetail("handle", twitter.getScreenName()).up();
} else {
builder.status("NotAuthenticated");
}
}
示例13: testDoHealthCheckNoQueueChecks
import org.springframework.boot.actuate.health.Health.Builder; //导入依赖的package包/类
@Test
public void testDoHealthCheckNoQueueChecks() throws Exception
{
Builder builder = new Builder(Status.OUT_OF_SERVICE);
healthIndicator.doHealthCheck(builder);
Assert.assertEquals(Status.UP, builder.build().getStatus());
}
开发者ID:julian-eggers,项目名称:spring-rabbitmq-actuator,代码行数:8,代码来源:RabbitQueueCheckHealthIndicatorTest.java
示例14: testDoHealthCheckSingleQueueCheckUp
import org.springframework.boot.actuate.health.Health.Builder; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "boxing" })
@Test
public void testDoHealthCheckSingleQueueCheckUp() throws Exception
{
Queue queue = generateQueue("test");
healthIndicator.addQueueCheck(queue, 10000, 2);
RabbitQueueProperties properties = new RabbitQueueProperties();
properties.setConsumerCount(4);
properties.setMessageCount(5883);
propertiesManager.request(queue);
PowerMock.expectLastCall().andReturn(properties);
PowerMock.replayAll();
Builder builder = new Builder(Status.OUT_OF_SERVICE);
healthIndicator.doHealthCheck(builder);
PowerMock.verifyAll();
Health health = builder.build();
Assert.assertEquals(Status.UP, health.getStatus());
Assert.assertNotNull(health.getDetails().get("test"));
Map<String, Object> details = (Map<String, Object>) health.getDetails().get("test");
Assert.assertEquals(Status.UP.getCode(), details.get("status"));
Assert.assertEquals(5883, details.get("currentMessageCount"));
Assert.assertEquals(10000, details.get("maxMessageCount"));
Assert.assertEquals(4, details.get("currentConsumerCount"));
Assert.assertEquals(2, details.get("minConsumerCount"));
}
开发者ID:julian-eggers,项目名称:spring-rabbitmq-actuator,代码行数:29,代码来源:RabbitQueueCheckHealthIndicatorTest.java
示例15: testDoHealthCheckSingleQueueCheckQueueSizeDown
import org.springframework.boot.actuate.health.Health.Builder; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "boxing" })
@Test
public void testDoHealthCheckSingleQueueCheckQueueSizeDown() throws Exception
{
Queue queue = generateQueue("test");
healthIndicator.addQueueCheck(queue, 10000, 2);
RabbitQueueProperties properties = new RabbitQueueProperties();
properties.setConsumerCount(4);
properties.setMessageCount(15883);
propertiesManager.request(queue);
PowerMock.expectLastCall().andReturn(properties);
PowerMock.replayAll();
Builder builder = new Builder(Status.OUT_OF_SERVICE);
healthIndicator.doHealthCheck(builder);
PowerMock.verifyAll();
Health health = builder.build();
Assert.assertEquals(Status.DOWN, health.getStatus());
Assert.assertNotNull(health.getDetails().get("test"));
Map<String, Object> details = (Map<String, Object>) health.getDetails().get("test");
Assert.assertEquals(Status.DOWN.getCode(), details.get("status"));
Assert.assertEquals(15883, details.get("currentMessageCount"));
Assert.assertEquals(10000, details.get("maxMessageCount"));
Assert.assertEquals(4, details.get("currentConsumerCount"));
Assert.assertEquals(2, details.get("minConsumerCount"));
}
开发者ID:julian-eggers,项目名称:spring-rabbitmq-actuator,代码行数:29,代码来源:RabbitQueueCheckHealthIndicatorTest.java