|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mongodb.WriteConcern
public class WriteConcern
WriteConcern control the write behavior for with various options, as well as exception raising on error conditions.
w
fsync force fsync to disk
Nested Class Summary | |
---|---|
static class |
WriteConcern.Majority
|
Field Summary | |
---|---|
static WriteConcern |
FSYNC_SAFE
Exceptions are raised for network issues, and server errors; the write operation waits for the server to flush the data to disk |
static WriteConcern |
JOURNAL_SAFE
Exceptions are raised for network issues, and server errors; the write operation waits for the server to group commit to the journal file on disk |
static WriteConcern |
MAJORITY
Exceptions are raised for network issues, and server errors; waits on a majority of servers for the write operation |
static WriteConcern |
NONE
No exceptions are raised, even for network issues |
static WriteConcern |
NORMAL
Exceptions are raised for network issues, but not server errors |
static WriteConcern |
REPLICAS_SAFE
Exceptions are raised for network issues, and server errors; waits for at least 2 servers for the write operation |
static WriteConcern |
SAFE
Exceptions are raised for network issues, and server errors; waits on a server for the write operation |
Constructor Summary | |
---|---|
WriteConcern()
Default constructor keeping all options as default |
|
WriteConcern(boolean fsync)
Calls WriteConcern(int, int, boolean) with w=1 and wtimeout=0 |
|
WriteConcern(int w)
Calls WriteConcern(int, int, boolean) with wtimeout=0 and fsync=false |
|
WriteConcern(int w,
int wtimeout)
Calls WriteConcern(int, int, boolean) with fsync=false |
|
WriteConcern(int w,
int wtimeout,
boolean fsync)
Creates a WriteConcern object. |
|
WriteConcern(int w,
int wtimeout,
boolean fsync,
boolean j)
Creates a WriteConcern object. |
|
WriteConcern(int w,
int wtimeout,
boolean fsync,
boolean j,
boolean continueInsertOnError)
Creates a WriteConcern object. |
|
WriteConcern(String w)
Tag based Write Concern with wtimeout=0, fsync=false, and j=false |
|
WriteConcern(String w,
boolean j)
Tag based Write Concern with configgable j and wtimeout=0, fsync=false |
|
WriteConcern(String w,
int wtimeout,
boolean fsync,
boolean j)
Creates a WriteConcern object. |
|
WriteConcern(String w,
int wtimeout,
boolean fsync,
boolean j,
Boolean continueInsertOnError)
Creates a WriteConcern object. |
Method Summary | |
---|---|
protected WriteConcern |
_instance(Object wValue,
int wtimeout,
boolean fsync,
boolean j,
boolean cont)
|
boolean |
callGetLastError()
Returns whether "getlasterror" should be called (w > 0) |
boolean |
continueOnErrorForInsert()
Returns whether (batch) inserts will continue if an error occurs before the end |
boolean |
equals(Object o)
|
boolean |
fsync()
Returns whether writes wait for files to be synced to disk |
BasicDBObject |
getCommand()
Gets the object representing the "getlasterror" command |
int |
getW()
Gets the number of servers to write to if W is not a string value, returns -999. |
String |
getWString()
|
int |
getWtimeout()
Gets the write timeout (in milliseconds) |
Object |
getWValue()
Gets the w value (either int or string) |
boolean |
j()
Returns whether writes will await a group commit to the journal. |
static WriteConcern.Majority |
majorityWriteConcern(int wtimeout,
boolean fsync,
boolean j)
Create a Majority Write Concern that requires a majority of servers to acknowledge the write. |
boolean |
raiseNetworkErrors()
Returns whether network error may be raised (w >= 0) |
String |
toString()
|
static WriteConcern |
valueOf(String name)
Gets the WriteConcern constants by name: NONE, NORMAL, SAFE, FSYNC_SAFE, REPLICA_SAFE. |
WriteConcern |
withContinueOnErrorForInsert(boolean cont)
Clones this WriteConcern with a new boolean mode for "continue inserts on error" (WriteConcerns are immutable) |
WriteConcern |
withFsync(boolean fsync)
Clones this WriteConcern with a new boolean mode for fsync (WriteConcerns are immutable) |
WriteConcern |
withJ(boolean j)
Clones this WriteConcern with a new "j" (WriteConcerns are immutable) |
WriteConcern |
withW(int w)
Clones this WriteConcern with a new int mode for "w" (WriteConcerns are immutable) |
WriteConcern |
withW(String mode)
Clones this WriteConcern with a new String mode for "w" (WriteConcerns are immutable) |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final WriteConcern NONE
public static final WriteConcern NORMAL
public static final WriteConcern SAFE
public static final WriteConcern MAJORITY
public static final WriteConcern FSYNC_SAFE
public static final WriteConcern JOURNAL_SAFE
public static final WriteConcern REPLICAS_SAFE
Constructor Detail |
---|
public WriteConcern()
public WriteConcern(int w)
WriteConcern(int, int, boolean)
with wtimeout=0 and fsync=false
w
- number of writespublic WriteConcern(String w)
w
- Write Concern tagpublic WriteConcern(String w, boolean j)
w
- Write Concern Tagj
- whether writes should wait for a journaling group commitpublic WriteConcern(int w, int wtimeout)
WriteConcern(int, int, boolean)
with fsync=false
w
- number of writeswtimeout
- timeout for write operationpublic WriteConcern(boolean fsync)
WriteConcern(int, int, boolean)
with w=1 and wtimeout=0
fsync
- whether or not to fsyncpublic WriteConcern(int w, int wtimeout, boolean fsync)
Specifies the number of servers to wait for on the write operation, and exception raising behavior
w represents the number of servers:
w=-1
None, no checking is donew=0
None, network socket errors raisedw=1
Checks server for errors as well as network socket errors raisedw>1
Checks servers (w) for errors as well as network socket errors raised
w
- number of writeswtimeout
- timeout for write operationfsync
- whether or not to fsyncpublic WriteConcern(int w, int wtimeout, boolean fsync, boolean j)
Specifies the number of servers to wait for on the write operation, and exception raising behavior
w represents the number of servers:
w=-1
None, no checking is donew=0
None, network socket errors raisedw=1
Checks server for errors as well as network socket errors raisedw>1
Checks servers (w) for errors as well as network socket errors raised
w
- number of writeswtimeout
- timeout for write operationfsync
- whether or not to fsyncj
- whether writes should wait for a journaling group commitpublic WriteConcern(int w, int wtimeout, boolean fsync, boolean j, boolean continueInsertOnError)
Specifies the number of servers to wait for on the write operation, and exception raising behavior
w represents the number of servers:
w=-1
None, no checking is donew=0
None, network socket errors raisedw=1
Checks server for errors as well as network socket errors raisedw>1
Checks servers (w) for errors as well as network socket errors raised
w
- number of writeswtimeout
- timeout for write operationfsync
- whether or not to fsyncj
- whether writes should wait for a journaling group commitpublic WriteConcern(String w, int wtimeout, boolean fsync, boolean j)
Specifies the number of servers to wait for on the write operation, and exception raising behavior
w represents the number of servers:
w=-1
None, no checking is donew=0
None, network socket errors raisedw=1
Checks server for errors as well as network socket errors raisedw>1
Checks servers (w) for errors as well as network socket errors raised
w
- number of writeswtimeout
- timeout for write operationfsync
- whether or not to fsyncj
- whether writes should wait for a journaling group commitpublic WriteConcern(String w, int wtimeout, boolean fsync, boolean j, Boolean continueInsertOnError)
Specifies the number of servers to wait for on the write operation, and exception raising behavior
w represents the number of servers:
w=-1
None, no checking is donew=0
None, network socket errors raisedw=1
Checks server for errors as well as network socket errors raisedw>1
Checks servers (w) for errors as well as network socket errors raised
w
- number of writeswtimeout
- timeout for write operationfsync
- whether or not to fsyncj
- whether writes should wait for a journaling group commitMethod Detail |
---|
public BasicDBObject getCommand()
public int getW()
public String getWString()
public int getWtimeout()
public boolean fsync()
public boolean j()
public boolean continueOnErrorForInsert()
public boolean raiseNetworkErrors()
public boolean callGetLastError()
public static WriteConcern valueOf(String name)
name
-
public String toString()
toString
in class Object
public boolean equals(Object o)
equals
in class Object
public Object getWValue()
public WriteConcern withW(String mode)
mode
-
public WriteConcern withW(int w)
mode
- w
-
public WriteConcern withJ(boolean j)
j
-
public WriteConcern withContinueOnErrorForInsert(boolean cont)
cont
-
public WriteConcern withFsync(boolean fsync)
fsync
-
protected WriteConcern _instance(Object wValue, int wtimeout, boolean fsync, boolean j, boolean cont)
public static WriteConcern.Majority majorityWriteConcern(int wtimeout, boolean fsync, boolean j)
wtimeout
- timeout for write operationfsync
- whether or not to fsyncj
- whether writes should wait for a journaling group commit
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |