From 519c4e8e6d867f3d9ce42420038757efe1995ad1 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Thu, 23 Mar 2023 12:33:10 +0300 Subject: [PATCH] CommandsLoadBalancer improvements --- .../connection/balancer/CommandsLoadBalancer.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/redisson/src/main/java/org/redisson/connection/balancer/CommandsLoadBalancer.java b/redisson/src/main/java/org/redisson/connection/balancer/CommandsLoadBalancer.java index 43a99d40b..41b6eb562 100644 --- a/redisson/src/main/java/org/redisson/connection/balancer/CommandsLoadBalancer.java +++ b/redisson/src/main/java/org/redisson/connection/balancer/CommandsLoadBalancer.java @@ -17,6 +17,7 @@ package org.redisson.connection.balancer; import org.redisson.client.protocol.RedisCommand; import org.redisson.connection.ClientConnectionsEntry; +import org.redisson.misc.RedisURI; import java.util.List; import java.util.Set; @@ -30,13 +31,13 @@ import java.util.stream.Collectors; public class CommandsLoadBalancer extends RoundRobinLoadBalancer implements LoadBalancer { private Set commands; - private String hostName; + private RedisURI address; @Override public ClientConnectionsEntry getEntry(List clientsCopy, RedisCommand redisCommand) { if (commands.contains(redisCommand.getName().toLowerCase())) { return clientsCopy.stream() - .filter(c -> c.getClient().getAddr().getHostName().equals(hostName)) + .filter(c -> address.equals(c.getClient().getAddr())) .findAny() .orElseGet(() -> { return getEntry(clientsCopy); @@ -45,8 +46,8 @@ public class CommandsLoadBalancer extends RoundRobinLoadBalancer implements Load return getEntry(clientsCopy); } - public void setHostName(String hostName) { - this.hostName = hostName; + public void setAddress(String address) { + this.address = new RedisURI(address); } public void setCommands(List commands) {