Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
Signed-off-by: OneSizeFitQuorum <[email protected]>
  • Loading branch information
OneSizeFitsQuorum committed Aug 7, 2023
1 parent 95b51e5 commit 82afe9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,16 @@ static String toString(Map<String, GcInfo> beforeSleep, TimeDuration extraSleepT
}

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;
}

Expand All @@ -119,7 +121,7 @@ private void detectPause() {
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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ String toString(RaftGroupId groupId, CompletableFuture<RaftServerImpl> f) {
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;
}
Expand Down

0 comments on commit 82afe9a

Please sign in to comment.