public class TopologyReaderResolver extends java.lang.Object implements ReaderResolver
ReaderResolver. Ports the legacy
ReadWriteSplittingPlugin.initializeReaderConnection/openNewReaderConnection:
single-host clusters fall back to the writer; otherwise a reader is selected via the
LoadBalancingPolicy with a bounded per-call retry loop (local candidate removal on
non-login failures, login fast-fail, writer fallback on exhaustion).| Constructor and Description |
|---|
TopologyReaderResolver(ReaderCandidateSource candidateSource,
LoadBalancingPolicy loadBalancingPolicy,
WriterResolver writerFallback) |
| Modifier and Type | Method and Description |
|---|---|
void |
closeStaleReaderIfNecessary(RwSplitContext ctx)
Closes the cached reader connection if it is no longer valid (e.g.
|
boolean |
isPerQuery()
Whether this resolver performs query-level load balancing (a fresh reader is selected on each
read-routing decision rather than a single sticky reader being reused).
|
void |
switchToReader(RwSplitContext ctx)
Establishes a fresh reader connection (selecting a candidate, connecting, binding, and
switching the current connection to it).
|
public TopologyReaderResolver(ReaderCandidateSource candidateSource, LoadBalancingPolicy loadBalancingPolicy, WriterResolver writerFallback)
public void switchToReader(RwSplitContext ctx) throws java.sql.SQLException
ReaderResolverinitializeReaderConnection.switchToReader in interface ReaderResolverctx - the read/write splitting contextjava.sql.SQLExceptionpublic void closeStaleReaderIfNecessary(RwSplitContext ctx)
ReaderResolvercloseStaleReaderIfNecessary in interface ReaderResolverctx - the read/write splitting contextpublic boolean isPerQuery()
ReaderResolverfalse keeps the sticky-reader behavior.isPerQuery in interface ReaderResolvertrue for per-query reader balancing; false (default) for sticky