question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

redis.clients.jedis.BinaryJedisCluster : Request to add feature to get reference of ConnectionHandler from JedisClusterConnection.

See original GitHub issue

Before 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.

  1. 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; }

  2. 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:closed
  • Created 6 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
HeartSaVioRcommented, Jun 28, 2017

The Josiah’s suggestion in discussion would be safe:

To repeat again: wrap your batch of commands in MULTI/EXEC. While that won’t prevent slot migration, no migration happens during the MULTI/EXEC execution, and all keys are checked before execution of any commands inside the MULTI/EXEC.

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)

0reactions
lixuanbincommented, Jul 9, 2018

when will this feature release?

Read more comments on GitHub >

github_iconTop Results From Across the Web

redis.clients.jedis.BinaryJedisCluster : Request to add feature ...
redis.clients.jedis.BinaryJedisCluster : Request to add feature to get reference of ConnectionHandler from JedisClusterConnection. #1527.
Read more >
redis.clients.jedis.JedisClusterConnectionHandler java code ...
try { connection = connectionHandler.getConnection();
Read more >
Intro to Jedis - the Java Redis Client Library - Baeldung
An introduction to Jedis, a client library in Java for Redis – the popular in-memory data structure store that can persist on disk...
Read more >
spring data redis cluster pipeline support - Stack Overflow
clients.jedis into our application with same class and package name and you have to add following method to expose connection handler. public ...
Read more >
BinaryJedisCluster (Jedis 2.9.0 API) - javadoc.io
public class BinaryJedisCluster extends Object implements BasicCommands, ... No key operation doesn't make sense for Redis Cluster and Redis Cluster doesn't ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found