Package com.mysql.cj.jdbc.ha.ca
Class ClusterAwareWriterFailoverHandler
java.lang.Object
com.mysql.cj.jdbc.ha.ca.ClusterAwareWriterFailoverHandler
- All Implemented Interfaces:
WriterFailoverHandler
public class ClusterAwareWriterFailoverHandler extends java.lang.Object implements WriterFailoverHandler
An implementation of WriterFailoverHandler.
Writer Failover Process goal is to re-establish connection to a writer. Connection to a writer may be disrupted either by temporary network issue, or due to writer host unavailability during cluster failover. This handler tries both approaches in parallel: 1) try to re-connect to the same writer host, 2) try to update cluster topology and connect to a newly elected writer.
-
Field Summary
Fields Modifier and Type Field Description protected ConnectionProviderconnectionProviderprotected java.util.Map<java.lang.String,java.lang.String>initialConnectionPropsprotected LoglogThe logger we're going to use.protected intmaxFailoverTimeoutMsprotected static LogNULL_LOGGERNull logger shared by all connections at startup.protected ReaderFailoverHandlerreaderFailoverHandlerprotected intreadTopologyIntervalMsprotected intreconnectWriterIntervalMsprotected TopologyServicetopologyService -
Constructor Summary
Constructors Constructor Description ClusterAwareWriterFailoverHandler(TopologyService topologyService, ConnectionProvider connectionProvider, ReaderFailoverHandler readerFailoverHandler, java.util.Map<java.lang.String,java.lang.String> initialConnectionProps, int failoverTimeoutMs, int readTopologyIntervalMs, int reconnectWriterIntervalMs, Log log)ClusterAwareWriterFailoverHandler constructor.ClusterAwareWriterFailoverHandler(TopologyService topologyService, ConnectionProvider connectionProvider, ReaderFailoverHandler readerFailoverHandler, java.util.Map<java.lang.String,java.lang.String> initialConnectionProps, Log log)ClusterAwareWriterFailoverHandler constructor. -
Method Summary
Modifier and Type Method Description WriterFailoverResultfailover(java.util.List<HostInfo> currentTopology)Called to start Writer Failover Process.
-
Field Details
-
NULL_LOGGER
Null logger shared by all connections at startup. -
log
The logger we're going to use. -
maxFailoverTimeoutMs
protected int maxFailoverTimeoutMs -
readTopologyIntervalMs
protected int readTopologyIntervalMs -
reconnectWriterIntervalMs
protected int reconnectWriterIntervalMs -
initialConnectionProps
protected java.util.Map<java.lang.String,java.lang.String> initialConnectionProps -
topologyService
-
connectionProvider
-
readerFailoverHandler
-
-
Constructor Details
-
ClusterAwareWriterFailoverHandler
public ClusterAwareWriterFailoverHandler(TopologyService topologyService, ConnectionProvider connectionProvider, ReaderFailoverHandler readerFailoverHandler, java.util.Map<java.lang.String,java.lang.String> initialConnectionProps, Log log)ClusterAwareWriterFailoverHandler constructor. -
ClusterAwareWriterFailoverHandler
public ClusterAwareWriterFailoverHandler(TopologyService topologyService, ConnectionProvider connectionProvider, ReaderFailoverHandler readerFailoverHandler, java.util.Map<java.lang.String,java.lang.String> initialConnectionProps, int failoverTimeoutMs, int readTopologyIntervalMs, int reconnectWriterIntervalMs, Log log)ClusterAwareWriterFailoverHandler constructor.
-
-
Method Details
-
failover
public WriterFailoverResult failover(java.util.List<HostInfo> currentTopology) throws java.sql.SQLExceptionCalled to start Writer Failover Process.- Specified by:
failoverin interfaceWriterFailoverHandler- Parameters:
currentTopology- Cluster current topology- Returns:
WriterFailoverResultThe results of this process.- Throws:
java.sql.SQLException
-