|
|
@ -46,14 +46,15 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class RedisConnection implements RedisCommands {
|
|
|
|
public class RedisConnection implements RedisCommands {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public enum Status {OPEN, CLOSED, CLOSED_IDLE}
|
|
|
|
|
|
|
|
|
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(RedisConnection.class);
|
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(RedisConnection.class);
|
|
|
|
private static final AttributeKey<RedisConnection> CONNECTION = AttributeKey.valueOf("connection");
|
|
|
|
private static final AttributeKey<RedisConnection> CONNECTION = AttributeKey.valueOf("connection");
|
|
|
|
|
|
|
|
|
|
|
|
final RedisClient redisClient;
|
|
|
|
final RedisClient redisClient;
|
|
|
|
|
|
|
|
|
|
|
|
private volatile CompletableFuture<Void> fastReconnect;
|
|
|
|
private volatile CompletableFuture<Void> fastReconnect;
|
|
|
|
private volatile boolean closed;
|
|
|
|
private volatile Status status = Status.OPEN;
|
|
|
|
private volatile boolean closedIdle;
|
|
|
|
|
|
|
|
volatile Channel channel;
|
|
|
|
volatile Channel channel;
|
|
|
|
|
|
|
|
|
|
|
|
private CompletableFuture<?> connectionPromise;
|
|
|
|
private CompletableFuture<?> connectionPromise;
|
|
|
@ -280,7 +281,7 @@ public class RedisConnection implements RedisCommands {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isClosed() {
|
|
|
|
public boolean isClosed() {
|
|
|
|
return closed;
|
|
|
|
return status != Status.OPEN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isFastReconnect() {
|
|
|
|
public boolean isFastReconnect() {
|
|
|
@ -323,16 +324,17 @@ public class RedisConnection implements RedisCommands {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ChannelFuture closeIdleAsync() {
|
|
|
|
public ChannelFuture closeIdleAsync() {
|
|
|
|
closedIdle = true;
|
|
|
|
status = Status.CLOSED_IDLE;
|
|
|
|
return closeAsync();
|
|
|
|
close();
|
|
|
|
|
|
|
|
return channel.closeFuture();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isClosedIdle() {
|
|
|
|
public boolean isClosedIdle() {
|
|
|
|
return closedIdle;
|
|
|
|
return status == Status.CLOSED_IDLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ChannelFuture closeAsync() {
|
|
|
|
public ChannelFuture closeAsync() {
|
|
|
|
closed = true;
|
|
|
|
status = Status.CLOSED;
|
|
|
|
close();
|
|
|
|
close();
|
|
|
|
return channel.closeFuture();
|
|
|
|
return channel.closeFuture();
|
|
|
|
}
|
|
|
|
}
|
|
|
|