Commit 7e6f4021 authored by Stephane Nicoll's avatar Stephane Nicoll

Polish contribution

Closes gh-6059
parent 42bb8433
/* /*
* Copyright 2012-2014 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -50,12 +50,16 @@ public class RedisHealthIndicator extends AbstractHealthIndicator { ...@@ -50,12 +50,16 @@ public class RedisHealthIndicator extends AbstractHealthIndicator {
.getConnection(this.redisConnectionFactory); .getConnection(this.redisConnectionFactory);
try { try {
if (connection instanceof RedisClusterConnection) { if (connection instanceof RedisClusterConnection) {
redisClusterInfo(builder, ClusterInfo clusterInfo = ((RedisClusterConnection) connection)
((RedisClusterConnection) connection).clusterGetClusterInfo()); .clusterGetClusterInfo();
builder.up()
.withDetail("cluster_size", clusterInfo.getClusterSize())
.withDetail("slots_up", clusterInfo.getSlotsOk())
.withDetail("slots_fail", clusterInfo.getSlotsFail());
} }
else { else {
Properties info = connection.info(); Properties info = connection.info();
defaultRedisInfo(builder, VERSION, info.getProperty(REDIS_VERSION)); builder.up().withDetail(VERSION, info.getProperty(REDIS_VERSION));
} }
} }
finally { finally {
...@@ -64,14 +68,4 @@ public class RedisHealthIndicator extends AbstractHealthIndicator { ...@@ -64,14 +68,4 @@ public class RedisHealthIndicator extends AbstractHealthIndicator {
} }
} }
private void redisClusterInfo(Health.Builder builder, ClusterInfo clusterInfo) {
defaultRedisInfo(builder, "cluster_size", clusterInfo.getClusterSize());
defaultRedisInfo(builder, "slots_up", clusterInfo.getSlotsOk());
defaultRedisInfo(builder, "slots_fail", clusterInfo.getSlotsFail());
}
private void defaultRedisInfo(Health.Builder builder, String key, Object value) {
builder.up().withDetail(key, value);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment