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 ea6faa47a RATIS-1867. To uniformly manage the timeout parameters for
detecting gc. (#899)
ea6faa47a is described below
commit ea6faa47a05a081708e192630dd5fac08a4d47b5
Author: Potato <[email protected]>
AuthorDate: Mon Aug 7 22:33:49 2023 +0800
RATIS-1867. To uniformly manage the timeout parameters for detecting gc.
(#899)
---
.../src/main/java/org/apache/ratis/util/JvmPauseMonitor.java | 8 +++++---
.../main/java/org/apache/ratis/server/impl/RaftServerProxy.java | 3 ++-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git
a/ratis-common/src/main/java/org/apache/ratis/util/JvmPauseMonitor.java
b/ratis-common/src/main/java/org/apache/ratis/util/JvmPauseMonitor.java
index 532bd2255..fac3d0ede 100644
--- a/ratis-common/src/main/java/org/apache/ratis/util/JvmPauseMonitor.java
+++ b/ratis-common/src/main/java/org/apache/ratis/util/JvmPauseMonitor.java
@@ -88,14 +88,16 @@ public class JvmPauseMonitor {
}
private static final TimeDuration SLEEP_TIME = TimeDuration.valueOf(500,
TimeUnit.MILLISECONDS);
- private static final TimeDuration WARN_THRESHOLD = TimeDuration.valueOf(100,
TimeUnit.MILLISECONDS);
+ private final TimeDuration sleepDeviationThreshold;
private final String name;
private final AtomicReference<Thread> threadRef = new AtomicReference<>();
private final CheckedConsumer<TimeDuration, IOException> handler;
- public JvmPauseMonitor(Object name, CheckedConsumer<TimeDuration,
IOException> handler) {
+ public JvmPauseMonitor(Object name, TimeDuration sleepDeviationThreshold,
+ CheckedConsumer<TimeDuration, IOException> handler) {
this.name = JavaUtils.getClassSimpleName(getClass()) + "-" + name;
+ this.sleepDeviationThreshold = sleepDeviationThreshold;
this.handler = handler;
}
@@ -119,7 +121,7 @@ public class JvmPauseMonitor {
return;
}
- if (extraSleep.compareTo(WARN_THRESHOLD) > 0) {
+ if (extraSleep.compareTo(sleepDeviationThreshold) > 0) {
final Map<String, GcInfo> after = getGcTimes();
LOG.warn("{}: {}", this, toString(before, extraSleep, after));
}
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 b6ca9b7c9..89f49210e 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
@@ -219,9 +219,10 @@ class RaftServerProxy implements RaftServer {
RaftServerConfigKeys.ThreadPool.proxySize(properties),
id + "-impl");
+ final TimeDuration sleepDeviationThreshold =
RaftServerConfigKeys.sleepDeviationThreshold(properties);
final TimeDuration rpcSlownessTimeout =
RaftServerConfigKeys.Rpc.slownessTimeout(properties);
final TimeDuration leaderStepDownWaitTime =
RaftServerConfigKeys.LeaderElection.leaderStepDownWaitTime(properties);
- this.pauseMonitor = new JvmPauseMonitor(id,
+ this.pauseMonitor = new JvmPauseMonitor(id, sleepDeviationThreshold,
extraSleep -> handleJvmPause(extraSleep, rpcSlownessTimeout,
leaderStepDownWaitTime));
this.threadGroup = threadGroup == null ? new
ThreadGroup(this.id.toString()) : threadGroup;
}