This is an automated email from the ASF dual-hosted git repository.
szetszwo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ratis.git
The following commit(s) were added to refs/heads/master by this push:
new a0f74e5a3 RATIS-1918 Introduces parameters that separately control the
shutdown of RaftServerProxy by JVMPauseMonitor. (#950)
a0f74e5a3 is described below
commit a0f74e5a3caf070c87f4ac8dbf1fdadbac91b6b7
Author: Potato <[email protected]>
AuthorDate: Tue Oct 24 23:24:39 2023 +0800
RATIS-1918 Introduces parameters that separately control the shutdown of
RaftServerProxy by JVMPauseMonitor. (#950)
---
.../java/org/apache/ratis/server/RaftServerConfigKeys.java | 10 ++++++++++
.../java/org/apache/ratis/server/impl/RaftServerProxy.java | 4 ++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git
a/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
b/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
index b59f25588..2d777cf7d 100644
---
a/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
+++
b/ratis-server-api/src/main/java/org/apache/ratis/server/RaftServerConfigKeys.java
@@ -81,6 +81,16 @@ public interface RaftServerConfigKeys {
setInt(properties::setInt, SLEEP_DEVIATION_THRESHOLD_KEY, thresholdMs);
}
+ String CLOSE_THRESHOLD_KEY = PREFIX + ".close.threshold";
+ TimeDuration CLOSE_THRESHOLD_DEFAULT = TimeDuration.valueOf(60,
TimeUnit.SECONDS);
+ static TimeDuration closeThreshold(RaftProperties properties) {
+ return
getTimeDuration(properties.getTimeDuration(CLOSE_THRESHOLD_DEFAULT.getUnit()),
+ CLOSE_THRESHOLD_KEY, CLOSE_THRESHOLD_DEFAULT, getDefaultLog());
+ }
+ static void setCloseThreshold(RaftProperties properties, int thresholdMs) {
+ setInt(properties::setInt, CLOSE_THRESHOLD_KEY, thresholdMs);
+ }
+
/**
* When bootstrapping a new peer, If the gap between the match index of the
* peer and the leader's latest committed index is less than this gap, we
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerProxy.java
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerProxy.java
index 7d384f601..fd80d6938 100644
---
a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerProxy.java
+++
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerProxy.java
@@ -222,11 +222,11 @@ class RaftServerProxy implements RaftServer {
id + "-impl"));
final TimeDuration sleepDeviationThreshold =
RaftServerConfigKeys.sleepDeviationThreshold(properties);
- final TimeDuration rpcSlownessTimeout =
RaftServerConfigKeys.Rpc.slownessTimeout(properties);
+ final TimeDuration closeThreshold =
RaftServerConfigKeys.closeThreshold(properties);
final TimeDuration leaderStepDownWaitTime =
RaftServerConfigKeys.LeaderElection.leaderStepDownWaitTime(properties);
this.pauseMonitor = JvmPauseMonitor.newBuilder().setName(id)
.setSleepDeviationThreshold(sleepDeviationThreshold)
- .setHandler(extraSleep -> handleJvmPause(extraSleep,
rpcSlownessTimeout, leaderStepDownWaitTime))
+ .setHandler(extraSleep -> handleJvmPause(extraSleep, closeThreshold,
leaderStepDownWaitTime))
.build();
this.threadGroup = threadGroup == null ? new
ThreadGroup(this.id.toString()) : threadGroup;
}