Enum HaMode

java.lang.Object
java.lang.Enum<HaMode>
org.mariadb.jdbc.export.HaMode
All Implemented Interfaces:
Serializable, Comparable<HaMode>, java.lang.constant.Constable

public enum HaMode extends Enum<HaMode>
Failover (High-availability) mode
  • Enum Constant Details

    • 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
    • LOAD_BALANCE_READ

      public static final HaMode 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

      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 Details

    • values

      public static HaMode[] 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

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