Author: manik.surtani(a)jboss.com
Date: 2009-04-02 05:55:56 -0400 (Thu, 02 Apr 2009)
New Revision: 7966
Modified:
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
Log:
Added degree of randomization in wait times between state transfer retries
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2009-04-02 09:46:44 UTC
(rev 7965)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2009-04-02 09:55:56 UTC
(rev 7966)
@@ -76,6 +76,7 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Random;
import java.util.Set;
import java.util.Vector;
import java.util.concurrent.TimeUnit;
@@ -393,8 +394,9 @@
return;
}
boolean success = false;
- int numRetries = 2; // should be 5
- int initwait = 100; // should be 1000
+ int numRetries = 5;
+ int initwait = (1 + new Random().nextInt(10)) * 100;
+ int waitIncreaseFactor = 2;
outer:
for (int i = 0, wait = initwait; i < numRetries; i++)
@@ -424,7 +426,7 @@
if (!success)
{
- wait <<= 2;
+ wait *= waitIncreaseFactor;
if (log.isWarnEnabled())
{
log.warn("Could not find available peer for state, backing off and
retrying after " + wait + " millis. Retries left: " + (numRetries - 1 -
i));
Show replies by date