|
|
|
@ -29,11 +29,10 @@ import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import java.net.InetSocketAddress;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.LinkedList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Queue;
|
|
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
|
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base connection pool class
|
|
|
|
@ -46,8 +45,6 @@ abstract class ConnectionPool<T extends RedisConnection> {
|
|
|
|
|
|
|
|
|
|
private final Logger log = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
|
|
|
|
final Queue<ClientConnectionsEntry> entries = new ConcurrentLinkedQueue<>();
|
|
|
|
|
|
|
|
|
|
final ConnectionManager connectionManager;
|
|
|
|
|
|
|
|
|
|
final MasterSlaveServersConfig config;
|
|
|
|
@ -60,17 +57,10 @@ abstract class ConnectionPool<T extends RedisConnection> {
|
|
|
|
|
this.connectionManager = connectionManager;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public final void addEntry(ClientConnectionsEntry entry) {
|
|
|
|
|
entries.add(entry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public final void removeEntry(ClientConnectionsEntry entry) {
|
|
|
|
|
entries.remove(entry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected abstract ConnectionsHolder<T> getConnectionHolder(ClientConnectionsEntry entry, boolean trackChanges);
|
|
|
|
|
|
|
|
|
|
public CompletableFuture<T> get(RedisCommand<?> command, boolean trackChanges) {
|
|
|
|
|
Collection<ClientConnectionsEntry> entries = masterSlaveEntry.getAllEntries();
|
|
|
|
|
List<ClientConnectionsEntry> entriesCopy = new LinkedList<>(entries);
|
|
|
|
|
entriesCopy.removeIf(n -> n.isFreezed() || !isHealthy(n));
|
|
|
|
|
if (!entriesCopy.isEmpty()) {
|
|
|
|
|