forked from valkey-io/valkey-glide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Java: Add INFO() commands to java client (valkey-io#920)
* Update commandmanager to remove optional<route> argument Signed-off-by: Andrew Carbonetto <[email protected]> * Java: Add Info commands to client Signed-off-by: Andrew Carbonetto <[email protected]> * Clean tests Signed-off-by: Andrew Carbonetto <[email protected]> * Fix build.gradle Signed-off-by: Andrew Carbonetto <[email protected]> * Update to merge easier Signed-off-by: Andrew Carbonetto <[email protected]> * Spotless Signed-off-by: Andrew Carbonetto <[email protected]> * Update javadoc for info clustered Signed-off-by: Andrew Carbonetto <[email protected]> --------- Signed-off-by: Andrew Carbonetto <[email protected]>
- Loading branch information
1 parent
47bc798
commit e6a0de5
Showing
12 changed files
with
545 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
java/client/src/main/java/glide/api/commands/ServerManagementClusterCommands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/** Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 */ | ||
package glide.api.commands; | ||
|
||
import glide.api.models.ClusterValue; | ||
import glide.api.models.commands.InfoOptions; | ||
import glide.api.models.configuration.RequestRoutingConfiguration.Route; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Server Management Commands interface. | ||
* | ||
* @see <a href="https://redis.io/commands/?group=server">Server Management Commands</a> | ||
*/ | ||
public interface ServerManagementClusterCommands { | ||
|
||
/** | ||
* Get information and statistics about the Redis server. DEFAULT option is assumed. The command | ||
* will be routed to all primaries. | ||
* | ||
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details. {@link | ||
* InfoOptions.Section#DEFAULT} option is assumed. | ||
* @return Response from Redis cluster with a <code>Map{@literal <String, String>}</code> with | ||
* each address as the key and its corresponding value is the information for the node. | ||
* @example | ||
* <p><code> | ||
* {@literal Map<String, String>} routedInfoResult = clusterClient.info().get().getMultiValue(); | ||
* </code> | ||
*/ | ||
CompletableFuture<ClusterValue<String>> info(); | ||
|
||
/** | ||
* Get information and statistics about the Redis server. DEFAULT option is assumed | ||
* | ||
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details. | ||
* @param route Routing configuration for the command. Client will route the command to the nodes | ||
* defined. | ||
* @return Response from Redis cluster with a <code>String</code> with the requested Sections. | ||
* When specifying a <code>route</code> other than a single node, it returns a <code> | ||
* Map{@literal <String, String>}</code> with each address as the key and its corresponding | ||
* value is the information for the node. | ||
*/ | ||
CompletableFuture<ClusterValue<String>> info(Route route); | ||
|
||
/** | ||
* Get information and statistics about the Redis server. The command will be routed to all | ||
* primaries. | ||
* | ||
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details. | ||
* @param options - A list of {@link InfoOptions.Section} values specifying which sections of | ||
* information to retrieve. When no parameter is provided, the {@link | ||
* InfoOptions.Section#DEFAULT} option is assumed. | ||
* @return Response from Redis cluster with a <code>Map{@literal <String, String>}</code> with | ||
* each address as the key and its corresponding value is the information of the sections | ||
* requested for the node. | ||
*/ | ||
CompletableFuture<ClusterValue<String>> info(InfoOptions options); | ||
|
||
/** | ||
* Get information and statistics about the Redis server. | ||
* | ||
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details. | ||
* @param options - A list of {@link InfoOptions.Section} values specifying which sections of | ||
* information to retrieve. When no parameter is provided, the {@link | ||
* InfoOptions.Section#DEFAULT} option is assumed. | ||
* @param route Routing configuration for the command. Client will route the command to the nodes | ||
* defined. | ||
* @return Response from Redis cluster with a <code>String</code> with the requested sections. | ||
* When specifying a <code>route</code> other than a single node, it returns a <code> | ||
* Map{@literal <String, String>}</code> with each address as the key and its corresponding | ||
* value is the information of the sections requested for the node. | ||
*/ | ||
CompletableFuture<ClusterValue<String>> info(InfoOptions options, Route route); | ||
} |
35 changes: 35 additions & 0 deletions
35
java/client/src/main/java/glide/api/commands/ServerManagementCommands.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 */ | ||
package glide.api.commands; | ||
|
||
import glide.api.models.commands.InfoOptions; | ||
import glide.api.models.commands.InfoOptions.Section; | ||
import java.util.concurrent.CompletableFuture; | ||
|
||
/** | ||
* Server Management Commands interface. | ||
* | ||
* @see <a href="https://redis.io/commands/?group=server">Server Management Commands</a> | ||
*/ | ||
public interface ServerManagementCommands { | ||
|
||
/** | ||
* Get information and statistics about the Redis server. No argument is provided, so the {@link | ||
* Section#DEFAULT} option is assumed. | ||
* | ||
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details. | ||
* @return Response from Redis containing a <code>String</code> with the information for the | ||
* default sections. | ||
*/ | ||
CompletableFuture<String> info(); | ||
|
||
/** | ||
* Get information and statistics about the Redis server. | ||
* | ||
* @see <a href="https://redis.io/commands/info/">redis.io</a> for details. | ||
* @param options A list of {@link Section} values specifying which sections of information to | ||
* retrieve. When no parameter is provided, the {@link Section#DEFAULT} option is assumed. | ||
* @return Response from Redis containing a <code>String</code> with the information for the | ||
* sections requested. | ||
*/ | ||
CompletableFuture<String> info(InfoOptions options); | ||
} |
64 changes: 64 additions & 0 deletions
64
java/client/src/main/java/glide/api/models/commands/InfoOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/** Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 */ | ||
package glide.api.models.commands; | ||
|
||
import glide.api.commands.ServerManagementCommands; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Singular; | ||
|
||
/** | ||
* Optional arguments to {@link ServerManagementCommands#info(InfoOptions)} | ||
* | ||
* @see <a href="https://redis.io/commands/info/">redis.io</a> | ||
*/ | ||
@Builder | ||
public final class InfoOptions { | ||
|
||
@Singular private final List<Section> sections; | ||
|
||
public enum Section { | ||
/** SERVER: General information about the Redis server */ | ||
SERVER, | ||
/** CLIENTS: Client connections section */ | ||
CLIENTS, | ||
/** MEMORY: Memory consumption related information */ | ||
MEMORY, | ||
/** PERSISTENCE: RDB and AOF related information */ | ||
PERSISTENCE, | ||
/** STATS: General statistics */ | ||
STATS, | ||
/** REPLICATION: Master/replica replication information */ | ||
REPLICATION, | ||
/** CPU: CPU consumption statistics */ | ||
CPU, | ||
/** COMMANDSTATS: Redis command statistics */ | ||
COMMANDSTATS, | ||
/** LATENCYSTATS: Redis command latency percentile distribution statistics */ | ||
LATENCYSTATS, | ||
/** SENTINEL: Redis Sentinel section (only applicable to Sentinel instances) */ | ||
SENTINEL, | ||
/** CLUSTER: Redis Cluster section */ | ||
CLUSTER, | ||
/** MODULES: Modules section */ | ||
MODULES, | ||
/** KEYSPACE: Database related statistics */ | ||
KEYSPACE, | ||
/** ERRORSTATS: Redis error statistics */ | ||
ERRORSTATS, | ||
/** ALL: Return all sections (excluding module generated ones) */ | ||
ALL, | ||
/** DEFAULT: Return only the default set of sections */ | ||
DEFAULT, | ||
/** EVERYTHING: Includes all and modules */ | ||
EVERYTHING, | ||
} | ||
|
||
/** | ||
* Converts options enum into a String[] to add to a Redis request. | ||
* | ||
* @return String[] | ||
*/ | ||
public String[] toArgs() { | ||
return sections.stream().map(Object::toString).toArray(String[]::new); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.