[JAVA-596] In case of replica set members which are located in different data center, are reads from the java driver will be data center aware? Created: 03/Jul/12  Updated: 11/Sep/19  Resolved: 03/Jul/12

Status: Closed
Project: Java Driver
Component/s: Connection Management
Affects Version/s: 2.0
Fix Version/s: None

Type: Task Priority: Critical - P2
Reporter: Vineet Saini Assignee: Unassigned
Resolution: Done Votes: 0
Labels: driver
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

One of our projects using replica sets which will be deployed across 2 data centers. Our plan is to use slaves in both data centers to serve reads. We are ok to write across datacenter but reads need to be served locally.
When we connect to mongo db from the App server which is in data center1 we expect the read request should go to the mongod which is running in the same data center. How we can ensure it happens, how java driver reroute the read request to available member of the replica set?

We have set slveOk = true in our application.



 Comments   
Comment by Scott Hernandez (Inactive) [ 03/Jul/12 ]

The java driver will connect to the closest replica, when using slaveOk/ReadPreference.Secondary, so queries will stay in the local datacenter. All writes must go to the primary in whichever DC it is in.

Generated at Thu Feb 08 08:52:39 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.