I have the following core mongo options configuration in spring:
<mongo:mongo host="${db.hostname}" >
<mongo:options
connections-per-host="40"
threads-allowed-to-block-for-connection-multiplier="1500"
connect-timeout="15000"
auto-connect-retry="true"
socket-timeout="60000"
write-number="1"
write-fsync="false"/>
</mongo:mongo>
What I want to know is about different write-number options which is relevant to write concern like none, normal, safe etc.
Can I assume the mapping of write-number to writeconcern as below?
NONE: -1
NORMAL: 0
SAFE: 1 (default)
FSYNC_SAFE: 2
REPLICAS_SAFE: 3
JOURNAL_SAFE: 4
MAJORITY: 5
Following link has provided a good help to set mongo options in spring, but not specific enough for write-number values: How to configure MongoDB Java driver MongoOptions for production use?
The write-concern number is the value of "w" which maps to the number of replicas that the write must propagate to before being considered successful when w > 1.
FSYNC_SAFE maps to setting write-fsync (true or false) and since JOURNAL_SAFE is also a boolean value, I suspect there is a similar boolean setting in Spring but I couldn't find it in any of their docs.
If you have everything installed to test this out empirically, just try several configurations and check the actual setting of the resultant write concern with something like:
WriteConcern wc = new WriteConcern(); // should get your default write concern
System.out.println(wc.getJ());
System.out.println(wc.getFsync());
System.out.println(wc.getW());
That should show you Journal setting, Fsync setting (both boolean), W (as an int).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With