Package org.mariadb.jdbc.export
Enum HaMode
- All Implemented Interfaces:
Serializable
,Comparable<HaMode>
,java.lang.constant.Constable
Failover (High-availability) mode
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionload-balance-read: driver will always connect primary servers according to connection string order and replica using round-robin, permitting balancing connectionsload-balance: driver will connect to any host using round-robin, permitting balancing connectionsno ha-mode.replication mode : first is primary, other are replicasequential: driver will always connect according to connection string order -
Method Summary
Modifier and TypeMethodDescriptionstatic HaMode
Get HAMode from values or aliasesabstract Optional
<HostAddress> getAvailableHost
(List<HostAddress> hostAddresses, ConcurrentMap<HostAddress, Long> denyList, boolean primary) List of hosts without blacklist entries, ordered according to HA modestatic Optional
<HostAddress> getAvailableHostInOrder
(List<HostAddress> hostAddresses, ConcurrentMap<HostAddress, Long> denyList, boolean primary) return hosts of corresponding type (primary or not) without blacklisted hosts.static Optional
<HostAddress> getAvailableRoundRobinHost
(HaMode haMode, List<HostAddress> hostAddresses, ConcurrentMap<HostAddress, Long> denyList, boolean primary) return hosts of corresponding type (primary or not) without blacklisted hosts.static HostAddress
getHostWithLessConnections
(List<HostAddress> hostAddresses, ConcurrentMap<HostAddress, Long> denyList, boolean primary) If all hosts not blacklisted connection number are known, choose the host with the less connections.void
For testing purpose onlystatic HaMode
Returns the enum constant of this type with the specified name.static HaMode[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
REPLICATION
replication mode : first is primary, other are replica -
SEQUENTIAL
sequential: driver will always connect according to connection string order -
LOAD_BALANCE_READ
load-balance-read: driver will always connect primary servers according to connection string order and replica using round-robin, permitting balancing connections -
LOADBALANCE
load-balance: driver will connect to any host using round-robin, permitting balancing connections -
NONE
no ha-mode. Connect to first host only
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
from
Get HAMode from values or aliases- Parameters:
value
- value or alias- Returns:
- HaMode if corresponding mode is found
-
getAvailableHostInOrder
public static Optional<HostAddress> getAvailableHostInOrder(List<HostAddress> hostAddresses, ConcurrentMap<HostAddress, Long> denyList, boolean primary) return hosts of corresponding type (primary or not) without blacklisted hosts. hosts in blacklist reaching blacklist timeout will be present. order corresponds to connection string order.- Parameters:
hostAddresses
- hostsdenyList
- blacklistprimary
- returns primary hosts or replica- Returns:
- list without denied hosts
-
getHostWithLessConnections
public static HostAddress getHostWithLessConnections(List<HostAddress> hostAddresses, ConcurrentMap<HostAddress, Long> denyList, boolean primary) If all hosts not blacklisted connection number are known, choose the host with the less connections.- Parameters:
hostAddresses
- host addressesdenyList
- blacklistprimary
- requires primary host- Returns:
- the host with less connection, or null if unknown.
-
getAvailableRoundRobinHost
public static Optional<HostAddress> getAvailableRoundRobinHost(HaMode haMode, List<HostAddress> hostAddresses, ConcurrentMap<HostAddress, Long> denyList, boolean primary) return hosts of corresponding type (primary or not) without blacklisted hosts. hosts in blacklist reaching blacklist timeout will be present, RoundRobin Order.- Parameters:
haMode
- current haModehostAddresses
- hostsdenyList
- blacklistprimary
- returns primary hosts or replica- Returns:
- list without denied hosts
-
resetLast
public void resetLast()For testing purpose only -
getAvailableHost
public abstract Optional<HostAddress> getAvailableHost(List<HostAddress> hostAddresses, ConcurrentMap<HostAddress, Long> denyList, boolean primary) List of hosts without blacklist entries, ordered according to HA mode- Parameters:
hostAddresses
- hostsdenyList
- hosts temporary deniedprimary
- type- Returns:
- list without denied hosts
-