diff --git a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java index 0831c68f75..d72accd63d 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisAsyncCommands.java @@ -34,7 +34,6 @@ import io.lettuce.core.output.KeyValueStreamingChannel; import io.lettuce.core.output.ScoredValueStreamingChannel; import io.lettuce.core.output.ValueStreamingChannel; -import io.lettuce.core.output.data.DynamicAggregateData; import io.lettuce.core.protocol.AsyncCommand; import io.lettuce.core.protocol.Command; import io.lettuce.core.protocol.CommandArgs; @@ -391,7 +390,7 @@ public RedisFuture clientTracking(TrackingArgs args) { } @Override - public RedisFuture clientTrackinginfo() { + public RedisFuture clientTrackinginfo() { return dispatch(commandBuilder.clientTrackinginfo()); } diff --git a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java index f7292d8e18..675bc31ba3 100644 --- a/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java +++ b/src/main/java/io/lettuce/core/AbstractRedisReactiveCommands.java @@ -34,7 +34,6 @@ import io.lettuce.core.output.KeyValueStreamingChannel; import io.lettuce.core.output.ScoredValueStreamingChannel; import io.lettuce.core.output.ValueStreamingChannel; -import io.lettuce.core.output.data.DynamicAggregateData; import io.lettuce.core.protocol.Command; import io.lettuce.core.protocol.CommandArgs; import io.lettuce.core.protocol.CommandType; @@ -409,7 +408,7 @@ public Mono clientTracking(TrackingArgs args) { } @Override - public Mono clientTrackinginfo() { + public Mono clientTrackinginfo() { return createMono(commandBuilder::clientTrackinginfo); } diff --git a/src/main/java/io/lettuce/core/RedisCommandBuilder.java b/src/main/java/io/lettuce/core/RedisCommandBuilder.java index 4b96eeb59c..46e5cb809b 100644 --- a/src/main/java/io/lettuce/core/RedisCommandBuilder.java +++ b/src/main/java/io/lettuce/core/RedisCommandBuilder.java @@ -28,7 +28,6 @@ import io.lettuce.core.models.stream.PendingMessage; import io.lettuce.core.models.stream.PendingMessages; import io.lettuce.core.output.*; -import io.lettuce.core.output.data.DynamicAggregateData; import io.lettuce.core.protocol.BaseRedisCommandBuilder; import io.lettuce.core.protocol.Command; import io.lettuce.core.protocol.CommandArgs; @@ -529,10 +528,10 @@ Command clientTracking(TrackingArgs trackingArgs) { return createCommand(CLIENT, new StatusOutput<>(codec), args); } - Command clientTrackinginfo() { + Command clientTrackinginfo() { CommandArgs args = new CommandArgs<>(codec).add(TRACKINGINFO); - return new Command<>(CLIENT, new DynamicAggregateOutput<>(codec), args); + return new Command<>(CLIENT, new ComplexOutput<>(codec, TrackingInfoParser.INSTANCE), args); } Command clientUnblock(long id, UnblockType type) { diff --git a/src/main/java/io/lettuce/core/TrackingInfo.java b/src/main/java/io/lettuce/core/TrackingInfo.java index 7c11da7442..113d0b78ce 100644 --- a/src/main/java/io/lettuce/core/TrackingInfo.java +++ b/src/main/java/io/lettuce/core/TrackingInfo.java @@ -18,7 +18,7 @@ * limitations under the License. */ -package io.lettuce.core.api.parsers.tracking; +package io.lettuce.core; import java.util.ArrayList; import java.util.Collections; diff --git a/src/main/java/io/lettuce/core/api/async/RedisServerAsyncCommands.java b/src/main/java/io/lettuce/core/api/async/RedisServerAsyncCommands.java index 3010e4df7a..a4245c2d54 100644 --- a/src/main/java/io/lettuce/core/api/async/RedisServerAsyncCommands.java +++ b/src/main/java/io/lettuce/core/api/async/RedisServerAsyncCommands.java @@ -30,7 +30,7 @@ import io.lettuce.core.ShutdownArgs; import io.lettuce.core.TrackingArgs; import io.lettuce.core.UnblockType; -import io.lettuce.core.output.data.DynamicAggregateData; +import io.lettuce.core.TrackingInfo; import io.lettuce.core.protocol.CommandType; /** @@ -181,12 +181,10 @@ public interface RedisServerAsyncCommands { /** * Returns information about the current client connection's use of the server assisted client side caching feature. * - * @return {@link DynamicAggregateData}, for more information check the documentation - * @see io.lettuce.core.api.parsers.tracking.TrackingInfoParser - * @see io.lettuce.core.api.parsers.tracking.TrackingInfo - * @since 7.0 + * @return {@link TrackingInfo}, for more information check the documentation + * @since 6.5 */ - RedisFuture clientTrackinginfo(); + RedisFuture clientTrackinginfo(); /** * Unblock the specified blocked client. diff --git a/src/main/java/io/lettuce/core/api/reactive/RedisServerReactiveCommands.java b/src/main/java/io/lettuce/core/api/reactive/RedisServerReactiveCommands.java index 51fb1f3b1f..e8f9c070fd 100644 --- a/src/main/java/io/lettuce/core/api/reactive/RedisServerReactiveCommands.java +++ b/src/main/java/io/lettuce/core/api/reactive/RedisServerReactiveCommands.java @@ -28,7 +28,7 @@ import io.lettuce.core.ShutdownArgs; import io.lettuce.core.TrackingArgs; import io.lettuce.core.UnblockType; -import io.lettuce.core.output.data.DynamicAggregateData; +import io.lettuce.core.TrackingInfo; import io.lettuce.core.protocol.CommandType; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -181,12 +181,10 @@ public interface RedisServerReactiveCommands { /** * Returns information about the current client connection's use of the server assisted client side caching feature. * - * @return {@link DynamicAggregateData}, for more information check the documentation - * @see io.lettuce.core.api.parsers.tracking.TrackingInfoParser - * @see io.lettuce.core.api.parsers.tracking.TrackingInfo - * @since 7.0 + * @return {@link TrackingInfo}, for more information check the documentation + * @since 6.5 */ - Mono clientTrackinginfo(); + Mono clientTrackinginfo(); /** * Unblock the specified blocked client. diff --git a/src/main/java/io/lettuce/core/api/sync/RedisServerCommands.java b/src/main/java/io/lettuce/core/api/sync/RedisServerCommands.java index 20c76789cd..28b0530448 100644 --- a/src/main/java/io/lettuce/core/api/sync/RedisServerCommands.java +++ b/src/main/java/io/lettuce/core/api/sync/RedisServerCommands.java @@ -28,8 +28,8 @@ import io.lettuce.core.KillArgs; import io.lettuce.core.ShutdownArgs; import io.lettuce.core.TrackingArgs; +import io.lettuce.core.TrackingInfo; import io.lettuce.core.UnblockType; -import io.lettuce.core.output.data.DynamicAggregateData; import io.lettuce.core.protocol.CommandType; /** @@ -180,12 +180,10 @@ public interface RedisServerCommands { /** * Returns information about the current client connection's use of the server assisted client side caching feature. * - * @return {@link DynamicAggregateData}, for more information check the documentation - * @see io.lettuce.core.api.parsers.tracking.TrackingInfoParser - * @see io.lettuce.core.api.parsers.tracking.TrackingInfo - * @since 7.0 + * @return {@link TrackingInfo}, for more information check the documentation + * @since 6.5 */ - DynamicAggregateData clientTrackinginfo(); + TrackingInfo clientTrackinginfo(); /** * Unblock the specified blocked client. diff --git a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionServerAsyncCommands.java b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionServerAsyncCommands.java index d3668a4b28..f3b7b877c0 100644 --- a/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionServerAsyncCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/async/NodeSelectionServerAsyncCommands.java @@ -19,16 +19,15 @@ */ package io.lettuce.core.cluster.api.async; -import java.util.Date; -import java.util.List; import java.util.Map; - +import java.util.List; +import java.util.Date; import io.lettuce.core.ClientListArgs; import io.lettuce.core.FlushMode; import io.lettuce.core.KillArgs; import io.lettuce.core.TrackingArgs; import io.lettuce.core.UnblockType; -import io.lettuce.core.output.data.DynamicAggregateData; +import io.lettuce.core.TrackingInfo; import io.lettuce.core.protocol.CommandType; /** @@ -179,12 +178,10 @@ public interface NodeSelectionServerAsyncCommands { /** * Returns information about the current client connection's use of the server assisted client side caching feature. * - * @return {@link DynamicAggregateData}, for more information check the documentation - * @see io.lettuce.core.api.parsers.tracking.TrackingInfoParser - * @see io.lettuce.core.api.parsers.tracking.TrackingInfo - * @since 7.0 + * @return {@link TrackingInfo}, for more information check the documentation + * @since 6.5 */ - AsyncExecutions clientTrackinginfo(); + AsyncExecutions clientTrackinginfo(); /** * Unblock the specified blocked client. diff --git a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionServerCommands.java b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionServerCommands.java index c1b1f26b4d..bd6b2e13d3 100644 --- a/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionServerCommands.java +++ b/src/main/java/io/lettuce/core/cluster/api/sync/NodeSelectionServerCommands.java @@ -28,7 +28,7 @@ import io.lettuce.core.KillArgs; import io.lettuce.core.TrackingArgs; import io.lettuce.core.UnblockType; -import io.lettuce.core.output.data.DynamicAggregateData; +import io.lettuce.core.TrackingInfo; import io.lettuce.core.protocol.CommandType; /** @@ -164,7 +164,7 @@ public interface NodeSelectionServerCommands { * @return simple-string-reply {@code OK} if the connection name was successfully set. * @since 6.3 */ - Executions clientSetinfo(String key, V value); + Executions clientSetinfo(String key, String value); /** * Enables the tracking feature of the Redis server, that is used for server assisted client side caching. Tracking messages @@ -179,12 +179,10 @@ public interface NodeSelectionServerCommands { /** * Returns information about the current client connection's use of the server assisted client side caching feature. * - * @return {@link DynamicAggregateData}, for more information check the documentation - * @see io.lettuce.core.api.parsers.tracking.TrackingInfoParser - * @see io.lettuce.core.api.parsers.tracking.TrackingInfo - * @since 7.0 + * @return {@link TrackingInfo}, for more information check the documentation + * @since 6.5 */ - Executions clientTrackinginfo(); + Executions clientTrackinginfo(); /** * Unblock the specified blocked client. diff --git a/src/main/java/io/lettuce/core/output/ArrayComplexData.java b/src/main/java/io/lettuce/core/output/ArrayComplexData.java index 673f1d1576..5674edc31d 100644 --- a/src/main/java/io/lettuce/core/output/ArrayComplexData.java +++ b/src/main/java/io/lettuce/core/output/ArrayComplexData.java @@ -29,25 +29,25 @@ import java.util.Set; /** - * An implementation of the {@link DynamicAggregateData} that handles arrays. + * An implementation of the {@link ComplexData} that handles arrays. *

- * For RESP2 calling the {@link DynamicAggregateData#getDynamicMap()} would heuristically go over the list of elements assuming - * every odd element is a key and every even object is the value and then adding them to an {@link Map}. The logic would follow - * the same order that was used when the elements were added to the {@link ArrayAggregateData}. Similarly calling the - * {@link DynamicAggregateData#getDynamicSet()} would return a set of all the elements, adding them in the same order. If - for - * some reason - duplicate elements exist they would be overwritten. + * For RESP2 calling the {@link ComplexData#getDynamicMap()} would heuristically go over the list of elements assuming every odd + * element is a key and every even object is the value and then adding them to an {@link Map}. The logic would follow the same + * order that was used when the elements were added to the {@link ArrayComplexData}. Similarly calling the + * {@link ComplexData#getDynamicSet()} would return a set of all the elements, adding them in the same order. If - for some + * reason - duplicate elements exist they would be overwritten. *

* All data structures that the implementation returns are unmodifiable * - * @see DynamicAggregateData + * @see ComplexData * @author Tihomir Mateev * @since 6.5 */ -class ArrayAggregateData extends DynamicAggregateData { +class ArrayComplexData extends ComplexData { private final List data; - public ArrayAggregateData(int count) { + public ArrayComplexData(int count) { data = new ArrayList<>(count); } diff --git a/src/main/java/io/lettuce/core/output/ComplexData.java b/src/main/java/io/lettuce/core/output/ComplexData.java index 46c111e0ed..61387cc485 100644 --- a/src/main/java/io/lettuce/core/output/ComplexData.java +++ b/src/main/java/io/lettuce/core/output/ComplexData.java @@ -25,18 +25,16 @@ import java.util.Set; /** - * The base type of all aggregate data, collected by a {@link io.lettuce.core.output.DynamicAggregateOutput} + * The base type of all complex data, collected by a {@link ComplexOutput} *

- * Commands typically result in simple types, however some of the commands could return complex nested structures. A simple - * solution to parse such a structure is to have a dynamic data type and leave the user to parse the result to a domain object. - * If there is some breach of contract then the code consuming the driver could simply stop using the provided parser and start - * parsing the new dynamic data itself, without having to change the version of the library. This allows a certain degree of - * stability against change. Consult the members of the {@link io.lettuce.core.api.parsers} package for details on how aggregate - * Objects could be parsed. + * Commands typically result in simple types, however some of the commands could return complex nested structures. In these + * cases, and with the help of a {@link ComplexDataParser}, the data gathered by the {@link ComplexOutput} could be parsed to a + * domain object. *

- * An aggregate data object could contain multiple (or no) units of simple data, as per the + * An complex data object could only be an aggregate data type as per the * RESP2 and - * RESP3 protocol definitions. + * RESP3 protocol definitions. Its + * contents, however, could be both the simple and aggregate data types. *

* For RESP2 the only possible aggregation is an array. RESP2 commands could also return sets (obviously, by simply making sure * the elements of the array are unique) or maps (by sending the keys as odd elements and their values as even elements in the @@ -45,21 +43,21 @@ * For RESP3 all the three aggregate types are supported (and indicated with special characters when the result is returned by * the server). *

- * Aggregate data types could also be nested by using the {@link DynamicAggregateData#storeObject(Object)} call. + * Aggregate data types could also be nested by using the {@link ComplexData#storeObject(Object)} call. *

- * Implementations of this class override the {@link DynamicAggregateData#getDynamicSet()}, - * {@link DynamicAggregateData#getDynamicList()} and {@link DynamicAggregateData#getDynamicMap()} methods to return the data - * received in the server in a implementation of the Collections framework. If a given implementation could not do the - * conversion in a meaningful way an {@link UnsupportedOperationException} would be thrown. + * Implementations of this class override the {@link ComplexData#getDynamicSet()}, {@link ComplexData#getDynamicList()} and + * {@link ComplexData#getDynamicMap()} methods to return the data received in the server in a implementation of the Collections + * framework. If a given implementation could not do the conversion in a meaningful way an {@link UnsupportedOperationException} + * would be thrown. * - * @see io.lettuce.core.output.DynamicAggregateOutput - * @see ArrayAggregateData - * @see SetAggregateData - * @see MapAggregateData + * @see ComplexOutput + * @see ArrayComplexData + * @see SetComplexData + * @see MapComplexData * @author Tihomir Mateev * @since 6.5 */ -public abstract class DynamicAggregateData { +public abstract class ComplexData { /** * Store a long value in the underlying data structure @@ -90,7 +88,7 @@ public void store(boolean value) { /** * Store an {@link Object} value in the underlying data structure. This method should be used when nesting one instance of - * {@link DynamicAggregateData} inside another + * {@link ComplexData} inside another * * @param value the value to store */ diff --git a/src/main/java/io/lettuce/core/output/ComplexDataParser.java b/src/main/java/io/lettuce/core/output/ComplexDataParser.java index 1f0a85c759..78291a7ec3 100644 --- a/src/main/java/io/lettuce/core/output/ComplexDataParser.java +++ b/src/main/java/io/lettuce/core/output/ComplexDataParser.java @@ -21,16 +21,16 @@ package io.lettuce.core.output; /** - * Any usage of the {@link DynamicAggregateOutput} comes hand in hand with a respective {@link DynamicAggregateDataParser} that - * is able to parse the data extracted from the server to a meaningful Java object. + * Any usage of the {@link ComplexOutput} comes hand in hand with a respective {@link ComplexDataParser} that is able to parse + * the data extracted from the server to a meaningful Java object. * * @param the type of the parsed object * @author Tihomir Mateev - * @see DynamicAggregateData - * @see DynamicAggregateOutput + * @see ComplexData + * @see ComplexOutput * @since 6.5 */ -public interface DynamicAggregateDataParser { +public interface ComplexDataParser { /** * Parse the data extracted from the server to a specific domain object. @@ -39,6 +39,6 @@ public interface DynamicAggregateDataParser { * @return the parsed object * @since 6.5 */ - T parse(DynamicAggregateData data); + T parse(ComplexData data); } diff --git a/src/main/java/io/lettuce/core/output/ComplexOutput.java b/src/main/java/io/lettuce/core/output/ComplexOutput.java index 10c853192f..c8450fb58e 100644 --- a/src/main/java/io/lettuce/core/output/ComplexOutput.java +++ b/src/main/java/io/lettuce/core/output/ComplexOutput.java @@ -28,32 +28,32 @@ import java.util.Deque; /** - * An implementation of the {@link CommandOutput} that is used in combination with a given {@link DynamicAggregateDataParser} to - * produce a domain object from the data extracted from the server. Since there already are implementations of the - * {@link CommandOutput} interface for most simple types, this implementation is better suited to parse complex, often nested, - * data structures, for example a map containing other maps, arrays or sets as values for one or more of its keys. + * An implementation of the {@link CommandOutput} that is used in combination with a given {@link ComplexDataParser} to produce + * a domain object from the data extracted from the server. Since there already are implementations of the {@link CommandOutput} + * interface for most simple types, this implementation is better suited to parse complex, often nested, data structures, for + * example a map containing other maps, arrays or sets as values for one or more of its keys. *

- * The implementation of the {@link DynamicAggregateDataParser} is responsible for mapping the data from the result to - * meaningful properties that the user of the LEttuce driver could then use in a statically typed manner. + * The implementation of the {@link ComplexDataParser} is responsible for mapping the data from the result to meaningful + * properties that the user of the LEttuce driver could then use in a statically typed manner. * - * @see DynamicAggregateDataParser + * @see ComplexDataParser * @author Tihomir Mateev * @since 6.5 */ -public class DynamicAggregateOutput extends CommandOutput { +public class ComplexOutput extends CommandOutput { - private final Deque dataStack; + private final Deque dataStack; - private final DynamicAggregateDataParser parser; + private final ComplexDataParser parser; - private DynamicAggregateData data; + private ComplexData data; /** - * Constructs a new instance of the {@link DynamicAggregateOutput} + * Constructs a new instance of the {@link ComplexOutput} * * @param codec the {@link RedisCodec} to be applied */ - public DynamicAggregateOutput(RedisCodec codec, DynamicAggregateDataParser parser) { + public ComplexOutput(RedisCodec codec, ComplexDataParser parser) { super(codec, null); dataStack = LettuceFactories.newSpScQueue(); this.parser = parser; @@ -121,7 +121,7 @@ public void complete(int depth) { } } - private void multi(DynamicAggregateData newData) { + private void multi(ComplexData newData) { // if there is no data set, then we are at the root object if (data == null) { data = newData; @@ -136,19 +136,19 @@ private void multi(DynamicAggregateData newData) { @Override public void multiSet(int count) { - SetAggregateData dynamicData = new SetAggregateData(count); + SetComplexData dynamicData = new SetComplexData(count); multi(dynamicData); } @Override public void multiArray(int count) { - ArrayAggregateData dynamicData = new ArrayAggregateData(count); + ArrayComplexData dynamicData = new ArrayComplexData(count); multi(dynamicData); } @Override public void multiMap(int count) { - MapAggregateData dynamicData = new MapAggregateData(count); + MapComplexData dynamicData = new MapComplexData(count); multi(dynamicData); } diff --git a/src/main/java/io/lettuce/core/output/MapComplexData.java b/src/main/java/io/lettuce/core/output/MapComplexData.java index bb908aa9b5..fc87a77946 100644 --- a/src/main/java/io/lettuce/core/output/MapComplexData.java +++ b/src/main/java/io/lettuce/core/output/MapComplexData.java @@ -25,21 +25,21 @@ import java.util.Map; /** - * An implementation of the {@link DynamicAggregateData} that handles maps. + * An implementation of the {@link ComplexData} that handles maps. *

* All data structures that the implementation returns are unmodifiable * - * @see DynamicAggregateData + * @see ComplexData * @author Tihomir Mateev * @since 6.5 */ -class MapAggregateData extends DynamicAggregateData { +class MapComplexData extends ComplexData { private final Map data; private Object key; - public MapAggregateData(int count) { + public MapComplexData(int count) { data = new HashMap<>(count); } diff --git a/src/main/java/io/lettuce/core/output/SetComplexData.java b/src/main/java/io/lettuce/core/output/SetComplexData.java index ff15caf640..66bda0d1a7 100644 --- a/src/main/java/io/lettuce/core/output/SetComplexData.java +++ b/src/main/java/io/lettuce/core/output/SetComplexData.java @@ -27,19 +27,19 @@ import java.util.Set; /** - * An implementation of the {@link DynamicAggregateData} that handles maps. + * An implementation of the {@link ComplexData} that handles maps. *

* All data structures that the implementation returns are unmodifiable * - * @see DynamicAggregateData + * @see ComplexData * @author Tihomir Mateev * @since 6.5 */ -public class SetAggregateData extends DynamicAggregateData { +public class SetComplexData extends ComplexData { private final Set data; - public SetAggregateData(int count) { + public SetComplexData(int count) { data = new HashSet<>(count); } diff --git a/src/main/java/io/lettuce/core/output/TrackingInfoParser.java b/src/main/java/io/lettuce/core/output/TrackingInfoParser.java index c9c1dbc2a8..af4b745c9c 100644 --- a/src/main/java/io/lettuce/core/output/TrackingInfoParser.java +++ b/src/main/java/io/lettuce/core/output/TrackingInfoParser.java @@ -20,8 +20,7 @@ package io.lettuce.core.output; -import io.lettuce.core.output.DynamicAggregateDataParser; -import io.lettuce.core.output.DynamicAggregateData; +import io.lettuce.core.TrackingInfo; import io.lettuce.core.protocol.CommandKeyword; import java.util.ArrayList; @@ -34,9 +33,9 @@ * Parser for Redis CLIENT TRACKINGINFO command output. * * @author Tihomir Mateev - * @since 7.0 + * @since 6.5 */ -public class TrackingInfoParser implements DynamicAggregateDataParser { +public class TrackingInfoParser implements ComplexDataParser { public static final TrackingInfoParser INSTANCE = new TrackingInfoParser(); @@ -52,11 +51,11 @@ private TrackingInfoParser() { * @param dynamicData output of CLIENT TRACKINGINFO command * @return an {@link TrackingInfo} instance */ - public TrackingInfo parse(DynamicAggregateData dynamicData) { + public TrackingInfo parse(ComplexData dynamicData) { Map data = verifyStructure(dynamicData); - Set flags = ((DynamicAggregateData) data.get(CommandKeyword.FLAGS.toString().toLowerCase())).getDynamicSet(); + Set flags = ((ComplexData) data.get(CommandKeyword.FLAGS.toString().toLowerCase())).getDynamicSet(); Long clientId = (Long) data.get(CommandKeyword.REDIRECT.toString().toLowerCase()); - List prefixes = ((DynamicAggregateData) data.get(CommandKeyword.PREFIXES.toString().toLowerCase())).getDynamicList(); + List prefixes = ((ComplexData) data.get(CommandKeyword.PREFIXES.toString().toLowerCase())).getDynamicList(); Set parsedFlags = new HashSet<>(); List parsedPrefixes = new ArrayList<>(); @@ -73,7 +72,7 @@ public TrackingInfo parse(DynamicAggregateData dynamicData) { return new TrackingInfo(parsedFlags, clientId, parsedPrefixes); } - private Map verifyStructure(DynamicAggregateData trackinginfoOutput) { + private Map verifyStructure(ComplexData trackinginfoOutput) { if (trackinginfoOutput == null) { throw new IllegalArgumentException("Failed while parsing CLIENT TRACKINGINFO: trackinginfoOutput must not be null"); diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisServerCoroutinesCommands.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisServerCoroutinesCommands.kt index 3bb92e8d3b..b5a92e53c4 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisServerCoroutinesCommands.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisServerCoroutinesCommands.kt @@ -21,7 +21,7 @@ package io.lettuce.core.api.coroutines import io.lettuce.core.* -import io.lettuce.core.output.data.DynamicAggregateData +import io.lettuce.core.TrackingInfo import io.lettuce.core.protocol.CommandType import java.util.* @@ -173,12 +173,10 @@ interface RedisServerCoroutinesCommands { /** * Returns information about the current client connection's use of the server assisted client side caching feature. * - * @return @link DynamicAggregateData}, for more information check the documentation - * @see io.lettuce.core.api.parsers.tracking.TrackingInfoParser - * @see io.lettuce.core.api.parsers.tracking.TrackingInfo - * @since 7.0 + * @return @link TrackingInfo}, for more information check the documentation + * @since 6.5 */ - suspend fun clientTrackinginfo(): DynamicAggregateData? + suspend fun clientTrackinginfo(): TrackingInfo? /** * Unblock the specified blocked client. diff --git a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisServerCoroutinesCommandsImpl.kt b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisServerCoroutinesCommandsImpl.kt index e84b67807c..ae0ef25481 100644 --- a/src/main/kotlin/io/lettuce/core/api/coroutines/RedisServerCoroutinesCommandsImpl.kt +++ b/src/main/kotlin/io/lettuce/core/api/coroutines/RedisServerCoroutinesCommandsImpl.kt @@ -21,8 +21,8 @@ package io.lettuce.core.api.coroutines import io.lettuce.core.* +import io.lettuce.core.TrackingInfo import io.lettuce.core.api.reactive.RedisServerReactiveCommands -import io.lettuce.core.output.data.DynamicAggregateData import io.lettuce.core.protocol.CommandType import kotlinx.coroutines.flow.toList import kotlinx.coroutines.reactive.asFlow @@ -76,7 +76,7 @@ internal class RedisServerCoroutinesCommandsImpl(internal val override suspend fun clientTracking(args: TrackingArgs): String? = ops.clientTracking(args).awaitFirstOrNull() - override suspend fun clientTrackinginfo(): DynamicAggregateData? = ops.clientTrackinginfo().awaitFirstOrNull() + override suspend fun clientTrackinginfo(): TrackingInfo? = ops.clientTrackinginfo().awaitFirstOrNull() override suspend fun clientUnblock(id: Long, type: UnblockType): Long? = ops.clientUnblock(id, type).awaitFirstOrNull() diff --git a/src/main/templates/io/lettuce/core/api/RedisServerCommands.java b/src/main/templates/io/lettuce/core/api/RedisServerCommands.java index e3a4c699c7..486443173a 100644 --- a/src/main/templates/io/lettuce/core/api/RedisServerCommands.java +++ b/src/main/templates/io/lettuce/core/api/RedisServerCommands.java @@ -29,6 +29,7 @@ import io.lettuce.core.ShutdownArgs; import io.lettuce.core.TrackingArgs; import io.lettuce.core.UnblockType; +import io.lettuce.core.TrackingInfo; import io.lettuce.core.protocol.CommandType; /** @@ -178,12 +179,10 @@ public interface RedisServerCommands { /** * Returns information about the current client connection's use of the server assisted client side caching feature. * - * @return {@link DynamicAggregateData}, for more information check the documentation - * @see io.lettuce.core.api.parsers.tracking.TrackingInfoParser - * @see io.lettuce.core.api.parsers.tracking.TrackingInfo - * @since 7.0 + * @return {@link TrackingInfo}, for more information check the documentation + * @since 6.5 */ - DynamicAggregateData clientTrackinginfo(); + TrackingInfo clientTrackinginfo(); /** * Unblock the specified blocked client. diff --git a/src/test/java/io/lettuce/core/commands/ServerCommandIntegrationTests.java b/src/test/java/io/lettuce/core/commands/ServerCommandIntegrationTests.java index feb93a43c2..3fed145c32 100644 --- a/src/test/java/io/lettuce/core/commands/ServerCommandIntegrationTests.java +++ b/src/test/java/io/lettuce/core/commands/ServerCommandIntegrationTests.java @@ -43,17 +43,12 @@ import io.lettuce.core.api.StatefulRedisConnection; import io.lettuce.core.api.push.PushMessage; import io.lettuce.core.api.sync.RedisCommands; -import io.lettuce.core.api.parsers.tracking.TrackingInfo; -import io.lettuce.core.api.parsers.tracking.TrackingInfoParser; -import io.lettuce.core.cluster.ClusterReadOnlyCommands; import io.lettuce.core.codec.StringCodec; import io.lettuce.core.models.command.CommandDetail; import io.lettuce.core.models.command.CommandDetailParser; import io.lettuce.core.models.role.RedisInstance; import io.lettuce.core.models.role.RoleParser; -import io.lettuce.core.output.data.DynamicAggregateData; import io.lettuce.core.protocol.CommandType; -import io.lettuce.core.protocol.ProtocolKeyword; import io.lettuce.test.LettuceExtension; import io.lettuce.test.Wait; import io.lettuce.test.condition.EnabledOnCommand; @@ -127,9 +122,7 @@ void clientCaching() { @Test void clientTrackinginfoDefaults() { - DynamicAggregateData rawTrackingInfo = redis.clientTrackinginfo(); - - TrackingInfo info = TrackingInfoParser.parse(rawTrackingInfo); + TrackingInfo info = redis.clientTrackinginfo(); assertThat(info.getFlags()).contains(TrackingInfo.TrackingFlag.OFF); assertThat(info.getRedirect()).isEqualTo(-1L); @@ -140,9 +133,7 @@ void clientTrackinginfoDefaults() { void clientTrackinginfo() { try { redis.clientTracking(TrackingArgs.Builder.enabled(true).bcast().prefixes("usr:", "grp:")); - DynamicAggregateData rawTrackingInfo = redis.clientTrackinginfo(); - - TrackingInfo info = TrackingInfoParser.parse(rawTrackingInfo); + TrackingInfo info = redis.clientTrackinginfo(); assertThat(info.getFlags()).contains(TrackingInfo.TrackingFlag.ON); assertThat(info.getFlags()).contains(TrackingInfo.TrackingFlag.BCAST); diff --git a/src/test/java/io/lettuce/core/output/TrackingInfoParserTest.java b/src/test/java/io/lettuce/core/output/TrackingInfoParserTest.java index ede4f6394d..dd5aa929e2 100644 --- a/src/test/java/io/lettuce/core/output/TrackingInfoParserTest.java +++ b/src/test/java/io/lettuce/core/output/TrackingInfoParserTest.java @@ -1,11 +1,26 @@ +/* + * Copyright 2024, Redis Ltd. and Contributors + * All rights reserved. + * + * Licensed under the MIT License. + * + * This file contains contributions from third-party contributors + * licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package io.lettuce.core.output; -import io.lettuce.core.api.parsers.tracking.TrackingInfo; -import io.lettuce.core.api.parsers.tracking.TrackingInfoParser; -import io.lettuce.core.output.ArrayAggregateData; -import io.lettuce.core.output.DynamicAggregateData; -import io.lettuce.core.output.MapAggregateData; -import io.lettuce.core.output.SetAggregateData; +import io.lettuce.core.TrackingInfo; import io.lettuce.core.protocol.CommandKeyword; import org.junit.jupiter.api.Test; @@ -16,13 +31,13 @@ class TrackingInfoParserTest { @Test void parseResp3() { - DynamicAggregateData flags = new SetAggregateData(2); + ComplexData flags = new SetComplexData(2); flags.store(TrackingInfo.TrackingFlag.ON.toString()); flags.store(TrackingInfo.TrackingFlag.OPTIN.toString()); - DynamicAggregateData prefixes = new ArrayAggregateData(0); + ComplexData prefixes = new ArrayComplexData(0); - DynamicAggregateData input = new MapAggregateData(3); + ComplexData input = new MapComplexData(3); input.store(CommandKeyword.FLAGS.toString().toLowerCase()); input.storeObject(flags); input.store(CommandKeyword.REDIRECT.toString().toLowerCase()); @@ -30,7 +45,7 @@ void parseResp3() { input.store(CommandKeyword.PREFIXES.toString().toLowerCase()); input.storeObject(prefixes); - TrackingInfo info = TrackingInfoParser.parse(input); + TrackingInfo info = TrackingInfoParser.INSTANCE.parse(input); assertThat(info.getFlags()).contains(TrackingInfo.TrackingFlag.ON, TrackingInfo.TrackingFlag.OPTIN); assertThat(info.getRedirect()).isEqualTo(0L); @@ -39,41 +54,41 @@ void parseResp3() { @Test void parseFailEmpty() { - DynamicAggregateData input = new MapAggregateData(0); + ComplexData input = new MapComplexData(0); Exception exception = assertThrows(IllegalArgumentException.class, () -> { - TrackingInfo info = TrackingInfoParser.parse(input); + TrackingInfo info = TrackingInfoParser.INSTANCE.parse(input); }); } @Test void parseFailNumberOfElements() { - DynamicAggregateData flags = new SetAggregateData(2); + ComplexData flags = new SetComplexData(2); flags.store(TrackingInfo.TrackingFlag.ON.toString()); flags.store(TrackingInfo.TrackingFlag.OPTIN.toString()); - DynamicAggregateData prefixes = new ArrayAggregateData(0); + ComplexData prefixes = new ArrayComplexData(0); - DynamicAggregateData input = new MapAggregateData(3); + ComplexData input = new MapComplexData(3); input.store(CommandKeyword.FLAGS.toString().toLowerCase()); input.storeObject(flags); input.store(CommandKeyword.REDIRECT.toString().toLowerCase()); input.store(-1L); Exception exception = assertThrows(IllegalArgumentException.class, () -> { - TrackingInfo info = TrackingInfoParser.parse(input); + TrackingInfo info = TrackingInfoParser.INSTANCE.parse(input); }); } @Test void parseResp2Compatibility() { - DynamicAggregateData flags = new ArrayAggregateData(2); + ComplexData flags = new ArrayComplexData(2); flags.store(TrackingInfo.TrackingFlag.ON.toString()); flags.store(TrackingInfo.TrackingFlag.OPTIN.toString()); - DynamicAggregateData prefixes = new ArrayAggregateData(0); + ComplexData prefixes = new ArrayComplexData(0); - DynamicAggregateData input = new ArrayAggregateData(3); + ComplexData input = new ArrayComplexData(3); input.store(CommandKeyword.FLAGS.toString().toLowerCase()); input.storeObject(flags); input.store(CommandKeyword.REDIRECT.toString().toLowerCase()); @@ -81,7 +96,7 @@ void parseResp2Compatibility() { input.store(CommandKeyword.PREFIXES.toString().toLowerCase()); input.storeObject(prefixes); - TrackingInfo info = TrackingInfoParser.parse(input); + TrackingInfo info = TrackingInfoParser.INSTANCE.parse(input); assertThat(info.getFlags()).contains(TrackingInfo.TrackingFlag.ON, TrackingInfo.TrackingFlag.OPTIN); assertThat(info.getRedirect()).isEqualTo(0L);