类 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.
    • 方法详细资料

      • getConnectionCount

        public long getConnectionCount()
      • getGroupName

        public String getGroupName()
      • 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.
        参数:
        hostPortPair - "host:port"
        抛出:
        SQLException - if an error occurs
      • 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.
        参数:
        hostPortPair - "host:port"
        closeGently - remove host when it's not in use
        抛出:
        SQLException - if an error occurs
      • 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.
        参数:
        hostPortPair - "host:port"
        抛出:
        SQLException - if an error occurs
      • removeMasterHost

        public void removeMasterHost​(String hostPortPair)
                              throws SQLException
        Removes a host from the masters hosts list.
        参数:
        hostPortPair - host:port
        抛出:
        SQLException - if an error occurs
      • 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.
        参数:
        hostPortPair - "host:port"
        closeGently - remove host when it's not in use
        抛出:
        SQLException - if an error occurs
      • 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()