|
|
@ -37,9 +37,12 @@ import io.netty.channel.nio.NioEventLoopGroup;
|
|
|
|
import io.netty.channel.socket.SocketChannel;
|
|
|
|
import io.netty.channel.socket.SocketChannel;
|
|
|
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
|
|
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
|
|
|
import io.netty.util.concurrent.Future;
|
|
|
|
import io.netty.util.concurrent.Future;
|
|
|
|
|
|
|
|
import io.netty.util.concurrent.GenericFutureListener;
|
|
|
|
import io.netty.util.concurrent.GlobalEventExecutor;
|
|
|
|
import io.netty.util.concurrent.GlobalEventExecutor;
|
|
|
|
import io.netty.util.concurrent.ImmediateEventExecutor;
|
|
|
|
import io.netty.util.concurrent.ImmediateEventExecutor;
|
|
|
|
import io.netty.util.concurrent.Promise;
|
|
|
|
import io.netty.util.concurrent.Promise;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import org.redisson.client.protocol.RedisCommands;
|
|
|
|
|
|
|
|
|
|
|
|
public class RedisClient {
|
|
|
|
public class RedisClient {
|
|
|
|
|
|
|
|
|
|
|
@ -150,6 +153,37 @@ public class RedisClient {
|
|
|
|
return channels.close();
|
|
|
|
return channels.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Execute INFO SERVER operation.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return Map extracted from each response line splitting by ':' symbol
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public Map<String, String> serverInfo() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return serverInfoAsync().sync().get();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
throw new RedisConnectionException("Unable to retrieve server into from: " + addr, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Asynchronously execute INFO SERVER operation.
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return A future for a map extracted from each response line splitting by
|
|
|
|
|
|
|
|
* ':' symbol
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public Future<Map<String, String>> serverInfoAsync() {
|
|
|
|
|
|
|
|
final RedisConnection connection = connect();
|
|
|
|
|
|
|
|
Promise<Map<String, String>> async = (Promise) connection.async(RedisCommands.SERVER_INFO);
|
|
|
|
|
|
|
|
async.addListener(new GenericFutureListener<Promise<Map<String, String>>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void operationComplete(Promise<Map<String, String>> future) throws Exception {
|
|
|
|
|
|
|
|
connection.closeAsync();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return async;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
public String toString() {
|
|
|
|
return "[addr=" + addr + "]";
|
|
|
|
return "[addr=" + addr + "]";
|
|
|
|