|
|
|
@ -151,6 +151,10 @@ public final class RedisClient {
|
|
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Timer getTimer() {
|
|
|
|
|
return timer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RedisConnection connect() {
|
|
|
|
|
try {
|
|
|
|
|
return connectAsync().syncUninterruptibly().getNow();
|
|
|
|
@ -311,7 +315,12 @@ public final class RedisClient {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public RFuture<Void> shutdownAsync() {
|
|
|
|
|
final RPromise<Void> result = new RedissonPromise<Void>();
|
|
|
|
|
RPromise<Void> result = new RedissonPromise<Void>();
|
|
|
|
|
if (channels.isEmpty()) {
|
|
|
|
|
shutdown(result);
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChannelGroupFuture channelsFuture = channels.newCloseFuture();
|
|
|
|
|
channelsFuture.addListener(new FutureListener<Void>() {
|
|
|
|
|
@Override
|
|
|
|
@ -321,11 +330,24 @@ public final class RedisClient {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!hasOwnTimer && !hasOwnExecutor && !hasOwnResolver && !hasOwnGroup) {
|
|
|
|
|
result.trySuccess(null);
|
|
|
|
|
return;
|
|
|
|
|
shutdown(result);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (Channel channel : channels) {
|
|
|
|
|
RedisConnection connection = RedisConnection.getFrom(channel);
|
|
|
|
|
if (connection != null) {
|
|
|
|
|
connection.closeAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void shutdown(RPromise<Void> result) {
|
|
|
|
|
if (!hasOwnTimer && !hasOwnExecutor && !hasOwnResolver && !hasOwnGroup) {
|
|
|
|
|
result.trySuccess(null);
|
|
|
|
|
} else {
|
|
|
|
|
Thread t = new Thread() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
@ -355,16 +377,6 @@ public final class RedisClient {
|
|
|
|
|
};
|
|
|
|
|
t.start();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (Channel channel : channels) {
|
|
|
|
|
RedisConnection connection = RedisConnection.getFrom(channel);
|
|
|
|
|
if (connection != null) {
|
|
|
|
|
connection.closeAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|