[JAVA-987] GridFS.findOne needs a variant that takes a ReadPreference Created: 03/Oct/13  Updated: 03/Sep/15  Resolved: 02/Sep/15

Status: Closed
Project: Java Driver
Component/s: API, GridFS
Affects Version/s: None
Fix Version/s: 3.1.0

Type: Improvement Priority: Major - P3
Reporter: Richard Wallace Assignee: Unassigned
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

For our app we've setup a replica set and chosen to use a secondary-preferred read preference to help distribute requests and recover from node failures. We have the DB configured for secondary preferred and set read preference to primary on a per-request basis - for read and update type operations.

This fails when dealing with GridFS because their is no ability to provide a read preference in the GridFS API. I started working on a workaround, reading from the bucket.fs collection and passing the preference that way.

But now the problem is that when reading file chunks, the input stream is reading from the chunks collection with the database default read preference of secondary-preferred. Consequently, I'm going to have to reimplement that in our app to get going. But it sure would be nice if I didn't have to do that.



 Comments   
Comment by Ross Lawley [ 02/Sep/15 ]

Fixed in the new GridFS implementation JAVA-1713 -The new api has an immutable readPreference but changing it is easy.

Comment by Jeffrey Yemin [ 03/Oct/13 ]

OK, I'll keep that in mind.

Comment by Richard Wallace [ 03/Oct/13 ]

It's not optimal, but it could work. It would require keeping two GridFS instances: one that uses secondary-preferred and one that uses primary and choosing between the two when making requests. I'd much prefer to just pass the read preference when making requests, but could live with that alternative.

Comment by Jeffrey Yemin [ 03/Oct/13 ]

Yeah, that's annoying. Would it be sufficient for your application to override the read preference per GridFS instance? Otherwise, there are an awfully large number of methods that would need to be overloaded to take a read preference.

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