Class ConnectionManager


  • public class ConnectionManager
    extends java.lang.Object
    ConnectionManager that wraps GlideNativeBridge to handle native client connections. Manages the lifecycle of native client instances and provides connection services.
    • Constructor Detail

      • ConnectionManager

        public ConnectionManager()
    • Method Detail

      • connectToValkey

        public java.util.concurrent.CompletableFuture<java.lang.Void> connectToValkey​(BaseClientConfiguration configuration)
        Connect to Valkey using the native bridge.
        Parameters:
        configuration - Connection Configuration
        Returns:
        CompletableFuture that completes when connection is established
      • closeConnection

        public java.util.concurrent.Future<java.lang.Void> closeConnection()
        Close the connection.
        Returns:
        Future that completes when connection is closed
      • closeConnectionSync

        public void closeConnectionSync()
        Close the connection immediately (synchronous version).
      • getNativeClientHandle

        public long getNativeClientHandle()
        Get the native client handle for use by CommandManager.
      • getMaxInflightRequests

        public int getMaxInflightRequests()
        Get max inflight requests setting.
      • getRequestTimeoutMs

        public int getRequestTimeoutMs()
        Get request timeout setting.
      • isClosed

        public boolean isClosed()
        Check if the connection is closed.
      • isConnected

        public boolean isConnected()
        Check if the client is connected and ready for commands.
      • getCredentials

        public ServerCredentials getCredentials()
        Returns the credentials configured for this connection, if any.
      • updateStoredPassword

        public void updateStoredPassword​(java.lang.String password)
        Update the cached password after a successful rotation (used by BaseClient).
      • getClientInfo

        public java.lang.String getClientInfo()
        Get client information from the native layer.
      • mapReadFrom

        public static ConnectionRequestOuterClass.ReadFrom mapReadFrom​(ReadFrom readFrom)
        Maps a client ReadFrom strategy onto its protobuf counterpart.

        Note that within this class the unqualified name ReadFrom refers to the protobuf enum, hence the fully-qualified parameter type.

        Throws:
        ConfigurationError - if the strategy has no protobuf mapping. This makes a newly added strategy fail loudly rather than silently defaulting to Primary. A GlideException subtype is required here: this runs inside connectToValkey's async body, whose handler rethrows GlideException unchanged but relabels anything else as a ClosingException, which would report a config mistake as a connection failure.
      • validateClientAz

        public static void validateClientAz​(BaseClientConfiguration configuration)
        Rejects an AZ-affinity read strategy that has no clientAZ to target.

        Without this check the core silently downgrades the strategy to PreferReplica, so reads would land on arbitrary nodes while the configuration suggested otherwise.

        Called synchronously from BaseClient.createClient, alongside the PubSub/RESP2 check, so callers see a direct throw rather than an ExecutionException.

        Throws:
        ConfigurationError - if an AZ-affinity strategy is selected without a clientAZ.
      • resolveClientAz

        public static java.lang.String resolveClientAz​(BaseClientConfiguration configuration)
        The clientAZ as it should reach the core: trimmed, or null when absent or blank.

        The core compares availability zones with exact equality and never trims ( standalone_client.rs, connections_container.rs), so a padded value such as " us-east-1a " — easily produced by getenv or a file read — would satisfy validation, engage the strategy, match no node, and silently spread reads cluster-wide. No real availability-zone name carries surrounding whitespace, so trimming cannot break a value that works today.