class DefaultServer extends java.lang.Object implements ClusterableServer
| Modifier and Type | Class and Description |
|---|---|
private class |
DefaultServer.DefaultServerProtocolExecutor |
private class |
DefaultServer.DefaultServerStateListener |
| Modifier and Type | Field and Description |
|---|---|
private ClusterConnectionMode |
clusterConnectionMode |
private CommandListener |
commandListener |
private ConnectionFactory |
connectionFactory |
private ConnectionPool |
connectionPool |
private ServerDescription |
description |
private boolean |
isClosed |
private static Logger |
LOGGER |
private ServerId |
serverId |
private ServerListener |
serverListener |
private ServerMonitor |
serverMonitor |
private ChangeListener<ServerDescription> |
serverStateListener |
| Constructor and Description |
|---|
DefaultServer(ServerId serverId,
ClusterConnectionMode clusterConnectionMode,
ConnectionPool connectionPool,
ConnectionFactory connectionFactory,
ServerMonitorFactory serverMonitorFactory,
java.util.List<ServerListener> serverListeners,
CommandListener commandListener) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the server.
|
void |
connect()
Attempt to connect to the server.
|
Connection |
getConnection()
Gets a connection to this server.
|
void |
getConnectionAsync(SingleResultCallback<AsyncConnection> callback)
Gets a connection to this server asynchronously.
|
(package private) ConnectionPool |
getConnectionPool() |
ServerDescription |
getDescription()
Gets the description of this server.
|
private void |
handleThrowable(java.lang.Throwable t) |
void |
invalidate()
Invalidate the description of this server.
|
boolean |
isClosed()
Returns true if the server is closed, false otherwise.
|
private static final Logger LOGGER
private final ServerId serverId
private final ConnectionPool connectionPool
private final ClusterConnectionMode clusterConnectionMode
private final ConnectionFactory connectionFactory
private final ServerMonitor serverMonitor
private final ChangeListener<ServerDescription> serverStateListener
private final ServerListener serverListener
private final CommandListener commandListener
private volatile ServerDescription description
private volatile boolean isClosed
public DefaultServer(ServerId serverId, ClusterConnectionMode clusterConnectionMode, ConnectionPool connectionPool, ConnectionFactory connectionFactory, ServerMonitorFactory serverMonitorFactory, java.util.List<ServerListener> serverListeners, CommandListener commandListener)
public Connection getConnection()
ServerGets a connection to this server. The connection should be released after the caller is done with it.
Implementations of this method are allowed to block while waiting for a free connection from a pool of available connection.
Implementations of this method will likely pool the underlying connection, so the effect of closing the returned connection will be to return the connection to the pool.
getConnection in interface Serverpublic void getConnectionAsync(SingleResultCallback<AsyncConnection> callback)
ServerGets a connection to this server asynchronously. The connection should be released after the caller is done with it.
Implementations of this method will likely pool the underlying connection, so the effect of closing the returned connection will be to return the connection to the pool.
getConnectionAsync in interface Servercallback - the callback to execute when the connection is available or an error occurspublic ServerDescription getDescription()
ServergetDescription in interface Serverpublic void invalidate()
ClusterableServerinvalidate in interface ClusterableServerpublic 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 ClusterableServerConnectionPool getConnectionPool()
private void handleThrowable(java.lang.Throwable t)