AutoCloseable
, Closeable
public interface Cluster extends Closeable
Modifier and Type | Method | Description |
---|---|---|
void |
close() |
Closes connections to the servers in the cluster.
|
BsonTimestamp |
getClusterTime() |
Get the last seen cluster time
|
ClusterDescription |
getCurrentDescription() |
Get the current description of this cluster.
|
ClusterDescription |
getDescription() |
Get the description of this cluster.
|
ClusterSettings |
getSettings() |
Gets the cluster settings with which this cluster was created.
|
boolean |
isClosed() |
Whether all the servers in the cluster are closed or not.
|
Server |
selectServer(ServerSelector serverSelector) |
Get a MongoDB server that matches the criteria defined by the serverSelector
|
void |
selectServerAsync(ServerSelector serverSelector,
SingleResultCallback<Server> callback) |
Asynchronously gets a MongoDB server that matches the criteria defined by the serverSelector.
|
ClusterSettings getSettings()
ClusterDescription getDescription()
MongoTimeoutException
- if the timeout has been reached before the cluster type is knownClusterDescription getCurrentDescription()
@Nullable BsonTimestamp getClusterTime()
Server selectServer(ServerSelector serverSelector)
serverSelector
- a ServerSelector that defines how to select the required ServerMongoTimeoutException
- if the timeout has been reached before a server matching the selector is availablevoid selectServerAsync(ServerSelector serverSelector, SingleResultCallback<Server> callback)
serverSelector
- a ServerSelector that defines how to select the required Servercallback
- the callback to invoke when the server is found or an error occursvoid close()
close
in interface AutoCloseable
close
in interface Closeable
boolean isClosed()