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/RedisClient.java b/java/client/src/main/java/glide/api/GlideClient.java similarity index 97% rename from java/client/src/main/java/glide/api/RedisClient.java rename to java/client/src/main/java/glide/api/GlideClient.java index 0f8607afb7..cbafdfea39 100644 --- a/java/client/src/main/java/glide/api/RedisClient.java +++ b/java/client/src/main/java/glide/api/GlideClient.java @@ -53,7 +53,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 +66,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 +81,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 26fc3e86e7..8cfe2d78ad 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, 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 e254d364ba..7674e703ef 100644 --- a/java/client/src/test/java/glide/api/RedisClientTest.java +++ b/java/client/src/test/java/glide/api/GlideClientTest.java @@ -324,12 +324,12 @@ import org.junit.jupiter.params.provider.MethodSource; import redis_request.RedisRequestOuterClass.RequestType; -public class RedisClientTest { +public class GlideClientTest { // bypass import conflict between Set (collection) and Set (enum variant) private static final RequestType pSet = RequestType.Set; - RedisClient service; + GlideClient service; ConnectionManager connectionManager; @@ -339,7 +339,7 @@ public class RedisClientTest { public void setUp() { connectionManager = mock(ConnectionManager.class); commandManager = mock(CommandManager.class); - service = new RedisClient(connectionManager, commandManager); + service = new GlideClient(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 97% rename from java/client/src/test/java/glide/api/RedisClusterClientTest.java rename to java/client/src/test/java/glide/api/GlideClusterClientTest.java index 7a82ff5e35..49fc7dba87 100644 --- a/java/client/src/test/java/glide/api/RedisClusterClientTest.java +++ b/java/client/src/test/java/glide/api/GlideClusterClientTest.java @@ -10,9 +10,6 @@ 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.SortBaseOptions.STORE_COMMAND_STRING; -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.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; @@ -82,9 +79,9 @@ import response.ResponseOuterClass.ConstantResponse; import response.ResponseOuterClass.Response; -public class RedisClusterClientTest { +public class GlideClusterClientTest { - RedisClusterClient service; + GlideClusterClient service; ConnectionManager connectionManager; @@ -96,7 +93,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 @@ -124,7 +121,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); @@ -160,7 +158,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; @@ -356,28 +354,6 @@ public void echo_returns_success() { assertEquals(message, echo); } - @SneakyThrows - @Test - public void echo_binary_returns_success() { - // setup - GlideString message = gs("GLIDE FOR REDIS"); - GlideString[] arguments = new GlideString[] {message}; - CompletableFuture testResponse = new CompletableFuture<>(); - testResponse.complete(message); - - // match on protobuf request - when(commandManager.submitNewCommand(eq(Echo), eq(arguments), any())) - .thenReturn(testResponse); - - // exercise - CompletableFuture response = service.echo(message); - GlideString echo = response.get(); - - // verify - assertEquals(testResponse, response); - assertEquals(message, echo); - } - @SneakyThrows @Test public void echo_with_route_returns_success() { @@ -401,29 +377,6 @@ public void echo_with_route_returns_success() { assertEquals(message, echo); } - @SneakyThrows - @Test - public void echo_binary_with_route_returns_success() { - // setup - GlideString message = gs("GLIDE FOR REDIS"); - GlideString[] arguments = new GlideString[] {message}; - CompletableFuture> testResponse = new CompletableFuture<>(); - testResponse.complete(ClusterValue.ofSingleValue(message)); - - // match on protobuf request - when(commandManager.>submitNewCommand( - eq(Echo), eq(arguments), eq(RANDOM), any())) - .thenReturn(testResponse); - - // exercise - CompletableFuture> response = service.echo(message, RANDOM); - GlideString echo = response.get().getSingleValue(); - - // verify - assertEquals(testResponse, response); - assertEquals(message, echo); - } - @SneakyThrows @Test public void info_returns_string() { @@ -726,7 +679,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() { @@ -751,7 +704,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..38d72d74e8 100644 --- a/java/client/src/test/java/glide/connection/ConnectionWithGlideMockTests.java +++ b/java/client/src/test/java/glide/connection/ConnectionWithGlideMockTests.java @@ -10,7 +10,7 @@ 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; @@ -64,7 +64,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 +183,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..8c3ca0c5b2 100644 --- a/java/client/src/test/java/glide/managers/ConnectionManagerTest.java +++ b/java/client/src/test/java/glide/managers/ConnectionManagerTest.java @@ -19,10 +19,10 @@ 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; @@ -69,7 +69,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 +82,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 +93,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 +108,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 +119,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 +180,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 +197,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 +217,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 +227,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/examples/src/main/java/glide/examples/ExamplesApp.java b/java/examples/src/main/java/glide/examples/ExamplesApp.java index 98dfbe6d59..b3685fd425 100644 --- a/java/examples/src/main/java/glide/examples/ExamplesApp.java +++ b/java/examples/src/main/java/glide/examples/ExamplesApp.java @@ -1,9 +1,9 @@ /** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */ package glide.examples; -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 java.util.concurrent.ExecutionException; public class ExamplesApp { @@ -18,14 +18,14 @@ private static void runGlideExamples() { Integer port = 6379; boolean useSsl = false; - RedisClientConfiguration config = - RedisClientConfiguration.builder() + GlideClientConfiguration config = + GlideClientConfiguration.builder() .address(NodeAddress.builder().host(host).port(port).build()) .useTLS(useSsl) .build(); try { - RedisClient client = RedisClient.CreateClient(config).get(); + GlideClient client = GlideClient.CreateClient(config).get(); System.out.println("PING: " + client.ping().get()); System.out.println("PING(found you): " + client.ping("found you").get()); 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..577f8b4fcd 100644 --- a/java/integTest/src/test/java/glide/SharedClientTests.java +++ b/java/integTest/src/test/java/glide/SharedClientTests.java @@ -8,8 +8,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import glide.api.BaseClient; -import glide.api.RedisClient; -import glide.api.RedisClusterClient; +import glide.api.GlideClient; +import glide.api.GlideClusterClient; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -28,17 +28,17 @@ @Timeout(25) // seconds public class SharedClientTests { - 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; @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()) + GlideClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(10000).build()) .get(); clients = List.of(Arguments.of(standaloneClient), Arguments.of(clusterClient)); diff --git a/java/integTest/src/test/java/glide/SharedCommandTests.java b/java/integTest/src/test/java/glide/SharedCommandTests.java index 408f07ed4c..4859090caa 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; @@ -78,9 +78,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; @@ -109,8 +109,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; @@ -122,16 +122,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()) @@ -2509,9 +2509,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()); @@ -2581,9 +2581,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()); @@ -2725,7 +2725,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( @@ -3055,7 +3056,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)); @@ -3122,7 +3124,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)); @@ -3197,7 +3200,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, @@ -3264,7 +3268,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), @@ -3304,7 +3309,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( @@ -3440,7 +3446,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, @@ -3570,9 +3577,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()); @@ -3755,9 +3762,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; @@ -4052,7 +4059,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, @@ -4107,7 +4115,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()); @@ -4185,9 +4194,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(); @@ -4196,7 +4205,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, @@ -5150,7 +5160,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", @@ -5163,7 +5174,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", @@ -5441,7 +5453,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 @@ -5641,9 +5654,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()); } @@ -5754,9 +5767,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); @@ -5890,9 +5905,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()); @@ -6008,13 +6023,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()); @@ -6059,7 +6076,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", @@ -6068,7 +6086,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()); @@ -6113,9 +6132,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()); @@ -6148,7 +6167,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); @@ -6156,7 +6176,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(); @@ -6371,16 +6392,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) }) @@ -6519,7 +6548,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()); // returns actual cardinality if limit is higher 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/ClusterClientTests.java b/java/integTest/src/test/java/glide/cluster/ClusterClientTests.java index 65a4f40572..37bc38963b 100644 --- a/java/integTest/src/test/java/glide/cluster/ClusterClientTests.java +++ b/java/integTest/src/test/java/glide/cluster/ClusterClientTests.java @@ -10,7 +10,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue; -import glide.api.RedisClusterClient; +import glide.api.GlideClusterClient; import glide.api.models.configuration.RedisCredentials; import glide.api.models.exceptions.ClosingException; import glide.api.models.exceptions.RequestException; @@ -30,8 +30,8 @@ public void register_client_name_and_version() { REDIS_VERSION.isGreaterThanOrEqualTo(minVersion), "Redis version required >= " + minVersion); - RedisClusterClient client = - RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get(); + GlideClusterClient client = + GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get(); String info = (String) client.customCommand(new String[] {"CLIENT", "INFO"}).get().getSingleValue(); @@ -44,8 +44,8 @@ public void register_client_name_and_version() { @SneakyThrows @Test public void can_connect_with_auth_requirepass() { - RedisClusterClient client = - RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get(); + GlideClusterClient client = + GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get(); String password = "TEST_AUTH"; client.customCommand(new String[] {"CONFIG", "SET", "requirepass", password}).get(); @@ -54,12 +54,12 @@ public void can_connect_with_auth_requirepass() { ExecutionException exception = assertThrows( ExecutionException.class, - () -> RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get()); + () -> GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get()); assertTrue(exception.getCause() instanceof ClosingException); // Creation of a new client with credentials - RedisClusterClient auth_client = - RedisClusterClient.CreateClient( + GlideClusterClient auth_client = + GlideClusterClient.CreateClient( commonClusterClientConfig() .credentials(RedisCredentials.builder().password(password).build()) .build()) @@ -81,8 +81,8 @@ public void can_connect_with_auth_requirepass() { @SneakyThrows @Test public void can_connect_with_auth_acl() { - RedisClusterClient client = - RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get(); + GlideClusterClient client = + GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get(); String username = "testuser"; String password = "TEST_AUTH"; @@ -112,8 +112,8 @@ public void can_connect_with_auth_acl() { assertEquals(OK, client.set(key, value).get()); // Creation of a new cluster client with credentials - RedisClusterClient testUserClient = - RedisClusterClient.CreateClient( + GlideClusterClient testUserClient = + GlideClusterClient.CreateClient( commonClusterClientConfig() .credentials( RedisCredentials.builder().username(username).password(password).build()) @@ -135,8 +135,8 @@ public void can_connect_with_auth_acl() { @SneakyThrows @Test public void client_name() { - RedisClusterClient client = - RedisClusterClient.CreateClient( + GlideClusterClient client = + GlideClusterClient.CreateClient( commonClusterClientConfig().clientName("TEST_CLIENT_NAME").build()) .get(); @@ -150,8 +150,8 @@ public void client_name() { @Test @SneakyThrows public void closed_client_throws_ExecutionException_with_ClosingException_as_cause() { - RedisClusterClient client = - RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get(); + GlideClusterClient client = + GlideClusterClient.CreateClient(commonClusterClientConfig().build()).get(); client.close(); ExecutionException executionException = diff --git a/java/integTest/src/test/java/glide/cluster/ClusterTransactionTests.java b/java/integTest/src/test/java/glide/cluster/ClusterTransactionTests.java index 5aacc3c65a..7aac4548f2 100644 --- a/java/integTest/src/test/java/glide/cluster/ClusterTransactionTests.java +++ b/java/integTest/src/test/java/glide/cluster/ClusterTransactionTests.java @@ -16,11 +16,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; @@ -39,14 +39,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()) @@ -184,7 +184,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()); @@ -222,7 +223,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()); } diff --git a/java/integTest/src/test/java/glide/cluster/CommandTests.java b/java/integTest/src/test/java/glide/cluster/CommandTests.java index c8793d33b4..d41ede4b1a 100644 --- a/java/integTest/src/test/java/glide/cluster/CommandTests.java +++ b/java/integTest/src/test/java/glide/cluster/CommandTests.java @@ -45,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assumptions.assumeTrue; -import glide.api.RedisClusterClient; +import glide.api.GlideClusterClient; import glide.api.models.ClusterTransaction; import glide.api.models.ClusterValue; import glide.api.models.GlideString; @@ -87,7 +87,7 @@ @Timeout(10) // seconds public class CommandTests { - private static RedisClusterClient clusterClient = null; + private static GlideClusterClient clusterClient = null; private static final String INITIAL_VALUE = "VALUE"; @@ -139,7 +139,7 @@ public class CommandTests { @SneakyThrows public static void init() { clusterClient = - RedisClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(7000).build()) + GlideClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(7000).build()) .get(); } @@ -1267,7 +1267,7 @@ public void functionStats_and_functionKill_without_route() { assertEquals(libName, clusterClient.functionLoad(code, true).get()); try (var testClient = - RedisClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(7000).build()) + GlideClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(7000).build()) .get()) { // call the function without await // Using a random primary node route, otherwise FCALL can go to a replica. @@ -1348,7 +1348,7 @@ public void functionStats_and_functionKill_with_route(boolean singleNodeRoute) { assertEquals(libName, clusterClient.functionLoad(code, true, route).get()); try (var testClient = - RedisClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(7000).build()) + GlideClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(7000).build()) .get()) { // call the function without await var promise = testClient.fcall(funcName, route); @@ -1434,7 +1434,7 @@ public void functionStats_and_functionKill_with_key_based_route() { assertEquals(libName, clusterClient.functionLoad(code, true, route).get()); try (var testClient = - RedisClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(7000).build()) + GlideClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(7000).build()) .get()) { // call the function without await var promise = testClient.fcall(funcName, new String[] {key}, new String[0]); @@ -1505,7 +1505,7 @@ public void functionStats_and_functionKill_write_function() { assertEquals(libName, clusterClient.functionLoad(code, true, route).get()); try (var testClient = - RedisClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(7000).build()) + GlideClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(7000).build()) .get()) { // call the function without await var promise = testClient.fcall(funcName, new String[] {key}, new String[0]); diff --git a/java/integTest/src/test/java/glide/standalone/CommandTests.java b/java/integTest/src/test/java/glide/standalone/CommandTests.java index d69cb817e8..d5cbf880c1 100644 --- a/java/integTest/src/test/java/glide/standalone/CommandTests.java +++ b/java/integTest/src/test/java/glide/standalone/CommandTests.java @@ -38,7 +38,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.GlideString; import glide.api.models.commands.InfoOptions; import glide.api.models.commands.SortOptions; @@ -63,13 +63,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 @@ -590,7 +590,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()); @@ -627,7 +628,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); @@ -659,7 +660,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(); @@ -698,7 +700,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]); @@ -730,7 +732,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(); @@ -917,7 +920,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()); @@ -973,7 +977,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 fa82d16f42..e71d99dbda 100644 --- a/java/integTest/src/test/java/glide/standalone/TransactionTests.java +++ b/java/integTest/src/test/java/glide/standalone/TransactionTests.java @@ -17,7 +17,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.GlideString; import glide.api.models.Transaction; import glide.api.models.commands.InfoOptions; @@ -39,12 +39,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