refactoring

pull/2979/head
Nikita Koksharov 5 years ago
parent fcfec4534d
commit 46c0459d1e

@ -289,12 +289,12 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
MasterSlaveEntry entry;
if (config.checkSkipSlavesInit()) {
entry = new SingleEntry(ClusterConnectionManager.this, config);
entry = new SingleEntry(ClusterConnectionManager.this, config, configEndpointHostName);
} else {
Set<String> slaveAddresses = partition.getSlaveAddresses().stream().map(r -> r.toString()).collect(Collectors.toSet());
config.setSlaveAddresses(slaveAddresses);
entry = new MasterSlaveEntry(ClusterConnectionManager.this, config);
entry = new MasterSlaveEntry(ClusterConnectionManager.this, config, configEndpointHostName);
}
RFuture<RedisClient> f = entry.setupMasterEntry(new RedisURI(config.getMasterAddress()));
@ -700,10 +700,6 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
}
}
public String getConfigEndpointHostName() {
return configEndpointHostName;
}
private int indexOf(byte[] array, byte element) {
for (int i = 0; i < array.length; ++i) {
if (array[i] == element) {

@ -355,9 +355,9 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
protected void initSingleEntry() {
try {
if (config.checkSkipSlavesInit()) {
masterSlaveEntry = new SingleEntry(this, config);
masterSlaveEntry = new SingleEntry(this, config, null);
} else {
masterSlaveEntry = new MasterSlaveEntry(this, config);
masterSlaveEntry = new MasterSlaveEntry(this, config, null);
}
RFuture<RedisClient> masterFuture = masterSlaveEntry.setupMasterEntry(new RedisURI(config.getMasterAddress()));
masterFuture.syncUninterruptibly();

@ -66,19 +66,17 @@ public class MasterSlaveEntry {
final AtomicBoolean active = new AtomicBoolean(true);
String sslHostname;
final String sslHostname;
public MasterSlaveEntry(ConnectionManager connectionManager, MasterSlaveServersConfig config) {
public MasterSlaveEntry(ConnectionManager connectionManager, MasterSlaveServersConfig config, String sslHostname) {
this.connectionManager = connectionManager;
this.config = config;
slaveBalancer = new LoadBalancerManager(config, connectionManager, this);
writeConnectionPool = new MasterConnectionPool(config, connectionManager, this);
pubSubConnectionPool = new MasterPubSubConnectionPool(config, connectionManager, this);
if (connectionManager instanceof ClusterConnectionManager) {
sslHostname = ((ClusterConnectionManager) connectionManager).getConfigEndpointHostName();
}
this.sslHostname = sslHostname;
}
public MasterSlaveServersConfig getConfig() {

@ -28,8 +28,8 @@ import org.redisson.misc.RedisURI;
*/
public class SingleEntry extends MasterSlaveEntry {
public SingleEntry(ConnectionManager connectionManager, MasterSlaveServersConfig config) {
super(connectionManager, config);
public SingleEntry(ConnectionManager connectionManager, MasterSlaveServersConfig config, String sslHostname) {
super(connectionManager, config, sslHostname);
}
@Override

Loading…
Cancel
Save