redis.clients.jedis.BinaryJedisCluster : Request to add feature to get reference of ConnectionHandler from JedisClusterConnection.
See original GitHub issueBefore starting thing, I want to clear that this not an issue but DETAILED request for new feature
Expected behavior
I am expecting reference of Connection Handler to get native connection Jedis by implementing some method in either redis.clients.jedis.BinaryJedisCluster or redis.clients.jedis.JedisCluster classes.
Actual behavior
In actual behaviour, We want to implement pipeline in redis 3.2 cluster but spring-data-redis JedisClusterConnection does not supports the pipeline on cluster. So we planned to create our own by getting native jedis connection from JedisPool. So for that, in current version JedisCluster class do not have any feature which will return us the reference of connection handler. so for that we require to overload BinaryJedisCluster class in our application with same package name and provide some method which returns connectionHandler reference object. But this is not good choice in the scenario if Jedis client version changed in future and some changes implemented in BinaryJedisCluster class then we need to again overload that class and provide that method. Also this approach/solution gives the issue of class loading. Sometime ClassLoader loads the Jedis BinaryJedisCluster class instead of our application overloaded class.
Steps to reproduce:
This is not issue but DETAILED request. To implement pipeline in our application we need connection handler to get native connection from JedisPool. So for that we need to following steps.
-
We need to overload BinaryJedisCluster class with package name redis.clients.jedis in our application. We need to implemented following method
public JedisSlotBasedConnectionHandler getConnectionHandler() { return (JedisSlotBasedConnectionHandler) this.connectionHandler; }
-
After that in code where we want Jedis native connection, we have call by following way
// Get Jedis Cluster Connection
JedisClusterConnection jedisClusterConnection = (JedisClusterConnection) stringRedisTemplate.getConnectionFactory().getClusterConnection();
// Get Jedis Cluster reference from Native Connection.
JedisCluster jedisCluster = jedisClusterConnection.getNativeConnection();
// This method call is new method which we have implemented to get Connection Handler reference from overloaded method, because Jedis library not provides it.
JedisSlotBasedConnectionHandler jedisClusterConnectionHandler = jedisCluster.getConnectionHandler();
-----------------------------OR ----------------------------- Change the visibility of getConnectionFromSlot(int slot) into JedisCluster and expose method into BinaryJedisCluster class same as getClusterNodes() method
public Jedis getConnectionFromSlot(int slot) { return this.connectionHandler.getConnectionFromSlot(slot); }
By this way no one can mess up connection handler and we can get the Jedis Connection by slot without exposing connection handler.
Redis / Jedis Configuration
We are using redis 3.2 cluster nodes
Jedis version:
2.8.2
Redis version:
3.2
Java version:
1.8
I request you kindly provide some solution overcome overloading of class issue. It is more appreciable if we can able to get reference of connection handler then every one can able to use pipeline on redis cluster.
Kindly find the google-group link, where i already raised the thread for same. https://groups.google.com/forum/#!topic/jedis_redis/rK2G6F4FyuE
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (6 by maintainers)
The Josiah’s suggestion in discussion would be safe:
In fact, that is not the true-pipelining. Commands are sent to the Redis in pipelining manner, but commands will be executed only when Redis receives EXEC, hence like a batch. If slot moving occurs in the middle of pipelining, whole commands would be fail and you need to handle the situation well. (maybe want to retry to the node which is slot’s new owner automatically)
when will this feature release?