Class ReplicationConnectionGroup
java.lang.Object
com.mysql.jdbc.ReplicationConnectionGroup
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSlaveHost(String hostPortPair) Adds a host to the slaves hosts list.longlongintgetConnectionCountWithHostAsMaster(String hostPortPair) intgetConnectionCountWithHostAsSlave(String hostPortPair) longlonglonglongvoidvoidpromoteSlaveToMaster(String hostPortPair) Promotes a slave host to master.longregisterReplicationConnection(ReplicationConnection conn, List<String> localMasterList, List<String> localSlaveList) voidremoveMasterHost(String hostPortPair) Removes a host from the masters hosts list.voidremoveMasterHost(String hostPortPair, boolean closeGently) Removes a host from the masters hosts list.voidremoveSlaveHost(String hostPortPair, boolean closeGently) Removes a host from the slaves hosts list.toString()
-
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
-
getMasterHosts
-
getSlaveHosts
-
addSlaveHost
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 toReplicationConnection.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
-
removeSlaveHost
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 toReplicationConnection.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
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 toReplicationConnection.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
Removes a host from the masters hosts list.- Throws:
SQLException- See Also:
-
removeMasterHost
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 toReplicationConnection.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
-
getConnectionCountWithHostAsMaster
-
getNumberOfSlavesAdded
public long getNumberOfSlavesAdded() -
getNumberOfSlavesRemoved
public long getNumberOfSlavesRemoved() -
getNumberOfSlavePromotions
public long getNumberOfSlavePromotions() -
getTotalConnectionCount
public long getTotalConnectionCount() -
getActiveConnectionCount
public long getActiveConnectionCount() -
toString
-