diff --git a/java/README.md b/java/README.md index 5d0077c3da..fc2d560e85 100644 --- a/java/README.md +++ b/java/README.md @@ -95,9 +95,9 @@ Other useful gradle developer commands: ### Standalone Redis: ```java -import glide.api.RedisClient; +import glide.api.GlideClient; -RedisClient client = RedisClient.CreateClient().get(); +GlideClient client = GlideClient.CreateClient().get(); CompletableFuture setResponse = client.set("key", "foobar"); assert setResponse.get() == "OK" : "Failed on client.set("key", "foobar") request"; diff --git a/java/benchmarks/src/main/java/glide/benchmarks/clients/glide/GlideAsyncClient.java b/java/benchmarks/src/main/java/glide/benchmarks/clients/glide/GlideAsyncClient.java index 3cb1361ee1..7bd05ffaec 100644 --- a/java/benchmarks/src/main/java/glide/benchmarks/clients/glide/GlideAsyncClient.java +++ b/java/benchmarks/src/main/java/glide/benchmarks/clients/glide/GlideAsyncClient.java @@ -4,11 +4,11 @@ import static java.util.concurrent.TimeUnit.SECONDS; import glide.api.BaseClient; -import glide.api.RedisClient; -import glide.api.RedisClusterClient; +import glide.api.GlideClient; +import glide.api.GlideClusterClient; +import glide.api.models.configuration.GlideClientConfiguration; +import glide.api.models.configuration.GlideClusterClientConfiguration; import glide.api.models.configuration.NodeAddress; -import glide.api.models.configuration.RedisClientConfiguration; -import glide.api.models.configuration.RedisClusterClientConfiguration; import glide.benchmarks.clients.AsyncClient; import glide.benchmarks.utils.ConnectionSettings; import java.util.concurrent.CompletableFuture; @@ -23,8 +23,8 @@ public class GlideAsyncClient implements AsyncClient { public void connectToRedis(ConnectionSettings connectionSettings) { if (connectionSettings.clusterMode) { - RedisClusterClientConfiguration config = - RedisClusterClientConfiguration.builder() + GlideClusterClientConfiguration config = + GlideClusterClientConfiguration.builder() .address( NodeAddress.builder() .host(connectionSettings.host) @@ -33,14 +33,14 @@ public void connectToRedis(ConnectionSettings connectionSettings) { .useTLS(connectionSettings.useSsl) .build(); try { - redisClient = RedisClusterClient.CreateClient(config).get(10, SECONDS); + redisClient = GlideClusterClient.CreateClient(config).get(10, SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException(e); } } else { - RedisClientConfiguration config = - RedisClientConfiguration.builder() + GlideClientConfiguration config = + GlideClientConfiguration.builder() .address( NodeAddress.builder() .host(connectionSettings.host) @@ -50,7 +50,7 @@ public void connectToRedis(ConnectionSettings connectionSettings) { .build(); try { - redisClient = RedisClient.CreateClient(config).get(10, SECONDS); + redisClient = GlideClient.CreateClient(config).get(10, SECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { throw new RuntimeException(e); } diff --git a/java/client/src/main/java/glide/api/BaseClient.java b/java/client/src/main/java/glide/api/BaseClient.java index c4f714dacc..21d6d324e1 100644 --- a/java/client/src/main/java/glide/api/BaseClient.java +++ b/java/client/src/main/java/glide/api/BaseClient.java @@ -3,15 +3,10 @@ import static glide.api.models.GlideString.gs; import static glide.api.models.commands.SortBaseOptions.STORE_COMMAND_STRING; -import static glide.api.models.commands.SortOptions.STORE_COMMAND_STRING; -import static glide.api.models.commands.bitmap.BitFieldOptions.BitFieldReadOnlySubCommands; -import static glide.api.models.commands.bitmap.BitFieldOptions.BitFieldSubCommands; import static glide.api.models.commands.bitmap.BitFieldOptions.createBitFieldArgs; import static glide.ffi.resolvers.SocketListenerResolver.getSocket; import static glide.utils.ArrayTransformUtils.castArray; -import static glide.utils.ArrayTransformUtils.castArrayofArrays; import static glide.utils.ArrayTransformUtils.castMapOf2DArray; -import static glide.utils.ArrayTransformUtils.castMapOfArrays; import static glide.utils.ArrayTransformUtils.concatenateArrays; import static glide.utils.ArrayTransformUtils.convertMapToKeyValueStringArray; import static glide.utils.ArrayTransformUtils.convertMapToValueKeyStringArray; @@ -116,57 +111,6 @@ import static redis_request.RedisRequestOuterClass.RequestType.SRandMember; import static redis_request.RedisRequestOuterClass.RequestType.SRem; import static redis_request.RedisRequestOuterClass.RequestType.SUnion; -import static redis_request.RedisRequestOuterClass.RequestType.SUnionStore; -import static redis_request.RedisRequestOuterClass.RequestType.Set; -import static redis_request.RedisRequestOuterClass.RequestType.SetBit; -import static redis_request.RedisRequestOuterClass.RequestType.SetRange; -import static redis_request.RedisRequestOuterClass.RequestType.Sort; -import static redis_request.RedisRequestOuterClass.RequestType.SortReadOnly; -import static redis_request.RedisRequestOuterClass.RequestType.Strlen; -import static redis_request.RedisRequestOuterClass.RequestType.TTL; -import static redis_request.RedisRequestOuterClass.RequestType.Touch; -import static redis_request.RedisRequestOuterClass.RequestType.Type; -import static redis_request.RedisRequestOuterClass.RequestType.Unlink; -import static redis_request.RedisRequestOuterClass.RequestType.Watch; -import static redis_request.RedisRequestOuterClass.RequestType.XAck; -import static redis_request.RedisRequestOuterClass.RequestType.XAdd; -import static redis_request.RedisRequestOuterClass.RequestType.XDel; -import static redis_request.RedisRequestOuterClass.RequestType.XGroupCreate; -import static redis_request.RedisRequestOuterClass.RequestType.XGroupCreateConsumer; -import static redis_request.RedisRequestOuterClass.RequestType.XGroupDelConsumer; -import static redis_request.RedisRequestOuterClass.RequestType.XGroupDestroy; -import static redis_request.RedisRequestOuterClass.RequestType.XLen; -import static redis_request.RedisRequestOuterClass.RequestType.XRange; -import static redis_request.RedisRequestOuterClass.RequestType.XRead; -import static redis_request.RedisRequestOuterClass.RequestType.XReadGroup; -import static redis_request.RedisRequestOuterClass.RequestType.XRevRange; -import static redis_request.RedisRequestOuterClass.RequestType.XTrim; -import static redis_request.RedisRequestOuterClass.RequestType.ZAdd; -import static redis_request.RedisRequestOuterClass.RequestType.ZCard; -import static redis_request.RedisRequestOuterClass.RequestType.ZCount; -import static redis_request.RedisRequestOuterClass.RequestType.ZDiff; -import static redis_request.RedisRequestOuterClass.RequestType.ZDiffStore; -import static redis_request.RedisRequestOuterClass.RequestType.ZIncrBy; -import static redis_request.RedisRequestOuterClass.RequestType.ZInter; -import static redis_request.RedisRequestOuterClass.RequestType.ZInterCard; -import static redis_request.RedisRequestOuterClass.RequestType.ZInterStore; -import static redis_request.RedisRequestOuterClass.RequestType.ZLexCount; -import static redis_request.RedisRequestOuterClass.RequestType.ZMPop; -import static redis_request.RedisRequestOuterClass.RequestType.ZMScore; -import static redis_request.RedisRequestOuterClass.RequestType.ZPopMax; -import static redis_request.RedisRequestOuterClass.RequestType.ZPopMin; -import static redis_request.RedisRequestOuterClass.RequestType.ZRandMember; -import static redis_request.RedisRequestOuterClass.RequestType.ZRange; -import static redis_request.RedisRequestOuterClass.RequestType.ZRangeStore; -import static redis_request.RedisRequestOuterClass.RequestType.ZRank; -import static redis_request.RedisRequestOuterClass.RequestType.ZRem; -import static redis_request.RedisRequestOuterClass.RequestType.ZRemRangeByLex; -import static redis_request.RedisRequestOuterClass.RequestType.ZRemRangeByRank; -import static redis_request.RedisRequestOuterClass.RequestType.ZRemRangeByScore; -import static redis_request.RedisRequestOuterClass.RequestType.ZRevRank; -import static redis_request.RedisRequestOuterClass.RequestType.ZScore; -import static redis_request.RedisRequestOuterClass.RequestType.ZUnion; -import static redis_request.RedisRequestOuterClass.RequestType.ZUnionStore; import glide.api.commands.BitmapBaseCommands; import glide.api.commands.GenericBaseCommands; @@ -200,6 +144,8 @@ import glide.api.models.commands.WeightAggregateOptions.KeyArray; import glide.api.models.commands.WeightAggregateOptions.KeysOrWeightedKeys; import glide.api.models.commands.ZAddOptions; +import glide.api.models.commands.bitmap.BitFieldOptions.BitFieldReadOnlySubCommands; +import glide.api.models.commands.bitmap.BitFieldOptions.BitFieldSubCommands; import glide.api.models.commands.bitmap.BitmapIndexType; import glide.api.models.commands.bitmap.BitwiseOperation; import glide.api.models.commands.geospatial.GeoAddOptions; @@ -222,6 +168,8 @@ import glide.managers.BaseCommandResponseResolver; import glide.managers.CommandManager; import glide.managers.ConnectionManager; +import glide.models.protobuf.response.ResponseOuterClass.ConstantResponse; +import glide.models.protobuf.response.ResponseOuterClass.Response; import java.util.EnumSet; import java.util.HashMap; import java.util.List; @@ -234,8 +182,6 @@ import lombok.AllArgsConstructor; import lombok.NonNull; import org.apache.commons.lang3.ArrayUtils; -import response.ResponseOuterClass.ConstantResponse; -import response.ResponseOuterClass.Response; /** Base Client class for Redis */ @AllArgsConstructor @@ -266,7 +212,7 @@ public abstract class BaseClient * @param config Redis client Configuration. * @param constructor Redis client constructor reference. * @param Client type. - * @return a Future to connect and return a RedisClient. + * @return a Future to connect and return a GlideClient. */ protected static CompletableFuture CreateClient( BaseClientConfiguration config, @@ -297,8 +243,8 @@ protected static CompletableFuture CreateClient( * Closes this resource, relinquishing any underlying resources. This method is invoked * automatically on objects managed by the try-with-resources statement. * - * @see AutoCloseable::close() + * @see AutoCloseable::close() */ @Override public void close() throws ExecutionException { @@ -2530,7 +2476,8 @@ public CompletableFuture> sunion(@NonNull String[] keys) { return commandManager.submitNewCommand(SUnion, keys, this::handleSetResponse); } - // Hack: convert all `byte[]` -> `GlideString`. Better doing it here in the Java realm + // Hack: convert all `byte[]` -> `GlideString`. Better doing it here in the Java + // realm // rather than doing it in the Rust code using JNI calls (performance) private Object convertByteArrayToGlideString(Object o) { if (o == null) return o; diff --git a/java/client/src/main/java/glide/api/RedisClient.java b/java/client/src/main/java/glide/api/GlideClient.java similarity index 96% rename from java/client/src/main/java/glide/api/RedisClient.java rename to java/client/src/main/java/glide/api/GlideClient.java index 4264594dc0..2b7014d781 100644 --- a/java/client/src/main/java/glide/api/RedisClient.java +++ b/java/client/src/main/java/glide/api/GlideClient.java @@ -3,11 +3,9 @@ import static glide.api.models.GlideString.gs; import static glide.api.models.commands.SortBaseOptions.STORE_COMMAND_STRING; -import static glide.api.models.commands.SortOptions.STORE_COMMAND_STRING; import static glide.api.models.commands.function.FunctionListOptions.LIBRARY_NAME_REDIS_API; import static glide.api.models.commands.function.FunctionListOptions.WITH_CODE_REDIS_API; import static glide.api.models.commands.function.FunctionLoadOptions.REPLACE; -import static glide.utils.ArrayTransformUtils.castArray; import static glide.utils.ArrayTransformUtils.concatenateArrays; import static glide.utils.ArrayTransformUtils.convertMapToKeyValueStringArray; import static redis_request.RedisRequestOuterClass.RequestType.ClientGetName; @@ -53,7 +51,7 @@ import glide.api.models.commands.InfoOptions; import glide.api.models.commands.SortOptions; import glide.api.models.commands.function.FunctionRestorePolicy; -import glide.api.models.configuration.RedisClientConfiguration; +import glide.api.models.configuration.GlideClientConfiguration; import glide.managers.CommandManager; import glide.managers.ConnectionManager; import java.util.Arrays; @@ -66,14 +64,14 @@ * Async (non-blocking) client for Redis in Standalone mode. Use {@link #CreateClient} to request a * client to Redis. */ -public class RedisClient extends BaseClient +public class GlideClient extends BaseClient implements GenericCommands, ServerManagementCommands, ConnectionManagementCommands, ScriptingAndFunctionsCommands, TransactionsCommands { - protected RedisClient(ConnectionManager connectionManager, CommandManager commandManager) { + protected GlideClient(ConnectionManager connectionManager, CommandManager commandManager) { super(connectionManager, commandManager); } @@ -81,11 +79,11 @@ protected RedisClient(ConnectionManager connectionManager, CommandManager comman * Async request for an async (non-blocking) Redis client in Standalone mode. * * @param config Redis client Configuration - * @return A Future to connect and return a RedisClient + * @return A Future to connect and return a GlideClient */ - public static CompletableFuture CreateClient( - @NonNull RedisClientConfiguration config) { - return CreateClient(config, RedisClient::new); + public static CompletableFuture CreateClient( + @NonNull GlideClientConfiguration config) { + return CreateClient(config, GlideClient::new); } @Override diff --git a/java/client/src/main/java/glide/api/RedisClusterClient.java b/java/client/src/main/java/glide/api/GlideClusterClient.java similarity index 98% rename from java/client/src/main/java/glide/api/RedisClusterClient.java rename to java/client/src/main/java/glide/api/GlideClusterClient.java index e6ff24b9b5..20d53b9a26 100644 --- a/java/client/src/main/java/glide/api/RedisClusterClient.java +++ b/java/client/src/main/java/glide/api/GlideClusterClient.java @@ -54,7 +54,7 @@ import glide.api.models.commands.InfoOptions; import glide.api.models.commands.SortClusterOptions; import glide.api.models.commands.function.FunctionRestorePolicy; -import glide.api.models.configuration.RedisClusterClientConfiguration; +import glide.api.models.configuration.GlideClusterClientConfiguration; import glide.api.models.configuration.RequestRoutingConfiguration.Route; import glide.api.models.configuration.RequestRoutingConfiguration.SingleNodeRoute; import glide.managers.CommandManager; @@ -72,14 +72,14 @@ * Async (non-blocking) client for Redis in Cluster mode. Use {@link #CreateClient} to request a * client to Redis. */ -public class RedisClusterClient extends BaseClient +public class GlideClusterClient extends BaseClient implements ConnectionManagementClusterCommands, GenericClusterCommands, ServerManagementClusterCommands, ScriptingAndFunctionsClusterCommands, TransactionsClusterCommands { - protected RedisClusterClient(ConnectionManager connectionManager, CommandManager commandManager) { + protected GlideClusterClient(ConnectionManager connectionManager, CommandManager commandManager) { super(connectionManager, commandManager); } @@ -87,11 +87,11 @@ protected RedisClusterClient(ConnectionManager connectionManager, CommandManager * Async request for an async (non-blocking) Redis client in Cluster mode. * * @param config Redis cluster client Configuration - * @return A Future to connect and return a RedisClusterClient + * @return A Future to connect and return a GlideClusterClient */ - public static CompletableFuture CreateClient( - @NonNull RedisClusterClientConfiguration config) { - return CreateClient(config, RedisClusterClient::new); + public static CompletableFuture CreateClient( + @NonNull GlideClusterClientConfiguration config) { + return CreateClient(config, GlideClusterClient::new); } @Override diff --git a/java/client/src/main/java/glide/api/models/commands/FlushMode.java b/java/client/src/main/java/glide/api/models/commands/FlushMode.java index 9ba5c2938c..1643a97271 100644 --- a/java/client/src/main/java/glide/api/models/commands/FlushMode.java +++ b/java/client/src/main/java/glide/api/models/commands/FlushMode.java @@ -1,8 +1,8 @@ /** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */ package glide.api.models.commands; -import glide.api.RedisClient; -import glide.api.RedisClusterClient; +import glide.api.GlideClient; +import glide.api.GlideClusterClient; import glide.api.models.configuration.RequestRoutingConfiguration.Route; import glide.api.models.configuration.RequestRoutingConfiguration.SingleNodeRoute; @@ -11,15 +11,15 @@ * Defines flushing mode for: * *
    - *
  • FLUSHALL command implemented by {@link RedisClient#flushall(FlushMode)}, - * {@link RedisClusterClient#flushall(FlushMode)}, and {@link - * RedisClusterClient#flushall(FlushMode, SingleNodeRoute)}. - *
  • FLUSHDB command implemented by {@link RedisClient#flushdb(FlushMode)}, {@link - * RedisClusterClient#flushdb(FlushMode)}, and {@link RedisClusterClient#flushdb(FlushMode, + *
  • FLUSHALL command implemented by {@link GlideClient#flushall(FlushMode)}, + * {@link GlideClusterClient#flushall(FlushMode)}, and {@link + * GlideClusterClient#flushall(FlushMode, SingleNodeRoute)}. + *
  • FLUSHDB command implemented by {@link GlideClient#flushdb(FlushMode)}, {@link + * GlideClusterClient#flushdb(FlushMode)}, and {@link GlideClusterClient#flushdb(FlushMode, * SingleNodeRoute)}. *
  • FUNCTION FLUSH command implemented by {@link - * RedisClient#functionFlush(FlushMode)}, {@link RedisClusterClient#functionFlush(FlushMode)}, - * and {@link RedisClusterClient#functionFlush(FlushMode, Route)}. + * GlideClient#functionFlush(FlushMode)}, {@link GlideClusterClient#functionFlush(FlushMode)}, + * and {@link GlideClusterClient#functionFlush(FlushMode, Route)}. *
* * @see flushall, null); callbackDispatcher.completeRequest(null); var exception = assertThrows(ExecutionException.class, future::get); - // a IOException thrown from CallbackDispatcher::completeRequest and then wrapped + // a IOException thrown from CallbackDispatcher::completeRequest and then + // wrapped // by a RuntimeException and rethrown by CommandManager::exceptionHandler assertTrue(exception.getCause() instanceof RuntimeException); assertTrue(exception.getCause().getCause() instanceof IOException); @@ -150,7 +150,8 @@ public void connection_manager_rethrows_non_RedisException_too() { callbackDispatcher.completeRequest(null); var exception = assertThrows(ExecutionException.class, future::get); - // a IOException thrown from CallbackDispatcher::completeRequest and then wrapped + // a IOException thrown from CallbackDispatcher::completeRequest and then + // wrapped // by a RuntimeException and rethrown by ConnectionManager::exceptionHandler assertTrue(exception.getCause() instanceof RuntimeException); assertTrue(exception.getCause().getCause() instanceof IOException); @@ -161,7 +162,8 @@ public void connection_manager_rethrows_non_RedisException_too() { @Test @SneakyThrows public void close_connection_on_response_with_closing_error() { - // CallbackDispatcher throws ClosingException which causes ConnectionManager and CommandManager + // CallbackDispatcher throws ClosingException which causes ConnectionManager and + // CommandManager // to close the channel var callbackDispatcher = new CallbackDispatcher(); var channelHandler = new TestChannelHandler(callbackDispatcher); @@ -179,10 +181,12 @@ public void close_connection_on_response_with_closing_error() { // check the channel assertTrue(channelHandler.wasClosed); - // all pending requests should be aborted once ClosingError received in callback dispatcher + // all pending requests should be aborted once ClosingError received in callback + // dispatcher exception = assertThrows(ExecutionException.class, future2::get); // or could be cancelled in CallbackDispatcher::shutdownGracefully - // cancellation overwrites previous status, so we may not get ClosingException due to a race + // cancellation overwrites previous status, so we may not get ClosingException + // due to a race assertTrue( exception.getCause() instanceof ClosingException || exception.getCause() instanceof CancellationException); @@ -249,10 +253,12 @@ public void close_connection_on_response_without_error_but_with_incorrect_callba // check the channel assertTrue(channelHandler.wasClosed); - // all pending requests should be aborted once ClosingError received in callback dispatcher + // all pending requests should be aborted once ClosingError received in callback + // dispatcher exception = assertThrows(ExecutionException.class, future2::get); // or could be cancelled in CallbackDispatcher::shutdownGracefully - // cancellation overwrites previous status, so we may not get ClosingException due to a race + // cancellation overwrites previous status, so we may not get ClosingException + // due to a race assertTrue( exception.getCause() instanceof ClosingException || exception.getCause() instanceof CancellationException); @@ -275,8 +281,8 @@ public void response_resolver_does_not_expect_errors() { } /** Create a config which causes connection failure. */ - private static RedisClientConfiguration createDummyConfig() { - return RedisClientConfiguration.builder().build(); + private static GlideClientConfiguration createDummyConfig() { + return GlideClientConfiguration.builder().build(); } /** Test ChannelHandler extension which allows to validate whether the channel was closed. */ diff --git a/java/client/src/test/java/glide/api/RedisClientCreateTest.java b/java/client/src/test/java/glide/api/GlideClientCreateTest.java similarity index 81% rename from java/client/src/test/java/glide/api/RedisClientCreateTest.java rename to java/client/src/test/java/glide/api/GlideClientCreateTest.java index ab6f3e9651..c6aa3ee20e 100644 --- a/java/client/src/test/java/glide/api/RedisClientCreateTest.java +++ b/java/client/src/test/java/glide/api/GlideClientCreateTest.java @@ -1,10 +1,11 @@ /** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */ package glide.api; +import static glide.api.BaseClient.CreateClient; import static glide.api.BaseClient.buildChannelHandler; -import static glide.api.RedisClient.CreateClient; -import static glide.api.RedisClient.buildCommandManager; -import static glide.api.RedisClient.buildConnectionManager; +import static glide.api.BaseClient.buildCommandManager; +import static glide.api.BaseClient.buildConnectionManager; +import static glide.api.GlideClient.CreateClient; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; @@ -13,7 +14,7 @@ import static org.mockito.Mockito.mockStatic; import static org.mockito.Mockito.when; -import glide.api.models.configuration.RedisClientConfiguration; +import glide.api.models.configuration.GlideClientConfiguration; import glide.api.models.exceptions.ClosingException; import glide.connectors.handlers.ChannelHandler; import glide.connectors.resources.ThreadPoolResource; @@ -28,7 +29,7 @@ import org.junit.jupiter.api.Test; import org.mockito.MockedStatic; -public class RedisClientCreateTest { +public class GlideClientCreateTest { private MockedStatic mockedClient; private ChannelHandler channelHandler; @@ -64,17 +65,17 @@ public void teardown() { @Test @SneakyThrows - public void createClient_with_default_config_successfully_returns_RedisClient() { + public void createClient_with_default_config_successfully_returns_GlideClient() { // setup CompletableFuture connectToRedisFuture = new CompletableFuture<>(); connectToRedisFuture.complete(null); - RedisClientConfiguration config = RedisClientConfiguration.builder().build(); + GlideClientConfiguration config = GlideClientConfiguration.builder().build(); when(connectionManager.connectToRedis(eq(config))).thenReturn(connectToRedisFuture); // exercise - CompletableFuture result = CreateClient(config); - RedisClient client = result.get(); + CompletableFuture result = CreateClient(config); + GlideClient client = result.get(); // verify assertEquals(connectionManager, client.connectionManager); @@ -83,18 +84,18 @@ public void createClient_with_default_config_successfully_returns_RedisClient() @Test @SneakyThrows - public void createClient_with_custom_config_successfully_returns_RedisClient() { + public void createClient_with_custom_config_successfully_returns_GlideClient() { // setup CompletableFuture connectToRedisFuture = new CompletableFuture<>(); connectToRedisFuture.complete(null); - RedisClientConfiguration config = - RedisClientConfiguration.builder().threadPoolResource(threadPoolResource).build(); + GlideClientConfiguration config = + GlideClientConfiguration.builder().threadPoolResource(threadPoolResource).build(); when(connectionManager.connectToRedis(eq(config))).thenReturn(connectToRedisFuture); // exercise - CompletableFuture result = CreateClient(config); - RedisClient client = result.get(); + CompletableFuture result = CreateClient(config); + GlideClient client = result.get(); // verify assertEquals(connectionManager, client.connectionManager); @@ -108,13 +109,13 @@ public void createClient_error_on_connection_throws_ExecutionException() { CompletableFuture connectToRedisFuture = new CompletableFuture<>(); ClosingException exception = new ClosingException("disconnected"); connectToRedisFuture.completeExceptionally(exception); - RedisClientConfiguration config = - RedisClientConfiguration.builder().threadPoolResource(threadPoolResource).build(); + GlideClientConfiguration config = + GlideClientConfiguration.builder().threadPoolResource(threadPoolResource).build(); when(connectionManager.connectToRedis(eq(config))).thenReturn(connectToRedisFuture); // exercise - CompletableFuture result = CreateClient(config); + CompletableFuture result = CreateClient(config); ExecutionException executionException = assertThrows(ExecutionException.class, result::get); diff --git a/java/client/src/test/java/glide/api/RedisClientTest.java b/java/client/src/test/java/glide/api/GlideClientTest.java similarity index 99% rename from java/client/src/test/java/glide/api/RedisClientTest.java rename to java/client/src/test/java/glide/api/GlideClientTest.java index 3b785f9a90..e8ed527431 100644 --- a/java/client/src/test/java/glide/api/RedisClientTest.java +++ b/java/client/src/test/java/glide/api/GlideClientTest.java @@ -315,12 +315,12 @@ import org.junit.jupiter.params.provider.MethodSource; import redis_request.RedisRequestOuterClass.RequestType; -public class RedisClientTest { +public class GliderClientTest { // bypass import conflict between Set (collection) and Set (enum variant) private static final RequestType pSet = RequestType.Set; - RedisClient service; + GliderClient service; ConnectionManager connectionManager; @@ -330,7 +330,7 @@ public class RedisClientTest { public void setUp() { connectionManager = mock(ConnectionManager.class); commandManager = mock(CommandManager.class); - service = new RedisClient(connectionManager, commandManager); + service = new GliderClient(connectionManager, commandManager); } @SneakyThrows diff --git a/java/client/src/test/java/glide/api/RedisClusterClientTest.java b/java/client/src/test/java/glide/api/GlideClusterClientTest.java similarity index 99% rename from java/client/src/test/java/glide/api/RedisClusterClientTest.java rename to java/client/src/test/java/glide/api/GlideClusterClientTest.java index ffdbf2c3b9..466a61e17a 100644 --- a/java/client/src/test/java/glide/api/RedisClusterClientTest.java +++ b/java/client/src/test/java/glide/api/GlideClusterClientTest.java @@ -6,10 +6,10 @@ import static glide.api.models.GlideString.gs; import static glide.api.models.commands.FlushMode.ASYNC; import static glide.api.models.commands.FlushMode.SYNC; +import static glide.api.models.commands.SortBaseOptions.ALPHA_COMMAND_STRING; +import static glide.api.models.commands.SortBaseOptions.LIMIT_COMMAND_STRING; import static glide.api.models.commands.SortBaseOptions.OrderBy.DESC; -import static glide.api.models.commands.SortOptions.ALPHA_COMMAND_STRING; -import static glide.api.models.commands.SortOptions.LIMIT_COMMAND_STRING; -import static glide.api.models.commands.SortOptions.STORE_COMMAND_STRING; +import static glide.api.models.commands.SortBaseOptions.STORE_COMMAND_STRING; import static glide.api.models.commands.function.FunctionListOptions.LIBRARY_NAME_REDIS_API; import static glide.api.models.commands.function.FunctionListOptions.WITH_CODE_REDIS_API; import static glide.api.models.configuration.RequestRoutingConfiguration.SimpleMultiNodeRoute.ALL_NODES; @@ -67,6 +67,8 @@ import glide.managers.CommandManager; import glide.managers.ConnectionManager; import glide.managers.RedisExceptionCheckedFunction; +import glide.models.protobuf.redis_request.RedisRequestOuterClass.RedisRequest; +import glide.models.protobuf.response.ResponseOuterClass.ConstantResponse; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; @@ -75,13 +77,10 @@ import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import redis_request.RedisRequestOuterClass.RedisRequest; -import response.ResponseOuterClass.ConstantResponse; -import response.ResponseOuterClass.Response; -public class RedisClusterClientTest { +public class GlideClusterClientTest { - RedisClusterClient service; + GlideClusterClient service; ConnectionManager connectionManager; @@ -93,7 +92,7 @@ public class RedisClusterClientTest { public void setUp() { connectionManager = mock(ConnectionManager.class); commandManager = mock(CommandManager.class); - service = new RedisClusterClient(connectionManager, commandManager); + service = new GlideClusterClient(connectionManager, commandManager); } @Test @@ -121,7 +120,8 @@ public void custom_command_returns_multi_value() { @Test @SneakyThrows - // test checks that even a map returned as a single value when single node route is used + // test checks that even a map returned as a single value when single node route + // is used public void custom_command_with_single_node_route_returns_single_value() { var commandManager = new TestCommandManager(null); @@ -157,7 +157,7 @@ public void custom_command_returns_single_value_on_constant_response() { } } - private static class TestClient extends RedisClusterClient { + private static class TestClient extends GlideClusterClient { private final Object object; @@ -678,7 +678,7 @@ public void configResetStat_with_route_returns_success() { assertEquals(OK, payload); } - // TODO copy/move tests from RedisClientTest which call super for coverage + // TODO copy/move tests from GlideClientTest which call super for coverage @SneakyThrows @Test public void configGet_returns_success() { @@ -703,7 +703,8 @@ public void configGet_returns_success() { @Test @SneakyThrows - // test checks that even a map returned as a single value when single node route is used + // test checks that even a map returned as a single value when single node route + // is used public void configGet_with_single_node_route_returns_single_value() { var commandManager = new TestCommandManager(null); diff --git a/java/client/src/test/java/glide/connection/ConnectionWithGlideMockTests.java b/java/client/src/test/java/glide/connection/ConnectionWithGlideMockTests.java index 27e00ef52b..40b007948c 100644 --- a/java/client/src/test/java/glide/connection/ConnectionWithGlideMockTests.java +++ b/java/client/src/test/java/glide/connection/ConnectionWithGlideMockTests.java @@ -8,15 +8,14 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import connection_request.ConnectionRequestOuterClass.ConnectionRequest; -import connection_request.ConnectionRequestOuterClass.NodeAddress; -import glide.api.RedisClient; +import glide.api.GlideClient; import glide.api.models.exceptions.ClosingException; import glide.connectors.handlers.CallbackDispatcher; import glide.connectors.handlers.ChannelHandler; import glide.connectors.resources.Platform; import glide.managers.CommandManager; import glide.managers.ConnectionManager; +import glide.models.protobuf.connection_request.ConnectionRequestOuterClass.ConnectionRequest; import glide.utils.RustCoreLibMockTestBase; import glide.utils.RustCoreMock; import java.util.concurrent.ExecutionException; @@ -28,7 +27,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import redis_request.RedisRequestOuterClass.RedisRequest; -import response.ResponseOuterClass.Response; public class ConnectionWithGlideMockTests extends RustCoreLibMockTestBase { @@ -64,7 +62,8 @@ public static void init() { @Test @SneakyThrows - // as of #710 https://github.com/aws/babushka/pull/710 - connection response is empty + // as of #710 https://github.com/aws/babushka/pull/710 - connection response is + // empty public void can_connect_with_empty_response() { RustCoreMock.updateGlideMock( new RustCoreMock.GlideMockProtobuf() { @@ -182,7 +181,7 @@ public void rethrow_error_if_UDS_channel_closed() { } } - private static class TestClient extends RedisClient { + private static class TestClient extends GlideClient { public TestClient(ChannelHandler channelHandler) { super(new ConnectionManager(channelHandler), new CommandManager(channelHandler)); diff --git a/java/client/src/test/java/glide/managers/ConnectionManagerTest.java b/java/client/src/test/java/glide/managers/ConnectionManagerTest.java index 792259799b..8b53048305 100644 --- a/java/client/src/test/java/glide/managers/ConnectionManagerTest.java +++ b/java/client/src/test/java/glide/managers/ConnectionManagerTest.java @@ -13,27 +13,26 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import connection_request.ConnectionRequestOuterClass; -import connection_request.ConnectionRequestOuterClass.AuthenticationInfo; -import connection_request.ConnectionRequestOuterClass.ConnectionRequest; -import connection_request.ConnectionRequestOuterClass.ConnectionRetryStrategy; -import connection_request.ConnectionRequestOuterClass.TlsMode; import glide.api.models.configuration.BackoffStrategy; +import glide.api.models.configuration.GlideClientConfiguration; +import glide.api.models.configuration.GlideClusterClientConfiguration; import glide.api.models.configuration.NodeAddress; import glide.api.models.configuration.ReadFrom; -import glide.api.models.configuration.RedisClientConfiguration; -import glide.api.models.configuration.RedisClusterClientConfiguration; import glide.api.models.configuration.RedisCredentials; import glide.api.models.exceptions.ClosingException; import glide.connectors.handlers.ChannelHandler; +import glide.models.protobuf.connection_request.ConnectionRequestOuterClass; +import glide.models.protobuf.connection_request.ConnectionRequestOuterClass.AuthenticationInfo; +import glide.models.protobuf.connection_request.ConnectionRequestOuterClass.ConnectionRequest; +import glide.models.protobuf.connection_request.ConnectionRequestOuterClass.ConnectionRetryStrategy; +import glide.models.protobuf.connection_request.ConnectionRequestOuterClass.TlsMode; +import glide.models.protobuf.response.ResponseOuterClass.ConstantResponse; import io.netty.channel.ChannelFuture; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import response.ResponseOuterClass.ConstantResponse; -import response.ResponseOuterClass.Response; public class ConnectionManagerTest { ConnectionManager connectionManager; @@ -69,7 +68,7 @@ public void setUp() { @Test public void connection_request_protobuf_generation_default_standalone_configuration() { // setup - RedisClientConfiguration redisClientConfiguration = RedisClientConfiguration.builder().build(); + GlideClientConfiguration glideClientConfiguration = GlideClientConfiguration.builder().build(); ConnectionRequest expectedProtobufConnectionRequest = ConnectionRequest.newBuilder() .setTlsMode(TlsMode.NoTls) @@ -82,7 +81,7 @@ public void connection_request_protobuf_generation_default_standalone_configurat // execute when(channel.connect(eq(expectedProtobufConnectionRequest))).thenReturn(completedFuture); - CompletableFuture result = connectionManager.connectToRedis(redisClientConfiguration); + CompletableFuture result = connectionManager.connectToRedis(glideClientConfiguration); // verify // no exception @@ -93,8 +92,8 @@ public void connection_request_protobuf_generation_default_standalone_configurat @Test public void connection_request_protobuf_generation_default_cluster_configuration() { // setup - RedisClusterClientConfiguration redisClusterClientConfiguration = - RedisClusterClientConfiguration.builder().build(); + GlideClusterClientConfiguration glideClusterClientConfiguration = + GlideClusterClientConfiguration.builder().build(); ConnectionRequest expectedProtobufConnectionRequest = ConnectionRequest.newBuilder() .setTlsMode(TlsMode.NoTls) @@ -108,7 +107,7 @@ public void connection_request_protobuf_generation_default_cluster_configuration // execute when(channel.connect(eq(expectedProtobufConnectionRequest))).thenReturn(completedFuture); CompletableFuture result = - connectionManager.connectToRedis(redisClusterClientConfiguration); + connectionManager.connectToRedis(glideClusterClientConfiguration); // verify assertNull(result.get()); @@ -119,8 +118,8 @@ public void connection_request_protobuf_generation_default_cluster_configuration @Test public void connection_request_protobuf_generation_with_all_fields_set() { // setup - RedisClientConfiguration redisClientConfiguration = - RedisClientConfiguration.builder() + GlideClientConfiguration redisClientConfiguration = + GlideClientConfiguration.builder() .address(NodeAddress.builder().host(HOST).port(PORT).build()) .address(NodeAddress.builder().host(DEFAULT_HOST).port(DEFAULT_PORT).build()) .useTLS(true) @@ -180,7 +179,7 @@ public void connection_request_protobuf_generation_with_all_fields_set() { @Test public void response_validation_on_constant_response_returns_successfully() { // setup - RedisClientConfiguration redisClientConfiguration = RedisClientConfiguration.builder().build(); + GlideClientConfiguration redisClientConfiguration = GlideClientConfiguration.builder().build(); CompletableFuture completedFuture = new CompletableFuture<>(); Response response = Response.newBuilder().setConstantResponse(ConstantResponse.OK).build(); completedFuture.complete(response); @@ -197,7 +196,7 @@ public void response_validation_on_constant_response_returns_successfully() { @Test public void connection_on_empty_response_throws_ClosingException() { // setup - RedisClientConfiguration redisClientConfiguration = RedisClientConfiguration.builder().build(); + GlideClientConfiguration redisClientConfiguration = GlideClientConfiguration.builder().build(); CompletableFuture completedFuture = new CompletableFuture<>(); Response response = Response.newBuilder().build(); completedFuture.complete(response); @@ -217,7 +216,7 @@ public void connection_on_empty_response_throws_ClosingException() { @Test public void connection_on_resp_pointer_throws_ClosingException() { // setup - RedisClientConfiguration redisClientConfiguration = RedisClientConfiguration.builder().build(); + GlideClientConfiguration glideClientConfiguration = GlideClientConfiguration.builder().build(); CompletableFuture completedFuture = new CompletableFuture<>(); Response response = Response.newBuilder().setRespPointer(42).build(); completedFuture.complete(response); @@ -227,7 +226,7 @@ public void connection_on_resp_pointer_throws_ClosingException() { ExecutionException executionException = assertThrows( ExecutionException.class, - () -> connectionManager.connectToRedis(redisClientConfiguration).get()); + () -> connectionManager.connectToRedis(glideClientConfiguration).get()); assertTrue(executionException.getCause() instanceof ClosingException); assertEquals("Unexpected data in response", executionException.getCause().getMessage()); diff --git a/java/integTest/src/test/java/glide/ConnectionTests.java b/java/integTest/src/test/java/glide/ConnectionTests.java index 4e9f978604..add35ce31e 100644 --- a/java/integTest/src/test/java/glide/ConnectionTests.java +++ b/java/integTest/src/test/java/glide/ConnectionTests.java @@ -1,9 +1,9 @@ /** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */ package glide; -import glide.api.RedisClient; +import glide.api.GlideClient; +import glide.api.models.configuration.GlideClientConfiguration; import glide.api.models.configuration.NodeAddress; -import glide.api.models.configuration.RedisClientConfiguration; import lombok.SneakyThrows; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; @@ -15,8 +15,8 @@ public class ConnectionTests { @SneakyThrows public void basic_client() { var regularClient = - RedisClient.CreateClient( - RedisClientConfiguration.builder() + GlideClient.CreateClient( + GlideClientConfiguration.builder() .address( NodeAddress.builder().port(TestConfiguration.STANDALONE_PORTS[0]).build()) .build()) @@ -28,8 +28,8 @@ public void basic_client() { @SneakyThrows public void cluster_client() { var regularClient = - RedisClient.CreateClient( - RedisClientConfiguration.builder() + GlideClient.CreateClient( + GlideClientConfiguration.builder() .address(NodeAddress.builder().port(TestConfiguration.CLUSTER_PORTS[0]).build()) .build()) .get(); diff --git a/java/integTest/src/test/java/glide/CustomThreadPoolResourceTest.java b/java/integTest/src/test/java/glide/CustomThreadPoolResourceTest.java index 1523df7c15..fab24aeda8 100644 --- a/java/integTest/src/test/java/glide/CustomThreadPoolResourceTest.java +++ b/java/integTest/src/test/java/glide/CustomThreadPoolResourceTest.java @@ -3,9 +3,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import glide.api.RedisClient; +import glide.api.GlideClient; +import glide.api.models.configuration.GlideClientConfiguration; import glide.api.models.configuration.NodeAddress; -import glide.api.models.configuration.RedisClientConfiguration; import glide.connectors.resources.EpollResource; import glide.connectors.resources.KQueuePoolResource; import glide.connectors.resources.Platform; @@ -32,8 +32,8 @@ public void standalone_client_with_custom_threadPoolResource() { } var regularClient = - RedisClient.CreateClient( - RedisClientConfiguration.builder() + GlideClient.CreateClient( + GlideClientConfiguration.builder() .address( NodeAddress.builder().port(TestConfiguration.STANDALONE_PORTS[0]).build()) .threadPoolResource(customThreadPoolResource) diff --git a/java/integTest/src/test/java/glide/ErrorHandlingTests.java b/java/integTest/src/test/java/glide/ErrorHandlingTests.java index cb9b889758..504fa5dd35 100644 --- a/java/integTest/src/test/java/glide/ErrorHandlingTests.java +++ b/java/integTest/src/test/java/glide/ErrorHandlingTests.java @@ -5,9 +5,9 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -import glide.api.RedisClient; +import glide.api.GlideClient; +import glide.api.models.configuration.GlideClientConfiguration; import glide.api.models.configuration.NodeAddress; -import glide.api.models.configuration.RedisClientConfiguration; import glide.api.models.exceptions.ClosingException; import glide.api.models.exceptions.RequestException; import java.net.ServerSocket; @@ -26,8 +26,8 @@ public void basic_client_tries_to_connect_to_wrong_address() { assertThrows( ExecutionException.class, () -> - RedisClient.CreateClient( - RedisClientConfiguration.builder() + GlideClient.CreateClient( + GlideClientConfiguration.builder() .address(NodeAddress.builder().port(getFreePort()).build()) .build()) .get()); @@ -40,8 +40,8 @@ public void basic_client_tries_to_connect_to_wrong_address() { @SneakyThrows public void basic_client_tries_wrong_command() { try (var regularClient = - RedisClient.CreateClient( - RedisClientConfiguration.builder() + GlideClient.CreateClient( + GlideClientConfiguration.builder() .address( NodeAddress.builder().port(TestConfiguration.STANDALONE_PORTS[0]).build()) .build()) @@ -60,8 +60,8 @@ public void basic_client_tries_wrong_command() { @SneakyThrows public void basic_client_tries_wrong_command_arguments() { try (var regularClient = - RedisClient.CreateClient( - RedisClientConfiguration.builder() + GlideClient.CreateClient( + GlideClientConfiguration.builder() .address( NodeAddress.builder().port(TestConfiguration.STANDALONE_PORTS[0]).build()) .build()) diff --git a/java/integTest/src/test/java/glide/SharedClientTests.java b/java/integTest/src/test/java/glide/SharedClientTests.java index 0dd919d557..1496c4d53b 100644 --- a/java/integTest/src/test/java/glide/SharedClientTests.java +++ b/java/integTest/src/test/java/glide/SharedClientTests.java @@ -8,7 +8,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import glide.api.BaseClient; -import glide.api.RedisClient; +import glide.api.GlideClient; import glide.api.RedisClusterClient; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -28,7 +28,7 @@ @Timeout(25) // seconds public class SharedClientTests { - private static RedisClient standaloneClient = null; + private static GlideClient standaloneClient = null; private static RedisClusterClient clusterClient = null; @Getter private static List clients; @@ -36,7 +36,7 @@ public class SharedClientTests { @BeforeAll @SneakyThrows public static void init() { - standaloneClient = RedisClient.CreateClient(commonClientConfig().build()).get(); + standaloneClient = GlideClient.CreateClient(commonClientConfig().build()).get(); clusterClient = RedisClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(10000).build()) .get(); diff --git a/java/integTest/src/test/java/glide/SharedCommandTests.java b/java/integTest/src/test/java/glide/SharedCommandTests.java index b22b17a1e3..8e8b9e676d 100644 --- a/java/integTest/src/test/java/glide/SharedCommandTests.java +++ b/java/integTest/src/test/java/glide/SharedCommandTests.java @@ -29,8 +29,8 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue; import glide.api.BaseClient; -import glide.api.RedisClient; -import glide.api.RedisClusterClient; +import glide.api.GlideClient; +import glide.api.GlideClusterClient; import glide.api.models.GlideString; import glide.api.models.Script; import glide.api.models.commands.ConditionalChange; @@ -77,9 +77,9 @@ import glide.api.models.commands.stream.StreamReadOptions; import glide.api.models.commands.stream.StreamTrimOptions.MaxLen; import glide.api.models.commands.stream.StreamTrimOptions.MinId; +import glide.api.models.configuration.GlideClientConfiguration; +import glide.api.models.configuration.GlideClusterClientConfiguration; import glide.api.models.configuration.NodeAddress; -import glide.api.models.configuration.RedisClientConfiguration; -import glide.api.models.configuration.RedisClusterClientConfiguration; import glide.api.models.exceptions.RequestException; import java.time.Instant; import java.util.Arrays; @@ -107,8 +107,8 @@ @Timeout(10) // seconds public class SharedCommandTests { - private static RedisClient standaloneClient = null; - private static RedisClusterClient clusterClient = null; + private static GlideClient standaloneClient = null; + private static GlideClusterClient clusterClient = null; @Getter private static List clients; @@ -120,16 +120,16 @@ public class SharedCommandTests { @SneakyThrows public static void init() { standaloneClient = - RedisClient.CreateClient( - RedisClientConfiguration.builder() + GlideClient.CreateClient( + GlideClientConfiguration.builder() .address(NodeAddress.builder().port(STANDALONE_PORTS[0]).build()) .requestTimeout(5000) .build()) .get(); clusterClient = - RedisClusterClient.CreateClient( - RedisClusterClientConfiguration.builder() + GlideClusterClient.CreateClient( + GlideClusterClientConfiguration.builder() .address(NodeAddress.builder().port(CLUSTER_PORTS[0]).build()) .requestTimeout(5000) .build()) @@ -2364,9 +2364,9 @@ public void bzpopmin_timeout_check(BaseClient client) { String key = UUID.randomUUID().toString(); // create new client with default request timeout (250 millis) try (var testClient = - client instanceof RedisClient - ? RedisClient.CreateClient(commonClientConfig().build()).get() - : RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { + client instanceof GlideClient + ? GlideClient.CreateClient(commonClientConfig().build()).get() + : GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { // ensure that commands doesn't time out even if timeout > request timeout assertNull(testClient.bzpopmin(new String[] {key}, 1).get()); @@ -2436,9 +2436,9 @@ public void bzpopmax_timeout_check(BaseClient client) { String key = UUID.randomUUID().toString(); // create new client with default request timeout (250 millis) try (var testClient = - client instanceof RedisClient - ? RedisClient.CreateClient(commonClientConfig().build()).get() - : RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { + client instanceof GlideClient + ? GlideClient.CreateClient(commonClientConfig().build()).get() + : GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { // ensure that commands doesn't time out even if timeout > request timeout assertNull(testClient.bzpopmax(new String[] {key}, 1).get()); @@ -2580,7 +2580,8 @@ public void zmscore(BaseClient client) { .zmscore( gs(key1), new GlideString[] { - gs("one"), gs("nonExistentMember"), gs("nonExistentMember"), gs("three") + gs("one"), gs("nonExistentMember"), + gs("nonExistentMember"), gs("three") }) .get()); assertArrayEquals( @@ -2910,7 +2911,8 @@ public void zrangestore_by_score(BaseClient client) { Map.of("two", 2.0, "three", 3.0), client.zrangeWithScores(destination, new RangeByIndex(0, -1)).get()); - // Range from positive to negative infinity with rev set to true. Limited to ranks 1 to 2. + // Range from positive to negative infinity with rev set to true. Limited to + // ranks 1 to 2. query = new RangeByScore( InfScoreBound.POSITIVE_INFINITY, InfScoreBound.NEGATIVE_INFINITY, new Limit(1, 2)); @@ -2977,7 +2979,8 @@ public void zrangestore_by_lex(BaseClient client) { Map.of("b", 2.0, "c", 3.0), client.zrangeWithScores(destination, new RangeByIndex(0, -1)).get()); - // Range from positive to negative infinity with rev set to true. Limited to ranks 1 to 2. + // Range from positive to negative infinity with rev set to true. Limited to + // ranks 1 to 2. query = new RangeByLex( InfLexBound.POSITIVE_INFINITY, InfLexBound.NEGATIVE_INFINITY, new Limit(1, 2)); @@ -3052,7 +3055,8 @@ public void zunionstore(BaseClient client) { assertEquals( Map.of("one", 2.0, "two", 9.0, "three", 6.0), client.zrangeWithScores(key3, query).get()); - // Union results are aggregated by the maximum score, with scores for key1 multiplied by 1.0 and + // Union results are aggregated by the maximum score, with scores for key1 + // multiplied by 1.0 and // for key2 by 2.0. assertEquals( 3, @@ -3119,7 +3123,8 @@ public void zunion(BaseClient client) { .zunionWithScores(new WeightedKeys(List.of(Pair.of(key1, 2.0), Pair.of(key2, 2.0)))) .get()); - // Union results are aggregated by the minimum score, with scores for key1 multiplied by 1.0 and + // Union results are aggregated by the minimum score, with scores for key1 + // multiplied by 1.0 and // for key2 by -2.0. assertEquals( Map.of("two", -7.0, "three", -6.0, "one", 1.0), @@ -3159,7 +3164,8 @@ public void zinter(BaseClient client) { assertEquals(2, client.zadd(key1, membersScores1).get()); assertEquals(2, client.zadd(key2, membersScores2).get()); - // Intersection results are aggregated by the sum of the scores of elements by default + // Intersection results are aggregated by the sum of the scores of elements by + // default assertArrayEquals( new String[] {"two"}, client.zinter(new KeyArray(new String[] {key1, key2})).get()); assertEquals( @@ -3295,7 +3301,8 @@ public void zinterstore(BaseClient client) { .get()); assertEquals(Map.of("one", 5.0, "two", 9.0), client.zrangeWithScores(key3, query).get()); - // Intersection results are aggregated by the minimum score, with scores for key1 multiplied by + // Intersection results are aggregated by the minimum score, with scores for + // key1 multiplied by // 1.0 and for key2 by -2.0. assertEquals( 2, @@ -3425,9 +3432,9 @@ public void bzmpop_timeout_check(BaseClient client) { String key = UUID.randomUUID().toString(); // create new client with default request timeout (250 millis) try (var testClient = - client instanceof RedisClient - ? RedisClient.CreateClient(commonClientConfig().build()).get() - : RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { + client instanceof GlideClient + ? GlideClient.CreateClient(commonClientConfig().build()).get() + : GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { // ensure that commands doesn't time out even if timeout > request timeout assertNull(testClient.bzmpop(new String[] {key}, MAX, 1).get()); @@ -3610,9 +3617,9 @@ public void xread_return_failures(BaseClient client) { assertInstanceOf(RequestException.class, executionException.getCause()); try (var testClient = - client instanceof RedisClient - ? RedisClient.CreateClient(commonClientConfig().build()).get() - : RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { + client instanceof GlideClient + ? GlideClient.CreateClient(commonClientConfig().build()).get() + : GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { // ensure that commands doesn't time out even if timeout > request timeout long oneSecondInMS = 1000L; @@ -3907,7 +3914,8 @@ public void xgroupCreateConsumer_xgroupDelConsumer_xreadgroup_xack(BaseClient cl .get()); assertTrue(client.xgroupCreateConsumer(key, groupName, consumerName).get()); - // create consumer for group that does not exist results in a NOGROUP request error + // create consumer for group that does not exist results in a NOGROUP request + // error ExecutionException executionException = assertThrows( ExecutionException.class, @@ -3962,7 +3970,8 @@ public void xgroupCreateConsumer_xgroupDelConsumer_xreadgroup_xack(BaseClient cl // xack streamid_1, and streamid_2 already received returns 0L assertEquals(0L, client.xack(key, groupName, new String[] {streamid_1, streamid_2}).get()); - // Consume the last message with the previously deleted consumer (creates the consumer anew) + // Consume the last message with the previously deleted consumer (creates the + // consumer anew) var result_3 = client.xreadgroup(Map.of(key, ">"), groupName, consumerName).get(); assertEquals(1, result_3.get(key).size()); @@ -4040,9 +4049,9 @@ public void xreadgroup_return_failures(BaseClient client) { assertInstanceOf(RequestException.class, executionException.getCause()); try (var testClient = - client instanceof RedisClient - ? RedisClient.CreateClient(commonClientConfig().build()).get() - : RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { + client instanceof GlideClient + ? GlideClient.CreateClient(commonClientConfig().build()).get() + : GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { String timeoutKey = "{key}:2" + UUID.randomUUID(); String timeoutGroupName = "group" + UUID.randomUUID(); String timeoutConsumerName = "consumer" + UUID.randomUUID(); @@ -4051,7 +4060,8 @@ public void xreadgroup_return_failures(BaseClient client) { // add a single stream entry and consumer // the first call to ">" will return an update consumer group // the second call to ">" will block waiting for new entries - // using anything other than ">" won't block, but will return the empty consumer result + // using anything other than ">" won't block, but will return the empty consumer + // result // see: https://github.com/redis/redis/issues/6587 assertEquals( OK, @@ -4691,7 +4701,8 @@ public void objectEncoding_binary_returns_string_embstr(BaseClient client) { public void objectEncoding_returns_list_listpack(BaseClient client) { String listListpackKey = UUID.randomUUID().toString(); assertEquals(1, client.lpush(listListpackKey, new String[] {"1"}).get()); - // API documentation states that a ziplist should be returned for Redis versions <= 6.2, but + // API documentation states that a ziplist should be returned for Redis versions + // <= 6.2, but // actual behavior returns a quicklist. assertEquals( REDIS_VERSION.isLowerThan("7.0.0") ? "quicklist" : "listpack", @@ -4704,7 +4715,8 @@ public void objectEncoding_returns_list_listpack(BaseClient client) { public void objectEncoding_binary_returns_list_listpack(BaseClient client) { GlideString listListpackKey = gs(UUID.randomUUID().toString()); assertEquals(1, client.lpush(listListpackKey, new GlideString[] {gs("1")}).get()); - // API documentation states that a ziplist should be returned for Redis versions <= 6.2, but + // API documentation states that a ziplist should be returned for Redis versions + // <= 6.2, but // actual behavior returns a quicklist. assertEquals( REDIS_VERSION.isLowerThan("7.0.0") ? "quicklist" : "listpack", @@ -4982,7 +4994,8 @@ public void geopos(BaseClient client) { String[] members = {"Palermo", "Catania"}; GlideString[] members_gs = {gs("Palermo"), gs("Catania")}; Double[][] expected = { - {13.36138933897018433, 38.11555639549629859}, {15.08726745843887329, 37.50266842333162032} + {13.36138933897018433, 38.11555639549629859}, + {15.08726745843887329, 37.50266842333162032} }; // adding locations @@ -5182,9 +5195,9 @@ public void getbit(BaseClient client) { assertEquals(1, client.getbit(gs(key1), 1).get()); assertEquals(0, client.getbit(gs(key1), 1000).get()); assertEquals(0, client.getbit(gs(missingKey), 1).get()); - if (client instanceof RedisClient) { + if (client instanceof GlideClient) { assertEquals( - 1L, ((RedisClient) client).customCommand(new String[] {"SETBIT", key1, "5", "0"}).get()); + 1L, ((GlideClient) client).customCommand(new String[] {"SETBIT", key1, "5", "0"}).get()); assertEquals(0, client.getbit(key1, 5).get()); } @@ -5295,9 +5308,11 @@ public void bitop(BaseClient client) { assertEquals(1L, client.bitop(BitwiseOperation.XOR, destination, new String[] {key1}).get()); assertEquals("a", client.get(destination).get()); assertEquals(1L, client.bitop(BitwiseOperation.NOT, destination, new String[] {key1}).get()); - // First bit is flipped to 1 and throws 'utf-8' codec can't decode byte 0x9e in position 0: + // First bit is flipped to 1 and throws 'utf-8' codec can't decode byte 0x9e in + // position 0: // invalid start byte - // TODO: update once fix is implemented for https://github.com/aws/glide-for-redis/issues/1447 + // TODO: update once fix is implemented for + // https://github.com/aws/glide-for-redis/issues/1447 ExecutionException executionException = assertThrows(ExecutionException.class, () -> client.get(destination).get()); assertTrue(executionException.getCause() instanceof RuntimeException); @@ -5431,9 +5446,9 @@ public void blmpop_timeout_check(BaseClient client) { String key = UUID.randomUUID().toString(); // create new client with default request timeout (250 millis) try (var testClient = - client instanceof RedisClient - ? RedisClient.CreateClient(commonClientConfig().build()).get() - : RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { + client instanceof GlideClient + ? GlideClient.CreateClient(commonClientConfig().build()).get() + : GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { // ensure that commands doesn't time out even if timeout > request timeout assertNull(testClient.blmpop(new String[] {key}, ListDirection.LEFT, 1).get()); @@ -5507,13 +5522,15 @@ public void lmove(BaseClient client) { // source does not exist or is empty assertNull(client.lmove(key1, key2, ListDirection.LEFT, ListDirection.RIGHT).get()); - // only source exists, only source elements gets popped, creates a list at nonExistingKey + // only source exists, only source elements gets popped, creates a list at + // nonExistingKey assertEquals(lpushArgs1.length, client.lpush(key1, lpushArgs1).get()); assertEquals( "four", client.lmove(key1, nonExistingKey, ListDirection.RIGHT, ListDirection.LEFT).get()); assertArrayEquals(new String[] {"one", "two", "three"}, client.lrange(key1, 0, -1).get()); - // source and destination are the same, performing list rotation, "three" gets popped and added + // source and destination are the same, performing list rotation, "three" gets + // popped and added // back assertEquals("one", client.lmove(key1, key1, ListDirection.LEFT, ListDirection.LEFT).get()); assertArrayEquals(new String[] {"one", "two", "three"}, client.lrange(key1, 0, -1).get()); @@ -5558,7 +5575,8 @@ public void blmove(BaseClient client) { // source does not exist or is empty assertNull(client.blmove(key1, key2, ListDirection.LEFT, ListDirection.RIGHT, timeout).get()); - // only source exists, only source elements gets popped, creates a list at nonExistingKey + // only source exists, only source elements gets popped, creates a list at + // nonExistingKey assertEquals(lpushArgs1.length, client.lpush(key1, lpushArgs1).get()); assertEquals( "four", @@ -5567,7 +5585,8 @@ public void blmove(BaseClient client) { .get()); assertArrayEquals(new String[] {"one", "two", "three"}, client.lrange(key1, 0, -1).get()); - // source and destination are the same, performing list rotation, "three" gets popped and added + // source and destination are the same, performing list rotation, "three" gets + // popped and added // back assertEquals( "one", client.blmove(key1, key1, ListDirection.LEFT, ListDirection.LEFT, timeout).get()); @@ -5612,9 +5631,9 @@ public void blmove_timeout_check(BaseClient client) { String key2 = "{key}-2" + UUID.randomUUID(); // create new client with default request timeout (250 millis) try (var testClient = - client instanceof RedisClient - ? RedisClient.CreateClient(commonClientConfig().build()).get() - : RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { + client instanceof GlideClient + ? GlideClient.CreateClient(commonClientConfig().build()).get() + : GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get()) { // ensure that commands doesn't time out even if timeout > request timeout assertNull(testClient.blmove(key1, key2, ListDirection.LEFT, ListDirection.LEFT, 1).get()); @@ -5647,7 +5666,8 @@ public void srandmember(BaseClient client) { String expectedNoCount = "one"; String[] expectedNegCount = new String[] {"one", "one"}; - // key does not exist, without count the command returns null, and with count command returns an + // key does not exist, without count the command returns null, and with count + // command returns an // empty array assertNull(client.srandmember(nonExistingKey).get()); assertEquals(0, client.srandmember(nonExistingKey, count).get().length); @@ -5655,7 +5675,8 @@ public void srandmember(BaseClient client) { // adding element to set client.sadd(key, singleArr).get(); - // with no count or a positive count, single array result should only contain element "one" + // with no count or a positive count, single array result should only contain + // element "one" String resultNoCount = client.srandmember(key).get(); assertEquals(resultNoCount, expectedNoCount); String[] resultPosCount = client.srandmember(key, count).get(); @@ -5731,13 +5752,21 @@ public void bitfieldReadOnly(BaseClient client) { .bitfieldReadOnly( key1, new BitFieldReadOnlySubCommands[] { - // Get value in: 0(11)00110 01101111 01101111 01100010 01100001 01110010 00010100 + // Get value in: 0(11)00110 01101111 + // 01101111 01100010 01100001 01110010 + // 00010100 unsignedOffsetGet, - // Get value in: 01100(110) 01101111 01101111 01100010 01100001 01110010 00010100 + // Get value in: 01100(110) 01101111 + // 01101111 01100010 01100001 01110010 + // 00010100 new BitFieldGet(new SignedEncoding(3), new Offset(5)), - // Get value in: 01100110 01101111 01101(111 0110)0010 01100001 01110010 00010100 + // Get value in: 01100110 01101111 + // 01101(111 0110)0010 01100001 01110010 + // 00010100 new BitFieldGet(new UnsignedEncoding(7), new OffsetMultiplier(3)), - // Get value in: 01100110 01101111 (01101111) 01100010 01100001 01110010 00010100 + // Get value in: 01100110 01101111 + // (01101111) 01100010 01100001 01110010 + // 00010100 new BitFieldGet(new SignedEncoding(8), new OffsetMultiplier(2)) }) .get()); @@ -5847,13 +5876,21 @@ public void bitfield(BaseClient client) { .bitfield( key1, new BitFieldSubCommands[] { - // binary value becomes: 0(10)00110 01101111 01101111 01100010 01100001 01110010 + // binary value becomes: 0(10)00110 + // 01101111 01101111 01100010 01100001 + // 01110010 new BitFieldSet(u2, offset1, 2), - // binary value becomes: 01000(011) 01101111 01101111 01100010 01100001 01110010 + // binary value becomes: 01000(011) + // 01101111 01101111 01100010 01100001 + // 01110010 new BitFieldSet(i3, offset5, 3), - // binary value becomes: 01000011 01101111 01101111 0110(0010 010)00001 01110010 + // binary value becomes: 01000011 + // 01101111 01101111 0110(0010 010)00001 + // 01110010 new BitFieldSet(u7, offsetMultiplier4, 18), - // binary value becomes: 01000011 01101111 01101111 01100010 01000001 01110010 + // binary value becomes: 01000011 + // 01101111 01101111 01100010 01000001 + // 01110010 // 00000000 00000000 (00010100) new BitFieldSet(i8, offsetMultiplier8, 20), new BitFieldGet(u2, offset1), @@ -5870,16 +5907,24 @@ public void bitfield(BaseClient client) { .bitfield( key1, new BitFieldSubCommands[] { - // binary value becomes: 0(11)00011 01101111 01101111 01100010 01000001 01110010 - // 00000000 00000000 00010100 + // binary value becomes: 0(11)00011 + // 01101111 01101111 01100010 01000001 + // 01110010 + // 00000000 00000000 00010100 new BitFieldIncrby(u2, offset1, 1), - // binary value becomes: 01100(101) 01101111 01101111 01100010 01000001 01110010 + // binary value becomes: 01100(101) + // 01101111 01101111 01100010 01000001 + // 01110010 // 00000000 00000000 00010100 new BitFieldIncrby(i3, offset5, 2), - // binary value becomes: 01100101 01101111 01101111 0110(0001 111)00001 01110010 + // binary value becomes: 01100101 + // 01101111 01101111 0110(0001 111)00001 + // 01110010 // 00000000 00000000 00010100 new BitFieldIncrby(u7, offsetMultiplier4, -3), - // binary value becomes: 01100101 01101111 01101111 01100001 11100001 01110010 + // binary value becomes: 01100101 + // 01101111 01101111 01100001 11100001 + // 01110010 // 00000000 00000000 (00011110) new BitFieldIncrby(i8, offsetMultiplier8, 10) }) @@ -6018,7 +6063,8 @@ public void sintercard(BaseClient client) { assertEquals(4, client.sadd(key2, saddargs2).get()); assertEquals(3, client.sintercard(keys).get()); - // returns limit as cardinality when the limit is reached partway through the computation + // returns limit as cardinality when the limit is reached partway through the + // computation assertEquals(limit, client.sintercard(keys, limit).get()); // non set keys are used diff --git a/java/integTest/src/test/java/glide/TestUtilities.java b/java/integTest/src/test/java/glide/TestUtilities.java index eb0f578312..bbb9809ff9 100644 --- a/java/integTest/src/test/java/glide/TestUtilities.java +++ b/java/integTest/src/test/java/glide/TestUtilities.java @@ -9,9 +9,9 @@ import static org.junit.jupiter.api.Assertions.fail; import glide.api.models.ClusterValue; +import glide.api.models.configuration.GlideClientConfiguration; +import glide.api.models.configuration.GlideClusterClientConfiguration; import glide.api.models.configuration.NodeAddress; -import glide.api.models.configuration.RedisClientConfiguration; -import glide.api.models.configuration.RedisClusterClientConfiguration; import java.security.SecureRandom; import java.util.HashMap; import java.util.List; @@ -71,15 +71,15 @@ public static Map parseInfoResponseToMap(String serverInfo) { HashMap::new)); } - public static RedisClientConfiguration.RedisClientConfigurationBuilder + public static GlideClientConfiguration.GlideClientConfigurationBuilder commonClientConfig() { - return RedisClientConfiguration.builder() + return GlideClientConfiguration.builder() .address(NodeAddress.builder().port(STANDALONE_PORTS[0]).build()); } - public static RedisClusterClientConfiguration.RedisClusterClientConfigurationBuilder + public static GlideClusterClientConfiguration.GlideClusterClientConfigurationBuilder commonClusterClientConfig() { - return RedisClusterClientConfiguration.builder() + return GlideClusterClientConfiguration.builder() .address(NodeAddress.builder().port(CLUSTER_PORTS[0]).build()); } diff --git a/java/integTest/src/test/java/glide/cluster/ClusterTransactionTests.java b/java/integTest/src/test/java/glide/cluster/ClusterTransactionTests.java index 8965cefc4c..86afe266a4 100644 --- a/java/integTest/src/test/java/glide/cluster/ClusterTransactionTests.java +++ b/java/integTest/src/test/java/glide/cluster/ClusterTransactionTests.java @@ -15,11 +15,11 @@ import glide.TestConfiguration; import glide.TransactionTestUtilities.TransactionBuilder; -import glide.api.RedisClusterClient; +import glide.api.GlideClusterClient; import glide.api.models.ClusterTransaction; import glide.api.models.commands.SortClusterOptions; +import glide.api.models.configuration.GlideClusterClientConfiguration; import glide.api.models.configuration.NodeAddress; -import glide.api.models.configuration.RedisClusterClientConfiguration; import glide.api.models.configuration.RequestRoutingConfiguration.SingleNodeRoute; import glide.api.models.configuration.RequestRoutingConfiguration.SlotIdRoute; import glide.api.models.configuration.RequestRoutingConfiguration.SlotType; @@ -38,14 +38,14 @@ @Timeout(10) // seconds public class ClusterTransactionTests { - private static RedisClusterClient clusterClient = null; + private static GlideClusterClient clusterClient = null; @BeforeAll @SneakyThrows public static void init() { clusterClient = - RedisClusterClient.CreateClient( - RedisClusterClientConfiguration.builder() + GlideClusterClient.CreateClient( + GlideClusterClientConfiguration.builder() .address(NodeAddress.builder().port(TestConfiguration.CLUSTER_PORTS[0]).build()) .requestTimeout(5000) .build()) @@ -183,7 +183,8 @@ public void watch() { ClusterTransaction setHelloTransaction = new ClusterTransaction(); String[] expectedExecResponse = new String[] {OK, OK, OK}; - // Returns null when a watched key is modified before it is executed in a transaction command. + // Returns null when a watched key is modified before it is executed in a + // transaction command. // Transaction commands are not performed. assertEquals(OK, clusterClient.watch(keys).get()); assertEquals(OK, clusterClient.set(key2, helloString).get()); @@ -193,7 +194,8 @@ public void watch() { assertEquals(helloString, clusterClient.get(key2).get()); assertEquals(null, clusterClient.get(key3).get()); - // Transaction executes command successfully with a read command on the watch key before + // Transaction executes command successfully with a read command on the watch + // key before // transaction is executed. assertEquals(OK, clusterClient.watch(keys).get()); assertEquals(helloString, clusterClient.get(key2).get()); @@ -209,7 +211,8 @@ public void watch() { assertEquals(foobarString, clusterClient.get(key2).get()); assertEquals(foobarString, clusterClient.get(key3).get()); - // Transaction executes command successfully with a modified watched key but is not in the + // Transaction executes command successfully with a modified watched key but is + // not in the // transaction. assertEquals(OK, clusterClient.watch(new String[] {key4}).get()); setHelloTransaction.set(key1, helloString).set(key2, helloString).set(key3, helloString); @@ -221,7 +224,7 @@ public void watch() { // WATCH can not have an empty String array parameter // Test fails due to https://github.com/amazon-contributing/redis-rs/issues/158 // ExecutionException executionException = - // assertThrows(ExecutionException.class, () -> clusterClient.watch(new String[] + // assertThrows(ExecutionException.class, () -> clusterClient.watch(new String[] // {}).get()); // assertInstanceOf(RequestException.class, executionException.getCause()); } @@ -240,7 +243,8 @@ public void unwatch() { // UNWATCH returns OK when there no watched keys assertEquals(OK, clusterClient.unwatch().get()); - // Transaction executes successfully after modifying a watched key then calling UNWATCH + // Transaction executes successfully after modifying a watched key then calling + // UNWATCH assertEquals(OK, clusterClient.watch(keys).get()); assertEquals(OK, clusterClient.set(key2, helloString).get()); assertEquals(OK, clusterClient.unwatch().get()); diff --git a/java/integTest/src/test/java/glide/standalone/CommandTests.java b/java/integTest/src/test/java/glide/standalone/CommandTests.java index 736284375c..e43137c252 100644 --- a/java/integTest/src/test/java/glide/standalone/CommandTests.java +++ b/java/integTest/src/test/java/glide/standalone/CommandTests.java @@ -19,7 +19,6 @@ import static glide.api.models.commands.InfoOptions.Section.MEMORY; import static glide.api.models.commands.InfoOptions.Section.SERVER; import static glide.api.models.commands.InfoOptions.Section.STATS; -import static glide.api.models.commands.SortBaseOptions.Limit; import static glide.api.models.commands.SortBaseOptions.OrderBy.ASC; import static glide.api.models.commands.SortBaseOptions.OrderBy.DESC; import static glide.api.models.commands.function.FunctionRestorePolicy.APPEND; @@ -37,9 +36,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue; -import glide.api.RedisClient; +import glide.api.GlideClient; import glide.api.models.GlideString; import glide.api.models.commands.InfoOptions; +import glide.api.models.commands.SortBaseOptions.Limit; import glide.api.models.commands.SortOptions; import glide.api.models.exceptions.RequestException; import java.time.Instant; @@ -62,13 +62,13 @@ public class CommandTests { private static final String INITIAL_VALUE = "VALUE"; - private static RedisClient regularClient = null; + private static GlideClient regularClient = null; @BeforeAll @SneakyThrows public static void init() { regularClient = - RedisClient.CreateClient(commonClientConfig().requestTimeout(7000).build()).get(); + GlideClient.CreateClient(commonClientConfig().requestTimeout(7000).build()).get(); } @AfterAll @@ -578,7 +578,8 @@ public void copy() { regularClient.select(2).get(); assertEquals("two", regularClient.get(destination).get()); - // both exists, with REPLACE, when value isn't the same, source always get copied to + // both exists, with REPLACE, when value isn't the same, source always get + // copied to // destination regularClient.select(0).get(); assertTrue(regularClient.copy(source, destination, index1, true).get()); @@ -615,7 +616,7 @@ public void functionStats_and_functionKill() { assertEquals(libName, regularClient.functionLoad(code, true).get()); try (var testClient = - RedisClient.CreateClient(commonClientConfig().requestTimeout(7000).build()).get()) { + GlideClient.CreateClient(commonClientConfig().requestTimeout(7000).build()).get()) { // call the function without await var promise = testClient.fcall(funcName); @@ -647,7 +648,8 @@ public void functionStats_and_functionKill() { assertTrue(exception.getMessage().contains("Script killed by user")); } } finally { - // If function wasn't killed, and it didn't time out - it blocks the server and cause rest + // If function wasn't killed, and it didn't time out - it blocks the server and + // cause rest // test to fail. try { regularClient.functionKill().get(); @@ -686,7 +688,7 @@ public void functionStats_and_functionKill_write_function() { assertEquals(libName, regularClient.functionLoad(code, true).get()); try (var testClient = - RedisClient.CreateClient(commonClientConfig().requestTimeout(7000).build()).get()) { + GlideClient.CreateClient(commonClientConfig().requestTimeout(7000).build()).get()) { // call the function without await var promise = testClient.fcall(funcName, new String[] {key}, new String[0]); @@ -718,7 +720,8 @@ public void functionStats_and_functionKill_write_function() { assertTrue(exception.getMessage().toLowerCase().contains("notbusy")); } } finally { - // If function wasn't killed, and it didn't time out - it blocks the server and cause rest + // If function wasn't killed, and it didn't time out - it blocks the server and + // cause rest // test to fail. try { regularClient.functionKill().get(); @@ -905,7 +908,8 @@ public void sort() { .build()) .get()); - // Non-existent key in the BY pattern will result in skipping the sorting operation + // Non-existent key in the BY pattern will result in skipping the sorting + // operation assertArrayEquals( userIDs, regularClient.sort(listKey, SortOptions.builder().byPattern("noSort").build()).get()); @@ -961,7 +965,8 @@ public void sort() { .build()) .get()); - // Non-existent key in the BY pattern will result in skipping the sorting operation + // Non-existent key in the BY pattern will result in skipping the sorting + // operation assertArrayEquals( userIDs, regularClient diff --git a/java/integTest/src/test/java/glide/standalone/StandaloneClientTests.java b/java/integTest/src/test/java/glide/standalone/StandaloneClientTests.java index 9da65bf6c3..ea17c3af36 100644 --- a/java/integTest/src/test/java/glide/standalone/StandaloneClientTests.java +++ b/java/integTest/src/test/java/glide/standalone/StandaloneClientTests.java @@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue; -import glide.api.RedisClient; +import glide.api.GlideClient; import glide.api.models.configuration.RedisCredentials; import glide.api.models.exceptions.ClosingException; import glide.api.models.exceptions.RequestException; @@ -30,7 +30,7 @@ public void register_client_name_and_version() { REDIS_VERSION.isGreaterThanOrEqualTo(minVersion), "Redis version required >= " + minVersion); - RedisClient client = RedisClient.CreateClient(commonClientConfig().build()).get(); + GlideClient client = GlideClient.CreateClient(commonClientConfig().build()).get(); String info = (String) client.customCommand(new String[] {"CLIENT", "INFO"}).get(); assertTrue(info.contains("lib-name=GlideJava")); @@ -42,7 +42,7 @@ public void register_client_name_and_version() { @SneakyThrows @Test public void can_connect_with_auth_require_pass() { - RedisClient client = RedisClient.CreateClient(commonClientConfig().build()).get(); + GlideClient client = GlideClient.CreateClient(commonClientConfig().build()).get(); String password = "TEST_AUTH"; client.customCommand(new String[] {"CONFIG", "SET", "requirepass", password}).get(); @@ -51,12 +51,12 @@ public void can_connect_with_auth_require_pass() { ExecutionException exception = assertThrows( ExecutionException.class, - () -> RedisClient.CreateClient(commonClientConfig().build()).get()); + () -> GlideClient.CreateClient(commonClientConfig().build()).get()); assertTrue(exception.getCause() instanceof ClosingException); // Creation of a new client with credentials - RedisClient auth_client = - RedisClient.CreateClient( + GlideClient auth_client = + GlideClient.CreateClient( commonClientConfig() .credentials(RedisCredentials.builder().password(password).build()) .build()) @@ -78,7 +78,7 @@ public void can_connect_with_auth_require_pass() { @SneakyThrows @Test public void can_connect_with_auth_acl() { - RedisClient client = RedisClient.CreateClient(commonClientConfig().build()).get(); + GlideClient client = GlideClient.CreateClient(commonClientConfig().build()).get(); String username = "testuser"; String password = "TEST_AUTH"; @@ -107,8 +107,8 @@ public void can_connect_with_auth_acl() { assertEquals(OK, client.set(key, value).get()); // Creation of a new client with credentials - RedisClient testUserClient = - RedisClient.CreateClient( + GlideClient testUserClient = + GlideClient.CreateClient( commonClientConfig() .credentials( RedisCredentials.builder().username(username).password(password).build()) @@ -129,7 +129,7 @@ public void can_connect_with_auth_acl() { @SneakyThrows @Test public void select_standalone_database_id() { - RedisClient client = RedisClient.CreateClient(commonClientConfig().databaseId(4).build()).get(); + GlideClient client = GlideClient.CreateClient(commonClientConfig().databaseId(4).build()).get(); String clientInfo = (String) client.customCommand(new String[] {"CLIENT", "INFO"}).get(); assertTrue(clientInfo.contains("db=4")); @@ -140,8 +140,8 @@ public void select_standalone_database_id() { @SneakyThrows @Test public void client_name() { - RedisClient client = - RedisClient.CreateClient(commonClientConfig().clientName("TEST_CLIENT_NAME").build()).get(); + GlideClient client = + GlideClient.CreateClient(commonClientConfig().clientName("TEST_CLIENT_NAME").build()).get(); String clientInfo = (String) client.customCommand(new String[] {"CLIENT", "INFO"}).get(); assertTrue(clientInfo.contains("name=TEST_CLIENT_NAME")); @@ -152,7 +152,7 @@ public void client_name() { @Test @SneakyThrows public void closed_client_throws_ExecutionException_with_ClosingException_as_cause() { - RedisClient client = RedisClient.CreateClient(commonClientConfig().build()).get(); + GlideClient client = GlideClient.CreateClient(commonClientConfig().build()).get(); client.close(); ExecutionException executionException = diff --git a/java/integTest/src/test/java/glide/standalone/TransactionTests.java b/java/integTest/src/test/java/glide/standalone/TransactionTests.java index dc0061a682..575982a9a4 100644 --- a/java/integTest/src/test/java/glide/standalone/TransactionTests.java +++ b/java/integTest/src/test/java/glide/standalone/TransactionTests.java @@ -15,7 +15,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue; import glide.TransactionTestUtilities.TransactionBuilder; -import glide.api.RedisClient; +import glide.api.GlideClient; import glide.api.models.Transaction; import glide.api.models.commands.InfoOptions; import glide.api.models.commands.SortOptions; @@ -36,12 +36,12 @@ @Timeout(10) // seconds public class TransactionTests { - private static RedisClient client = null; + private static GlideClient client = null; @BeforeAll @SneakyThrows public static void init() { - client = RedisClient.CreateClient(commonClientConfig().requestTimeout(7000).build()).get(); + client = GlideClient.CreateClient(commonClientConfig().requestTimeout(7000).build()).get(); } @AfterAll @@ -266,7 +266,8 @@ public void watch() { Transaction setHelloTransaction = new Transaction(); String[] expectedExecResponse = new String[] {OK, OK, OK}; - // Returns null when a watched key is modified before it is executed in a transaction command. + // Returns null when a watched key is modified before it is executed in a + // transaction command. // Transaction commands are not performed. assertEquals(OK, client.watch(keys).get()); assertEquals(OK, client.set(key2, helloString).get()); @@ -276,7 +277,8 @@ public void watch() { assertEquals(helloString, client.get(key2).get()); assertEquals(null, client.get(key3).get()); - // Transaction executes command successfully with a read command on the watch key before + // Transaction executes command successfully with a read command on the watch + // key before // transaction is executed. assertEquals(OK, client.watch(keys).get()); assertEquals(helloString, client.get(key2).get()); @@ -292,7 +294,8 @@ public void watch() { assertEquals(foobarString, client.get(key2).get()); assertEquals(foobarString, client.get(key3).get()); - // Transaction executes command successfully with a modified watched key but is not in the + // Transaction executes command successfully with a modified watched key but is + // not in the // transaction. assertEquals(OK, client.watch(new String[] {key4}).get()); setHelloTransaction.set(key1, helloString).set(key2, helloString).set(key3, helloString); @@ -321,7 +324,8 @@ public void unwatch() { // UNWATCH returns OK when there no watched keys assertEquals(OK, client.unwatch().get()); - // Transaction executes successfully after modifying a watched key then calling UNWATCH + // Transaction executes successfully after modifying a watched key then calling + // UNWATCH assertEquals(OK, client.watch(keys).get()); assertEquals(OK, client.set(key2, helloString).get()); assertEquals(OK, client.unwatch().get()); diff --git a/utils/rejson.so b/utils/rejson.so new file mode 100755 index 0000000000..20d88ef717 Binary files /dev/null and b/utils/rejson.so differ