类 ReplicationConnectionProxy
- java.lang.Object
-
- com.mysql.cj.jdbc.ha.MultiHostConnectionProxy
-
- com.mysql.cj.jdbc.ha.ReplicationConnectionProxy
-
- 所有已实现的接口:
PingTarget,InvocationHandler
public class ReplicationConnectionProxy extends MultiHostConnectionProxy implements PingTarget
Connection that opens two connections, one two a replication source, and another to one or more replicas, and decides to use source when the connection is not read-only, and use replica(s) when the connection is read-only.
-
-
字段概要
字段 修饰符和类型 字段 说明 protected booleanallowReplicaDownConnectionsprotected booleanallowSourceDownConnectionsprotected booleanenableJMXprotected booleanreadFromSourceWhenNoReplicasprotected booleanreadFromSourceWhenNoReplicasOriginalprotected booleanreadOnlyprotected LoadBalancedConnectionreplicasConnectionprotected LoadBalancedConnectionsourceConnection-
从类继承的字段 com.mysql.cj.jdbc.ha.MultiHostConnectionProxy
connectionUrl, lastExceptionDealtWith
-
-
方法概要
所有方法 静态方法 实例方法 具体方法 已过时的方法 修饰符和类型 方法 说明 voidaddReplicaHost(String hostPortPair)voidaddSlaveHost(String hostPortPair)已过时。static ReplicationConnectioncreateProxyInstance(ConnectionUrl connectionUrl)Static factory to createReplicationConnectioninstances.voiddoPing()Pings both l/b connections.longgetConnectionGroupId()JdbcConnectiongetCurrentConnection()JdbcConnectiongetMasterConnection()已过时。JdbcConnectiongetReplicasConnection()JdbcConnectiongetSlavesConnection()已过时。JdbcConnectiongetSourceConnection()booleanisHostMaster(String hostPortPair)已过时。booleanisHostReplica(String hostPortPair)booleanisHostSlave(String hostPortPair)已过时。booleanisHostSource(String hostPortPair)booleanisReadOnly()booleanisReplicasConnection()Checks if current connection is the replicas l/b connection.booleanisSlavesConnection()已过时。booleanisSourceConnection()Checks if current connection is the sources l/b connection.voidpromoteReplicaToSource(String hostPortPair)voidpromoteSlaveToMaster(String hostPortPair)已过时。protected voidpropagateProxyDown(JdbcConnection proxyConn)Propagates the connection proxy down through all live connections.voidremoveMasterHost(String hostPortPair)已过时。voidremoveMasterHost(String hostPortPair, boolean waitUntilNotInUse)已过时。voidremoveMasterHost(String hostPortPair, boolean waitUntilNotInUse, boolean isNowReplica)已过时。voidremoveReplica(String hostPortPair)voidremoveReplica(String hostPortPair, boolean closeGently)voidremoveSlave(String hostPortPair)已过时。voidremoveSlave(String hostPortPair, boolean closeGently)已过时。voidremoveSourceHost(String hostPortPair)voidremoveSourceHost(String hostPortPair, boolean waitUntilNotInUse)voidremoveSourceHost(String hostPortPair, boolean waitUntilNotInUse, boolean isNowReplica)voidsetReadOnly(boolean readOnly)-
从类继承的方法 com.mysql.cj.jdbc.ha.MultiHostConnectionProxy
allowedOnClosedConnection, getParentProxy, getProxy, invoke, setProxy
-
-
-
-
字段详细资料
-
enableJMX
protected boolean enableJMX
-
allowSourceDownConnections
protected boolean allowSourceDownConnections
-
allowReplicaDownConnections
protected boolean allowReplicaDownConnections
-
readFromSourceWhenNoReplicas
protected boolean readFromSourceWhenNoReplicas
-
readFromSourceWhenNoReplicasOriginal
protected boolean readFromSourceWhenNoReplicasOriginal
-
readOnly
protected boolean readOnly
-
sourceConnection
protected LoadBalancedConnection sourceConnection
-
replicasConnection
protected LoadBalancedConnection replicasConnection
-
-
方法详细资料
-
createProxyInstance
public static ReplicationConnection createProxyInstance(ConnectionUrl connectionUrl) throws SQLException
Static factory to createReplicationConnectioninstances.- 参数:
connectionUrl- The connection URL containing the hosts in a replication setup.- 返回:
- A
ReplicationConnectionproxy. - 抛出:
SQLException- if an error occurs
-
propagateProxyDown
protected void propagateProxyDown(JdbcConnection proxyConn)
Propagates the connection proxy down through all live connections.- 覆盖:
propagateProxyDown在类中MultiHostConnectionProxy- 参数:
proxyConn- The top level connection in the multi-host connections chain.
-
isSourceConnection
public boolean isSourceConnection()
Checks if current connection is the sources l/b connection.
-
isReplicasConnection
public boolean isReplicasConnection()
Checks if current connection is the replicas l/b connection.- 返回:
- true if current connection is the replicas l/b connection
-
isSlavesConnection
@Deprecated public boolean isSlavesConnection()
已过时。UseisReplicasConnection()instead.- 返回:
- true if it's a replicas connection
-
doPing
public void doPing() throws SQLExceptionPings both l/b connections. Switch to another connection in case of failure.- 指定者:
doPing在接口中PingTarget- 抛出:
SQLException
-
getCurrentConnection
public JdbcConnection getCurrentConnection()
-
getConnectionGroupId
public long getConnectionGroupId()
-
getSourceConnection
public JdbcConnection getSourceConnection()
-
getMasterConnection
@Deprecated public JdbcConnection getMasterConnection()
已过时。UsegetSourceConnection()instead.- 返回:
JdbcConnection
-
promoteReplicaToSource
public void promoteReplicaToSource(String hostPortPair) throws SQLException
- 抛出:
SQLException
-
promoteSlaveToMaster
@Deprecated public void promoteSlaveToMaster(String hostPortPair) throws SQLException
已过时。UsepromoteReplicaToSource(String)instead.- 参数:
hostPortPair- host:port- 抛出:
SQLException
-
removeSourceHost
public void removeSourceHost(String hostPortPair) throws SQLException
- 抛出:
SQLException
-
removeMasterHost
@Deprecated public void removeMasterHost(String hostPortPair) throws SQLException
已过时。UseremoveSourceHost(String)instead.- 参数:
hostPortPair- host:port- 抛出:
SQLException
-
removeSourceHost
public void removeSourceHost(String hostPortPair, boolean waitUntilNotInUse) throws SQLException
- 抛出:
SQLException
-
removeMasterHost
@Deprecated public void removeMasterHost(String hostPortPair, boolean waitUntilNotInUse) throws SQLException
已过时。UseremoveSourceHost(String, boolean)instead.- 参数:
hostPortPair- host:portwaitUntilNotInUse- remove only when not in use- 抛出:
SQLException
-
removeSourceHost
public void removeSourceHost(String hostPortPair, boolean waitUntilNotInUse, boolean isNowReplica) throws SQLException
- 抛出:
SQLException
-
removeMasterHost
@Deprecated public void removeMasterHost(String hostPortPair, boolean waitUntilNotInUse, boolean isNowReplica) throws SQLException
已过时。UseremoveSourceHost(String, boolean, boolean)instead.- 参数:
hostPortPair- host:portwaitUntilNotInUse- remove only when not in useisNowReplica- place to replicas- 抛出:
SQLException
-
isHostSource
public boolean isHostSource(String hostPortPair)
-
isHostMaster
@Deprecated public boolean isHostMaster(String hostPortPair)
已过时。UseisHostSource(String)instead.- 参数:
hostPortPair- host:port- 返回:
- true if it's a source host
-
getReplicasConnection
public JdbcConnection getReplicasConnection()
-
getSlavesConnection
@Deprecated public JdbcConnection getSlavesConnection()
已过时。UsegetReplicasConnection()instead.- 返回:
JdbcConnection
-
addReplicaHost
public void addReplicaHost(String hostPortPair) throws SQLException
- 抛出:
SQLException
-
addSlaveHost
@Deprecated public void addSlaveHost(String hostPortPair) throws SQLException
已过时。UseaddReplicaHost(String)instead.- 参数:
hostPortPair- host:port- 抛出:
SQLException
-
removeReplica
public void removeReplica(String hostPortPair) throws SQLException
- 抛出:
SQLException
-
removeSlave
@Deprecated public void removeSlave(String hostPortPair) throws SQLException
已过时。UseremoveReplica(String)instead.- 参数:
hostPortPair- host:port- 抛出:
SQLException
-
removeReplica
public void removeReplica(String hostPortPair, boolean closeGently) throws SQLException
- 抛出:
SQLException
-
removeSlave
@Deprecated public void removeSlave(String hostPortPair, boolean closeGently) throws SQLException
已过时。UseremoveReplica(String, boolean)instead.- 参数:
hostPortPair- host:portcloseGently- option- 抛出:
SQLException
-
isHostReplica
public boolean isHostReplica(String hostPortPair)
-
isHostSlave
@Deprecated public boolean isHostSlave(String hostPortPair)
已过时。UseisHostReplica(String)instead.- 参数:
hostPortPair- host:port- 返回:
- true if it's a replica
-
setReadOnly
public void setReadOnly(boolean readOnly) throws SQLException- 抛出:
SQLException
-
isReadOnly
public boolean isReadOnly() throws SQLException- 抛出:
SQLException
-
-