diff --git a/src/main/java/org/redisson/client/RedisClient.java b/src/main/java/org/redisson/client/RedisClient.java index 32e5445aa..b22ac2512 100644 --- a/src/main/java/org/redisson/client/RedisClient.java +++ b/src/main/java/org/redisson/client/RedisClient.java @@ -37,9 +37,12 @@ import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioSocketChannel; import io.netty.util.concurrent.Future; +import io.netty.util.concurrent.GenericFutureListener; import io.netty.util.concurrent.GlobalEventExecutor; import io.netty.util.concurrent.ImmediateEventExecutor; import io.netty.util.concurrent.Promise; +import java.util.Map; +import org.redisson.client.protocol.RedisCommands; public class RedisClient { @@ -150,6 +153,37 @@ public class RedisClient { return channels.close(); } + /** + * Execute INFO SERVER operation. + * + * @return Map extracted from each response line splitting by ':' symbol + */ + public Map 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> serverInfoAsync() { + final RedisConnection connection = connect(); + Promise> async = (Promise) connection.async(RedisCommands.SERVER_INFO); + async.addListener(new GenericFutureListener>>() { + @Override + public void operationComplete(Promise> future) throws Exception { + connection.closeAsync(); + } + }); + return async; + } + @Override public String toString() { return "[addr=" + addr + "]";