Skip to content

Commit f46652c

Browse files
committed
set a max fall off for retry in event of long failure
1 parent c0d7ba6 commit f46652c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/com/danga/MemCached/SockIOPool.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ public class SockIOPool {
132132
public static final int OLD_COMPAT_HASH = 1; // original compatibility hashing algorithm (works with other clients)
133133
public static final int NEW_COMPAT_HASH = 2; // new CRC32 based compatibility hashing algorithm (works with other clients)
134134

135+
public static final long MAX_RETRY_DELAY = 10 * 60 * 1000; // max of 10 minute delay for fall off
136+
135137
// Pool data
136138
private MaintThread maintThread;
137139
private boolean initialized = false;
@@ -625,7 +627,12 @@ protected SockIO createSocket( String host ) {
625627
if ( socket == null ) {
626628
Date now = new Date();
627629
hostDead.put( host, now );
630+
628631
long expire = ( hostDeadDur.containsKey( host ) ) ? (((Long)hostDeadDur.get( host )).longValue() * 2) : 1000;
632+
633+
if ( expire > MAX_RETRY_DELAY )
634+
expire = MAX_RETRY_DELAY;
635+
629636
hostDeadDur.put( host, new Long( expire ) );
630637
log.debug( "++++ ignoring dead host: " + host + " for " + expire + " ms" );
631638

0 commit comments

Comments
 (0)