ReplicationConnectionGroup
Date: 2018-05-06

com.mysql.jdbc

## Class ReplicationConnectionGroup

- java.lang.Object
- - com.mysql.jdbc.ReplicationConnectionGroup

-     public class ReplicationConnectionGroup
      extends java.lang.Object

  Group of connection objects which can be configured as a group. This is used for promotion/demotion of slaves and masters in a replication configuration, and for exposing metrics around replication-aware connections.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReplicationConnectionGroup(java.lang.String groupName)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addSlaveHost(java.lang.String host)` Adds a host to the slaves hosts list.
    `long` | `getActiveConnectionCount()`
    `long` | `getConnectionCount()`
    `int` | `getConnectionCountWithHostAsMaster(java.lang.String host)`
    `int` | `getConnectionCountWithHostAsSlave(java.lang.String host)`
    `java.lang.String` | `getGroupName()`
    `java.util.Collection<java.lang.String>` | `getMasterHosts()`
    `long` | `getNumberOfSlavePromotions()`
    `long` | `getNumberOfSlavesAdded()`
    `long` | `getNumberOfSlavesRemoved()`
    `java.util.Collection<java.lang.String>` | `getSlaveHosts()`
    `long` | `getTotalConnectionCount()`
    `void` | `handleCloseConnection(ReplicationConnection conn)`
    `void` | `promoteSlaveToMaster(java.lang.String host)` Promotes a slave host to master.
    `long` | `registerReplicationConnection(ReplicationConnection conn, java.util.List<java.lang.String> localMasterList, java.util.List<java.lang.String> localSlaveList)`
    `void` | `removeMasterHost(java.lang.String host)` Removes a host from the masters hosts list.
    `void` | `removeMasterHost(java.lang.String host, boolean closeGently)` Removes a host from the masters hosts list.
    `void` | `removeSlaveHost(java.lang.String host, boolean closeGently)` Removes a host from the slaves hosts list.
    `java.lang.String` | `toString()`

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

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ReplicationConnectionGroup

          ReplicationConnectionGroup(java.lang.String groupName)

  - ### Method Detail

    - #### getConnectionCount

          public long getConnectionCount()

    - #### registerReplicationConnection

          public long registerReplicationConnection(ReplicationConnection conn,
                                           java.util.List<java.lang.String> localMasterList,
                                           java.util.List<java.lang.String> localSlaveList)

    - #### getGroupName

          public java.lang.String getGroupName()

    - #### getMasterHosts

          public java.util.Collection<java.lang.String> getMasterHosts()

    - #### getSlaveHosts

          public java.util.Collection<java.lang.String> getSlaveHosts()

    - #### addSlaveHost

          public void addSlaveHost(java.lang.String host)
                            throws java.sql.SQLException

      Adds a host to the slaves hosts list. We can safely assume that if this host was added to the slaves list, then it must be added to each one of the replication connections from this group as well. Unnecessary calls to `ReplicationConnection.addSlaveHost(String)` could result in undesirable locking issues, assuming that this method is synchronized by nature. This is a no-op if the group already has this host in a slave role.
      Parameters:
        `host` -
      Throws:
        `java.sql.SQLException`

    - #### handleCloseConnection

          public void handleCloseConnection(ReplicationConnection conn)

    - #### removeSlaveHost

          public void removeSlaveHost(java.lang.String host,
                             boolean closeGently)
                               throws java.sql.SQLException

      Removes a host from the slaves hosts list. We can safely assume that if this host was removed from the slaves list, then it must be removed from each one of the replication connections from this group as well. Unnecessary calls to `ReplicationConnection.removeSlave(String, boolean)` could result in undesirable locking issues, assuming that this method is synchronized by nature. This is a no-op if the group doesn't have this host in a slave role.
      Parameters:
        `host` -
        `closeGently` -
      Throws:
        `java.sql.SQLException`

    - #### promoteSlaveToMaster

          public void promoteSlaveToMaster(java.lang.String host)
                                    throws java.sql.SQLException

      Promotes a slave host to master. We can safely assume that if this host was removed from the slaves list or added to the masters list, then the same host promotion must happen in each one of the replication connections from this group as well. Unnecessary calls to `ReplicationConnection.promoteSlaveToMaster(String)` could result in undesirable locking issues, assuming that this method is synchronized by nature. This is a no-op if the group already has this host in a master role and not in slave role.
      Parameters:
        `host` -
      Throws:
        `java.sql.SQLException`

    - #### removeMasterHost

          public void removeMasterHost(java.lang.String host)
                                throws java.sql.SQLException

      Removes a host from the masters hosts list.
      Throws:
        `java.sql.SQLException`
      See Also:
        `removeMasterHost(String, boolean)`

    - #### removeMasterHost

          public void removeMasterHost(java.lang.String host,
                              boolean closeGently)
                                throws java.sql.SQLException

      Removes a host from the masters hosts list. We can safely assume that if this host was removed from the masters list, then it must be removed from each one of the replication connections from this group as well. Unnecessary calls to `ReplicationConnection.removeMasterHost(String, boolean)` could result in undesirable locking issues, assuming that this method is synchronized by nature. This is a no-op if the group doesn't have this host in a master role.
      Parameters:
        `host` -
        `closeGently` -
      Throws:
        `java.sql.SQLException`

    - #### getConnectionCountWithHostAsSlave

          public int getConnectionCountWithHostAsSlave(java.lang.String host)

    - #### getConnectionCountWithHostAsMaster

          public int getConnectionCountWithHostAsMaster(java.lang.String host)

    - #### getNumberOfSlavesAdded

          public long getNumberOfSlavesAdded()

    - #### getNumberOfSlavesRemoved

          public long getNumberOfSlavesRemoved()

    - #### getNumberOfSlavePromotions

          public long getNumberOfSlavePromotions()

    - #### getTotalConnectionCount

          public long getTotalConnectionCount()

    - #### getActiveConnectionCount

          public long getActiveConnectionCount()

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`