Merge branch 'master' into 3.0.0

pull/1821/head
Nikita 7 years ago
commit d614f7f1d3

@ -25,6 +25,7 @@ import org.redisson.client.RedisClient;
import org.redisson.client.RedisConnection; import org.redisson.client.RedisConnection;
import org.redisson.client.RedisPubSubConnection; import org.redisson.client.RedisPubSubConnection;
import org.redisson.config.MasterSlaveServersConfig; import org.redisson.config.MasterSlaveServersConfig;
import org.redisson.config.ReadMode;
import org.redisson.pubsub.AsyncSemaphore; import org.redisson.pubsub.AsyncSemaphore;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -73,6 +74,10 @@ public class ClientConnectionsEntry {
connectionManager.getConnectionWatcher().add(poolMinSize, poolMaxSize, freeConnections, freeConnectionsCounter); connectionManager.getConnectionWatcher().add(poolMinSize, poolMaxSize, freeConnections, freeConnectionsCounter);
} }
public boolean isMasterForRead() {
return getFreezeReason() == FreezeReason.SYSTEM && getConfig().getReadMode() == ReadMode.MASTER_SLAVE;
}
public void setNodeType(NodeType nodeType) { public void setNodeType(NodeType nodeType) {
this.nodeType = nodeType; this.nodeType = nodeType;
} }

@ -343,7 +343,7 @@ public class MasterSlaveEntry {
} }
private RFuture<Void> addSlave(URI address, final boolean freezed, final NodeType nodeType) { private RFuture<Void> addSlave(URI address, final boolean freezed, final NodeType nodeType) {
RedisClient client = connectionManager.createClient(NodeType.SLAVE, address, sslHostname); RedisClient client = connectionManager.createClient(nodeType, address, sslHostname);
return addSlave(client, freezed, nodeType); return addSlave(client, freezed, nodeType);
} }

@ -29,7 +29,6 @@ import org.redisson.client.RedisConnectionException;
import org.redisson.client.protocol.RedisCommand; import org.redisson.client.protocol.RedisCommand;
import org.redisson.client.protocol.RedisCommands; import org.redisson.client.protocol.RedisCommands;
import org.redisson.config.MasterSlaveServersConfig; import org.redisson.config.MasterSlaveServersConfig;
import org.redisson.config.ReadMode;
import org.redisson.connection.ClientConnectionsEntry; import org.redisson.connection.ClientConnectionsEntry;
import org.redisson.connection.ClientConnectionsEntry.FreezeReason; import org.redisson.connection.ClientConnectionsEntry.FreezeReason;
import org.redisson.connection.ConnectionManager; import org.redisson.connection.ConnectionManager;
@ -168,8 +167,7 @@ abstract class ConnectionPool<T extends RedisConnection> {
List<ClientConnectionsEntry> entriesCopy = new LinkedList<ClientConnectionsEntry>(entries); List<ClientConnectionsEntry> entriesCopy = new LinkedList<ClientConnectionsEntry>(entries);
while (!entriesCopy.isEmpty()) { while (!entriesCopy.isEmpty()) {
ClientConnectionsEntry entry = config.getLoadBalancer().getEntry(entriesCopy); ClientConnectionsEntry entry = config.getLoadBalancer().getEntry(entriesCopy);
if ((!entry.isFreezed() || if ((!entry.isFreezed() || entry.isMasterForRead()) &&
(entry.getFreezeReason() == FreezeReason.SYSTEM && config.getReadMode() == ReadMode.MASTER_SLAVE)) &&
tryAcquireConnection(entry)) { tryAcquireConnection(entry)) {
return acquireConnection(command, entry); return acquireConnection(command, entry);
} }
@ -421,7 +419,7 @@ abstract class ConnectionPool<T extends RedisConnection> {
} }
public void returnConnection(ClientConnectionsEntry entry, T connection) { public void returnConnection(ClientConnectionsEntry entry, T connection) {
if (entry.isFreezed()) { if (entry.isFreezed() && !entry.isMasterForRead()) {
connection.closeAsync(); connection.closeAsync();
} else { } else {
releaseConnection(entry, connection); releaseConnection(entry, connection);

Loading…
Cancel
Save