Mongo Java driver and replication tags

29 views
Skip to first unread message

Andy.Fan

unread,
May 20, 2015, 10:27:54 PM5/20/15
to mongod...@googlegroups.com
I added some tags in our mongo replication set like http://docs.mongodb.org/manual/tutorial/configure-replica-set-tag-sets/, then our application uses tags like 
cms.config.need.query.tag.normal=query:normal
cms.config.need.query.tag.regex=query:regex

I guess the tags are used by Java driver to choose which instance to request rather than mongo server decide which instance to server a request. 

So I want to know how does java driver use their tags, for example, What if the query is send without a tag while all the instances are tagged? What if the query with a tag, but the host with that tag is not available at that time?

It's be great that you can point the related Java class in Java driver. 

Ross Lawley

unread,
May 22, 2015, 9:08:31 AM5/22/15
to mongod...@googlegroups.com
Hi,

Read preferences can be set at the MongoClient, Database, Collection or on a query by query basis and its part of the driver code to handle the server selection for a given request.

There is a specification regarding sever selection available here https://github.com/mongodb/specifications/blob/master/source/server-selection/server-selection.rst and the Java driver adheres to that specification.

Ross
Reply all
Reply to author
Forward
0 new messages