Skip to content

Commit bda4c06

Browse files
committed
[JAVA-241]: driver has a bunch of hardcoded timing settings that many customers want to tweak
1 parent 71e4670 commit bda4c06

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/main/com/mongodb/ReplicaSetStatus.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ ServerAddress getASecondary(){
9090
}
9191

9292
long diff = best._pingTime - n._pingTime;
93-
if ( diff > 15 ||
93+
if ( diff > slaveAcceptableLatencyMS ||
9494
// this is a complex way to make sure we get a random distribution of slaves
9595
( ( badBeforeBest - mybad ) / ( _all.size() - 1 ) ) > _random.nextDouble() )
9696
{
@@ -261,7 +261,7 @@ public void run(){
261261
}
262262

263263
try {
264-
Thread.sleep( 5 * 1000 );
264+
Thread.sleep( updaterIntervalMS );
265265
}
266266
catch ( InterruptedException ie ){
267267
// TODO: maybe something smarter
@@ -374,10 +374,16 @@ void close(){
374374

375375
final Random _random = new Random();
376376

377+
static int updaterIntervalMS;
378+
static int slaveAcceptableLatencyMS;
379+
377380
static final MongoOptions _mongoOptions = new MongoOptions();
381+
378382
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"));
381387
}
382388

383389
static final DBObject _isMasterCmd = new BasicDBObject( "ismaster" , 1 );

0 commit comments

Comments
 (0)