Class ConnectionManager
- java.lang.Object
-
- glide.managers.ConnectionManager
-
public class ConnectionManager extends java.lang.ObjectConnectionManager that wraps GlideNativeBridge to handle native client connections. Manages the lifecycle of native client instances and provides connection services.
-
-
Constructor Summary
Constructors Constructor Description ConnectionManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.Future<java.lang.Void>closeConnection()Close the connection.voidcloseConnectionSync()Close the connection immediately (synchronous version).java.util.concurrent.CompletableFuture<java.lang.Void>connectToValkey(BaseClientConfiguration configuration)Connect to Valkey using the native bridge.java.lang.StringgetClientInfo()Get client information from the native layer.ServerCredentialsgetCredentials()Returns the credentials configured for this connection, if any.intgetMaxInflightRequests()Get max inflight requests setting.longgetNativeClientHandle()Get the native client handle for use by CommandManager.intgetRequestTimeoutMs()Get request timeout setting.booleanisClosed()Check if the connection is closed.booleanisConnected()Check if the client is connected and ready for commands.static ConnectionRequestOuterClass.ReadFrommapReadFrom(ReadFrom readFrom)Maps a clientReadFromstrategy onto its protobuf counterpart.static java.lang.StringresolveClientAz(BaseClientConfiguration configuration)TheclientAZas it should reach the core: trimmed, or null when absent or blank.voidupdateStoredPassword(java.lang.String password)Update the cached password after a successful rotation (used by BaseClient).static voidvalidateClientAz(BaseClientConfiguration configuration)Rejects an AZ-affinity read strategy that has noclientAZto target.
-
-
-
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 clientReadFromstrategy onto its protobuf counterpart.Note that within this class the unqualified name
ReadFromrefers 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 toPrimary. AGlideExceptionsubtype is required here: this runs insideconnectToValkey's async body, whose handler rethrowsGlideExceptionunchanged but relabels anything else as aClosingException, 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 noclientAZto 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 anExecutionException.- Throws:
ConfigurationError- if an AZ-affinity strategy is selected without aclientAZ.
-
resolveClientAz
public static java.lang.String resolveClientAz(BaseClientConfiguration configuration)
TheclientAZas 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 bygetenvor 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.
-
-