|
|
|
@ -39,7 +39,6 @@ import java.util.concurrent.CompletionStage;
|
|
|
|
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
|
import java.util.function.BiConsumer;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base connection pool class
|
|
|
|
@ -106,10 +105,8 @@ abstract class ConnectionPool<T extends RedisConnection> {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
acquireConnection(entry, new Runnable() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
CompletableFuture<Void> f = acquireConnection(entry, null);
|
|
|
|
|
f.thenAccept(r -> {
|
|
|
|
|
CompletableFuture<T> promise = new CompletableFuture<T>();
|
|
|
|
|
createConnection(entry, promise);
|
|
|
|
|
promise.whenComplete((conn, e) -> {
|
|
|
|
@ -166,12 +163,11 @@ abstract class ConnectionPool<T extends RedisConnection> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, null);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void acquireConnection(ClientConnectionsEntry entry, Runnable runnable, RedisCommand<?> command) {
|
|
|
|
|
entry.acquireConnection(runnable, command);
|
|
|
|
|
protected CompletableFuture<Void> acquireConnection(ClientConnectionsEntry entry, RedisCommand<?> command) {
|
|
|
|
|
return entry.acquireConnection(command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected abstract int getMinimumIdleSize(ClientConnectionsEntry entry);
|
|
|
|
@ -218,17 +214,18 @@ abstract class ConnectionPool<T extends RedisConnection> {
|
|
|
|
|
return acquireConnection(command, entry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract static class AcquireCallback<T> implements Runnable, BiConsumer<T, Throwable> {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected final CompletableFuture<T> acquireConnection(RedisCommand<?> command, ClientConnectionsEntry entry) {
|
|
|
|
|
CompletableFuture<T> result = new CompletableFuture<T>();
|
|
|
|
|
|
|
|
|
|
Runnable callback = () -> {
|
|
|
|
|
CompletableFuture<Void> f = acquireConnection(entry, command);
|
|
|
|
|
f.thenAccept(r -> {
|
|
|
|
|
connectTo(entry, result, command);
|
|
|
|
|
};
|
|
|
|
|
acquireConnection(entry, callback, command);
|
|
|
|
|
});
|
|
|
|
|
result.whenComplete((r, e) -> {
|
|
|
|
|
if (e != null) {
|
|
|
|
|
f.completeExceptionally(e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|