@ThreadSafe public class MongoClients extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
MongoClients.Builder
Configures and builds a ConnectionPool.
|
| Modifier and Type | Field and Description |
|---|---|
private Map<List<com.mongodb.ServerAddress>,com.mongodb.MongoClient> |
connections |
private List<com.mongodb.MongoCredential> |
credentials |
private Map<com.mongodb.ServerAddress,com.mongodb.MongoClient> |
directConnections |
private com.mongodb.MongoClientOptions |
options |
| Modifier | Constructor and Description |
|---|---|
private |
MongoClients(com.mongodb.MongoClientOptions options,
List<com.mongodb.MongoCredential> credentials) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear out and close any open connections.
|
com.mongodb.MongoClient |
clientFor(com.mongodb.ServerAddress address)
Obtain a direct client connection to the specified server.
|
com.mongodb.MongoClient |
clientFor(String addressString)
Obtain a direct client connection to the specified server.
|
com.mongodb.MongoClient |
clientForMembers(List<com.mongodb.ServerAddress> seedAddresses)
Obtain a client connection to the replica set or cluster.
|
com.mongodb.MongoClient |
clientForMembers(com.mongodb.ServerAddress... seeds)
Obtain a client connection to the replica set or cluster.
|
com.mongodb.MongoClient |
clientForMembers(String addressList)
Obtain a client connection to the replica set or cluster.
|
protected com.mongodb.MongoClient |
connection(List<com.mongodb.ServerAddress> addresses) |
static MongoClients.Builder |
create()
Obtain a builder that can be used to configure and
create a connection pool. |
protected com.mongodb.MongoClient |
directConnection(com.mongodb.ServerAddress address) |
private final Map<com.mongodb.ServerAddress,com.mongodb.MongoClient> directConnections
private final List<com.mongodb.MongoCredential> credentials
private final com.mongodb.MongoClientOptions options
private MongoClients(com.mongodb.MongoClientOptions options,
List<com.mongodb.MongoCredential> credentials)
public static MongoClients.Builder create()
create a connection pool.public void clear()
public com.mongodb.MongoClient clientFor(String addressString)
The format of the supplied string is one of the following:
host:port hostwhere
host contains the resolvable hostname or IP address of the server, and port is the integral port
number. If the port is not provided, the default port is used. If neither the host
or port are provided (or addressString is null), then an address will use the
default host and default port.addressString - the string that contains the host and port of the serverpublic com.mongodb.MongoClient clientFor(com.mongodb.ServerAddress address)
address - the address of the server to usepublic com.mongodb.MongoClient clientForMembers(String addressList)
The format of the supplied string is one of the following:
replicaSetName/host:port replicaSetName/host:port,host2:port2 replicaSetName/host:port,host2:port2,host3:port3 host:port host:port,host2:port2 host:port,host2:port2,host3:port3where
replicaSetName is the name of the replica set, host contains the resolvable hostname or IP address of
the server, and port is the integral port number. If the port is not provided, the
default port is used. If neither the host or port are provided (or
addressString is null), then an address will use the default host and
default port.
This method does not use the replica set name.
addressList - the string containing a comma-separated list of host and port pairs, optionally preceded by a
replica set namepublic com.mongodb.MongoClient clientForMembers(com.mongodb.ServerAddress... seeds)
seeds - the seed addressespublic com.mongodb.MongoClient clientForMembers(List<com.mongodb.ServerAddress> seedAddresses)
seedAddresses - the seed addressesprotected com.mongodb.MongoClient directConnection(com.mongodb.ServerAddress address)
protected com.mongodb.MongoClient connection(List<com.mongodb.ServerAddress> addresses)
Copyright © 2017 JBoss by Red Hat. All rights reserved.