2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-22 20:28:00 +00:00

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.setMaxTotal(node.getNode("compatibility-max-connections").getInt(3));
config.setBlockWhenExhausted(true); config.setBlockWhenExhausted(true);
jedisPool = new JedisPool(config, redisServer, redisPort, 0, redisPassword, useSSL); jedisPool = new JedisPool(config, redisServer, redisPort, 0, redisPassword, useSSL);
plugin.logInfo("Compatibility JedisPool was created");
} }
GenericObjectPoolConfig<Connection> poolConfig = new GenericObjectPoolConfig<>(); GenericObjectPoolConfig<Connection> poolConfig = new GenericObjectPoolConfig<>();
poolConfig.setMaxTotal(maxConnections); poolConfig.setMaxTotal(maxConnections);

View File

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