|
18 | 18 |
|
19 | 19 | import java.util.List; |
20 | 20 |
|
21 | | - |
22 | 21 | /** |
23 | | - * Represents a <a href="http://www.mongodb.org/display/DOCS/Connections">URI</a> which can be used to create a |
24 | | - * MongoClient instance. The URI describes the hosts to be used and options. <p>The format of the URI is: |
| 22 | + * Represents a <a href="http://www.mongodb.org/display/DOCS/Connections">URI</a> |
| 23 | + * which can be used to create a MongoClient instance. The URI describes the hosts to |
| 24 | + * be used and options. |
| 25 | + * <p>The format of the URI is: |
25 | 26 | * <pre> |
26 | 27 | * mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]] |
27 | 28 | * </pre> |
28 | | - * <ul> <li>{@code mongodb://} is a required prefix to identify that this is a string in the standard connection |
29 | | - * format.</li> <li>{@code username:password@} are optional. If given, the driver will attempt to login to a database |
30 | | - * after connecting to a database server.</li> <li>{@code host1} is the only required part of the URI. It identifies a |
31 | | - * server address to connect to.</li> <li>{@code :portX} is optional and defaults to :27017 if not provided.</li> |
32 | | - * <li>{@code /database} is the name of the database to login to and thus is only relevant if the {@code |
33 | | - * username:password@} syntax is used. If not specified the "admin" database will be used by default.</li> <li>{@code |
34 | | - * ?options} are connection options. Note that if {@code database} is absent there is still a {@code /} required between |
35 | | - * the last host and the {@code ?} introducing the options. Options are name=value pairs and the pairs are separated by |
36 | | - * "&". For backwards compatibility, ";" is accepted as a separator in addition to "&", but should be considered |
37 | | - * as deprecated.</li> </ul> <p> The Java driver supports the following options (case insensitive): <p> Replica set |
38 | | - * configuration: </p> <ul> <li>{@code replicaSet=name}: Implies that the hosts given are a seed list, and the driver |
39 | | - * will attempt to find all members of the set.</li> </ul> <p>Connection Configuration:</p> <ul> <li>{@code |
40 | | - * connectTimeoutMS=ms}: How long a connection can take to be opened before timing out.</li> <li>{@code |
41 | | - * socketTimeoutMS=ms}: How long a send or receive on a socket can take before timing out.</li> </ul> <p>Connection pool |
42 | | - * configuration:</p> <ul> <li>{@code maxPoolSize=n}: The maximum number of connections in the connection pool.</li> |
43 | | - * <li>{@code waitQueueMultiple=n} : this multiplier, multiplied with the maxPoolSize setting, gives the maximum number |
44 | | - * of threads that may be waiting for a connection to become available from the pool. All further threads will get an |
45 | | - * exception right away.</li> <li>{@code waitQueueTimeoutMS=ms}: The maximum wait time in milliseconds that a thread may |
46 | | - * wait for a connection to become available.</li> </ul> <p>Write concern configuration:</p> <ul> <li>{@code |
47 | | - * safe=true|false} <ul> <li>{@code true}: the driver sends a getLastError command after every update to ensure that the |
48 | | - * update succeeded (see also {@code w} and {@code wtimeoutMS}).</li> <li>{@code false}: the driver does not send a |
49 | | - * getLastError command after every update.</li> </ul> </li> <li>{@code w=wValue} <ul> <li>The driver adds { w : wValue |
50 | | - * } to the getLastError command. Implies {@code safe=true}.</li> <li>wValue is typically a number, but can be any |
51 | | - * string in order to allow for specifications like {@code "majority"}</li> </ul> </li> <li>{@code wtimeoutMS=ms} <ul> |
52 | | - * <li>The driver adds { wtimeout : ms } to the getlasterror command. Implies {@code safe=true}.</li> <li>Used in |
53 | | - * combination with {@code w}</li> </ul> </li> </ul> <p>Read preference configuration:</p> <ul> <li>{@code |
54 | | - * slaveOk=true|false}: Whether a driver connected to a replica set will send reads to slaves/secondaries.</li> |
| 29 | + * <ul> |
| 30 | + * <li>{@code mongodb://} is a required prefix to identify that this is a string in the standard connection format.</li> |
| 31 | + * <li>{@code username:password@} are optional. If given, the driver will attempt to login to a database after |
| 32 | + * connecting to a database server. For some authentication mechanisms, only the username is specified and the password is not, |
| 33 | + * in which case the ":" after the username is left off as well</li> |
| 34 | + * <li>{@code host1} is the only required part of the URI. It identifies a server address to connect to.</li> |
| 35 | + * <li>{@code :portX} is optional and defaults to :27017 if not provided.</li> |
| 36 | + * <li>{@code /database} is the name of the database to login to and thus is only relevant if the |
| 37 | + * {@code username:password@} syntax is used. If not specified the "admin" database will be used by default.</li> |
| 38 | + * <li>{@code ?options} are connection options. Note that if {@code database} is absent there is still a {@code /} |
| 39 | + * required between the last host and the {@code ?} introducing the options. Options are name=value pairs and the pairs |
| 40 | + * are separated by "&". For backwards compatibility, ";" is accepted as a separator in addition to "&", |
| 41 | + * but should be considered as deprecated.</li> |
| 42 | + * </ul> |
| 43 | + * <p> |
| 44 | + * The following options are supported (case insensitive): |
| 45 | + * <p> |
| 46 | + * Replica set configuration: |
| 47 | + * </p> |
| 48 | + * <ul> |
| 49 | + * <li>{@code replicaSet=name}: Implies that the hosts given are a seed list, and the driver will attempt to find |
| 50 | + * all members of the set.</li> |
| 51 | + * </ul> |
| 52 | + * <p>Connection Configuration:</p> |
| 53 | + * <ul> |
| 54 | + * <li>{@code ssl=true|false}: Whether to connect using SSL.</li> |
| 55 | + * <li>{@code connectTimeoutMS=ms}: How long a connection can take to be opened before timing out.</li> |
| 56 | + * <li>{@code socketTimeoutMS=ms}: How long a send or receive on a socket can take before timing out.</li> |
| 57 | + * </ul> |
| 58 | + * <p>Connection pool configuration:</p> |
| 59 | + * <ul> |
| 60 | + * <li>{@code maxPoolSize=n}: The maximum number of connections in the connection pool.</li> |
| 61 | + * <li>{@code waitQueueMultiple=n} : this multiplier, multiplied with the maxPoolSize setting, gives the maximum number of |
| 62 | + * threads that may be waiting for a connection to become available from the pool. All further threads will get an |
| 63 | + * exception right away.</li> |
| 64 | + * <li>{@code waitQueueTimeoutMS=ms}: The maximum wait time in milliseconds that a thread may wait for a connection to |
| 65 | + * become available.</li> |
| 66 | + * </ul> |
| 67 | + * <p>Write concern configuration:</p> |
| 68 | + * <ul> |
| 69 | + * <li>{@code safe=true|false} |
| 70 | + * <ul> |
| 71 | + * <li>{@code true}: the driver sends a getLastError command after every update to ensure that the update succeeded |
| 72 | + * (see also {@code w} and {@code wtimeoutMS}).</li> |
| 73 | + * <li>{@code false}: the driver does not send a getLastError command after every update.</li> |
| 74 | + * </ul> |
| 75 | + * </li> |
| 76 | + * <li>{@code w=wValue} |
| 77 | + * <ul> |
| 78 | + * <li>The driver adds { w : wValue } to the getLastError command. Implies {@code safe=true}.</li> |
| 79 | + * <li>wValue is typically a number, but can be any string in order to allow for specifications like |
| 80 | + * {@code "majority"}</li> |
| 81 | + * </ul> |
| 82 | + * </li> |
| 83 | + * <li>{@code wtimeoutMS=ms} |
| 84 | + * <ul> |
| 85 | + * <li>The driver adds { wtimeout : ms } to the getlasterror command. Implies {@code safe=true}.</li> |
| 86 | + * <li>Used in combination with {@code w}</li> |
| 87 | + * </ul> |
| 88 | + * </li> |
| 89 | + * </ul> |
| 90 | + * <p>Read preference configuration:</p> |
| 91 | + * <ul> |
| 92 | + * <li>{@code slaveOk=true|false}: Whether a driver connected to a replica set will send reads to slaves/secondaries.</li> |
55 | 93 | * <li>{@code readPreference=enum}: The read preference for this connection. If set, it overrides any slaveOk value. |
56 | | - * <ul> <li>Enumerated values: <ul> <li>{@code primary}</li> <li>{@code primaryPreferred}</li> <li>{@code |
57 | | - * secondary}</li> <li>{@code secondaryPreferred}</li> <li>{@code nearest}</li> </ul> </li> </ul> </li> <li>{@code |
58 | | - * readPreferenceTags=string}. A representation of a tag set as a comma-separated list of colon-separated key-value |
59 | | - * pairs, e.g. {@code "dc:ny,rack:1}". Spaces are stripped from beginning and end of all keys and values. To specify a |
60 | | - * list of tag sets, using multiple readPreferenceTags, e.g. {@code readPreferenceTags=dc:ny, |
61 | | - * rack:1;readPreferenceTags=dc:ny;readPreferenceTags=} |
62 | | - * <ul> <li>Note the empty value for the last one, which means match any secondary as a last resort.</li> <li>Order |
63 | | - * matters when using multiple readPreferenceTags.</li> </ul> </li> </ul> |
64 | | - * <p/> |
| 94 | + * <ul> |
| 95 | + * <li>Enumerated values: |
| 96 | + * <ul> |
| 97 | + * <li>{@code primary}</li> |
| 98 | + * <li>{@code primaryPreferred}</li> |
| 99 | + * <li>{@code secondary}</li> |
| 100 | + * <li>{@code secondaryPreferred}</li> |
| 101 | + * <li>{@code nearest}</li> |
| 102 | + * </ul> |
| 103 | + * </li> |
| 104 | + * </ul> |
| 105 | + * </li> |
| 106 | + * <li>{@code readPreferenceTags=string}. A representation of a tag set as a comma-separated list of colon-separated |
| 107 | + * key-value pairs, e.g. {@code "dc:ny,rack:1}". Spaces are stripped from beginning and end of all keys and values. |
| 108 | + * To specify a list of tag sets, using multiple readPreferenceTags, |
| 109 | + * e.g. {@code readPreferenceTags=dc:ny,rack:1;readPreferenceTags=dc:ny;readPreferenceTags=} |
| 110 | + * <ul> |
| 111 | + * <li>Note the empty value for the last one, which means match any secondary as a last resort.</li> |
| 112 | + * <li>Order matters when using multiple readPreferenceTags.</li> |
| 113 | + * </ul> |
| 114 | + * </li> |
| 115 | + * </ul> |
| 116 | + * <p>Authentication configuration:</p> |
| 117 | + * <ul> |
| 118 | + * <li>{@code authMechanism=MONGO-CR|GSSAPI|PLAIN}: The authentication mechanism to use if a credential was supplied. |
| 119 | + * The default is MONGODB-CR, which is the native MongoDB Challenge Response mechanism. For the GSSAPI mechanism, no password is accepted, |
| 120 | + * only the username. |
| 121 | + * </li> |
| 122 | + * <li>{@code authSource=string}: The source of the authentication credentials. This is typically the database that |
| 123 | + * the credentials have been created. The value defaults to the database specified in the path portion of the URI. |
| 124 | + * If the database is specified in neither place, the default value is "admin". This option is only respected when using the MONGO-CR |
| 125 | + * mechanism (the default). |
| 126 | + * </li> |
| 127 | + * <ul> |
| 128 | + * <p> |
65 | 129 | * Note: This class is a replacement for {@code MongoURI}, to be used with {@code MongoClient}. The main difference in |
66 | 130 | * behavior is that the default write concern is {@code WriteConcern.ACKNOWLEDGED}. |
67 | 131 | * |
|
0 commit comments