public class WeightedRandomHostSelector extends java.lang.Object implements HostSelector
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
STRATEGY_WEIGHTED_RANDOM |
static AwsWrapperProperty |
WEIGHTED_RANDOM_HOST_WEIGHT_PAIRS |
| Constructor and Description |
|---|
WeightedRandomHostSelector() |
WeightedRandomHostSelector(java.util.Random random) |
| Modifier and Type | Method and Description |
|---|---|
HostSpec |
getHost(@NonNull java.util.List<HostSpec> hosts,
@NonNull HostRole role,
@Nullable java.util.Properties props)
Selects a host with the requested role from the given host list.
|
public static final AwsWrapperProperty WEIGHTED_RANDOM_HOST_WEIGHT_PAIRS
public static final java.lang.String STRATEGY_WEIGHTED_RANDOM
public WeightedRandomHostSelector()
public WeightedRandomHostSelector(java.util.Random random)
public HostSpec getHost(@NonNull java.util.List<HostSpec> hosts, @NonNull 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.props - connection properties that may be needed by the host selector in order to choose a host.java.sql.SQLException - if the host list does not contain any hosts matching the requested role or
an error occurs while selecting a host