From ec684623be3d15b269a28f8eee0793709a9096e9 Mon Sep 17 00:00:00 2001 From: seakider Date: Fri, 3 Jan 2025 21:29:58 +0800 Subject: [PATCH] Feature - Support CLIENT LIST command for Spring Data #6108 Signed-off-by: xuxiaolei --- .../data/connection/RedissonConnection.java | 2 +- .../connection/RedissonConnectionTest.java | 9 ++++++++ .../data/connection/RedissonConnection.java | 2 +- .../connection/RedissonConnectionTest.java | 11 +++++++++- .../data/connection/RedissonConnection.java | 2 +- .../connection/RedissonConnectionTest.java | 9 +++++++- .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 11 +++++++++- .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 8 ++++++- .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 10 ++++++++- .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 10 ++++++++- .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 9 +++++++- .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 9 +++++++- .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 10 ++++++++- .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 9 +++++++- .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 7 +++++++ .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 7 +++++++ .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 7 +++++++ .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 7 +++++++ .../RedissonReactiveServerCommandsTest.java | 20 ++++++++++++++++++ .../data/connection/RedissonConnection.java | 2 +- .../RedissonReactiveServerCommands.java | 6 +++++- .../connection/RedissonConnectionTest.java | 7 +++++++ .../RedissonReactiveServerCommandsTest.java | 21 +++++++++++++++++++ 58 files changed, 472 insertions(+), 39 deletions(-) create mode 100644 redisson-spring-data/redisson-spring-data-20/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-22/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-23/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-24/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-25/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-27/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-30/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-31/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-32/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-33/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java create mode 100644 redisson-spring-data/redisson-spring-data-34/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java diff --git a/redisson-spring-data/redisson-spring-data-16/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-16/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 717230307..5ab4c2f70 100644 --- a/redisson-spring-data/redisson-spring-data-16/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-16/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1711,7 +1711,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null,StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } @Override diff --git a/redisson-spring-data/redisson-spring-data-16/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-16/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index ee2b0ce01..48cde8b60 100644 --- a/redisson-spring-data/redisson-spring-data-16/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-16/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -3,6 +3,9 @@ package org.redisson.spring.data.connection; import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; +import org.springframework.data.redis.core.types.RedisClientInfo; + +import java.util.List; public class RedissonConnectionTest extends BaseConnectionTest { @@ -22,5 +25,11 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(connection.hSet("key".getBytes(), "field".getBytes(), "value".getBytes())).isTrue(); assertThat(connection.hGet("key".getBytes(), "field".getBytes())).isEqualTo("value".getBytes()); } + + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } } diff --git a/redisson-spring-data/redisson-spring-data-17/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-17/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index f1794cc9e..8c973e0b4 100644 --- a/redisson-spring-data/redisson-spring-data-17/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-17/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1738,7 +1738,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } @Override diff --git a/redisson-spring-data/redisson-spring-data-17/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-17/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index ee2b0ce01..2cd3eb6c6 100644 --- a/redisson-spring-data/redisson-spring-data-17/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-17/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -3,6 +3,9 @@ package org.redisson.spring.data.connection; import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; +import org.springframework.data.redis.core.types.RedisClientInfo; + +import java.util.List; public class RedissonConnectionTest extends BaseConnectionTest { @@ -22,5 +25,11 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(connection.hSet("key".getBytes(), "field".getBytes(), "value".getBytes())).isTrue(); assertThat(connection.hGet("key".getBytes(), "field".getBytes())).isEqualTo("value".getBytes()); } - + + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } + } diff --git a/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 6f1a5ca58..854c4753b 100644 --- a/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-18/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1767,7 +1767,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } @Override diff --git a/redisson-spring-data/redisson-spring-data-18/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-18/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index b507ba37c..55d1155f7 100644 --- a/redisson-spring-data/redisson-spring-data-18/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-18/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -5,6 +5,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; import org.springframework.data.geo.*; import org.springframework.data.redis.connection.RedisGeoCommands; +import org.springframework.data.redis.core.types.RedisClientInfo; import java.util.List; @@ -74,5 +75,11 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(connection.hSet("key".getBytes(), "field".getBytes(), "value".getBytes())).isTrue(); assertThat(connection.hGet("key".getBytes(), "field".getBytes())).isEqualTo("value".getBytes()); } - + + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } + } diff --git a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 8293ffa8b..db38f4f22 100644 --- a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1771,7 +1771,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } @Override diff --git a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index 534432e5f..fe0da9714 100644 --- a/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-20/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -29,6 +29,7 @@ import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -157,9 +158,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-20/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-20/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index ee2b0ce01..2cd3eb6c6 100644 --- a/redisson-spring-data/redisson-spring-data-20/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-20/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -3,6 +3,9 @@ package org.redisson.spring.data.connection; import static org.assertj.core.api.Assertions.assertThat; import org.junit.Test; +import org.springframework.data.redis.core.types.RedisClientInfo; + +import java.util.List; public class RedissonConnectionTest extends BaseConnectionTest { @@ -22,5 +25,11 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(connection.hSet("key".getBytes(), "field".getBytes(), "value".getBytes())).isTrue(); assertThat(connection.hGet("key".getBytes(), "field".getBytes())).isEqualTo("value".getBytes()); } - + + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } + } diff --git a/redisson-spring-data/redisson-spring-data-20/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-20/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..93d56cfa5 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-20/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} diff --git a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 955fcbf9d..cd4bf0ca9 100644 --- a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1774,7 +1774,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } @Override diff --git a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index 534432e5f..fe0da9714 100644 --- a/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-21/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -29,6 +29,7 @@ import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -157,9 +158,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index eb1cfaceb..39fe81600 100644 --- a/redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -10,6 +10,7 @@ import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; import java.util.ArrayList; import java.util.List; @@ -69,5 +70,10 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(t.next().getValue()).isEqualTo("value2".getBytes()); } - + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } + } diff --git a/redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..93d56cfa5 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-21/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} diff --git a/redisson-spring-data/redisson-spring-data-22/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-22/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 038034119..ccafdc80e 100644 --- a/redisson-spring-data/redisson-spring-data-22/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-22/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1773,7 +1773,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } @Override diff --git a/redisson-spring-data/redisson-spring-data-22/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-22/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index 534432e5f..fe0da9714 100644 --- a/redisson-spring-data/redisson-spring-data-22/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-22/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -29,6 +29,7 @@ import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -157,9 +158,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-22/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-22/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index a35577560..3a31e6ae0 100644 --- a/redisson-spring-data/redisson-spring-data-22/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-22/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -6,6 +6,9 @@ import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; + +import java.util.List; import static org.assertj.core.api.Assertions.assertThat; @@ -64,5 +67,10 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(t.next().getValue()).isEqualTo("value2".getBytes()); } - + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } + } diff --git a/redisson-spring-data/redisson-spring-data-22/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-22/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..93d56cfa5 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-22/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} diff --git a/redisson-spring-data/redisson-spring-data-23/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-23/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 85c3207f7..b4ddf12d8 100644 --- a/redisson-spring-data/redisson-spring-data-23/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-23/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1774,7 +1774,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } @Override diff --git a/redisson-spring-data/redisson-spring-data-23/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-23/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index 534432e5f..fe0da9714 100644 --- a/redisson-spring-data/redisson-spring-data-23/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-23/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -29,6 +29,7 @@ import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -157,9 +158,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-23/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-23/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index 1e94206f2..bc3d5f759 100644 --- a/redisson-spring-data/redisson-spring-data-23/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-23/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -13,6 +13,9 @@ import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; + +import java.util.List; public class RedissonConnectionTest extends BaseConnectionTest { @@ -82,5 +85,10 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(t.next().getValue()).isEqualTo("value2".getBytes()); } - + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } + } diff --git a/redisson-spring-data/redisson-spring-data-23/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-23/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..93d56cfa5 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-23/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} diff --git a/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index bf06b9356..afb508d5e 100644 --- a/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1791,7 +1791,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } @Override diff --git a/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index 534432e5f..fe0da9714 100644 --- a/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-24/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -29,6 +29,7 @@ import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -157,9 +158,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-24/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-24/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index 59ef0d7cb..552b1e505 100644 --- a/redisson-spring-data/redisson-spring-data-24/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-24/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -14,7 +14,9 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.SetOperations; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; +import java.util.List; import java.util.Set; public class RedissonConnectionTest extends BaseConnectionTest { @@ -113,5 +115,10 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(t.next().getValue()).isEqualTo("value2".getBytes()); } - + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } + } diff --git a/redisson-spring-data/redisson-spring-data-24/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-24/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..93d56cfa5 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-24/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} diff --git a/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index c2d703c3c..6513dea80 100644 --- a/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1831,7 +1831,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } @Override diff --git a/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index f8adf1c64..fad8639af 100644 --- a/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-25/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -31,6 +31,7 @@ import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -170,9 +171,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-25/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-25/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index 59ef0d7cb..552b1e505 100644 --- a/redisson-spring-data/redisson-spring-data-25/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-25/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -14,7 +14,9 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.SetOperations; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; +import java.util.List; import java.util.Set; public class RedissonConnectionTest extends BaseConnectionTest { @@ -113,5 +115,10 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(t.next().getValue()).isEqualTo("value2".getBytes()); } - + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } + } diff --git a/redisson-spring-data/redisson-spring-data-25/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-25/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..93d56cfa5 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-25/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} diff --git a/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 014a76ad0..3287c4242 100644 --- a/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1836,7 +1836,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } @Override diff --git a/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index f8adf1c64..fad8639af 100644 --- a/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-26/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -31,6 +31,7 @@ import org.redisson.client.protocol.decoder.TimeLongObjectDecoder; import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -170,9 +171,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index 572cb5919..1fd41c0bc 100644 --- a/redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -14,7 +14,9 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.SetOperations; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; +import java.util.List; import java.util.Set; public class RedissonConnectionTest extends BaseConnectionTest { @@ -132,5 +134,11 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(r.getValue()).isEqualTo("value1".getBytes()); assertThat(r.getScore()).isEqualTo(1); } - + + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } + } diff --git a/redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..93d56cfa5 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-26/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} diff --git a/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 032371262..e834037ea 100644 --- a/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1836,7 +1836,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } @Override diff --git a/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index 08f55afb3..7942640dc 100644 --- a/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-27/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -32,6 +32,7 @@ import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; import org.springframework.data.redis.connection.RedisServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -193,9 +194,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-27/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-27/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index b584f4bd3..dbe85fc9d 100644 --- a/redisson-spring-data/redisson-spring-data-27/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-27/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -14,7 +14,9 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.SetOperations; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; +import java.util.List; import java.util.Set; public class RedissonConnectionTest extends BaseConnectionTest { @@ -120,5 +122,10 @@ public class RedissonConnectionTest extends BaseConnectionTest { assertThat(t.next().getValue()).isEqualTo("value2".getBytes()); } - + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } + } diff --git a/redisson-spring-data/redisson-spring-data-27/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-27/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..93d56cfa5 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-27/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} diff --git a/redisson-spring-data/redisson-spring-data-30/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-30/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 2bd97a67d..b4ec80cb3 100644 --- a/redisson-spring-data/redisson-spring-data-30/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-30/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1763,7 +1763,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } // @Override diff --git a/redisson-spring-data/redisson-spring-data-30/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-30/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index 08f55afb3..7942640dc 100644 --- a/redisson-spring-data/redisson-spring-data-30/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-30/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -32,6 +32,7 @@ import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; import org.springframework.data.redis.connection.RedisServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -193,9 +194,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-30/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-30/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index e3cc8a862..8c7bb31f8 100644 --- a/redisson-spring-data/redisson-spring-data-30/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-30/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -15,6 +15,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.SetOperations; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; import java.util.List; import java.util.Map; @@ -138,5 +139,11 @@ public class RedissonConnectionTest extends BaseConnectionTest { byte[] f = connection.hRandField("map".getBytes()); assertThat((Object) f).isIn("key1".getBytes(), "key2".getBytes(), "key3".getBytes()); } + + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } } diff --git a/redisson-spring-data/redisson-spring-data-30/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-30/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..93d56cfa5 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-30/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} diff --git a/redisson-spring-data/redisson-spring-data-31/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-31/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 78cd08190..b44bdb8e0 100644 --- a/redisson-spring-data/redisson-spring-data-31/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-31/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1763,7 +1763,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } // @Override diff --git a/redisson-spring-data/redisson-spring-data-31/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-31/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index 08f55afb3..7942640dc 100644 --- a/redisson-spring-data/redisson-spring-data-31/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-31/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -32,6 +32,7 @@ import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; import org.springframework.data.redis.connection.RedisServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -193,9 +194,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-31/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-31/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index d2432fae3..62a303ae3 100644 --- a/redisson-spring-data/redisson-spring-data-31/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-31/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -13,6 +13,7 @@ import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.*; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; import java.nio.ByteBuffer; import java.time.Duration; @@ -283,5 +284,11 @@ public class RedissonConnectionTest extends BaseConnectionTest { byte[] f = connection.hRandField("map".getBytes()); assertThat((Object) f).isIn("key1".getBytes(), "key2".getBytes(), "key3".getBytes()); } + + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } } diff --git a/redisson-spring-data/redisson-spring-data-31/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-31/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..93d56cfa5 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-31/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} diff --git a/redisson-spring-data/redisson-spring-data-32/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-32/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 3f0043a0a..b7d5ec720 100644 --- a/redisson-spring-data/redisson-spring-data-32/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-32/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1763,7 +1763,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } // @Override diff --git a/redisson-spring-data/redisson-spring-data-32/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-32/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index 08f55afb3..7942640dc 100644 --- a/redisson-spring-data/redisson-spring-data-32/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-32/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -32,6 +32,7 @@ import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; import org.springframework.data.redis.connection.RedisServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -193,9 +194,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-32/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-32/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index d2432fae3..62a303ae3 100644 --- a/redisson-spring-data/redisson-spring-data-32/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-32/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -13,6 +13,7 @@ import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.*; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; import java.nio.ByteBuffer; import java.time.Duration; @@ -283,5 +284,11 @@ public class RedissonConnectionTest extends BaseConnectionTest { byte[] f = connection.hRandField("map".getBytes()); assertThat((Object) f).isIn("key1".getBytes(), "key2".getBytes(), "key3".getBytes()); } + + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } } diff --git a/redisson-spring-data/redisson-spring-data-32/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-32/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..93d56cfa5 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-32/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} diff --git a/redisson-spring-data/redisson-spring-data-33/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-33/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 2230b957f..53065ad7f 100644 --- a/redisson-spring-data/redisson-spring-data-33/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-33/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1763,7 +1763,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } // @Override diff --git a/redisson-spring-data/redisson-spring-data-33/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-33/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index 08f55afb3..7942640dc 100644 --- a/redisson-spring-data/redisson-spring-data-33/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-33/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -32,6 +32,7 @@ import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; import org.springframework.data.redis.connection.RedisServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -193,9 +194,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-33/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-33/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index fda561fd6..c09781ba3 100644 --- a/redisson-spring-data/redisson-spring-data-33/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-33/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -13,6 +13,7 @@ import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.*; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; import java.nio.ByteBuffer; import java.time.Duration; @@ -264,5 +265,11 @@ public class RedissonConnectionTest extends BaseConnectionTest { byte[] f = connection.hRandField("map".getBytes()); assertThat((Object) f).isIn("key1".getBytes(), "key2".getBytes(), "key3".getBytes()); } + + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } } diff --git a/redisson-spring-data/redisson-spring-data-33/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-33/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..e76083afe --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-33/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,20 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + } +} \ No newline at end of file diff --git a/redisson-spring-data/redisson-spring-data-34/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java b/redisson-spring-data/redisson-spring-data-34/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java index 2230b957f..53065ad7f 100644 --- a/redisson-spring-data/redisson-spring-data-34/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java +++ b/redisson-spring-data/redisson-spring-data-34/src/main/java/org/redisson/spring/data/connection/RedissonConnection.java @@ -1763,7 +1763,7 @@ public class RedissonConnection extends AbstractRedisConnection { @Override public List getClientList() { - throw new UnsupportedOperationException(); + return read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); } // @Override diff --git a/redisson-spring-data/redisson-spring-data-34/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java b/redisson-spring-data/redisson-spring-data-34/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java index 08f55afb3..7942640dc 100644 --- a/redisson-spring-data/redisson-spring-data-34/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java +++ b/redisson-spring-data/redisson-spring-data-34/src/main/java/org/redisson/spring/data/connection/RedissonReactiveServerCommands.java @@ -32,6 +32,7 @@ import org.redisson.misc.CompletableFutureWrapper; import org.redisson.reactive.CommandReactiveExecutor; import org.springframework.data.redis.connection.ReactiveServerCommands; import org.springframework.data.redis.connection.RedisServerCommands; +import org.springframework.data.redis.connection.convert.StringToRedisClientInfoConverter; import org.springframework.data.redis.core.types.RedisClientInfo; import reactor.core.publisher.Flux; @@ -193,9 +194,12 @@ public class RedissonReactiveServerCommands extends RedissonBaseReactive impleme throw new UnsupportedOperationException(); } + private static final StringToRedisClientInfoConverter CONVERTER = new StringToRedisClientInfoConverter(); + @Override public Flux getClientList() { - throw new UnsupportedOperationException(); + Mono> m = read(null, StringCodec.INSTANCE, RedisCommands.CLIENT_LIST); + return m.flatMapMany(s -> Flux.fromIterable(CONVERTER.convert(s.toArray(new String[s.size()])))); } } diff --git a/redisson-spring-data/redisson-spring-data-34/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java b/redisson-spring-data/redisson-spring-data-34/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java index fda561fd6..c09781ba3 100644 --- a/redisson-spring-data/redisson-spring-data-34/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java +++ b/redisson-spring-data/redisson-spring-data-34/src/test/java/org/redisson/spring/data/connection/RedissonConnectionTest.java @@ -13,6 +13,7 @@ import org.springframework.data.redis.connection.RedisZSetCommands; import org.springframework.data.redis.connection.zset.Tuple; import org.springframework.data.redis.core.*; import org.springframework.data.redis.core.types.Expiration; +import org.springframework.data.redis.core.types.RedisClientInfo; import java.nio.ByteBuffer; import java.time.Duration; @@ -264,5 +265,11 @@ public class RedissonConnectionTest extends BaseConnectionTest { byte[] f = connection.hRandField("map".getBytes()); assertThat((Object) f).isIn("key1".getBytes(), "key2".getBytes(), "key3".getBytes()); } + + @Test + public void testGetClientList() { + List info = connection.getClientList(); + assertThat(info.size()).isGreaterThan(10); + } } diff --git a/redisson-spring-data/redisson-spring-data-34/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java b/redisson-spring-data/redisson-spring-data-34/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java new file mode 100644 index 000000000..d91f039b1 --- /dev/null +++ b/redisson-spring-data/redisson-spring-data-34/src/test/java/org/redisson/spring/data/connection/RedissonReactiveServerCommandsTest.java @@ -0,0 +1,21 @@ +package org.redisson.spring.data.connection; + +import org.junit.Test; +import org.springframework.data.redis.connection.ReactiveRedisConnection; +import org.springframework.data.redis.core.types.RedisClientInfo; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import static org.assertj.core.api.Assertions.assertThat; + +public class RedissonReactiveServerCommandsTest extends BaseConnectionTest { + @Test + public void testGetClientList() { + RedissonConnectionFactory factory = new RedissonConnectionFactory(redisson); + ReactiveRedisConnection reactiveConnection = factory.getReactiveConnection(); + Flux flux = reactiveConnection.serverCommands().getClientList(); + Mono count = flux.count(); + count.subscribe(s -> assertThat(s).isGreaterThan(10)); + + } +}