Class ReplicationConnectionGroup

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

public class ReplicationConnectionGroup extends 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 Details

    • ReplicationConnectionGroup

      ReplicationConnectionGroup(String groupName)
  • Method Details

    • getConnectionCount

      public long getConnectionCount()
    • registerReplicationConnection

      public long registerReplicationConnection(ReplicationConnection conn, List<String> localMasterList, List<String> localSlaveList)
    • getGroupName

      public String getGroupName()
    • getMasterHosts

      public Collection<String> getMasterHosts()
    • getSlaveHosts

      public Collection<String> getSlaveHosts()
    • addSlaveHost

      public void addSlaveHost(String hostPortPair) throws 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:
      hostPortPair -
      Throws:
      SQLException
    • handleCloseConnection

      public void handleCloseConnection(ReplicationConnection conn)
    • removeSlaveHost

      public void removeSlaveHost(String hostPortPair, boolean closeGently) throws 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:
      hostPortPair -
      closeGently -
      Throws:
      SQLException
    • promoteSlaveToMaster

      public void promoteSlaveToMaster(String hostPortPair) throws 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:
      hostPortPair -
      Throws:
      SQLException
    • removeMasterHost

      public void removeMasterHost(String hostPortPair) throws SQLException
      Removes a host from the masters hosts list.
      Throws:
      SQLException
      See Also:
    • removeMasterHost

      public void removeMasterHost(String hostPortPair, boolean closeGently) throws 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:
      hostPortPair -
      closeGently -
      Throws:
      SQLException
    • getConnectionCountWithHostAsSlave

      public int getConnectionCountWithHostAsSlave(String hostPortPair)
    • getConnectionCountWithHostAsMaster

      public int getConnectionCountWithHostAsMaster(String hostPortPair)
    • getNumberOfSlavesAdded

      public long getNumberOfSlavesAdded()
    • getNumberOfSlavesRemoved

      public long getNumberOfSlavesRemoved()
    • getNumberOfSlavePromotions

      public long getNumberOfSlavePromotions()
    • getTotalConnectionCount

      public long getTotalConnectionCount()
    • getActiveConnectionCount

      public long getActiveConnectionCount()
    • toString

      public String toString()
      Overrides:
      toString in class Object