public class LoadBalancedConnectionProxy extends MultiHostConnectionProxy implements PingTarget
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.String,ConnectionImpl> |
liveConnections |
connectionUrl, lastExceptionDealtWith
Constructor and Description |
---|
LoadBalancedConnectionProxy(ConnectionUrl connectionUrl)
Creates a proxy for java.sql.Connection that routes requests between the hosts in the connection URL.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addHost(java.lang.String hostPortPair)
Adds a host to the hosts list.
|
void |
addToGlobalBlacklist(java.lang.String host)
Deprecated.
|
void |
addToGlobalBlacklist(java.lang.String host,
long timeout)
Deprecated.
|
void |
addToGlobalBlocklist(java.lang.String host)
Adds a host to the blocklist.
|
void |
addToGlobalBlocklist(java.lang.String host,
long timeout)
Adds a host to the blocklist with the given timeout.
|
ConnectionImpl |
createConnectionForHost(HostInfo hostInfo)
Creates a new physical connection for the given
HostInfo and updates required internal mappings and statistics for that connection. |
ConnectionImpl |
createConnectionForHost(java.lang.String hostPortPair)
Creates a new physical connection for the given host:port info.
|
static LoadBalancedConnection |
createProxyInstance(ConnectionUrl connectionUrl)
Static factory to create
LoadBalancedConnection instances. |
void |
doPing()
Pings live connections.
|
long |
getActivePhysicalConnectionCount() |
long |
getConnectionGroupProxyID() |
java.lang.String |
getCurrentActiveHost() |
long |
getCurrentTransactionDuration() |
java.util.Map<java.lang.String,java.lang.Long> |
getGlobalBlacklist()
Deprecated.
|
java.util.Map<java.lang.String,java.lang.Long> |
getGlobalBlocklist()
Returns a local hosts blocklist, while cleaning up expired records from the global blocklist, or a blocklist with the hosts to be removed.
|
long |
getTotalPhysicalConnectionCount() |
long |
getTransactionCount() |
boolean |
inTransaction() |
boolean |
isGlobalBlacklistEnabled()
Deprecated.
|
boolean |
isGlobalBlocklistEnabled()
Checks if host blocklist management was enabled.
|
void |
pickNewConnection()
Picks the "best" connection to use for the next transaction based on the BalanceStrategy in use.
|
protected void |
propagateProxyDown(JdbcConnection proxyConn)
Propagates the connection proxy down through all live connections.
|
void |
removeFromGlobalBlacklist(java.lang.String host)
Deprecated.
|
void |
removeFromGlobalBlocklist(java.lang.String host)
Removes a host from the blocklist.
|
void |
removeHost(java.lang.String hostPortPair)
Removes a host from the host list.
|
void |
removeHostWhenNotInUse(java.lang.String hostPortPair)
Removes a host from the host list, allowing it some time to be released gracefully if needed.
|
boolean |
shouldExceptionTriggerFailover(java.lang.Throwable t)
Deprecated.
|
allowedOnClosedConnection, getParentProxy, getProxy, invoke, setProxy
protected java.util.Map<java.lang.String,ConnectionImpl> liveConnections
public LoadBalancedConnectionProxy(ConnectionUrl connectionUrl) throws java.sql.SQLException
connectionUrl
- The connection URL containing the hosts to load balance.java.sql.SQLException
- if an error occurspublic static LoadBalancedConnection createProxyInstance(ConnectionUrl connectionUrl) throws java.sql.SQLException
LoadBalancedConnection
instances.connectionUrl
- The connection URL containing the hosts in a load-balance setup.LoadBalancedConnection
proxy.java.sql.SQLException
- if an error occursprotected void propagateProxyDown(JdbcConnection proxyConn)
propagateProxyDown
in class MultiHostConnectionProxy
proxyConn
- The top level connection in the multi-host connections chain.@Deprecated public boolean shouldExceptionTriggerFailover(java.lang.Throwable t)
public void pickNewConnection() throws java.sql.SQLException
java.sql.SQLException
- if an error occurspublic ConnectionImpl createConnectionForHost(HostInfo hostInfo) throws java.sql.SQLException
HostInfo
and updates required internal mappings and statistics for that connection.hostInfo
- The host info instance.java.sql.SQLException
- if an error occurspublic ConnectionImpl createConnectionForHost(java.lang.String hostPortPair) throws java.sql.SQLException
hostPortPair
- The host:port pair identifying the host to connect to.java.sql.SQLException
- if an error occurspublic void doPing() throws java.sql.SQLException
doPing
in interface PingTarget
java.sql.SQLException
- if an error occurspublic void addToGlobalBlocklist(java.lang.String host, long timeout)
host
- The host to be blocklisted.timeout
- The blocklist timeout for this entry.public void removeFromGlobalBlocklist(java.lang.String host)
host
- The host to be removed from the blocklist.@Deprecated public void removeFromGlobalBlacklist(java.lang.String host)
removeFromGlobalBlocklist(String)
instead.host
- host@Deprecated public void addToGlobalBlacklist(java.lang.String host, long timeout)
addToGlobalBlocklist(String, long)
instead.host
- The host to be blocklisted.timeout
- The blocklist timeout for this entry.public void addToGlobalBlocklist(java.lang.String host)
host
- The host to be blocklisted.@Deprecated public void addToGlobalBlacklist(java.lang.String host)
addToGlobalBlocklist(String)
instead.host
- The host to be blocklisted.public boolean isGlobalBlocklistEnabled()
@Deprecated public boolean isGlobalBlacklistEnabled()
isGlobalBlocklistEnabled()
instead.public java.util.Map<java.lang.String,java.lang.Long> getGlobalBlocklist()
@Deprecated public java.util.Map<java.lang.String,java.lang.Long> getGlobalBlacklist()
getGlobalBlocklist()
instead.public void removeHostWhenNotInUse(java.lang.String hostPortPair) throws java.sql.SQLException
hostPortPair
- The host to be removed.java.sql.SQLException
- if an error occurspublic void removeHost(java.lang.String hostPortPair) throws java.sql.SQLException
hostPortPair
- The host to be removed.java.sql.SQLException
- if an error occurspublic boolean addHost(java.lang.String hostPortPair)
hostPortPair
- The host to be added.public boolean inTransaction()
public long getTransactionCount()
public long getActivePhysicalConnectionCount()
public long getTotalPhysicalConnectionCount()
public long getConnectionGroupProxyID()
public java.lang.String getCurrentActiveHost()
public long getCurrentTransactionDuration()