Package glide.api.commands
Interface NodeManagementCommands
-
- All Known Implementing Classes:
GlideClusterClient
public interface NodeManagementCommandsSupports commands for managing cluster node membership and replication.- See Also:
- Cluster Commands
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.Long>clusterCountFailureReports(java.lang.String nodeId)Returns the number of failure reports for the specified node.java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Long>>clusterCountFailureReports(java.lang.String nodeId, RequestRoutingConfiguration.Route route)Returns the number of failure reports for the specified node.java.util.concurrent.CompletableFuture<java.lang.String>clusterForget(java.lang.String nodeId)Removes a node from the cluster.java.util.concurrent.CompletableFuture<java.lang.String>clusterMeet(java.lang.String host, long port)Adds a new node to the cluster.java.util.concurrent.CompletableFuture<ClusterValue<java.lang.String>>clusterMeet(java.lang.String host, long port, RequestRoutingConfiguration.Route route)Adds a new node to the cluster.java.util.concurrent.CompletableFuture<java.lang.String[]>clusterReplicas(java.lang.String nodeId)Returns a list of replicas (slaves) for the specified primary node.java.util.concurrent.CompletableFuture<ClusterValue<java.lang.String[]>>clusterReplicas(java.lang.String nodeId, RequestRoutingConfiguration.Route route)Returns a list of replicas (slaves) for the specified primary node.java.util.concurrent.CompletableFuture<java.lang.String>clusterReplicate(java.lang.String nodeId)Configures the current node to replicate data from a primary node identified bynodeId.
-
-
-
Method Detail
-
clusterMeet
java.util.concurrent.CompletableFuture<java.lang.String> clusterMeet(java.lang.String host, long port)Adds a new node to the cluster. This command is used to connect a new node to the cluster by specifying the IP address and port of the node to add.
The command will be routed to a random node in the cluster.- Parameters:
host- The IP address or hostname of the node to add to the cluster.port- The port number of the node to add to the cluster.- Returns:
OKif the node was successfully added to the cluster.- See Also:
- valkey.io for details.
- Example:
String result = clusterClient.clusterMeet("192.168.1.100", 6379).get(); assert result.equals("OK");
-
clusterMeet
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.String>> clusterMeet(java.lang.String host, long port, RequestRoutingConfiguration.Route route)
Adds a new node to the cluster. This command is used to connect a new node to the cluster by specifying the IP address and port of the node to add.- Parameters:
host- The IP address or hostname of the node to add to the cluster.port- The port number of the node to add to the cluster.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
OKif the node was successfully added to the cluster. When specifying arouteother than a single node, it returns aMap<String, String>with each address as the key and its corresponding result.- See Also:
- valkey.io for details.
- Example:
ClusterValue<String> result = clusterClient.clusterMeet("192.168.1.100", 6379, ALL_PRIMARIES).get(); // Command sent to all primary nodes, expecting MultiValue result. for (Map.Entry<String, String> entry : result.getMultiValue().entrySet()) { System.out.println("Node [" + entry.getKey() + "]: " + entry.getValue()); }
-
clusterForget
java.util.concurrent.CompletableFuture<java.lang.String> clusterForget(java.lang.String nodeId)
Removes a node from the cluster. The node is specified by its ID. This command must be sent to a node that is not the one being removed.
The command will be routed to a random node in the cluster.Warning: This is a permanent operation. Once a node is forgotten, it must be re-added to the cluster using
clusterMeet(String, long)if you wish to include it again.- Parameters:
nodeId- The ID of the node to remove from the cluster. The node ID is a 40-character hexadecimal string.- Returns:
OKif the node was successfully removed from the cluster.- See Also:
- valkey.io for details.
- Example:
String result = clusterClient.clusterForget("1234567890abcdef1234567890abcdef12345678").get(); assert result.equals("OK");
-
clusterReplicate
java.util.concurrent.CompletableFuture<java.lang.String> clusterReplicate(java.lang.String nodeId)
Configures the current node to replicate data from a primary node identified bynodeId. This command reconfigures a node to become a replica of the specified primary.
The command must be sent to the node that should become the replica.- Parameters:
nodeId- The ID of the primary node to replicate. The node ID is a 40-character hexadecimal string.- Returns:
OKif the node was successfully configured as a replica.- See Also:
- valkey.io for details.
- Example:
String result = clusterClient.clusterReplicate("1234567890abcdef1234567890abcdef12345678").get(); assert result.equals("OK");
-
clusterReplicas
java.util.concurrent.CompletableFuture<java.lang.String[]> clusterReplicas(java.lang.String nodeId)
Returns a list of replicas (slaves) for the specified primary node. Each line in the output represents a replica and contains information similar to theCLUSTER NODESformat.
The command will be routed to a random node in the cluster.- Parameters:
nodeId- The ID of the primary node to get replicas for. The node ID is a 40-character hexadecimal string.- Returns:
- An array of strings, where each string contains information about a replica node.
- See Also:
- valkey.io for details.
- Example:
String[] replicas = clusterClient.clusterReplicas("1234567890abcdef1234567890abcdef12345678").get(); for (String replica : replicas) { System.out.println("Replica: " + replica); }
-
clusterReplicas
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.String[]>> clusterReplicas(java.lang.String nodeId, RequestRoutingConfiguration.Route route)
Returns a list of replicas (slaves) for the specified primary node. Each line in the output represents a replica and contains information similar to theCLUSTER NODESformat.- Parameters:
nodeId- The ID of the primary node to get replicas for. The node ID is a 40-character hexadecimal string.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- An array of strings, where each string contains information about a replica node. When
specifying a
routeother than a single node, it returns aMap<String, String[]>with each address as the key and its corresponding result. - See Also:
- valkey.io for details.
- Example:
ClusterValue<String[]> replicas = clusterClient.clusterReplicas( "1234567890abcdef1234567890abcdef12345678", ALL_PRIMARIES).get(); // Command sent to all primary nodes, expecting MultiValue result. for (Map.Entry<String, String[]> entry : replicas.getMultiValue().entrySet()) { System.out.println("Node [" + entry.getKey() + "]:"); for (String replica : entry.getValue()) { System.out.println(" Replica: " + replica); } }
-
clusterCountFailureReports
java.util.concurrent.CompletableFuture<java.lang.Long> clusterCountFailureReports(java.lang.String nodeId)
Returns the number of failure reports for the specified node. Failure reports are the way nodes in the cluster signal that another node might be in a failure state.
The command will be routed to a random node in the cluster.- Parameters:
nodeId- The ID of the node to get failure report count for. The node ID is a 40-character hexadecimal string.- Returns:
- The number of active failure reports for the specified node.
- See Also:
- valkey.io for details.
- Example:
Long failureCount = clusterClient.clusterCountFailureReports( "1234567890abcdef1234567890abcdef12345678").get(); System.out.println("Failure reports: " + failureCount);
-
clusterCountFailureReports
java.util.concurrent.CompletableFuture<ClusterValue<java.lang.Long>> clusterCountFailureReports(java.lang.String nodeId, RequestRoutingConfiguration.Route route)
Returns the number of failure reports for the specified node. Failure reports are the way nodes in the cluster signal that another node might be in a failure state.- Parameters:
nodeId- The ID of the node to get failure report count for. The node ID is a 40-character hexadecimal string.route- Specifies the routing configuration for the command. The client will route the command to the nodes defined byroute.- Returns:
- The number of active failure reports for the specified node. When specifying a
routeother than a single node, it returns aMap<String, Long>with each address as the key and its corresponding result. - See Also:
- valkey.io for details.
- Example:
ClusterValue<Long> failureReports = clusterClient.clusterCountFailureReports( "1234567890abcdef1234567890abcdef12345678", ALL_NODES).get(); // Command sent to all nodes, expecting MultiValue result. for (Map.Entry<String, Long> entry : failureReports.getMultiValue().entrySet()) { System.out.println("Node [" + entry.getKey() + "]: " + entry.getValue() + " failure reports"); }
-
-