Skip to content

Conversation

@rgorodischer
Copy link

This change fixes the following bug in max reconnect delay initialization:

The 'maxDelay' parameter is used to be set in seconds (but if it was specified in milliseconds, the things would be even worser). Currently, it's transformed during initialization with TimeUnit.SECONDS.toMillis.
It means that the specified value is multiplied by 1000 in constructor.
And then it appears in this code snippet from method 'queueReconnect':

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

As you can see, it's multiplied by 1000 second time here, what is obviously causes 1000 times longer delay then the user expects.


/**
* 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.

Copy link

@caoziwen caoziwen left a comment

Choose a reason for hiding this comment

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

I think it should be in second

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants