Package org.mariadb.jdbc.export

## Enum HaMode

- java.lang.Object
- - java.lang.Enum<HaMode>
  - - org.mariadb.jdbc.export.HaMode

All Implemented Interfaces:
  `Serializable`, `Comparable<HaMode>`

    public enum HaMode
    extends Enum<HaMode>

Failover (High-availability) mode

### Enum Constant Summary

Enum Constants
`LOADBALANCE` load-balance: driver will connect to any host using round-robin, permitting balancing connections
`NONE` no ha-mode.
`REPLICATION` replication mode : first is primary, other are replica
`SEQUENTIAL` sequential: driver will always connect according to connection string order

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
`static HaMode` `from​(String value)` Get HAMode from values or aliases
`abstract Optional<HostAddress>` `getAvailableHost​(List<HostAddress> hostAddresses, ConcurrentMap<HostAddress,​Long> denyList, boolean primary)` List of hosts without blacklist entries, ordered according to HA mode
`static 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` `resetLast()` For testing purpose only
`static HaMode` `valueOf​(String name)` 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.

### Methods inherited from class java.lang.Enum

`clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`

### Enum Constant Detail

#### REPLICATION

    public static final HaMode REPLICATION

replication mode : first is primary, other are replica

#### SEQUENTIAL

    public static final HaMode SEQUENTIAL

sequential: driver will always connect according to connection string order

#### LOADBALANCE

    public static final HaMode LOADBALANCE

load-balance: driver will connect to any host using round-robin, permitting balancing connections

#### NONE

    public static final HaMode NONE

no ha-mode. Connect to first host only

### Method Detail

#### values

    public static HaMode[] values()

Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

    for (HaMode c : HaMode.values())
        System.out.println(c);

Returns:
  an array containing the constants of this enum type, in the order they are declared

#### valueOf

    public static HaMode valueOf​(String name)

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 name
  `NullPointerException` - if the argument is null

#### resetLast

    public void resetLast()

For testing purpose only

#### from

    public static HaMode from​(String value)

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` - hosts
  `denyList` - blacklist
  `primary` - 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 addresses
  `denyList` - blacklist
  `primary` - 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 haMode
  `hostAddresses` - hosts
  `denyList` - blacklist
  `primary` - returns primary hosts or replica
Returns:
  list without denied hosts

#### 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` - hosts
  `denyList` - hosts temporary denied
  `primary` - type
Returns:
  list without denied hosts