25
25
26
26
/**
27
27
* <p>WriteConcern control the write behavior for with various options, as well as exception raising on error conditions.</p>
28
- *
28
+ *
29
29
* <p>
30
30
* <b>w</b>
31
31
* <ul>
41
41
* </ul>
42
42
* </p>
43
43
* <p><b>fsync</b> force fsync to disk </p>
44
- *
44
+ *
45
45
* @dochub databases
46
46
*/
47
47
public class WriteConcern {
@@ -51,7 +51,7 @@ public class WriteConcern {
51
51
52
52
/** Exceptions are raised for network issues, but not server errors */
53
53
public final static WriteConcern NORMAL = new WriteConcern (0 );
54
-
54
+
55
55
/** Exceptions are raised for network issues, and server errors; waits on a server for the write operation */
56
56
public final static WriteConcern SAFE = new WriteConcern (1 );
57
57
@@ -66,7 +66,7 @@ public class WriteConcern {
66
66
67
67
/** Exceptions are raised for network issues, and server errors; waits for at least 2 servers for the write operation*/
68
68
public final static WriteConcern REPLICAS_SAFE = new WriteConcern (2 );
69
-
69
+
70
70
// map of the constants from above for use by fromString
71
71
private static Map <String , WriteConcern > _namedConcerns = null ;
72
72
@@ -76,8 +76,8 @@ public class WriteConcern {
76
76
public WriteConcern (){
77
77
this (0 );
78
78
}
79
-
80
- /**
79
+
80
+ /**
81
81
* Calls {@link WriteConcern#WriteConcern(int, int, boolean)} with wtimeout=0 and fsync=false
82
82
* @param w number of writes
83
83
*/
@@ -93,7 +93,7 @@ public WriteConcern( String w ){
93
93
this ( w , 0 , false , false );
94
94
}
95
95
96
- /**
96
+ /**
97
97
* Calls {@link WriteConcern#WriteConcern(int, int, boolean)} with fsync=false
98
98
* @param w number of writes
99
99
* @param wtimeout timeout for write operation
@@ -109,8 +109,8 @@ public WriteConcern( int w , int wtimeout ){
109
109
public WriteConcern ( boolean fsync ){
110
110
this ( 1 , 0 , fsync );
111
111
}
112
-
113
- /**
112
+
113
+ /**
114
114
* Creates a WriteConcern object.
115
115
* <p>Specifies the number of servers to wait for on the write operation, and exception raising behavior </p>
116
116
* <p> w represents the number of servers:
@@ -182,7 +182,7 @@ public WriteConcern( String w , int wtimeout , boolean fsync, boolean j ){
182
182
public BasicDBObject getCommand (){
183
183
BasicDBObject _command = new BasicDBObject ( "getlasterror" , 1 );
184
184
185
- if ( _wValue instanceof Integer && ( (Integer ) _wValue > 0 ) ||
185
+ if ( _wValue instanceof Integer && ( (Integer ) _wValue > 0 ) ||
186
186
( _wValue instanceof String && _wValue != null ) ){
187
187
_command .put ( "w" , _wValue );
188
188
_command .put ( "wtimeout" , _wtimeout );
@@ -199,36 +199,36 @@ public BasicDBObject getCommand(){
199
199
200
200
/**
201
201
* Sets the w value (the write strategy)
202
- * @param wValue
202
+ * @param wValue
203
203
*/
204
204
public void setWObject (Object wValue ) {
205
205
this ._wValue = wValue ;
206
206
}
207
-
207
+
208
208
/**
209
209
* Gets the w value (the write strategy)
210
210
* @return
211
211
*/
212
212
public Object getWObject (){
213
213
return _wValue ;
214
214
}
215
-
215
+
216
216
/**
217
217
* Sets the w value (the write strategy)
218
- * @param w
218
+ * @param w
219
219
*/
220
220
public void setW (int w ) {
221
221
_wValue = w ;
222
222
}
223
-
223
+
224
224
/**
225
225
* Gets the w parameter (the write strategy)
226
226
* @return
227
227
*/
228
228
public int getW (){
229
229
return (Integer ) _wValue ;
230
230
}
231
-
231
+
232
232
/**
233
233
* Gets the w parameter (the write strategy) in String format
234
234
* @return
@@ -239,7 +239,7 @@ public String getWString(){
239
239
240
240
/**
241
241
* Sets the write timeout (in milliseconds)
242
- * @param wtimeout
242
+ * @param wtimeout
243
243
*/
244
244
public void setWtimeout (int wtimeout ) {
245
245
this ._wtimeout = wtimeout ;
@@ -260,23 +260,23 @@ public int getWtimeout(){
260
260
public void setFsync (boolean fsync ) {
261
261
_fsync = fsync ;
262
262
}
263
-
263
+
264
264
/**
265
265
* Gets the fsync flag (fsync to disk on the server)
266
266
* @return
267
267
*/
268
268
public boolean getFsync (){
269
269
return _fsync ;
270
270
}
271
-
271
+
272
272
/**
273
273
* Gets the fsync flag (fsync to disk on the server)
274
274
* @return
275
275
*/
276
276
public boolean fsync (){
277
277
return _fsync ;
278
278
}
279
-
279
+
280
280
/**
281
281
* Returns whether network error may be raised (w >= 0)
282
282
* @return
@@ -347,23 +347,25 @@ public void setJ(boolean j) {
347
347
348
348
/**
349
349
* Gets the j parameter (journal syncing)
350
- * @return
350
+ * @return
351
351
*/
352
352
public boolean getJ () {
353
353
return _j ;
354
354
}
355
355
356
356
/**
357
- * Sets the "continue inserts on error" mode
358
- * @param continueOnErrorForInsert
357
+ * Sets the "continue inserts on error" mode. This only applies to server side errors.
358
+ * If there is a document which does not validate in the client, an exception will still
359
+ * be thrown in the client.
360
+ * @param continueOnErrorForInsert
359
361
*/
360
362
public void setContinueOnErrorForInsert (boolean continueOnErrorForInsert ) {
361
363
this ._continueOnErrorForInsert = continueOnErrorForInsert ;
362
364
}
363
365
364
366
/**
365
367
* Gets the "continue inserts on error" mode
366
- * @return
368
+ * @return
367
369
*/
368
370
public boolean getContinueOnErrorForInsert () {
369
371
return _continueOnErrorForInsert ;
0 commit comments