Package glide.api.commands
Interface ClusterOperationsCommands
-
- All Known Implementing Classes:
GlideClusterClient
public interface ClusterOperationsCommandsSupports commands for cluster operational control including failover, slot management, and epoch operations.- See Also:
- Cluster Commands
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.String>clusterBumpEpoch()Forces a node to increment its configuration epoch.java.util.concurrent.CompletableFuture<java.lang.String>clusterFailover()Initiates a manual failover of the primary node to one of its replicas.java.util.concurrent.CompletableFuture<java.lang.String>clusterFailover(@NonNull ClusterFailoverOptions options)Initiates a manual failover of the primary node to one of its replicas with specified options.java.util.concurrent.CompletableFuture<java.lang.String>clusterFlushSlots()Clears the node's hash slot ownership information.java.util.concurrent.CompletableFuture<java.lang.String>clusterReset()Resets a cluster node, clearing its cluster configuration and state.java.util.concurrent.CompletableFuture<java.lang.String>clusterReset(@NonNull ClusterResetOptions options)Resets a cluster node with specified options, clearing its cluster configuration and state.
The command must be sent to the node to reset.java.util.concurrent.CompletableFuture<java.lang.String>clusterSetConfigEpoch(long configEpoch)Sets the configuration epoch for a node.java.util.concurrent.CompletableFuture<java.lang.String>clusterSetSlot(long slot, @NonNull ClusterSetSlotOptions options)Manages the assignment of hash slots to nodes in the cluster.
-
-
-
Method Detail
-
clusterFailover
java.util.concurrent.CompletableFuture<java.lang.String> clusterFailover()
Initiates a manual failover of the primary node to one of its replicas. This command must be sent to a replica node. The replica will attempt to perform a failover, becoming the new primary.
The command must be sent to a replica node.- Returns:
OKif the failover was successfully initiated.- See Also:
- valkey.io for details.
- Example:
String result = clusterClient.clusterFailover().get(); assert result.equals("OK");
-
clusterFailover
java.util.concurrent.CompletableFuture<java.lang.String> clusterFailover(@NonNull @NonNull ClusterFailoverOptions options)Initiates a manual failover of the primary node to one of its replicas with specified options. This command must be sent to a replica node. The replica will attempt to perform a failover, becoming the new primary.- Parameters:
options- The failover options specifying the type of failover to perform (FORCE or TAKEOVER).- Returns:
OKif the failover was successfully initiated.- See Also:
- valkey.io for details.
- Example:
String result = clusterClient.clusterFailover(ClusterFailoverOptions.FORCE).get(); assert result.equals("OK");
-
clusterSetSlot
java.util.concurrent.CompletableFuture<java.lang.String> clusterSetSlot(long slot, @NonNull @NonNull ClusterSetSlotOptions options)Manages the assignment of hash slots to nodes in the cluster. This command is used during cluster reconfiguration to migrate slots between nodes. The specific action depends on the provided options (IMPORTING, MIGRATING, STABLE, or NODE).- Parameters:
slot- The hash slot number to manage (0-16383).options- The options specifying the action to perform on the slot.- Returns:
OKif the slot assignment was successfully updated.- See Also:
- valkey.io for details.
- Example:
// Mark slot 1234 as migrating to node with given ID String result = clusterClient.clusterSetSlot( 1234, ClusterSetSlotOptions.migrating("1234567890abcdef1234567890abcdef12345678")).get(); assert result.equals("OK");
-
clusterBumpEpoch
java.util.concurrent.CompletableFuture<java.lang.String> clusterBumpEpoch()
Forces a node to increment its configuration epoch. This is an advanced command that should be used with caution. It is primarily used during cluster reconfiguration scenarios to force epoch increments.- Returns:
BUMPEDif the epoch was successfully incremented, orSTILLif the current configuration epoch is already the greatest in the cluster.- See Also:
- valkey.io for details.
- Example:
String result = clusterClient.clusterBumpEpoch().get(); System.out.println("Epoch bump result: " + result);
-
clusterSetConfigEpoch
java.util.concurrent.CompletableFuture<java.lang.String> clusterSetConfigEpoch(long configEpoch)
Sets the configuration epoch for a node. This is an advanced command used during cluster reconfiguration. The configuration epoch is a version number for the cluster configuration, and this command allows explicitly setting it.Warning: Misuse of this command can lead to cluster inconsistencies. Use with caution and only during controlled reconfiguration scenarios.
- Parameters:
configEpoch- The configuration epoch value to set.- Returns:
OKif the configuration epoch was successfully set.- See Also:
- valkey.io for details.
- Example:
String result = clusterClient.clusterSetConfigEpoch(123).get(); assert result.equals("OK");
-
clusterFlushSlots
java.util.concurrent.CompletableFuture<java.lang.String> clusterFlushSlots()
Clears the node's hash slot ownership information. This command removes all slots assigned to the node, effectively clearing its slot assignment cache. This is typically used during cluster reconfiguration or resharding.Warning: This is a disruptive operation that clears the node's slot assignments. The node will no longer claim ownership of any slots until they are reassigned.
- Returns:
OKif the slots were successfully flushed.- See Also:
- valkey.io for details.
- Example:
String result = clusterClient.clusterFlushSlots().get(); assert result.equals("OK");
-
clusterReset
java.util.concurrent.CompletableFuture<java.lang.String> clusterReset()
Resets a cluster node, clearing its cluster configuration and state. By default, performs a soft reset.
The command must be sent to the node to reset.Warning: This is a destructive operation. A soft reset will clear cluster state but preserve data. Use with caution.
- Returns:
OKif the node was successfully reset.- See Also:
- valkey.io for details.
- Example:
String result = clusterClient.clusterReset().get(); assert result.equals("OK");
-
clusterReset
java.util.concurrent.CompletableFuture<java.lang.String> clusterReset(@NonNull @NonNull ClusterResetOptions options)Resets a cluster node with specified options, clearing its cluster configuration and state.
The command must be sent to the node to reset.Warning: This is a destructive operation. A soft reset clears cluster state but preserves data, while a hard reset clears both cluster state and all data. Use with extreme caution, especially with HARD option.
- Parameters:
options- The reset options specifying the type of reset (SOFT or HARD).- Returns:
OKif the node was successfully reset.- See Also:
- valkey.io for details.
- Example:
// Perform a soft reset (preserves data) String result = clusterClient.clusterReset(ClusterResetOptions.SOFT).get(); assert result.equals("OK");
-
-