Baqend / Orestes-Bloomfilter

Library of different Bloom filters in Java with optional Redis-backing, counting and many hashing options.
Other
843 stars 245 forks source link

Error while reading from redis slave #61

Open Krittam opened 4 years ago

Krittam commented 4 years ago

Using version 2.0.0

I've created a redis backed bloom filter using this code new FilterBuilder(5000000, 0.01) .redisBacked(true) .name(id) .redisHost(redisMaster) .addReadSlave(redisSlave1, REDIS_PORT) .addReadSlave(redisSlave2, REDIS_PORT) .password(redisPassword) .buildBloomFilter());

Inserted some test elements to it

Used below code in some other application to access the above filter new FilterBuilder(5000000, 0.01) .redisBacked(true) .name(bloomFilterId) .overwriteIfExists(false) .redisHost(redisMaster) .addReadSlave(redisSlave1, REDIS_PORT) .addReadSlave(redisSlave2, REDIS_PORT) .password(redisPassword) .buildBloomFilter();

Now when i use bf.contains("testElement") it triggers below exception

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
        at redis.clients.util.Pool.getResource(Pool.java:53)
        at redis.clients.jedis.JedisPool.getResource(JedisPool.java:226)
        at redis.clients.jedis.JedisPool.getResource(JedisPool.java:16)
        at orestes.bloomfilter.redis.helper.RedisPool.safelyReturn(RedisPool.java:94)
        at orestes.bloomfilter.redis.helper.RedisPool.transactionallyDo(RedisPool.java:110)
        at orestes.bloomfilter.redis.RedisBitSet.getBulk(RedisBitSet.java:47)
        at orestes.bloomfilter.redis.RedisBitSet.isAllSet(RedisBitSet.java:179)
        at orestes.bloomfilter.redis.BloomFilterRedis.contains(BloomFilterRedis.java:103)
        at orestes.bloomfilter.BloomFilter.contains(BloomFilter.java:64)
 Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused (Connection refused)
        at redis.clients.jedis.Connection.connect(Connection.java:207)
        at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:93)
        at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1767)
        at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:106)
        at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:868)
        at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:435)
        at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:363)
        at redis.clients.util.Pool.getResource(Pool.java:49)
        ... 39 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
        at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
        at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
        at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
        at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:403)
        at java.base/java.net.Socket.connect(Socket.java:609)
        at redis.clients.jedis.Connection.connect(Connection.java:184)
        ... 46 more

But when i do bf.contains(Collections.singleton("testElement")) It works exactly as expected; Also i've checked any possible connectivity issues. all redis instances (master and slaves) are accessible from my machine. Also it works just fine if i disable slaves and work with master alone.

Please help me resolve this issue; Any help is much appreciated !

zhangb191 commented 2 years ago

i have the same problem,help!!