@@ -90,7 +90,7 @@ ServerAddress getASecondary(){
90
90
}
91
91
92
92
long diff = best ._pingTime - n ._pingTime ;
93
- if ( diff > 15 ||
93
+ if ( diff > slaveAcceptableLatencyMS ||
94
94
// this is a complex way to make sure we get a random distribution of slaves
95
95
( ( badBeforeBest - mybad ) / ( _all .size () - 1 ) ) > _random .nextDouble () )
96
96
{
@@ -261,7 +261,7 @@ public void run(){
261
261
}
262
262
263
263
try {
264
- Thread .sleep ( 5 * 1000 );
264
+ Thread .sleep ( updaterIntervalMS );
265
265
}
266
266
catch ( InterruptedException ie ){
267
267
// TODO: maybe something smarter
@@ -374,10 +374,16 @@ void close(){
374
374
375
375
final Random _random = new Random ();
376
376
377
+ static int updaterIntervalMS ;
378
+ static int slaveAcceptableLatencyMS ;
379
+
377
380
static final MongoOptions _mongoOptions = new MongoOptions ();
381
+
378
382
static {
379
- _mongoOptions .connectTimeout = 20000 ;
380
- _mongoOptions .socketTimeout = 20000 ;
383
+ updaterIntervalMS = Integer .parseInt (System .getProperty ("com.mongodb.updaterIntervalMS" , "5000" ));
384
+ slaveAcceptableLatencyMS = Integer .parseInt (System .getProperty ("com.mongodb.slaveAcceptableLatencyMS" , "15" ));
385
+ _mongoOptions .connectTimeout = Integer .parseInt (System .getProperty ("com.mongodb.updaterConnectTimeoutMS" , "20000" ));
386
+ _mongoOptions .socketTimeout = Integer .parseInt (System .getProperty ("com.mongodb.updaterSocketTimeoutMS" , "20000" ));
381
387
}
382
388
383
389
static final DBObject _isMasterCmd = new BasicDBObject ( "ismaster" , 1 );
0 commit comments