public class LowestLoadHostSelector extends java.lang.Object implements HostSelector
HostSpec.getCpuPercent() and HostSpec.getLagMs()
Note: Non-Aurora dialects may not be compatible as they do not populate host cpuPercent or lagMs.
| Modifier and Type | Field and Description |
|---|---|
protected static long |
CPU_DEFAULT |
protected static long |
LAG_MS_DEFAULT |
static AwsWrapperProperty |
LOWEST_LOAD_CPU_WEIGHT |
static AwsWrapperProperty |
LOWEST_LOAD_LAG_WEIGHT |
static java.lang.String |
STRATEGY_LOWEST_LOAD |
static java.lang.String |
STRATEGY_LOWEST_LOAD_BY_CPU |
static java.lang.String |
STRATEGY_LOWEST_LOAD_BY_LAG |
| Constructor and Description |
|---|
LowestLoadHostSelector() |
LowestLoadHostSelector(long defaultCpuWeight,
long defaultLagWeight) |
| Modifier and Type | Method and Description |
|---|---|
static LowestLoadHostSelector |
byCpu() |
static LowestLoadHostSelector |
byLag() |
@Nullable HostSpec |
getHost(@NonNull java.util.List<HostSpec> hosts,
@Nullable HostRole role,
@Nullable java.util.Properties props)
Selects a host with the requested role from the given host list.
|
public static final java.lang.String STRATEGY_LOWEST_LOAD
public static final java.lang.String STRATEGY_LOWEST_LOAD_BY_CPU
public static final java.lang.String STRATEGY_LOWEST_LOAD_BY_LAG
public static final AwsWrapperProperty LOWEST_LOAD_CPU_WEIGHT
public static final AwsWrapperProperty LOWEST_LOAD_LAG_WEIGHT
protected static final long CPU_DEFAULT
protected static final long LAG_MS_DEFAULT
public LowestLoadHostSelector()
public LowestLoadHostSelector(long defaultCpuWeight,
long defaultLagWeight)
public static LowestLoadHostSelector byCpu()
public static LowestLoadHostSelector byLag()
public @Nullable HostSpec getHost(@NonNull java.util.List<HostSpec> hosts, @Nullable HostRole role, @Nullable java.util.Properties props) throws java.sql.SQLException
HostSelectorgetHost in interface HostSelectorhosts - a list of available hosts to pick from.role - the desired host role - either a writer or a reader. Null value means no preferences on host role.props - connection properties that may be needed by the host selector in order to choose a host.java.sql.SQLException - if an error occurs while selecting a host