add log option, check connection for JedisPooled

This commit is contained in:
mohammed jasem alaajel 2022-07-26 17:55:16 +04:00
parent d77e909e7d
commit 2ae9b5d480
2 changed files with 10 additions and 3 deletions

View File

@ -109,6 +109,7 @@ public interface ConfigLoader {
config.setMaxTotal(node.getNode("compatibility-max-connections").getInt(3));
config.setBlockWhenExhausted(true);
jedisPool = new JedisPool(config, redisServer, redisPort, 0, redisPassword, useSSL);
plugin.logInfo("Compatibility JedisPool was created");
}
GenericObjectPoolConfig<Connection> poolConfig = new GenericObjectPoolConfig<>();
poolConfig.setMaxTotal(maxConnections);

View File

@ -14,10 +14,16 @@ public class JedisPooledSummoner implements Summoner<JedisPooled> {
public JedisPooledSummoner(JedisPooled jedisPooled, JedisPool jedisPool) {
this.jedisPooled = jedisPooled;
this.jedisPool = jedisPool;
try (Jedis jedis = this.jedisPool.getResource()) {
// Test the connection to make sure configuration is right
jedis.ping();
// test connections
if (jedisPool != null) {
try (Jedis jedis = this.jedisPool.getResource()) {
// Test the connection to make sure configuration is right
jedis.ping();
}
}
jedisPooled.set("random_data", "0");
jedisPooled.del("random_data");
}
@Override