diff --git a/src/main/java/redis/clients/jedis/BuilderFactory.java b/src/main/java/redis/clients/jedis/BuilderFactory.java index 3e9714479d..9b755b9106 100644 --- a/src/main/java/redis/clients/jedis/BuilderFactory.java +++ b/src/main/java/redis/clients/jedis/BuilderFactory.java @@ -1312,7 +1312,8 @@ public String toString() { } }; - private static final Builder> STREAM_CONSUMER_FULL_INFO_LIST = new Builder>() { + private static final Builder> STREAM_CONSUMER_FULL_INFO_LIST + = new Builder>() { final Map mappingFunctions = createDecoderMap(); @@ -1340,7 +1341,8 @@ public List build(Object data) { for (Object streamsEntry : streamsEntries) { List consumerInfoList = (List) streamsEntry; Iterator consumerInfoIterator = consumerInfoList.iterator(); - StreamConsumerFullInfo consumerInfo = new StreamConsumerFullInfo(createMapFromDecodingFunctions(consumerInfoIterator, mappingFunctions)); + StreamConsumerFullInfo consumerInfo = new StreamConsumerFullInfo( + createMapFromDecodingFunctions(consumerInfoIterator, mappingFunctions)); list.add(consumerInfo); } return list; @@ -1352,7 +1354,8 @@ public String toString() { } }; - private static final Builder> STREAM_GROUP_FULL_INFO_LIST = new Builder>() { + private static final Builder> STREAM_GROUP_FULL_INFO_LIST + = new Builder>() { final Map mappingFunctions = createDecoderMap(); @@ -1384,8 +1387,8 @@ public List build(Object data) { Iterator groupInfoIterator = groupInfo.iterator(); - StreamGroupFullInfo groupFullInfo = new StreamGroupFullInfo(createMapFromDecodingFunctions( - groupInfoIterator, mappingFunctions)); + StreamGroupFullInfo groupFullInfo = new StreamGroupFullInfo( + createMapFromDecodingFunctions(groupInfoIterator, mappingFunctions)); list.add(groupFullInfo); } diff --git a/src/main/java/redis/clients/jedis/resps/StreamConsumerFullInfo.java b/src/main/java/redis/clients/jedis/resps/StreamConsumerFullInfo.java index 134e570284..cb87b89c51 100644 --- a/src/main/java/redis/clients/jedis/resps/StreamConsumerFullInfo.java +++ b/src/main/java/redis/clients/jedis/resps/StreamConsumerFullInfo.java @@ -14,11 +14,13 @@ public class StreamConsumerFullInfo implements Serializable { public static final String NAME = "name"; public static final String SEEN_TIME = "seen-time"; + public static final String ACTIVE_TIME = "active-time"; public static final String PEL_COUNT = "pel-count"; public static final String PENDING = "pending"; private final String name; private final Long seenTime; + private final Long activeTime; // since Redis 7.2 private final Long pelCount; private final List> pending; private final Map consumerInfo; @@ -28,20 +30,29 @@ public StreamConsumerFullInfo(Map map) { consumerInfo = map; name = (String) map.get(NAME); seenTime = (Long) map.get(SEEN_TIME); + activeTime = (Long) map.get(ACTIVE_TIME); pending = (List>) map.get(PENDING); pelCount = (Long) map.get(PEL_COUNT); - pending.stream().forEach(entry -> entry.set(0, new StreamEntryID((String) entry.get(0)))); + pending.forEach(entry -> entry.set(0, new StreamEntryID((String) entry.get(0)))); } public String getName() { return name; } + // TODO: Long public long getSeenTime() { return seenTime; } + /** + * Since Redis 7.2. + */ + public Long getActiveTime() { + return activeTime; + } + public Long getPelCount() { return pelCount; } @@ -50,6 +61,9 @@ public List> getPending() { return pending; } + /** + * All data. + */ public Map getConsumerInfo() { return consumerInfo; } diff --git a/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java b/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java index e42c55a4f7..75e4aef84e 100644 --- a/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java +++ b/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java @@ -18,6 +18,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicReference; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; import org.junit.Test; import redis.clients.jedis.BuilderFactory; @@ -917,6 +919,8 @@ public void xinfoStreamFullWithPending() { assertEquals(1, group.getConsumers().size()); StreamConsumerFullInfo consumer = group.getConsumers().get(0); assertEquals("xreadGroup-consumer", consumer.getName()); + MatcherAssert.assertThat(consumer.getSeenTime(), Matchers.greaterThanOrEqualTo(0L)); + MatcherAssert.assertThat(consumer.getActiveTime(), Matchers.greaterThanOrEqualTo(0L)); assertEquals(1, consumer.getPending().size()); List consumerPendingEntry = consumer.getPending().get(0); assertEquals(id1, consumerPendingEntry.get(0));