refactoring

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

@ -289,12 +289,12 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
MasterSlaveEntry entry; MasterSlaveEntry entry;
if (config.checkSkipSlavesInit()) { if (config.checkSkipSlavesInit()) {
entry = new SingleEntry(ClusterConnectionManager.this, config); entry = new SingleEntry(ClusterConnectionManager.this, config, configEndpointHostName);
} else { } else {
Set<String> slaveAddresses = partition.getSlaveAddresses().stream().map(r -> r.toString()).collect(Collectors.toSet()); Set<String> slaveAddresses = partition.getSlaveAddresses().stream().map(r -> r.toString()).collect(Collectors.toSet());
config.setSlaveAddresses(slaveAddresses); 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())); 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) { private int indexOf(byte[] array, byte element) {
for (int i = 0; i < array.length; ++i) { for (int i = 0; i < array.length; ++i) {
if (array[i] == element) { if (array[i] == element) {

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

@ -66,9 +66,9 @@ public class MasterSlaveEntry {
final AtomicBoolean active = new AtomicBoolean(true); 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.connectionManager = connectionManager;
this.config = config; this.config = config;
@ -76,9 +76,7 @@ public class MasterSlaveEntry {
writeConnectionPool = new MasterConnectionPool(config, connectionManager, this); writeConnectionPool = new MasterConnectionPool(config, connectionManager, this);
pubSubConnectionPool = new MasterPubSubConnectionPool(config, connectionManager, this); pubSubConnectionPool = new MasterPubSubConnectionPool(config, connectionManager, this);
if (connectionManager instanceof ClusterConnectionManager) { this.sslHostname = sslHostname;
sslHostname = ((ClusterConnectionManager) connectionManager).getConfigEndpointHostName();
}
} }
public MasterSlaveServersConfig getConfig() { public MasterSlaveServersConfig getConfig() {

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

Loading…
Cancel
Save