class MongoClientImpl extends java.lang.Object implements MongoClient
Modifier and Type | Field and Description |
---|---|
private ClientSessionHelper |
clientSessionHelper |
private Cluster |
cluster |
private AsyncOperationExecutor |
executor |
private java.io.Closeable |
externalResourceCloser |
private static Logger |
LOGGER |
private ServerSessionPool |
serverSessionPool |
private MongoClientSettings |
settings |
Modifier | Constructor and Description |
---|---|
(package private) |
MongoClientImpl(MongoClientSettings settings,
Cluster cluster,
AsyncOperationExecutor executor) |
private |
MongoClientImpl(MongoClientSettings settings,
Cluster cluster,
AsyncOperationExecutor executor,
java.io.Closeable externalResourceCloser) |
(package private) |
MongoClientImpl(MongoClientSettings settings,
Cluster cluster,
java.io.Closeable externalResourceCloser) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the client, which will close all underlying cached resources, including, for example,
sockets and background monitoring threads.
|
private MongoIterable<java.lang.String> |
createListDatabaseNamesIterable(ClientSession clientSession) |
private <T> ListDatabasesIterable<T> |
createListDatabasesIterable(ClientSession clientSession,
java.lang.Class<T> clazz) |
(package private) Cluster |
getCluster() |
MongoDatabase |
getDatabase(java.lang.String name)
Gets the database with the given name.
|
(package private) ServerSessionPool |
getServerSessionPool() |
MongoClientSettings |
getSettings()
Gets the settings that this client uses to connect to server.
|
MongoIterable<java.lang.String> |
listDatabaseNames()
Get a list of the database names
|
MongoIterable<java.lang.String> |
listDatabaseNames(ClientSession clientSession)
Get a list of the database names
|
ListDatabasesIterable<Document> |
listDatabases()
Gets the list of databases
|
<T> ListDatabasesIterable<T> |
listDatabases(java.lang.Class<T> resultClass)
Gets the list of databases
|
ListDatabasesIterable<Document> |
listDatabases(ClientSession clientSession)
Gets the list of databases
|
<TResult> ListDatabasesIterable<TResult> |
listDatabases(ClientSession clientSession,
java.lang.Class<TResult> resultClass)
Gets the list of databases
|
void |
startSession(ClientSessionOptions options,
SingleResultCallback<ClientSession> callback)
Creates a client session.
|
private static final Logger LOGGER
private final Cluster cluster
private final MongoClientSettings settings
private final AsyncOperationExecutor executor
private final java.io.Closeable externalResourceCloser
private final ServerSessionPool serverSessionPool
private final ClientSessionHelper clientSessionHelper
MongoClientImpl(MongoClientSettings settings, Cluster cluster, java.io.Closeable externalResourceCloser)
MongoClientImpl(MongoClientSettings settings, Cluster cluster, AsyncOperationExecutor executor)
private MongoClientImpl(MongoClientSettings settings, Cluster cluster, AsyncOperationExecutor executor, java.io.Closeable externalResourceCloser)
public void startSession(ClientSessionOptions options, SingleResultCallback<ClientSession> callback)
MongoClient
Note: A ClientSession instance can not be used concurrently in multiple asynchronous operations.
startSession
in interface MongoClient
options
- the options for the client sessioncallback
- the callback that is passed the clientSession or a MongoClientException
if the MongoDB cluster to which
this client is connected does not support sessionspublic MongoDatabase getDatabase(java.lang.String name)
MongoClient
getDatabase
in interface MongoClient
name
- the name of the databaseMongoNamespace.checkDatabaseNameValidity(String)
public void close()
MongoClient
close
in interface MongoClient
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public MongoClientSettings getSettings()
MongoClient
Note: MongoClientSettings
is immutable.
getSettings
in interface MongoClient
public MongoIterable<java.lang.String> listDatabaseNames()
MongoClient
listDatabaseNames
in interface MongoClient
public MongoIterable<java.lang.String> listDatabaseNames(ClientSession clientSession)
MongoClient
listDatabaseNames
in interface MongoClient
clientSession
- the client session with which to associate this operationprivate MongoIterable<java.lang.String> createListDatabaseNamesIterable(ClientSession clientSession)
public ListDatabasesIterable<Document> listDatabases()
MongoClient
listDatabases
in interface MongoClient
public ListDatabasesIterable<Document> listDatabases(ClientSession clientSession)
MongoClient
listDatabases
in interface MongoClient
clientSession
- the client session with which to associate this operationpublic <T> ListDatabasesIterable<T> listDatabases(java.lang.Class<T> resultClass)
MongoClient
listDatabases
in interface MongoClient
T
- the type of the class to use instead of Document
.resultClass
- the class to cast the database documents topublic <TResult> ListDatabasesIterable<TResult> listDatabases(ClientSession clientSession, java.lang.Class<TResult> resultClass)
MongoClient
listDatabases
in interface MongoClient
TResult
- the type of the class to use instead of Document
.clientSession
- the client session with which to associate this operationresultClass
- the class to cast the database documents toprivate <T> ListDatabasesIterable<T> createListDatabasesIterable(ClientSession clientSession, java.lang.Class<T> clazz)
Cluster getCluster()
ServerSessionPool getServerSessionPool()