MongoDB : How to find if slaveOk=true is set or not


We are using Mongo DB in our Application .
We have one primary and one secondary for this purpose .

How can i make sure that my Application is reading data from Primary Or Secondary ??

My question is how can i know if slaveOk=true is set or not ??

Thanks in advance .

Edited Part

Not sure of the Driver what i am uisng
I am connecting Mongo DB through Java as shown

ServerAddress addr = new ServerAddress(new InetSocketAddress(host, port));servAddrList.add(addr);}MongoOptions options = new MongoOptions();options.autoConnectRetry = true;options.connectionsPerHost = Config.intParam("mongo.connectionsPerHost", 1200);      mongo = new Mongo("", 27017);

And i am using mongo 2.4.jar

Please let m know how can i find what driver i am using ??

Best Solution

What are you looking for in my opinion is readPreference :

In the api ( documentation there is an isSlaveOk() method :

See this question: How to perform read operations from primary only

There is the answer for setting read preference


and your answer is to get read preference:


Unfortunately these features do not exist in versions after 2.4.