refactoring

pull/3742/head
Nikita Koksharov 4 years ago
parent 313d67dd2b
commit 82e7beaa27

@ -444,6 +444,9 @@ public interface RedisCommands {
Set<String> PUBSUB_COMMANDS = new HashSet<String>(
Arrays.asList(PSUBSCRIBE.getName(), SUBSCRIBE.getName(), PUNSUBSCRIBE.getName(), UNSUBSCRIBE.getName()));
Set<String> SCAN_COMMANDS = new HashSet<String>(
Arrays.asList(HSCAN.getName(), SCAN.getName(), ZSCAN.getName(), SSCAN.getName()));
RedisStrictCommand<List<ClusterNodeInfo>> CLUSTER_NODES = new RedisStrictCommand<List<ClusterNodeInfo>>("CLUSTER", "NODES",
new ObjectDecoder(new ClusterNodesDecoder(false)));
RedisStrictCommand<List<ClusterNodeInfo>> CLUSTER_NODES_SSL = new RedisStrictCommand<List<ClusterNodeInfo>>("CLUSTER", "NODES",

@ -157,9 +157,18 @@ public class ClientConnectionsEntry {
return freeConnectionsCounter.getCounter();
}
private boolean isPolled(RedisCommand<?> command) {
return command == null
|| RedisCommands.FLUSHDB.getName().equals(command.getName())
|| RedisCommands.FLUSHALL.getName().equals(command.getName())
|| RedisCommands.BLOCKING_COMMAND_NAMES.contains(command.getName())
|| RedisCommands.BLOCKING_COMMANDS.contains(command)
|| RedisCommands.PUBSUB_COMMANDS.contains(command.getName())
|| RedisCommands.SCAN_COMMANDS.contains(command.getName());
}
public void acquireConnection(Runnable runnable, RedisCommand<?> command) {
if (command == null || RedisCommands.BLOCKING_COMMAND_NAMES.contains(command.getName())
|| RedisCommands.BLOCKING_COMMANDS.contains(command)) {
if (isPolled(command)) {
freeConnectionsCounter.acquire(runnable);
return;
}
@ -178,9 +187,7 @@ public class ClientConnectionsEntry {
AtomicBoolean lock = new AtomicBoolean();
public RedisConnection pollConnection(RedisCommand<?> command) {
if (command == null
|| RedisCommands.BLOCKING_COMMAND_NAMES.contains(command.getName())
|| RedisCommands.BLOCKING_COMMANDS.contains(command)) {
if (isPolled(command)) {
while (true) {
if (lock.compareAndSet(false, true)) {
RedisConnection c = freeConnections.poll();

Loading…
Cancel
Save