Skip to content

Commit

Permalink
fix(health): remove potentially expensive Redis health indicator (spi…
Browse files Browse the repository at this point in the history
  • Loading branch information
robfletcher authored and dibyom committed Apr 26, 2019
1 parent 2f27aa0 commit 3138e2e
Showing 1 changed file with 0 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,40 +70,4 @@ private static JedisPool createPool(GenericObjectPoolConfig redisPoolConfig,

return new JedisPool(redisPoolConfig, host, port, timeout, password, database, null);
}

@Bean
public HealthIndicator redisHealth(final JedisPool jedisPool) {
return new HealthIndicator() {
@Override
public Health health() {
Health.Builder health;
try (Jedis jedis = jedisPool.getResource()) {
if ("PONG".equals(jedis.ping())) {
health = Health.up();
} else {
health = Health.down();
}
} catch (Exception ex) {
health = Health.down(ex);
}

try {
Field f = FieldUtils.getField(JedisPool.class, "internalPool", true /*forceAccess*/);
Object o = FieldUtils.readField(f, jedisPool, true /*forceAccess*/);
if (o instanceof GenericObjectPool) {
GenericObjectPool internal = (GenericObjectPool) o;
health.withDetail("maxIdle", internal.getMaxIdle());
health.withDetail("minIdle", internal.getMinIdle());
health.withDetail("numActive", internal.getNumActive());
health.withDetail("numIdle", internal.getNumIdle());
health.withDetail("numWaiters", internal.getNumWaiters());
}
} catch (IllegalAccessException iae) {
log.debug("Can't access jedis' internal pool", iae);
}

return health.build();
}
};
}
}

0 comments on commit 3138e2e

Please sign in to comment.