Interface MongoClient
- All Superinterfaces:
AutoCloseable
,Closeable
,MongoCluster
A client-side representation of a MongoDB cluster. Instances can represent either a standalone MongoDB instance, a replica set,
or a sharded cluster. Instance of this class are responsible for maintaining an up-to-date state of the cluster,
and possibly cache resources related to this, including background threads for monitoring, and connection pools.
Instance of this class server as factories for MongoDatabase
instances.
- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the client, which will close all underlying cached resources, including, for example, sockets and background monitoring threads.Gets the current cluster description.Methods inherited from interface com.mongodb.reactivestreams.client.MongoCluster
getCodecRegistry, getDatabase, getReadConcern, getReadPreference, getTimeout, getWriteConcern, listDatabaseNames, listDatabaseNames, listDatabases, listDatabases, listDatabases, listDatabases, startSession, startSession, watch, watch, watch, watch, watch, watch, watch, watch, withCodecRegistry, withReadConcern, withReadPreference, withTimeout, withWriteConcern
-
Method Details
-
close
void close()Close the client, which will close all underlying cached resources, including, for example, sockets and background monitoring threads.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
getClusterDescription
ClusterDescription getClusterDescription()Gets the current cluster description.This method will not block, meaning that it may return a
ClusterDescription
whoseclusterType
is unknown and whoseServerDescription
s are all in the connecting state. If the application requires notifications after the driver has connected to a member of the cluster, it should register aClusterListener
via theClusterSettings
inMongoClientSettings
.- Returns:
- the current cluster description
- Since:
- 4.1
- See Also:
-