public class PerQueryBalancedReaderPolicy extends java.lang.Object implements LoadBalancingPolicy
LoadBalancingPolicy that rotates readers per read query (query-level load balancing).
When includeWriter is set, the writer is also an eligible target (role null).
Rotation is confined by the plugin to an established read-only phase, so it never changes role.| Constructor and Description |
|---|
PerQueryBalancedReaderPolicy(boolean includeWriter,
java.lang.String readerSelectorStrategy) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
includesWriter() |
boolean |
isPerQuery()
Whether this policy rotates readers per read query (query-level load balancing).
|
@Nullable HostSpec |
pickReader(RwSplitContext ctx,
java.util.List<HostSpec> candidates)
Selects the reader target for this request, or
null when no eligible target is
available. |
public PerQueryBalancedReaderPolicy(boolean includeWriter,
java.lang.String readerSelectorStrategy)
public @Nullable HostSpec pickReader(RwSplitContext ctx, java.util.List<HostSpec> candidates) throws java.sql.SQLException
LoadBalancingPolicynull when no eligible target is
available.pickReader in interface LoadBalancingPolicyctx - the read/write splitting contextcandidates - the eligible reader candidatesnull if none is availablejava.sql.SQLExceptionpublic boolean isPerQuery()
LoadBalancingPolicytrue, the plugin selects a fresh reader on each read-routing decision within an
established read-only phase instead of reusing a single sticky reader.isPerQuery in interface LoadBalancingPolicytrue for per-query balancing; false (default) for a sticky readerpublic boolean includesWriter()