public class ClusterPinger extends Object implements Runnable, Closeable
Modifier and Type | Class and Description |
---|---|
protected static class |
ClusterPinger.Pinger
Pinger provides logic to ping servers.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_PING_INTERVAL_SECONDS
The default interval between ping sweeps in seconds.
|
protected static Logger |
LOG
The logger for the
ClusterPinger . |
Constructor and Description |
---|
ClusterPinger(ClusterState cluster,
ClusterType clusterType,
ProxiedConnectionFactory factory,
MongoClientConfiguration config)
Creates a new ClusterPinger.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
TimeUnit |
getIntervalUnits()
Returns the units for the ping sweep intervals.
|
int |
getPingSweepInterval()
Returns the interval for a ping sweep across all of the servers..
|
void |
initialSweep()
Performs a single sweep through the servers sending a ping with a
callback to set the latency and tags for each server.
|
static boolean |
ping(InetSocketAddress addr,
Connection conn)
Pings the server and suppresses all exceptions.
|
void |
run() |
void |
setIntervalUnits(TimeUnit intervalUnits)
Sets the value of units for the ping sweep intervals.
|
void |
setPingSweepInterval(int pingSweepInterval)
Sets the interval for a ping sweep across all of the servers..
|
void |
start()
Starts the background pinger.
|
void |
stop()
Stops the background pinger.
|
public static final int DEFAULT_PING_INTERVAL_SECONDS
protected static final Logger LOG
ClusterPinger
.public ClusterPinger(ClusterState cluster, ClusterType clusterType, ProxiedConnectionFactory factory, MongoClientConfiguration config)
cluster
- The state of the cluster.clusterType
- The type of cluster being managed.factory
- The factory for creating connections to the servers.config
- The configuration for the connections.public static boolean ping(InetSocketAddress addr, Connection conn)
addr
- The address of the server. Used for logging.conn
- The connection to ping.public void close()
Overridden to close the pinger.
close
in interface Closeable
close
in interface AutoCloseable
public TimeUnit getIntervalUnits()
public int getPingSweepInterval()
public void initialSweep()
This method will not return until at least 50% of the servers have replied (which may be a failure) to the initial ping.
public void run()
Overridden to periodically wake-up and ping the servers. At first this will occur fairly often but eventually degrade to once every 5 minutes.
public void setIntervalUnits(TimeUnit intervalUnits)
intervalUnits
- The new value for the units for the ping sweep intervals.public void setPingSweepInterval(int pingSweepInterval)
pingSweepInterval
- The new value for the interval for a ping sweep across all of
the servers..public void start()
public void stop()
close()
.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.