Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

com.mongodb
Class WriteConcern

java.lang.Object
  spacer com.mongodb.WriteConcern

public class WriteConcern
extends Object

WriteConcern control the write behavior for with various options, as well as exception raising on error conditions.

w

wtimeout how long to wait for slaves before failing

fsync force fsync to disk


MongoDB Doc Links

Field Summary
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 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.
 
Method Summary
 boolean callGetLastError()
          Returns whether "getlasterror" should be called (w > 0)
 boolean equals(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)
 String toString()
           
static WriteConcern valueOf(String name)
          Gets the WriteConcern constants by name: NONE, NORMAL, SAFE, FSYNC_SAFE, REPLICA_SAFE.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final WriteConcern NONE
No exceptions are raised, even for network issues


NORMAL

public static final WriteConcern NORMAL
Exceptions are raised for network issues, but not server errors


SAFE

public static final WriteConcern SAFE
Exceptions are raised for network issues, and server errors; waits on a server for the write operation


FSYNC_SAFE

public static final 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


REPLICAS_SAFE

public static final WriteConcern REPLICAS_SAFE
Exceptions are raised for network issues, and server errors; waits for at least 2 servers for the write operation

Constructor Detail

WriteConcern

public WriteConcern()
Default constructor keeping all options as default


WriteConcern

public WriteConcern(int w)
Calls WriteConcern(int, int, boolean) with wtimeout=0 and fsync=false

Parameters:
w - number of writes

WriteConcern

public WriteConcern(int w,
                    int wtimeout)
Calls WriteConcern(int, int, boolean) with fsync=false

Parameters:
w - number of writes
wtimeout - timeout for write operation

WriteConcern

public WriteConcern(boolean fsync)
Calls WriteConcern(int, int, boolean) with w=1 and wtimeout=0

Parameters:
fsync - whether or not to fsync

WriteConcern

public WriteConcern(int w,
                    int wtimeout,
                    boolean fsync)
Creates a WriteConcern object.

Specifies the number of servers to wait for on the write operation, and exception raising behavior

w represents the number of servers:

Parameters:
w - number of writes
wtimeout - timeout for write operation
fsync - whether or not to fsync
Method Detail

valueOf

public static WriteConcern valueOf(String name)
Gets the WriteConcern constants by name: NONE, NORMAL, SAFE, FSYNC_SAFE, REPLICA_SAFE. (matching is done case insensitively)

Parameters:
name -
Returns:

getCommand

public BasicDBObject getCommand()
Gets the object representing the "getlasterror" command

Returns:

getW

public int getW()
Gets the number of servers to write to

Returns:

getWtimeout

public int getWtimeout()
Gets the write timeout (in milliseconds)

Returns:

fsync

public boolean fsync()
Returns whether files are synced to disk

Returns:

raiseNetworkErrors

public boolean raiseNetworkErrors()
Returns whether network error may be raised (w >= 0)

Returns:

callGetLastError

public boolean callGetLastError()
Returns whether "getlasterror" should be called (w > 0)

Returns:

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

Overview  Package   Class  Use  Tree  Deprecated  Index  Help 
 PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.