Skip to content

Commit

Permalink
- issue33: add support for 'j' and string 'w' in writeconcern
Browse files Browse the repository at this point in the history
  • Loading branch information
agirbal committed Oct 29, 2011
1 parent 774bc6f commit 83a442f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
Binary file modified lib/SwingFast.jar
Binary file not shown.
Binary file modified lib/bson.jar
Binary file not shown.
Binary file modified lib/mongo.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion resource/xml/JMongoBrowser.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
18 changes: 14 additions & 4 deletions src/org/mongo/jmongob/OptionDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ enum Item {
awaitData,
exhaust,
writeFactor,
writePolicy,
writeTimeout,
fsync
fsync,
jsync
}

public OptionDialog() {
Expand All @@ -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());
}
Expand All @@ -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.