public class ReplicationConnectionProxy extends MultiHostConnectionProxy implements PingTarget
MultiHostConnectionProxy.JdbcInterfaceProxy| Modifier and Type | Field and Description |
|---|---|
protected boolean |
allowReplicaDownConnections |
protected boolean |
allowSourceDownConnections |
(package private) ReplicationConnectionGroup |
connectionGroup |
private long |
connectionGroupID |
protected boolean |
enableJMX |
protected boolean |
readFromSourceWhenNoReplicas |
protected boolean |
readFromSourceWhenNoReplicasOriginal |
protected boolean |
readOnly |
private java.util.List<HostInfo> |
replicaHosts |
protected LoadBalancedConnection |
replicasConnection |
protected LoadBalancedConnection |
sourceConnection |
private java.util.List<HostInfo> |
sourceHosts |
private ReplicationConnection |
thisAsReplicationConnection |
autoReconnect, closedExplicitly, closedReason, connectionUrl, currentConnection, hostsList, isClosed, lastExceptionDealtWith, parentProxyConnection, thisAsConnection, topProxyConnection| Modifier | Constructor and Description |
|---|---|
private |
ReplicationConnectionProxy(ConnectionUrl connectionUrl)
Creates a proxy for java.sql.Connection that routes requests to a load-balanced connection of source servers or a load-balanced connection of replica
servers.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addReplicaHost(java.lang.String hostPortPair) |
void |
addSlaveHost(java.lang.String hostPortPair)
Deprecated.
|
private void |
checkConnectionCapabilityForMethod(java.lang.reflect.Method method)
Checks if this connection is in a state capable to invoke the provided method.
|
static ReplicationConnection |
createProxyInstance(ConnectionUrl connectionUrl)
Static factory to create
ReplicationConnection instances. |
(package private) void |
doAbort(java.util.concurrent.Executor executor)
Executes a abort() invocation;
|
(package private) void |
doAbortInternal()
Executes a abortInternal() invocation;
|
(package private) void |
doClose()
Executes a close() invocation;
|
void |
doPing()
Pings both l/b connections.
|
long |
getConnectionGroupId() |
private ReplicationConnectionUrl |
getConnectionUrl() |
JdbcConnection |
getCurrentConnection() |
JdbcConnection |
getMasterConnection()
Deprecated.
|
(package private) JdbcConnection |
getNewWrapperForThisAsConnection()
Wraps this object with a new replication Connection instance.
|
private HostInfo |
getReplicaHost(java.lang.String hostPortPair) |
JdbcConnection |
getReplicasConnection() |
JdbcConnection |
getSlavesConnection()
Deprecated.
|
JdbcConnection |
getSourceConnection() |
private HostInfo |
getSourceHost(java.lang.String hostPortPair) |
private JdbcConnection |
initializeReplicasConnection() |
private JdbcConnection |
initializeSourceConnection() |
(package private) java.lang.Object |
invokeMore(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
Proxies method invocation on the java.sql.Connection interface.
|
boolean |
isHostMaster(java.lang.String hostPortPair)
Deprecated.
|
boolean |
isHostReplica(java.lang.String hostPortPair) |
boolean |
isHostSlave(java.lang.String hostPortPair)
Deprecated.
|
boolean |
isHostSource(java.lang.String hostPortPair) |
boolean |
isReadOnly() |
boolean |
isReplicasConnection()
Checks if current connection is the replicas l/b connection.
|
boolean |
isSlavesConnection()
Deprecated.
|
boolean |
isSourceConnection()
Checks if current connection is the sources l/b connection.
|
(package private) void |
pickNewConnection()
Picks the "best" connection to use from now on.
|
void |
promoteReplicaToSource(java.lang.String hostPortPair) |
void |
promoteSlaveToMaster(java.lang.String hostPortPair)
Deprecated.
|
protected void |
propagateProxyDown(JdbcConnection proxyConn)
Propagates the connection proxy down through all live connections.
|
void |
removeMasterHost(java.lang.String hostPortPair)
Deprecated.
|
void |
removeMasterHost(java.lang.String hostPortPair,
boolean waitUntilNotInUse)
Deprecated.
|
void |
removeMasterHost(java.lang.String hostPortPair,
boolean waitUntilNotInUse,
boolean isNowReplica)
Deprecated.
|
void |
removeReplica(java.lang.String hostPortPair) |
void |
removeReplica(java.lang.String hostPortPair,
boolean closeGently) |
void |
removeSlave(java.lang.String hostPortPair)
Deprecated.
|
void |
removeSlave(java.lang.String hostPortPair,
boolean closeGently)
Deprecated.
|
void |
removeSourceHost(java.lang.String hostPortPair) |
void |
removeSourceHost(java.lang.String hostPortPair,
boolean waitUntilNotInUse) |
void |
removeSourceHost(java.lang.String hostPortPair,
boolean waitUntilNotInUse,
boolean isNowReplica) |
private void |
resetReadFromSourceWhenNoReplicas() |
void |
setReadOnly(boolean readOnly) |
(package private) boolean |
shouldExceptionTriggerConnectionSwitch(java.lang.Throwable t)
Has no use in replication connections.
|
private boolean |
switchToReplicasConnection() |
private boolean |
switchToReplicasConnectionIfNecessary() |
private boolean |
switchToSourceConnection() |
(package private) void |
syncSessionState(JdbcConnection source,
JdbcConnection target,
boolean readonly)
Synchronizes session state between two connections, allowing to override the read-only status.
|
allowedOnClosedConnection, createConnectionForHost, dealWithInvocationException, getNewJdbcInterfaceProxy, getParentProxy, getProxy, initializeHostsSpecs, invalidateConnection, invalidateCurrentConnection, invoke, isMasterConnection, proxyIfReturnTypeIsJdbcInterface, setProxy, syncSessionStateprivate ReplicationConnection thisAsReplicationConnection
protected boolean enableJMX
protected boolean allowSourceDownConnections
protected boolean allowReplicaDownConnections
protected boolean readFromSourceWhenNoReplicas
protected boolean readFromSourceWhenNoReplicasOriginal
protected boolean readOnly
ReplicationConnectionGroup connectionGroup
private long connectionGroupID
private java.util.List<HostInfo> sourceHosts
protected LoadBalancedConnection sourceConnection
private java.util.List<HostInfo> replicaHosts
protected LoadBalancedConnection replicasConnection
private ReplicationConnectionProxy(ConnectionUrl connectionUrl) throws java.sql.SQLException
connectionUrl - The connection URL containing the hosts in a replication setup.java.sql.SQLException - if an error occurspublic static ReplicationConnection createProxyInstance(ConnectionUrl connectionUrl) throws java.sql.SQLException
ReplicationConnection instances.connectionUrl - The connection URL containing the hosts in a replication setup.ReplicationConnection proxy.java.sql.SQLException - if an error occursJdbcConnection getNewWrapperForThisAsConnection() throws java.sql.SQLException
getNewWrapperForThisAsConnection in class MultiHostConnectionProxyjava.sql.SQLException - if an error occursprotected void propagateProxyDown(JdbcConnection proxyConn)
propagateProxyDown in class MultiHostConnectionProxyproxyConn - The top level connection in the multi-host connections chain.boolean shouldExceptionTriggerConnectionSwitch(java.lang.Throwable t)
false.shouldExceptionTriggerConnectionSwitch in class MultiHostConnectionProxyt - The Exception instance to check.public boolean isSourceConnection()
isSourceConnection in class MultiHostConnectionProxypublic boolean isReplicasConnection()
@Deprecated public boolean isSlavesConnection()
isReplicasConnection() instead.void pickNewConnection()
throws java.sql.SQLException
MultiHostConnectionProxypickNewConnection in class MultiHostConnectionProxyjava.sql.SQLException - if an error occursvoid syncSessionState(JdbcConnection source, JdbcConnection target, boolean readonly) throws java.sql.SQLException
MultiHostConnectionProxysyncSessionState in class MultiHostConnectionProxysource - The connection where to get state from.target - The connection where to set state.readonly - The new read-only status.java.sql.SQLException - if an error occursvoid doClose()
throws java.sql.SQLException
MultiHostConnectionProxydoClose in class MultiHostConnectionProxyjava.sql.SQLException - if an error occursvoid doAbortInternal()
throws java.sql.SQLException
MultiHostConnectionProxydoAbortInternal in class MultiHostConnectionProxyjava.sql.SQLException - if an error occursvoid doAbort(java.util.concurrent.Executor executor)
throws java.sql.SQLException
MultiHostConnectionProxydoAbort in class MultiHostConnectionProxyexecutor - executorjava.sql.SQLException - if an error occursjava.lang.Object invokeMore(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
invokeMore in class MultiHostConnectionProxyproxy - proxy objectmethod - method to invokeargs - method parametersjava.lang.Throwable - if an error occursprivate void checkConnectionCapabilityForMethod(java.lang.reflect.Method method)
throws java.lang.Throwable
method - methodjava.lang.Throwable - if an error occurspublic void doPing()
throws java.sql.SQLException
doPing in interface PingTargetjava.sql.SQLExceptionprivate JdbcConnection initializeSourceConnection() throws java.sql.SQLException
java.sql.SQLExceptionprivate JdbcConnection initializeReplicasConnection() throws java.sql.SQLException
java.sql.SQLExceptionprivate boolean switchToSourceConnection()
throws java.sql.SQLException
java.sql.SQLExceptionprivate boolean switchToReplicasConnection()
throws java.sql.SQLException
java.sql.SQLExceptionprivate boolean switchToReplicasConnectionIfNecessary()
throws java.sql.SQLException
java.sql.SQLExceptionpublic JdbcConnection getCurrentConnection()
public long getConnectionGroupId()
public JdbcConnection getSourceConnection()
@Deprecated public JdbcConnection getMasterConnection()
getSourceConnection() instead.JdbcConnectionpublic void promoteReplicaToSource(java.lang.String hostPortPair)
throws java.sql.SQLException
java.sql.SQLException@Deprecated
public void promoteSlaveToMaster(java.lang.String hostPortPair)
throws java.sql.SQLException
promoteReplicaToSource(String) instead.hostPortPair - host:portjava.sql.SQLExceptionpublic void removeSourceHost(java.lang.String hostPortPair)
throws java.sql.SQLException
java.sql.SQLException@Deprecated
public void removeMasterHost(java.lang.String hostPortPair)
throws java.sql.SQLException
removeSourceHost(String) instead.hostPortPair - host:portjava.sql.SQLExceptionpublic void removeSourceHost(java.lang.String hostPortPair,
boolean waitUntilNotInUse)
throws java.sql.SQLException
java.sql.SQLException@Deprecated
public void removeMasterHost(java.lang.String hostPortPair,
boolean waitUntilNotInUse)
throws java.sql.SQLException
removeSourceHost(String, boolean) instead.hostPortPair - host:portwaitUntilNotInUse - remove only when not in usejava.sql.SQLExceptionpublic void removeSourceHost(java.lang.String hostPortPair,
boolean waitUntilNotInUse,
boolean isNowReplica)
throws java.sql.SQLException
java.sql.SQLException@Deprecated
public void removeMasterHost(java.lang.String hostPortPair,
boolean waitUntilNotInUse,
boolean isNowReplica)
throws java.sql.SQLException
removeSourceHost(String, boolean, boolean) instead.hostPortPair - host:portwaitUntilNotInUse - remove only when not in useisNowReplica - place to replicasjava.sql.SQLExceptionpublic boolean isHostSource(java.lang.String hostPortPair)
@Deprecated public boolean isHostMaster(java.lang.String hostPortPair)
isHostSource(String) instead.hostPortPair - host:portpublic JdbcConnection getReplicasConnection()
@Deprecated public JdbcConnection getSlavesConnection()
getReplicasConnection() instead.JdbcConnectionpublic void addReplicaHost(java.lang.String hostPortPair)
throws java.sql.SQLException
java.sql.SQLException@Deprecated
public void addSlaveHost(java.lang.String hostPortPair)
throws java.sql.SQLException
addReplicaHost(String) instead.hostPortPair - host:portjava.sql.SQLExceptionpublic void removeReplica(java.lang.String hostPortPair)
throws java.sql.SQLException
java.sql.SQLException@Deprecated
public void removeSlave(java.lang.String hostPortPair)
throws java.sql.SQLException
removeReplica(String) instead.hostPortPair - host:portjava.sql.SQLExceptionpublic void removeReplica(java.lang.String hostPortPair,
boolean closeGently)
throws java.sql.SQLException
java.sql.SQLException@Deprecated
public void removeSlave(java.lang.String hostPortPair,
boolean closeGently)
throws java.sql.SQLException
removeReplica(String, boolean) instead.hostPortPair - host:portcloseGently - optionjava.sql.SQLExceptionpublic boolean isHostReplica(java.lang.String hostPortPair)
@Deprecated public boolean isHostSlave(java.lang.String hostPortPair)
isHostReplica(String) instead.hostPortPair - host:portpublic void setReadOnly(boolean readOnly)
throws java.sql.SQLException
java.sql.SQLExceptionpublic boolean isReadOnly()
throws java.sql.SQLException
java.sql.SQLExceptionprivate void resetReadFromSourceWhenNoReplicas()
private HostInfo getSourceHost(java.lang.String hostPortPair)
private HostInfo getReplicaHost(java.lang.String hostPortPair)
private ReplicationConnectionUrl getConnectionUrl()