Reputation: 419
The Java Mongodb client exposes two sets of options:
getOptions
, which the docs say are for the default query options.getMongoClientOptions
, which the doc says are related to the connection between the client and the cluster.Are the query options inherited from the client options?
setOptions
expects an int
, where can I find the documentation explaining what the various magic numbers do?
Upvotes: 1
Views: 394
Reputation: 20860
GetOptions() - Gets the query options. It returns the bitmask of options
.
From the GetOptions() and this documentation : you can see the flags(bit vectors of query options).
The bit values correspond to the following:
0 is reserved. Must be set to 0.
1 corresponds to TailableCursor. Tailable means cursor is not closed when the last data is retrieved. Rather, the cursor marks the final object’s position. You can resume using the cursor later, from where it was located, if more data were received. Like any “latent cursor”, the cursor may become invalid at some point (CursorNotFound) – for example if the final object it references were deleted.
2 corresponds to SlaveOk.Allow query of replica slave. Normally these return an error except for namespace “local”.
3 corresponds to OplogReplay. Internal replication use only - driver should not set.
4 corresponds to NoCursorTimeout. The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.
5 corresponds to AwaitData. Use with TailableCursor. If we are at the end of the data, block for a while rather than returning no data. After a timeout period, we do return as normal.
6 corresponds to Exhaust. Stream the data down full blast in multiple “more” packages, on the assumption that the client will fully read all data queried. Faster when you are pulling a lot of data and know you want to pull it all down. Note: the client is not allowed to not read all the data unless it closes the connection.
7 corresponds to Partial. Get partial results from a mongos if some shards are down (instead of throwing an error)
8-31 are reserved. Must be set to 0.
GetMongoClientOptions() - Gets the options that this client uses to connect to server. It returns various settings to control the behavior of a MongoClient. Following are the methods of MongoClientOptions returned by above method. for example:
getClusterListeners()
getConnectionsPerHost()
getConnectTimeout()
getLocalThreshold()
You can see other methods in the following link : http://api.mongodb.com/java/current/com/mongodb/MongoClientOptions.html
Upvotes: 3