-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZOOKEEPER-2849: Exponential back-off retry for Quorum port binding #419
base: master
Are you sure you want to change the base?
Conversation
Added BackoffStrategy interface with ExponentialBackoffStrategy as a concrete implementation. Enhanced QuorumCnxManager to utilize the provided BackoffStrategy to determine retry of port binding as opposed to a fixed interval/count.
Added missing Apache license header
@@ -946,7 +946,8 @@ protected Election createElectionAlgorithm(int electionAlgorithm){ | |||
le = new AuthFastLeaderElection(this, true); | |||
break; | |||
case 3: | |||
qcm = new QuorumCnxManager(this); | |||
qcm = new QuorumCnxManager(this, | |||
ExponentialBackoffStrategy.builder().build()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should find a way to make this pluggable? Perhaps we can read which backoff strategy to use from a java system property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For instance, it may be nice to have the default strategy perform the existing behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, included in my upcoming push.
/** | ||
* Builder for instances of {@link ExponentialBackoffStrategy}. | ||
*/ | ||
public static final class Builder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure a builder is the best way to handle this. Since I think it would be nice to have much of this be user configurable, perhaps we can just pull the config from system properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it should be configurable, but I don't think using a Builder pattern precludes this. I'm about to push changes that adds support for using system properties, that's a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I probably wasn't clear here. It would be great if it was also possible, since backoff strategy is such a nicely defined interface, if the user could include jar with their own backoff strategy in the classpath and tell zookeeper to use that. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be doable.
/** | ||
* Unit tests for {@link ExponentialBackoffStrategy}. | ||
*/ | ||
public class ExponentialBackoffStrategyTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should extend ZKTestCase
Unit tests extend ZKTestCase
Added support for FixedIntervalBackoffStrategy to maintain the current retry behavior. BackoffStrategy is now configurable via system properties, user can select the type of BackoffStrategy as well as configure it as desired.
Add FixedIntervalBackoffStrategy and unit test that got missed.
Add support for external implementations of BackoffStrategy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this patch has been abandonen.
|
||
private void validateInclusiveBetween(long min, long max, long value) { | ||
if(value < min) { | ||
throw new IllegalArgumentException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be useful to add some information about the parameter with illegal value. Exception message would be fine for that if you could add it as a parameter of this method.
Same applies to all places where you throw IllegalArgumentException.
* @return a new {@link Builder} instance. | ||
*/ | ||
public static Builder builder() { | ||
return new Builder(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why do you need a method for creating Builder instance.
try { | ||
builder.setBackoffMultiplier(Double.valueOf(multiplierProp)); | ||
} catch(NumberFormatException nfe) { | ||
LOG.warn("{} is not a valid floating point value, ignoring it.", multiplierProp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to add:
...floating point value for backoffMultiplier, ignoring...
Added BackoffStrategy interface with ExponentialBackoffStrategy as a concrete implementation. Enhanced
QuorumCnxManager to utilize the provided BackoffStrategy to determine retry of port binding as opposed to
a fixed interval/count.