Interface ClusterAdminCommands

  • All Known Implementing Classes:
    GlideClusterClient

    public interface ClusterAdminCommands
    Supports commands for cluster administration including configuration persistence and key inspection during slot migration.
    See Also:
    Cluster Commands
    • Method Detail

      • clusterSaveConfig

        java.util.concurrent.CompletableFuture<java.lang.String> clusterSaveConfig()
        Saves the cluster configuration to disk. This forces the node to persist its current cluster configuration (including node mappings, slot assignments, etc.) to the cluster configuration file on disk.
        The command will be routed to a random node in the cluster.
        Returns:
        OK if the configuration was successfully saved.
        See Also:
        valkey.io for details.
        Example:
        
         String result = clusterClient.clusterSaveConfig().get();
         assert result.equals("OK");
         
      • clusterSaveConfig

        java.util.concurrent.CompletableFuture<ClusterValue<java.lang.String>> clusterSaveConfig​(RequestRoutingConfiguration.Route route)
        Saves the cluster configuration to disk. This forces the node(s) to persist their current cluster configuration (including node mappings, slot assignments, etc.) to the cluster configuration file on disk.
        Parameters:
        route - Specifies the routing configuration for the command. The client will route the command to the nodes defined by route.
        Returns:
        OK if the configuration was successfully saved. When specifying a route other than a single node, it returns a Map<String, String> with each address as the key and its corresponding result.
        See Also:
        valkey.io for details.
        Example:
        
         ClusterValue<String> result = clusterClient.clusterSaveConfig(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());
         }
         
      • clusterGetKeysInSlot

        java.util.concurrent.CompletableFuture<java.lang.String[]> clusterGetKeysInSlot​(long slot,
                                                                                        long count)
        Returns an array of keys stored in the specified hash slot. This command is useful for inspecting the contents of a slot, particularly during slot migration or resharding operations.
        The command will be routed to the node that owns the specified slot.
        Parameters:
        slot - The hash slot number to query (0-16383).
        count - The maximum number of keys to return from the slot.
        Returns:
        An array of keys stored in the specified slot. The array may contain fewer keys than count if the slot has fewer keys.
        See Also:
        valkey.io for details.
        Example:
        
         // Get up to 10 keys from slot 1234
         String[] keys = clusterClient.clusterGetKeysInSlot(1234, 10).get();
         for (String key : keys) {
             System.out.println("Key in slot 1234: " + key);
         }