public class ClusterAwareWriterFailoverHandler extends Object implements 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.
Modifier and Type | Field and Description |
---|---|
protected Properties |
connectionProps |
protected ConnectionProvider |
connectionProvider |
protected int |
maxFailoverTimeoutMs |
protected ReaderFailoverHandler |
readerFailoverHandler |
protected int |
readTopologyIntervalMs |
protected int |
reconnectWriterIntervalMs |
protected TopologyService |
topologyService |
Constructor and Description |
---|
ClusterAwareWriterFailoverHandler(TopologyService topologyService,
ConnectionProvider connectionProvider,
Properties connectionProps,
ReaderFailoverHandler readerFailoverHandler)
ClusterAwareWriterFailoverHandler constructor
|
ClusterAwareWriterFailoverHandler(TopologyService topologyService,
ConnectionProvider connectionProvider,
Properties connectionProps,
ReaderFailoverHandler readerFailoverHandler,
int failoverTimeoutMs,
int readTopologyIntervalMs,
int reconnectWriterIntervalMs)
ClusterAwareWriterFailoverHandler constructor.
|
Modifier and Type | Method and Description |
---|---|
WriterFailoverResult |
failover(List<HostInfo> currentTopology)
Called to start Writer Failover Process.
|
protected int maxFailoverTimeoutMs
protected int readTopologyIntervalMs
protected int reconnectWriterIntervalMs
protected TopologyService topologyService
protected ConnectionProvider connectionProvider
protected ReaderFailoverHandler readerFailoverHandler
protected Properties connectionProps
public ClusterAwareWriterFailoverHandler(TopologyService topologyService, ConnectionProvider connectionProvider, Properties connectionProps, ReaderFailoverHandler readerFailoverHandler)
topologyService
- The topology service used to update and query the cluster topologyconnectionProvider
- The connection provider used to establish the database connectionconnectionProps
- a set of properties for a new connectionsreaderFailoverHandler
- The reader failover handler used with this connectionpublic ClusterAwareWriterFailoverHandler(TopologyService topologyService, ConnectionProvider connectionProvider, Properties connectionProps, ReaderFailoverHandler readerFailoverHandler, int failoverTimeoutMs, int readTopologyIntervalMs, int reconnectWriterIntervalMs)
topologyService
- The topology service used to update and query the cluster topologyconnectionProvider
- The connection provider used to establish the database connectionconnectionProps
- a set of properties for a new connectionsreaderFailoverHandler
- The reader failover handler used with this connectionfailoverTimeoutMs
- The maximum allowable time for failover in msreadTopologyIntervalMs
- The refresh rate of the cluster topology in msreconnectWriterIntervalMs
- The time in ms to wait before re-attempting to reconnect to the writerpublic WriterFailoverResult failover(List<HostInfo> currentTopology) throws SQLException
failover
in interface WriterFailoverHandler
currentTopology
- Current topology for the cluster.WriterFailoverResult
The results of this process.SQLException
- if failover failsCopyright © 1997-2021 PostgreSQL Global Development Group. All Rights Reserved.