Skip to content

Commit

Permalink
Update JavaDocs and comments
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Jan 2, 2024
1 parent 91674ae commit d23001f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 15 deletions.
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 @@ -4,7 +4,7 @@
import glide.managers.ConnectionManager;
import lombok.AllArgsConstructor;

/** Base Client class for connecting to Redis */
/** Base Client class for Redis */
@AllArgsConstructor
public abstract class BaseClient implements AutoCloseable {

Expand Down
7 changes: 3 additions & 4 deletions java/client/src/main/java/glide/api/RedisClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;

/** Factory class for creating Glide/Redis-client connections */
/** Async (non-blocking) client for Redis in Standalone mode. Use {@link #CreateClient()} to
* request a client to Redis. */
public class RedisClient extends BaseClient {

public static CompletableFuture<RedisClient> CreateClient() {
Expand All @@ -29,14 +30,12 @@ public static CompletableFuture<RedisClient> CreateClient(String host, Integer p
}

/**
* Async (non-blocking) connection to Redis.
* Request an async (non-blocking) Redis client in Standalone mode.
*
* @param config - Redis Client Configuration
* @return a promise to connect and return a RedisClient
*/
public static CompletableFuture<RedisClient> CreateClient(RedisClientConfiguration config) {
AtomicBoolean connectionStatus = new AtomicBoolean(false);

CallbackDispatcher callbackDispatcher = new CallbackDispatcher();
ChannelHandler channelHandler = new ChannelHandler(callbackDispatcher, getSocket());
var connectionManager = new ConnectionManager(channelHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import lombok.Singular;
import lombok.experimental.SuperBuilder;

/** Represents the configuration settings for a Redis client. */
/** Configuration settings class for creating a Redis Client. Shared settings for both a standalone and cluster clients. */
@Getter
@SuperBuilder
public abstract class BaseClientConfiguration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CallbackDispatcher {
private final AtomicInteger requestId = new AtomicInteger(0);

/**
* Storage of Futures to handle responses. Map key is callback id, which starts from 1.<br>
* Storage of Futures to handle responses. Map key is callback id, which starts from 0.
* Each future is a promise for every submitted by user request.
*/
private final Map<Integer, CompletableFuture<Response>> responses = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import response.ResponseOuterClass.Response;

/**
* Class responsible for handling calls to/from a netty.io {@link Channel}.<br>
* Class responsible for handling calls to/from a netty.io {@link Channel}.
* Uses a {@link CallbackDispatcher} to record callbacks of every request sent.
*/
public class ChannelHandler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static class Capabilities {
new Capabilities(isKQueueAvailable(), isEPollAvailable(), false, false);

/**
* Thread pools supplied to <em>Netty</em> to perform all async IO.<br>
* Thread pools supplied to <em>Netty</em> to perform all async IO.
* Map key is supposed to be pool name + thread count as a string concat product.
*/
private static final Map<String, EventLoopGroup> groups = new ConcurrentHashMap<>();
Expand Down Expand Up @@ -123,7 +123,7 @@ public static Class<? extends DomainSocketChannel> getClientUdsNettyChannelType(

/**
* A JVM shutdown hook to be registered. It is responsible for closing connection and freeing
* resources. It is recommended to use a class instead of lambda to ensure that it is called.<br>
* resources. It is recommended to use a class instead of lambda to ensure that it is called.
* See {@link Runtime#addShutdownHook}.
*/
private static class ShutdownHook implements Runnable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CallbackManager {
private final AtomicInteger requestId = new AtomicInteger(0);

/**
* Storage of Futures to handle responses. Map key is callback id, which starts from 1.<br>
* Storage of Futures to handle responses. Map key is callback id, which starts from 0.
* Each future is a promise for every submitted by user request.
*/
private final Map<Integer, CompletableFuture<Response>> responses = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ private ConnectionRequestOuterClass.ReadFrom mapReadFromEnum(ReadFrom readFrom)

/** Check a response received from Glide. */
private Void checkGlideRsResponse(Response response) {
// TODO do we need to check callback value? It could be -1 or 0
if (response.hasRequestError()) {
// TODO do we need to support different types of exceptions and distinguish them by type?
// TODO support different types of exceptions and distinguish them by type:
throw new RuntimeException(
String.format(
"%s: %s",
Expand All @@ -171,8 +170,6 @@ private Void checkGlideRsResponse(Response response) {
} else if (response.hasRespPointer()) {
throw new RuntimeException("Unexpected data in response");
}
// TODO commented out due to #710 https://github.com/aws/babushka/issues/710
// empty response means a successful connection
// throw new IllegalStateException("A malformed response received: " + response.toString());
return null;
}
Expand Down

0 comments on commit d23001f

Please sign in to comment.