Skip to content

Commit

Permalink
Java: Rename RedisClient, RedisClusterClient to GlideClient, GlideClu…
Browse files Browse the repository at this point in the history
…sterClient (#1671)
  • Loading branch information
shohamazon authored Jul 7, 2024
1 parent 929e667 commit 2eb51e2
Show file tree
Hide file tree
Showing 34 changed files with 310 additions and 314 deletions.
4 changes: 2 additions & 2 deletions java/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ The return types of these methods are in the form of a `CompletableFuture`, whic
When implementing a command, include both a unit test and an integration test.
Implement unit tests in the following files:
- [RedisClientTest.java](https://github.com/aws/glide-for-redis/blob/main/java/client/src/test/java/glide/api/RedisClientTest.java) for standalone commands.
- [RedisClusterClientTest.java](https://github.com/aws/glide-for-redis/blob/main/java/client/src/test/java/glide/api/RedisClusterClientTest.java) for cluster commands.
- [GlideClientTest.java](https://github.com/aws/glide-for-redis/blob/main/java/client/src/test/java/glide/api/GlideClientTest.java) for standalone commands.
- [GlideClusterClientTest.java](https://github.com/aws/glide-for-redis/blob/main/java/client/src/test/java/glide/api/GlideClusterClientTest.java) for cluster commands.
These files are found in the java/client/src/test/java/glide/api path.
Implement integration tests in the following files:
Expand Down
4 changes: 2 additions & 2 deletions java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ public class Main {
Integer port6 = 7006;
boolean useSsl = false;

RedisClusterClientConfiguration config =
RedisClusterClientConfiguration.builder()
GlideClusterClientConfiguration config =
GlideClusterClientConfiguration.builder()
.address(NodeAddress.builder().host(host).port(port1).port(port2).port(port3).port(port4).port(port5).port(port6).build())
.useTLS(useSsl)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,14 +17,14 @@

/** A Glide client with async capabilities */
public class GlideAsyncClient implements AsyncClient<String> {
private BaseClient redisClient;
private BaseClient glideClient;

@Override
public void connectToRedis(ConnectionSettings connectionSettings) {

if (connectionSettings.clusterMode) {
RedisClusterClientConfiguration config =
RedisClusterClientConfiguration.builder()
GlideClusterClientConfiguration config =
GlideClusterClientConfiguration.builder()
.address(
NodeAddress.builder()
.host(connectionSettings.host)
Expand All @@ -33,14 +33,14 @@ public void connectToRedis(ConnectionSettings connectionSettings) {
.useTLS(connectionSettings.useSsl)
.build();
try {
redisClient = RedisClusterClient.createClient(config).get(10, SECONDS);
glideClient = 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)
Expand All @@ -50,7 +50,7 @@ public void connectToRedis(ConnectionSettings connectionSettings) {
.build();

try {
redisClient = RedisClient.createClient(config).get(10, SECONDS);
glideClient = GlideClient.createClient(config).get(10, SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
throw new RuntimeException(e);
}
Expand All @@ -59,18 +59,18 @@ public void connectToRedis(ConnectionSettings connectionSettings) {

@Override
public CompletableFuture<String> asyncSet(String key, String value) {
return redisClient.set(key, value);
return glideClient.set(key, value);
}

@Override
public CompletableFuture<String> asyncGet(String key) {
return redisClient.get(key);
return glideClient.get(key);
}

@Override
public void closeConnection() {
try {
redisClient.close();
glideClient.close();
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
Expand Down
2 changes: 1 addition & 1 deletion java/client/src/main/java/glide/api/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ protected static class ClientBuilder {
* @param config Redis client Configuration.
* @param constructor Redis client constructor reference.
* @param <T> Client type.
* @return a Future to connect and return a RedisClient.
* @return a Future to connect and return a client.
*/
protected static <T extends BaseClient> CompletableFuture<T> createClient(
@NonNull BaseClientConfiguration config, Function<ClientBuilder, T> constructor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import glide.api.models.commands.SortOptionsBinary;
import glide.api.models.commands.function.FunctionRestorePolicy;
import glide.api.models.commands.scan.ScanOptions;
import glide.api.models.configuration.RedisClientConfiguration;
import glide.api.models.configuration.GlideClientConfiguration;
import glide.utils.ArgsBuilder;
import java.util.Arrays;
import java.util.Map;
Expand All @@ -64,10 +64,9 @@
import org.apache.commons.lang3.ArrayUtils;

/**
* Async (non-blocking) client for Redis in Standalone mode. Use {@link #createClient} to request a
* client to Redis.
* Async (non-blocking) client for Standalone mode. Use {@link #createClient} to request a client.
*/
public class RedisClient extends BaseClient
public class GlideClient extends BaseClient
implements GenericCommands,
ServerManagementCommands,
ConnectionManagementCommands,
Expand All @@ -77,19 +76,19 @@ public class RedisClient extends BaseClient
/**
* A constructor. Use {@link #createClient} to get a client. Made protected to simplify testing.
*/
protected RedisClient(ClientBuilder builder) {
protected GlideClient(ClientBuilder builder) {
super(builder);
}

/**
* Async request for an async (non-blocking) Redis client in Standalone mode.
* Async request for an async (non-blocking) client in Standalone mode.
*
* @param config Redis client Configuration.
* @return A Future to connect and return a RedisClient.
* @param config Glide client Configuration.
* @return A Future to connect and return a GlideClient.
*/
public static CompletableFuture<RedisClient> createClient(
@NonNull RedisClientConfiguration config) {
return createClient(config, RedisClient::new);
public static CompletableFuture<GlideClient> createClient(
@NonNull GlideClientConfiguration config) {
return createClient(config, GlideClient::new);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import glide.api.models.commands.function.FunctionRestorePolicy;
import glide.api.models.commands.scan.ClusterScanCursor;
import glide.api.models.commands.scan.ScanOptions;
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.ffi.resolvers.ClusterScanCursorResolver;
Expand All @@ -74,11 +74,8 @@
import org.apache.commons.lang3.ArrayUtils;
import response.ResponseOuterClass.Response;

/**
* Async (non-blocking) client for Redis in Cluster mode. Use {@link #createClient} to request a
* client to Redis.
*/
public class RedisClusterClient extends BaseClient
/** Async (non-blocking) client for Cluster mode. Use {@link #createClient} to request a client. */
public class GlideClusterClient extends BaseClient
implements ConnectionManagementClusterCommands,
GenericClusterCommands,
ServerManagementClusterCommands,
Expand All @@ -87,19 +84,19 @@ public class RedisClusterClient extends BaseClient
PubSubClusterCommands {

/** A private constructor. Use {@link #createClient} to get a client. */
RedisClusterClient(ClientBuilder builder) {
GlideClusterClient(ClientBuilder builder) {
super(builder);
}

/**
* Async request for an async (non-blocking) Redis client in Cluster mode.
* Async request for an async (non-blocking) client in Cluster mode.
*
* @param config Redis cluster client Configuration.
* @return A Future to connect and return a RedisClusterClient.
* @param config Glide cluster client Configuration.
* @return A Future to connect and return a GlideClusterClient.
*/
public static CompletableFuture<RedisClusterClient> createClient(
@NonNull RedisClusterClientConfiguration config) {
return createClient(config, RedisClusterClient::new);
public static CompletableFuture<GlideClusterClient> createClient(
@NonNull GlideClusterClientConfiguration config) {
return createClient(config, GlideClusterClient::new);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import static command_request.CommandRequestOuterClass.RequestType.SortReadOnly;
import static glide.api.models.commands.SortBaseOptions.STORE_COMMAND_STRING;

import glide.api.RedisClusterClient;
import glide.api.GlideClusterClient;
import glide.api.models.commands.SortClusterOptions;
import lombok.NonNull;

/**
* Transaction implementation for cluster {@link RedisClusterClient}. Transactions allow the
* Transaction implementation for cluster {@link GlideClusterClient}. Transactions allow the
* execution of a group of commands in a single step.
*
* <p>Transaction Response: An <code>array</code> of command responses is returned by the client
* {@link RedisClusterClient#exec} command, in the order they were given. Each element in the array
* {@link GlideClusterClient#exec} command, in the order they were given. Each element in the array
* represents a command given to the {@link ClusterTransaction}. The response for each command
* depends on the executed Redis command. Specific response types are documented alongside each
* method.
Expand Down
6 changes: 3 additions & 3 deletions java/client/src/main/java/glide/api/models/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
import static glide.api.commands.GenericCommands.DB_REDIS_API;
import static glide.api.models.commands.SortBaseOptions.STORE_COMMAND_STRING;

import glide.api.RedisClient;
import glide.api.GlideClient;
import glide.api.models.commands.SortOptions;
import glide.api.models.commands.scan.ScanOptions;
import lombok.NonNull;

/**
* Transaction implementation for standalone {@link RedisClient}. Transactions allow the execution
* Transaction implementation for standalone {@link GlideClient}. Transactions allow the execution
* of a group of commands in a single step.
*
* <p>Transaction Response: An <code>array</code> of command responses is returned by the client
* {@link RedisClient#exec} API, in the order they were given. Each element in the array represents
* {@link GlideClient#exec} API, in the order they were given. Each element in the array represents
* a command given to the {@link Transaction}. The response for each command depends on the executed
* Valkey command. Specific response types are documented alongside each method.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -11,15 +11,15 @@
* Defines flushing mode for:
*
* <ul>
* <li><code>FLUSHALL</code> command implemented by {@link RedisClient#flushall(FlushMode)},
* {@link RedisClusterClient#flushall(FlushMode)}, and {@link
* RedisClusterClient#flushall(FlushMode, SingleNodeRoute)}.
* <li><code>FLUSHDB</code> command implemented by {@link RedisClient#flushdb(FlushMode)}, {@link
* RedisClusterClient#flushdb(FlushMode)}, and {@link RedisClusterClient#flushdb(FlushMode,
* <li><code>FLUSHALL</code> command implemented by {@link GlideClient#flushall(FlushMode)},
* {@link GlideClusterClient#flushall(FlushMode)}, and {@link
* GlideClusterClient#flushall(FlushMode, SingleNodeRoute)}.
* <li><code>FLUSHDB</code> command implemented by {@link GlideClient#flushdb(FlushMode)}, {@link
* GlideClusterClient#flushdb(FlushMode)}, and {@link GlideClusterClient#flushdb(FlushMode,
* SingleNodeRoute)}.
* <li><code>FUNCTION FLUSH</code> 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)}.
* </ul>
*
* @see <a href="https://valkey.io/commands/flushall/">flushall</a>, <a
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */
package glide.api.models.configuration;

import glide.api.RedisClusterClient;
import glide.api.GlideClusterClient;
import glide.api.models.GlideString;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -10,7 +10,7 @@
import lombok.Getter;

/**
* Subscription configuration for {@link RedisClusterClient}.
* Subscription configuration for {@link GlideClusterClient}.
*
* @example
* <pre>{@code
Expand All @@ -22,9 +22,9 @@
* .subscription(SHARDED, "data")
* .callback(callback)
* .build();
* // Now it could be supplied to `RedisClusterClientConfiguration`:
* RedisClusterClientConfiguration clientConfiguration =
* RedisClusterClientConfiguration.builder()
* // Now it could be supplied to `GlideClusterClientConfiguration`:
* GlideClusterClientConfiguration clientConfiguration =
* GlideClusterClientConfiguration.builder()
* .address(NodeAddress.builder().port(6379).build())
* .subscriptionConfiguration(subscriptionConfiguration)
* .build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */
package glide.api.models.configuration;

import glide.api.RedisClient;
import glide.api.GlideClient;
import lombok.Getter;
import lombok.experimental.SuperBuilder;

/**
* Represents the configuration settings for a Standalone {@link RedisClient}.
* Represents the configuration settings for a Standalone {@link GlideClient}.
*
* @example
* <pre>{@code
* RedisClientConfiguration redisClientConfiguration =
* RedisClientConfiguration.builder()
* GlideClientConfiguration glideClientConfiguration =
* GlideClientConfiguration.builder()
* .address(node1address)
* .address(node2address)
* .useTLS(true)
Expand All @@ -27,7 +27,7 @@
*/
@Getter
@SuperBuilder
public class RedisClientConfiguration extends BaseClientConfiguration {
public class GlideClientConfiguration extends BaseClientConfiguration {
/** Strategy used to determine how and when to reconnect, in case of connection failures. */
private final BackoffStrategy reconnectStrategy;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/** Copyright Valkey GLIDE Project Contributors - SPDX Identifier: Apache-2.0 */
package glide.api.models.configuration;

import glide.api.RedisClusterClient;
import glide.api.GlideClusterClient;
import lombok.Getter;
import lombok.experimental.SuperBuilder;

/**
* Represents the configuration settings for a Cluster Redis client {@link RedisClusterClient}.
* Represents the configuration settings for a Cluster Redis client {@link GlideClusterClient}.
*
* @apiNote Currently, the reconnection strategy in cluster mode is not configurable, and
* exponential backoff with fixed values is used.
* @example
* <pre>{@code
* RedisClientConfiguration redisClientConfiguration =
* RedisClientConfiguration.builder()
* GlideClientConfiguration glideClientConfiguration =
* GlideClientConfiguration.builder()
* .address(node1address)
* .address(node2address)
* .useTLS(true)
Expand All @@ -27,7 +27,7 @@
*/
@SuperBuilder
@Getter
public class RedisClusterClientConfiguration extends BaseClientConfiguration {
public class GlideClusterClientConfiguration extends BaseClientConfiguration {

/** Subscription configuration for the current client. */
private final ClusterSubscriptionConfiguration subscriptionConfiguration;
Expand Down
Loading

0 comments on commit 2eb51e2

Please sign in to comment.