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 ClusterClock |
clusterClock |
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,
ServerListener serverListener,
CommandListener commandListener,
ClusterClock clusterClock) |
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 final ClusterClock clusterClock
private volatile ServerDescription description
private volatile boolean isClosed
DefaultServer(ServerId serverId, ClusterConnectionMode clusterConnectionMode, ConnectionPool connectionPool, ConnectionFactory connectionFactory, ServerMonitorFactory serverMonitorFactory, ServerListener serverListener, CommandListener commandListener, ClusterClock clusterClock)
public Connection getConnection()
Server
Gets 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 Server
public void getConnectionAsync(SingleResultCallback<AsyncConnection> callback)
Server
Gets 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 Server
callback
- the callback to execute when the connection is available or an error occurspublic ServerDescription getDescription()
Server
getDescription
in interface Server
public void invalidate()
ClusterableServer
invalidate
in interface ClusterableServer
public void close()
ClusterableServer
Closes 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 ClusterableServer
public boolean isClosed()
ClusterableServer
isClosed
in interface ClusterableServer
public void connect()
ClusterableServer
connect
in interface ClusterableServer
ConnectionPool getConnectionPool()
private void handleThrowable(java.lang.Throwable t)