Top Description Fields Constructors Methods
com.mysql.cj.jdbc.ha

public Class ReplicationConnectionGroup

extends Object
Class Inheritance
Imports
java.sql.SQLException, java.util.Collection, .HashMap, .List, .Set, java.util.concurrent.CopyOnWriteArraySet

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

Field Summary

Modifier and TypeField and Description
private long
private long
private String
private boolean
private Set<String>
private long
private long
private long
private HashMap<Long, ReplicationConnection>
private Set<String>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
addReplicaHost(String
"host:port"
hostPortPair
)

Adds a host to the replicas hosts list.

public long
public long
public int
public int
public String
public long
public long
public long
public Collection<String>
public Collection<String>
public long
public void
public void
promoteReplicaToSource(String
"host:port"
hostPortPair
)

Promotes a replica host to source.

public long
registerReplicationConnection(ReplicationConnection conn, List<String> localSourceList, List<String> localReplicaList)

public void
removeReplicaHost(String
"host:port"
hostPortPair
,
boolean
remove host when it's not in use
closeGently
)

Removes a host from the replicas hosts list.

public void
removeSourceHost(String
host:port
hostPortPair
)

Removes a host from the sources hosts list.

public void
removeSourceHost(String
"host:port"
hostPortPair
,
boolean
remove host when it's not in use
closeGently
)

Removes a host from the sources hosts list.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

activeConnectionsback to summary
private long activeConnections
connectionsback to summary
private long connections
groupNameback to summary
private String groupName
isInitializedback to summary
private boolean isInitialized
replicaHostListback to summary
private Set<String> replicaHostList
replicasAddedback to summary
private long replicasAdded
replicasPromotedback to summary
private long replicasPromoted
replicasRemovedback to summary
private long replicasRemoved
replicationConnectionsback to summary
private HashMap<Long, ReplicationConnection> replicationConnections
sourceHostListback to summary
private Set<String> sourceHostList

Constructor Detail

ReplicationConnectionGroupback to summary
pack-priv ReplicationConnectionGroup(String groupName)

Method Detail

addReplicaHostback to summary
public void addReplicaHost(String hostPortPair) throws SQLException

Adds a host to the replicas hosts list. We can safely assume that if this host was added to the replicas list, then it must be added to each one of the replication connections from this group as well. Unnecessary calls to ReplicationConnection#addReplicaHost(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 replica role.

Parameters
hostPortPair:String

"host:port"

Exceptions
SQLException:
if an error occurs
getActiveConnectionCountback to summary
public long getActiveConnectionCount()
getConnectionCountback to summary
public long getConnectionCount()
getConnectionCountWithHostAsReplicaback to summary
public int getConnectionCountWithHostAsReplica(String hostPortPair)
getConnectionCountWithHostAsSourceback to summary
public int getConnectionCountWithHostAsSource(String hostPortPair)
getGroupNameback to summary
public String getGroupName()
getNumberOfReplicaPromotionsback to summary
public long getNumberOfReplicaPromotions()
getNumberOfReplicasAddedback to summary
public long getNumberOfReplicasAdded()
getNumberOfReplicasRemovedback to summary
public long getNumberOfReplicasRemoved()
getReplicaHostsback to summary
public Collection<String> getReplicaHosts()
getSourceHostsback to summary
public Collection<String> getSourceHosts()
getTotalConnectionCountback to summary
public long getTotalConnectionCount()
handleCloseConnectionback to summary
public void handleCloseConnection(ReplicationConnection conn)
promoteReplicaToSourceback to summary
public void promoteReplicaToSource(String hostPortPair) throws SQLException

Promotes a replica host to source. We can safely assume that if this host was removed from the replicas list or added to the sources list, then the same host promotion must happen in each one of the replication connections from this group as well. Unnecessary calls to ReplicationConnection#promoteReplicaToSource(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 source role and not in replica role.

Parameters
hostPortPair:String

"host:port"

Exceptions
SQLException:
if an error occurs
registerReplicationConnectionback to summary
public long registerReplicationConnection(ReplicationConnection conn, List<String> localSourceList, List<String> localReplicaList)
removeReplicaHostback to summary
public void removeReplicaHost(String hostPortPair, boolean closeGently) throws SQLException

Removes a host from the replicas hosts list. We can safely assume that if this host was removed from the replicas list, then it must be removed from each one of the replication connections from this group as well. Unnecessary calls to ReplicationConnection#removeReplica(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 replica role.

Parameters
hostPortPair:String

"host:port"

closeGently:boolean

remove host when it's not in use

Exceptions
SQLException:
if an error occurs
removeSourceHostback to summary
public void removeSourceHost(String hostPortPair) throws SQLException

Removes a host from the sources hosts list.

Parameters
hostPortPair:String

host:port

Exceptions
SQLException:
if an error occurs
removeSourceHostback to summary
public void removeSourceHost(String hostPortPair, boolean closeGently) throws SQLException

Removes a host from the sources hosts list. We can safely assume that if this host was removed from the sources list, then it must be removed from each one of the replication connections from this group as well. Unnecessary calls to ReplicationConnection#removeSourceHost(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 source role.

Parameters
hostPortPair:String

"host:port"

closeGently:boolean

remove host when it's not in use

Exceptions
SQLException:
if an error occurs
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override