refactoring

pull/1506/merge
Nikita 7 years ago
parent 979d11ae0e
commit 14b39b20ff

@ -17,7 +17,6 @@ package org.redisson.connection;
import java.net.InetSocketAddress;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
@ -348,10 +347,6 @@ public class MasterSlaveEntry {
return addSlave(client, freezed, nodeType);
}
public ClientConnectionsEntry getSlaveEntry(RedisClient client) {
return slaveBalancer.getEntry(client);
}
public Collection<ClientConnectionsEntry> getAllEntries() {
return slaveBalancer.getEntries();
}
@ -453,8 +448,8 @@ public class MasterSlaveEntry {
oldMaster.freezeMaster(FreezeReason.MANAGER);
slaveDown(oldMaster);
slaveBalancer.changeType(oldMaster.getClient(), NodeType.SLAVE);
slaveBalancer.changeType(newMasterClient, NodeType.MASTER);
slaveBalancer.changeType(oldMaster.getClient().getAddr(), NodeType.SLAVE);
slaveBalancer.changeType(newMasterClient.getAddr(), NodeType.MASTER);
// more than one slave available, so master can be removed from slaves
if (!config.checkSkipSlavesInit()

@ -66,12 +66,8 @@ public class LoadBalancerManager {
pubSubConnectionPool = new PubSubConnectionPool(config, connectionManager, entry);
}
public void changeType(RedisClient redisClient, NodeType nodeType) {
ClientConnectionsEntry entry = getEntry(redisClient);
changeType(nodeType, entry);
}
protected void changeType(NodeType nodeType, ClientConnectionsEntry entry) {
public void changeType(InetSocketAddress address, NodeType nodeType) {
ClientConnectionsEntry entry = getEntry(address);
if (entry != null) {
if (connectionManager.isClusterMode()) {
entry.getClient().getConfig().setReadOnly(nodeType == NodeType.SLAVE && connectionManager.getConfig().getReadMode() != ReadMode.MASTER);
@ -200,7 +196,7 @@ public class LoadBalancerManager {
return getEntry(redisClient) != null;
}
protected ClientConnectionsEntry getEntry(URI addr) {
private ClientConnectionsEntry getEntry(URI addr) {
for (ClientConnectionsEntry entry : client2Entry.values()) {
InetSocketAddress entryAddr = entry.getClient().getAddr();
if (URIBuilder.compare(entryAddr, addr)) {
@ -210,7 +206,7 @@ public class LoadBalancerManager {
return null;
}
protected ClientConnectionsEntry getEntry(InetSocketAddress address) {
private ClientConnectionsEntry getEntry(InetSocketAddress address) {
for (ClientConnectionsEntry entry : client2Entry.values()) {
InetSocketAddress addr = entry.getClient().getAddr();
if (addr.getAddress().equals(address.getAddress()) && addr.getPort() == address.getPort()) {
@ -220,7 +216,7 @@ public class LoadBalancerManager {
return null;
}
public ClientConnectionsEntry getEntry(RedisClient redisClient) {
private ClientConnectionsEntry getEntry(RedisClient redisClient) {
return client2Entry.get(redisClient);
}

Loading…
Cancel
Save