slfan1989 commented on code in PR #1349:
URL: https://github.com/apache/ratis/pull/1349#discussion_r2820926513
##########
ratis-netty/src/main/java/org/apache/ratis/netty/NettyConfigKeys.java:
##########
@@ -176,6 +176,47 @@ static TimeDuration replyQueueGracePeriod(RaftProperties
properties) {
static void setReplyQueueGracePeriod(RaftProperties properties,
TimeDuration timeoutDuration) {
setTimeDuration(properties::setTimeDuration,
REPLY_QUEUE_GRACE_PERIOD_KEY, timeoutDuration);
}
+
+ /**
+ * Initial delay for reconnect attempts.
+ * The delay doubles on each failure with 0.5x-1.5x jitter.
+ */
+ String RECONNECT_DELAY_KEY = PREFIX + ".reconnect.delay";
+ TimeDuration RECONNECT_DELAY_DEFAULT = TimeDuration.valueOf(100,
TimeUnit.MILLISECONDS);
+ static TimeDuration reconnectDelay(RaftProperties properties) {
+ return
getTimeDuration(properties.getTimeDuration(RECONNECT_DELAY_DEFAULT.getUnit()),
+ RECONNECT_DELAY_KEY, RECONNECT_DELAY_DEFAULT, getDefaultLog());
+ }
+ static void setReconnectDelay(RaftProperties properties, TimeDuration
delay) {
+ setTimeDuration(properties::setTimeDuration, RECONNECT_DELAY_KEY,
delay);
+ }
+
+ /**
+ * Maximum delay for reconnect attempts.
+ * The backoff increases until this upper bound.
+ */
+ String RECONNECT_MAX_DELAY_KEY = PREFIX + ".reconnect.max-delay";
+ TimeDuration RECONNECT_MAX_DELAY_DEFAULT = TimeDuration.valueOf(5,
TimeUnit.SECONDS);
+ static TimeDuration reconnectMaxDelay(RaftProperties properties) {
+ return
getTimeDuration(properties.getTimeDuration(RECONNECT_MAX_DELAY_DEFAULT.getUnit()),
+ RECONNECT_MAX_DELAY_KEY, RECONNECT_MAX_DELAY_DEFAULT,
getDefaultLog());
+ }
+ static void setReconnectMaxDelay(RaftProperties properties, TimeDuration
delay) {
+ setTimeDuration(properties::setTimeDuration, RECONNECT_MAX_DELAY_KEY,
delay);
+ }
+
+ /**
+ * Maximum number of reconnect attempts.
+ * Use {@link Integer#MAX_VALUE} for unlimited attempts.
+ */
+ String RECONNECT_MAX_ATTEMPTS_KEY = PREFIX + ".reconnect.max-attempts";
+ int RECONNECT_MAX_ATTEMPTS_DEFAULT = Integer.MAX_VALUE;
+ static int reconnectMaxAttempts(RaftProperties properties) {
+ return getInt(properties::getInt, RECONNECT_MAX_ATTEMPTS_KEY,
RECONNECT_MAX_ATTEMPTS_DEFAULT, getDefaultLog());
+ }
+ static void setReconnectMaxAttempts(RaftProperties properties, int
maxAttempts) {
+ setInt(properties::setInt, RECONNECT_MAX_ATTEMPTS_KEY, maxAttempts);
+ }
Review Comment:
Agreed. We’ll use a single configuration object so we can support additional
RetryPolicy implementations later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]