Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/net/spy/memcached/ConnectionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ MemcachedNode createMemcachedNode(SocketAddress sa, SocketChannel c,
HashAlgorithm getHashAlg();

/**
* Maximum number of milliseconds to wait between reconnect attempts.
* Maximum number of seconds to wait between reconnect attempts.
Copy link

@jhbae jhbae Feb 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be milliseconds.

Because, in this commit, you just used f.getMaxReconnectDelay()
and as you may already know maxDelay is applied to calculate delay as follows.

long delay = (long) Math.min(maxDelay, Math.pow(2, node.getReconnectCount()) * 1000); long reconnectTime = System.currentTimeMillis() + delay;

As we can see above, delay will be just added to currentTimeMillis()
and the value 1000 is multiplied only to Math.pow(2, node.getReconnectCount()) not to maxDelay.

So I think it should be milliseconds as originally it was.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

although maxDelay is in millisecond, maxDelay = TimeUnit.SECONDS.toMillis(f.getMaxReconnectDelay()); MaxReconnectDelay should be in second

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
long getMaxReconnectDelay();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/spy/memcached/MemcachedConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public MemcachedConnection(final int bufSize, final ConnectionFactory f,
addedQueue = new ConcurrentLinkedQueue<MemcachedNode>();
failureMode = fm;
shouldOptimize = f.shouldOptimize();
maxDelay = TimeUnit.SECONDS.toMillis(f.getMaxReconnectDelay());
maxDelay = f.getMaxReconnectDelay();
opFact = opfactory;
timeoutExceptionThreshold = f.getTimeoutExceptionThreshold();
selector = Selector.open();
Expand Down