Permalink
Browse files

- issue33: add support for 'j' and string 'w' in writeconcern

  • Loading branch information...
1 parent 774bc6f commit 83a442fcfac2102f12161954bd0a2b225bdb51e3 @agirbal committed Oct 29, 2011
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
@@ -23,9 +23,11 @@
<CheckBox id="opLogReplay" toolTipText="Internal replication use only - driver should not set"/>
</Div>
<Div id="writeConcern">
- <IntSpinner id="writeFactor" minValue="0" value="0" toolTipText="Sets the number of server that data should be written to, before returning the call. 0 means 'fire-and-forget', 1 means write to primary and wait for acknowledgment.'"/>
+ <IntSpinner id="writeFactor" minValue="0" value="0" toolTipText="Sets the number of servers that write should be acknowledged from. 0 means 'fire-and-forget'."/>
+ <TextField id="writePolicy" toolTipText="Sets the write policy. If set, will override the write factor number."/>
<IntSpinner id="writeTimeout" minValue="0" value="0" toolTipText="Timeout in milliseconds for primary server to ensure that write operation was fulfilled on all servers."/>
<CheckBox id="fsync" value="false" toolTipText="Forces syncing of memory to disk on the server before acknowledgment of write operation success."/>
+ <CheckBox id="jsync" value="false" toolTipText="Waits that the data has been commited to the journal on disk."/>
</Div>
</TabbedDiv>
</org.mongo.jmongob.OptionDialog>
@@ -24,8 +24,10 @@
awaitData,
exhaust,
writeFactor,
+ writePolicy,
writeTimeout,
- fsync
+ fsync,
+ jsync
}
public OptionDialog() {
@@ -39,8 +41,12 @@ void update(int options, WriteConcern wc) {
setBooleanFieldValue(Item.noTimeout, (options & Bytes.QUERYOPTION_NOTIMEOUT) != 0);
setBooleanFieldValue(Item.awaitData, (options & Bytes.QUERYOPTION_AWAITDATA) != 0);
setBooleanFieldValue(Item.exhaust, (options & Bytes.QUERYOPTION_EXHAUST) != 0);
-
- setIntFieldValue(Item.writeFactor, wc.getW());
+
+ Object w = wc.getWObject();
+ int wInt = (Integer) (w instanceof Integer ? w : 0);
+ String wStr = (String) (w instanceof String ? w : "");
+ setIntFieldValue(Item.writeFactor, wInt);
+ setStringFieldValue(Item.writePolicy, wStr);
setIntFieldValue(Item.writeTimeout, wc.getWtimeout());
setBooleanFieldValue(Item.fsync, wc.fsync());
}
@@ -58,8 +64,12 @@ int getQueryOptions() {
WriteConcern getWriteConcern() {
int w = getIntFieldValue(Item.writeFactor);
+ String wPolicy = getStringFieldValue(Item.writePolicy);
int wtimeout = getIntFieldValue(Item.writeTimeout);
boolean fsync = getBooleanFieldValue(Item.fsync);
- return new WriteConcern(w, wtimeout, fsync);
+ boolean jsync = getBooleanFieldValue(Item.jsync);
+ if (!wPolicy.trim().isEmpty())
+ return new WriteConcern(wPolicy, wtimeout, fsync, jsync);
+ return new WriteConcern(w, wtimeout, fsync, jsync);
}
}

0 comments on commit 83a442f

Please sign in to comment.