Reformat all files in the project according to java conventions.
This commit is contained in:
@@ -2,47 +2,45 @@ package redis.clients.jedis;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class JedisSlotBasedConnectionHandler extends JedisClusterConnectionHandler {
|
||||
public class JedisSlotBasedConnectionHandler extends
|
||||
JedisClusterConnectionHandler {
|
||||
|
||||
private Jedis currentConnection;
|
||||
|
||||
public JedisSlotBasedConnectionHandler(Set<HostAndPort> nodes) {
|
||||
super(nodes);
|
||||
private Jedis currentConnection;
|
||||
|
||||
public JedisSlotBasedConnectionHandler(Set<HostAndPort> nodes) {
|
||||
super(nodes);
|
||||
}
|
||||
|
||||
public Jedis getConnection() {
|
||||
return currentConnection != null ? currentConnection
|
||||
: getRandomConnection().getResource();
|
||||
}
|
||||
|
||||
private void returnCurrentConnection() {
|
||||
if (currentConnection != null) {
|
||||
nodes.get(
|
||||
currentConnection.getClient().getHost()
|
||||
+ currentConnection.getClient().getPort())
|
||||
.returnResource(currentConnection);
|
||||
}
|
||||
|
||||
|
||||
public Jedis getConnection() {
|
||||
return currentConnection != null ? currentConnection : getRandomConnection().getResource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assignSlotToNode(int slot, HostAndPort targetNode) {
|
||||
super.assignSlotToNode(slot, targetNode);
|
||||
getConnectionFromSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Jedis getConnectionFromSlot(int slot) {
|
||||
returnCurrentConnection();
|
||||
JedisPool connectionPool = slots.get(slot);
|
||||
if (connectionPool == null) {
|
||||
connectionPool = getRandomConnection();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void returnCurrentConnection() {
|
||||
if (currentConnection != null) {
|
||||
nodes.get(currentConnection.getClient().getHost()+currentConnection.getClient().getPort()).returnResource(currentConnection);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void assignSlotToNode(int slot, HostAndPort targetNode) {
|
||||
super.assignSlotToNode(slot, targetNode);
|
||||
getConnectionFromSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Jedis getConnectionFromSlot(int slot) {
|
||||
returnCurrentConnection();
|
||||
JedisPool connectionPool = slots.get(slot);
|
||||
if (connectionPool == null) {
|
||||
connectionPool = getRandomConnection();
|
||||
}
|
||||
currentConnection = connectionPool.getResource();
|
||||
return connectionPool.getResource();
|
||||
}
|
||||
|
||||
|
||||
currentConnection = connectionPool.getResource();
|
||||
return connectionPool.getResource();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user