class DefaultServer extends java.lang.Object implements ClusterableServer
| Modifier and Type | Class and Description |
|---|---|
private class |
DefaultServer.DefaultServerStateListener |
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<ChangeListener<ServerDescription>,java.lang.Boolean> |
changeListeners |
private PooledConnectionProvider |
connectionProvider |
private ServerDescription |
description |
private boolean |
isClosed |
private ServerAddress |
serverAddress |
private ServerMonitor |
serverMonitor |
private ChangeListener<ServerDescription> |
serverStateListener |
| Constructor and Description |
|---|
DefaultServer(ServerAddress serverAddress,
ServerSettings settings,
java.lang.String clusterId,
PooledConnectionProvider connectionProvider,
Mongo mongo) |
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(ChangeListener<ServerDescription> changeListener)
Adds a change listener to this server.
|
void |
close()
Closes the server.
|
void |
connect()
Attempt to connect to the server.
|
Connection |
getConnection(long maxWaitTime,
java.util.concurrent.TimeUnit timeUnit) |
ServerDescription |
getDescription()
Gets the description of this server.
|
void |
invalidate()
Invalidate the description of this server.
|
boolean |
isClosed()
Returns true if the server is closed, false otherwise.
|
private final ServerAddress serverAddress
private final ServerMonitor serverMonitor
private final PooledConnectionProvider connectionProvider
private final java.util.Map<ChangeListener<ServerDescription>,java.lang.Boolean> changeListeners
private final ChangeListener<ServerDescription> serverStateListener
private volatile ServerDescription description
private volatile boolean isClosed
public DefaultServer(ServerAddress serverAddress, ServerSettings settings, java.lang.String clusterId, PooledConnectionProvider connectionProvider, Mongo mongo)
public ServerDescription getDescription()
ServergetDescription in interface Serverpublic Connection getConnection(long maxWaitTime, java.util.concurrent.TimeUnit timeUnit)
getConnection in interface Serverpublic void addChangeListener(ChangeListener<ServerDescription> changeListener)
ClusterableServeraddChangeListener in interface ClusterableServerchangeListener - the listener for change events to the description of this serverpublic void invalidate()
ClusterableServerinvalidate in interface ClusterableServerinvalidate in interface Serverpublic void close()
ClusterableServerCloses the server. Instances that have been closed will no longer be available for use.
Implementations should ensure that this method can be called multiple times with no ill effects.
close in interface ClusterableServerpublic boolean isClosed()
ClusterableServerisClosed in interface ClusterableServerpublic void connect()
ClusterableServerconnect in interface ClusterableServer