Polishing.
Revert changes in JedisClusterKeyCommands. Switch clusterGetNodeForKey method to calculate the slot locally. See #2156 Original pull request: #2159.
This commit is contained in:
@@ -38,6 +38,7 @@ import java.util.function.Function;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.PropertyAccessor;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
@@ -691,6 +692,15 @@ public class JedisClusterConnection implements DefaultedRedisClusterConnection {
|
||||
.clusterKeySlot(JedisConverters.toString(key)).intValue()).getValue();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisClusterCommands#clusterGetNodeForKey(byte[])
|
||||
*/
|
||||
@Override
|
||||
public RedisClusterNode clusterGetNodeForKey(byte[] key) {
|
||||
return topologyProvider.getTopology().getKeyServingMasterNode(key);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisClusterCommands#clusterGetNodeForSlot(int)
|
||||
@@ -757,15 +767,6 @@ public class JedisClusterConnection implements DefaultedRedisClusterConnection {
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisClusterCommands#clusterGetNodeForKey(byte[])
|
||||
*/
|
||||
@Override
|
||||
public RedisClusterNode clusterGetNodeForKey(byte[] key) {
|
||||
return clusterGetNodeForSlot(clusterGetSlotForKey(key));
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.redis.connection.RedisClusterCommands#clusterGetClusterInfo()
|
||||
|
||||
@@ -441,7 +441,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
|
||||
return connection.getClusterCommandExecutor()
|
||||
.executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.pttl(key),
|
||||
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
|
||||
connection.clusterGetNodeForKey(key))
|
||||
.getValue();
|
||||
}
|
||||
|
||||
@@ -457,7 +457,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
return connection.getClusterCommandExecutor()
|
||||
.executeCommandOnSingleNode(
|
||||
(JedisClusterCommandCallback<Long>) client -> Converters.millisecondsToTimeUnit(client.pttl(key), timeUnit),
|
||||
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
|
||||
connection.clusterGetNodeForKey(key))
|
||||
.getValue();
|
||||
}
|
||||
|
||||
@@ -472,7 +472,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
|
||||
return connection.getClusterCommandExecutor()
|
||||
.executeCommandOnSingleNode((JedisClusterCommandCallback<byte[]>) client -> client.dump(key),
|
||||
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
|
||||
connection.clusterGetNodeForKey(key))
|
||||
.getValue();
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
return JedisConverters.toString(this.connection.execute("RESTORE", key,
|
||||
Arrays.asList(JedisConverters.toBytes(ttlInMillis), serializedValue, JedisConverters.toBytes("REPLACE"))));
|
||||
|
||||
}, connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key));
|
||||
}, connection.clusterGetNodeForKey(key));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -582,7 +582,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
|
||||
return connection.getClusterCommandExecutor()
|
||||
.executeCommandOnSingleNode((JedisClusterCommandCallback<byte[]>) client -> client.objectEncoding(key),
|
||||
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
|
||||
connection.clusterGetNodeForKey(key))
|
||||
.mapValue(JedisConverters::toEncoding);
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
|
||||
return connection.getClusterCommandExecutor()
|
||||
.executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.objectIdletime(key),
|
||||
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
|
||||
connection.clusterGetNodeForKey(key))
|
||||
.mapValue(Converters::secondsToDuration);
|
||||
}
|
||||
|
||||
@@ -614,7 +614,7 @@ class JedisClusterKeyCommands implements RedisKeyCommands {
|
||||
|
||||
return connection.getClusterCommandExecutor()
|
||||
.executeCommandOnSingleNode((JedisClusterCommandCallback<Long>) client -> client.objectRefcount(key),
|
||||
connection.getTopologyProvider().getTopology().getKeyServingMasterNode(key))
|
||||
connection.clusterGetNodeForKey(key))
|
||||
.getValue();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user