public class WriteConcern
extends java.lang.Object
WriteConcern control the write behavior for with various options, as well as exception raising on error conditions.
w
fsync force fsync to disk
Modifier and Type | Field and Description |
---|---|
static WriteConcern |
FSYNC_SAFE
Exceptions are raised for network issues, and server errors and the write operation waits for the server to flush the data to disk
|
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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
boolean |
callGetLastError()
Returns whether "getlasterror" should be called (w > 0)
|
boolean |
equals(java.lang.Object o) |
boolean |
fsync()
Returns whether files are synced to disk
|
BasicDBObject |
getCommand()
Gets the object representing the "getlasterror" command
|
int |
getW()
Gets the number of servers to write to
|
int |
getWtimeout()
Gets the write timeout (in milliseconds)
|
boolean |
raiseNetworkErrors()
Returns whether network error may be raised (w >= 0)
|
java.lang.String |
toString() |
static WriteConcern |
valueOf(java.lang.String name)
Gets the WriteConcern constants by name: NONE, NORMAL, SAFE, FSYNC_SAFE,
REPLICA_SAFE.
|
public static final WriteConcern NONE
public static final WriteConcern NORMAL
public static final WriteConcern SAFE
public static final WriteConcern FSYNC_SAFE
public static final WriteConcern REPLICAS_SAFE
public WriteConcern()
public WriteConcern(int w)
WriteConcern(int, int, boolean)
with wtimeout=0 and fsync=falsew
- number of writespublic WriteConcern(int w, int wtimeout)
WriteConcern(int, int, boolean)
with fsync=falsew
- number of writeswtimeout
- timeout for write operationpublic WriteConcern(boolean fsync)
WriteConcern(int, int, boolean)
with w=1 and wtimeout=0fsync
- 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 raisedw
- number of writeswtimeout
- timeout for write operationfsync
- whether or not to fsyncpublic static WriteConcern valueOf(java.lang.String name)
name
- public BasicDBObject getCommand()
public int getW()
public int getWtimeout()
public boolean fsync()
public boolean raiseNetworkErrors()
public boolean callGetLastError()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object