This is an automated email from the ASF dual-hosted git repository.
shashikant pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ratis.git
The following commit(s) were added to refs/heads/master by this push:
new 63cd2fb RATIS-650. Add metrics to track commit index of each peer in
a RaftGroup. Contributed by Supratim Deka.
63cd2fb is described below
commit 63cd2fb981933aba137ba39bfc07e389166f5863
Author: Shashikant Banerjee <[email protected]>
AuthorDate: Fri Oct 4 23:28:15 2019 +0530
RATIS-650. Add metrics to track commit index of each peer in a RaftGroup.
Contributed by Supratim Deka.
---
.../org/apache/ratis/server/impl/LeaderState.java | 25 ++--
.../org/apache/ratis/server/impl/LogAppender.java | 2 +-
.../ratis/server/impl/RaftLeaderMetrics.java | 126 +++++++++++++++++++++
.../apache/ratis/server/impl/RaftServerImpl.java | 8 ++
.../ratis/server/metrics/HeartbeatMetrics.java | 63 -----------
.../ratis/server/metrics/RatisMetricNames.java | 6 +-
.../apache/ratis/server/metrics/RatisMetrics.java | 11 +-
.../java/org/apache/ratis/LogAppenderTests.java | 10 +-
.../test/java/org/apache/ratis/RaftBasicTests.java | 27 ++++-
.../ratis/TestRaftServerSlownessDetection.java | 10 +-
10 files changed, 197 insertions(+), 91 deletions(-)
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderState.java
b/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderState.java
index 17e4664..67a3120 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderState.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderState.java
@@ -21,7 +21,6 @@ import org.apache.ratis.conf.RaftProperties;
import org.apache.ratis.proto.RaftProtos.ReplicationLevel;
import org.apache.ratis.protocol.*;
import org.apache.ratis.server.RaftServerConfigKeys;
-import org.apache.ratis.server.metrics.HeartbeatMetrics;
import org.apache.ratis.server.protocol.TermIndex;
import org.apache.ratis.server.raftlog.RaftLog;
import org.apache.ratis.proto.RaftProtos.CommitInfoProto;
@@ -201,7 +200,7 @@ public class LeaderState {
private final int stagingCatchupGap;
private final TimeDuration syncInterval;
private final long placeHolderIndex;
- private final HeartbeatMetrics heartbeatMetrics;
+ private final RaftLeaderMetrics raftLeaderMetrics;
LeaderState(RaftServerImpl server, RaftProperties properties) {
this.name = server.getMemberId() + "-" + getClass().getSimpleName();
@@ -224,7 +223,7 @@ public class LeaderState {
placeHolderIndex = raftLog.getNextIndex();
senders = new SenderList();
- heartbeatMetrics = HeartbeatMetrics.getHeartbeatMetrics(server);
+ raftLeaderMetrics = RaftLeaderMetrics.getRaftLeaderMetrics(server);
addSenders(others, placeHolderIndex, true);
voterLists = divideFollowers(conf);
}
@@ -337,7 +336,7 @@ public class LeaderState {
void commitIndexChanged() {
getMajorityMin(FollowerInfo::getCommitIndex,
raftLog::getLastCommittedIndex).ifPresent(m -> {
- // Normally, leader commit index is always ahead followers.
+ // Normally, leader commit index is always ahead of followers.
// However, after a leader change, the new leader commit index may
// be behind some followers in the beginning.
watchRequests.update(ReplicationLevel.ALL_COMMITTED, m.min);
@@ -390,7 +389,8 @@ public class LeaderState {
final List<LogAppender> newAppenders = newPeers.stream()
.map(peer -> {
LogAppender logAppender = server.newLogAppender(this, peer, t,
nextIndex, attendVote);
-
heartbeatMetrics.addFollower(logAppender.getFollower().getPeer().getId().toString());
+ raftLeaderMetrics
+ .addFollower(logAppender.getFollower().getPeer());
return logAppender;
}).collect(Collectors.toList());
senders.addAll(newAppenders);
@@ -794,11 +794,20 @@ public class LeaderState {
/**
* Record Follower Heartbeat Elapsed Time.
- * @param followerId Follower Peer ID.
+ * @param follower RaftPeer.
* @param elapsedTime Elapsed time in Nanos.
*/
- void recordFollowerHeartbeatElapsedTime(String followerId, long elapsedTime)
{
- heartbeatMetrics.recordFollowerHeartbeatElapsedTime(followerId,
elapsedTime);
+ void recordFollowerHeartbeatElapsedTime(RaftPeer follower, long elapsedTime)
{
+ raftLeaderMetrics.recordFollowerHeartbeatElapsedTime(follower,
+ elapsedTime);
+ }
+
+ /**
+ * Return the metric registry for the Group Leader.
+ * @return the group leader metrics registry
+ */
+ RaftLeaderMetrics getRaftLeaderMetrics() {
+ return raftLeaderMetrics;
}
@Override
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/impl/LogAppender.java
b/ratis-server/src/main/java/org/apache/ratis/server/impl/LogAppender.java
index 5768bc4..c72c333 100644
--- a/ratis-server/src/main/java/org/apache/ratis/server/impl/LogAppender.java
+++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/LogAppender.java
@@ -527,7 +527,7 @@ public class LogAppender {
if (follower.isSlow()) {
server.getStateMachine().notifySlowness(server.getRoleInfoProto());
}
-
leaderState.recordFollowerHeartbeatElapsedTime(follower.getPeer().getId().toString(),
+ leaderState.recordFollowerHeartbeatElapsedTime(follower.getPeer(),
follower.getLastRpcResponseTime().elapsedTime().getDuration());
}
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftLeaderMetrics.java
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftLeaderMetrics.java
new file mode 100644
index 0000000..04b6895
--- /dev/null
+++
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftLeaderMetrics.java
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ratis.server.impl;
+
+import static
org.apache.ratis.server.metrics.RatisMetricNames.LEADER_METRIC_PEER_COMMIT_INDEX;
+import static
org.apache.ratis.server.metrics.RatisMetricNames.LEADER_METRIC_FOLLOWER_LAST_HEARTBEAT_ELAPSED_TIME_METRIC;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.SortedMap;
+
+import com.codahale.metrics.Gauge;
+import com.google.common.annotations.VisibleForTesting;
+import org.apache.ratis.metrics.RatisMetricRegistry;
+import org.apache.ratis.protocol.RaftPeer;
+import org.apache.ratis.server.metrics.RatisMetrics;
+import org.apache.ratis.util.Preconditions;
+
+/**
+ * Metric Registry for Raft Group Leader. One instance per leader.
+ */
+public final class RaftLeaderMetrics {
+
+ private RatisMetricRegistry registry = null;
+ private Map<String, Long> followerLastHeartbeatElapsedTimeMap = new
HashMap<>();
+ private CommitInfoCache commitInfoCache;
+
+ private static Map<String, RaftLeaderMetrics> metricsMap = new HashMap<>();
+
+ public static RaftLeaderMetrics getRaftLeaderMetrics(
+ RaftServerImpl raftServer) {
+ RaftLeaderMetrics leaderMetrics = new RaftLeaderMetrics(raftServer);
+ metricsMap.put(raftServer.getMemberId().toString(), leaderMetrics);
+
+ return leaderMetrics;
+ }
+
+ private RaftLeaderMetrics(RaftServerImpl server) {
+ registry = RatisMetrics.getMetricRegistryForRaftLeader(
+ server.getMemberId().toString());
+ commitInfoCache = server.getCommitInfoCache();
+ addPeerCommitIndexGauge(server.getPeer());
+ }
+
+ /**
+ * Register a follower with this Leader Metrics registry instance.
+ * @param peer {@Link RaftPeer} representing the follower
+ */
+ public void addFollower(RaftPeer peer) {
+ String followerName = peer.getId().toString();
+ String followerHbMetricKey = String.format(
+ LEADER_METRIC_FOLLOWER_LAST_HEARTBEAT_ELAPSED_TIME_METRIC,
+ followerName);
+
+ followerLastHeartbeatElapsedTimeMap.put(followerName, 0L);
+ registry.gauge(followerHbMetricKey,
+ () -> () -> followerLastHeartbeatElapsedTimeMap.get(followerName));
+
+ addPeerCommitIndexGauge(peer);
+ }
+
+ /**
+ * Register a commit index tracker for the peer in cluster.
+ * @param peer
+ */
+ public void addPeerCommitIndexGauge(RaftPeer peer) {
+ String followerCommitIndexKey = String.format(
+ LEADER_METRIC_PEER_COMMIT_INDEX, peer.getId().toString());
+ registry.gauge(followerCommitIndexKey,
+ () -> () -> commitInfoCache.get(peer.getId()).getCommitIndex());
+ }
+
+ /**
+ * Get the commit index gauge for the given peer of the server
+ * @param server
+ * @param peerServer
+ * @return Metric Gauge holding the value of commit index of the peer
+ */
+ @VisibleForTesting
+ public static Gauge getPeerCommitIndexGauge(RaftServerImpl server,
+ RaftServerImpl peerServer) {
+
+ RaftLeaderMetrics leaderMetrics =
+ metricsMap.get(server.getMemberId().toString());
+ if (leaderMetrics == null) {
+ return null;
+ }
+
+ String followerCommitIndexKey = String.format(
+ LEADER_METRIC_PEER_COMMIT_INDEX,
+ peerServer.getPeer().getId().toString());
+
+ SortedMap<String, Gauge> map =
+ leaderMetrics.registry.getGauges((s, metric) ->
+ s.contains(followerCommitIndexKey));
+
+ Preconditions.assertTrue(map.size() <= 1);
+ return map.get(map.firstKey());
+ }
+
+ /**
+ * Record heartbeat elapsed time for a follower within a Raft group.
+ * @param peer {@Link RaftPeer} representing the follower.
+ * @param elapsedTime Elapsed time in Nanos.
+ */
+ public void recordFollowerHeartbeatElapsedTime(RaftPeer peer, long
elapsedTime) {
+ followerLastHeartbeatElapsedTimeMap.put(peer.getId().toString(),
+ elapsedTime);
+ }
+}
\ No newline at end of file
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
index bc4e69a..45a7029 100644
---
a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
+++
b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java
@@ -298,6 +298,14 @@ public class RaftServerImpl implements RaftServerProtocol,
RaftServerAsynchronou
}
/**
+ * return ref to the commit info cache.
+ * @return commit info cache
+ */
+ public CommitInfoCache getCommitInfoCache() {
+ return commitInfoCache;
+ }
+
+ /**
* Change the server state to Follower if this server is in a different role
or force is true.
* @param newTerm The new term.
* @param force Force to start a new {@link FollowerState} even if this
server is already a follower.
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/metrics/HeartbeatMetrics.java
b/ratis-server/src/main/java/org/apache/ratis/server/metrics/HeartbeatMetrics.java
deleted file mode 100644
index 9a8c4bd..0000000
---
a/ratis-server/src/main/java/org/apache/ratis/server/metrics/HeartbeatMetrics.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ratis.server.metrics;
-
-import static
org.apache.ratis.server.metrics.RatisMetricNames.FOLLOWER_LAST_HEARTBEAT_ELAPSED_TIME_METRIC;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.ratis.metrics.RatisMetricRegistry;
-import org.apache.ratis.server.impl.RaftServerImpl;
-
-/**
- * Metric Registry for Heartbeat. One instance per leader per group.
- */
-public final class HeartbeatMetrics {
-
- private RatisMetricRegistry registry = null;
- private Map<String, Long> followerLastHeartbeatElapsedTimeMap = new
HashMap<>();
-
- public static HeartbeatMetrics getHeartbeatMetrics(RaftServerImpl
raftServer) {
- return new HeartbeatMetrics(raftServer.getMemberId().toString());
- }
-
- private HeartbeatMetrics(String serverId) {
- registry = RatisMetrics.getMetricRegistryForHeartbeat(serverId);
- }
-
- /**
- * Register a follower with this Heartbeat Metrics registry instance.
- * @param followerName Name of the follower.
- */
- public void addFollower(String followerName) {
- String followerMetricKey =
String.format(FOLLOWER_LAST_HEARTBEAT_ELAPSED_TIME_METRIC, followerName);
- followerLastHeartbeatElapsedTimeMap.put(followerName, 0L);
- registry.gauge(followerMetricKey, () -> () ->
followerLastHeartbeatElapsedTimeMap.get(followerName));
- }
-
- /**
- * Record heartbeat elapsed time for a follower within a Raft group.
- * @param followerName Name of the follower.
- * @param elapsedTime Elapsed time in Nanos.
- */
- public void recordFollowerHeartbeatElapsedTime(String followerName, long
elapsedTime) {
- followerLastHeartbeatElapsedTimeMap.put(followerName, elapsedTime);
- }
-}
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/metrics/RatisMetricNames.java
b/ratis-server/src/main/java/org/apache/ratis/server/metrics/RatisMetricNames.java
index 7bf4404..7bc1033 100644
---
a/ratis-server/src/main/java/org/apache/ratis/server/metrics/RatisMetricNames.java
+++
b/ratis-server/src/main/java/org/apache/ratis/server/metrics/RatisMetricNames.java
@@ -28,7 +28,11 @@ public final class RatisMetricNames {
public static final String LEADER_ELECTION_LATENCY = "leaderElectionLatency";
public static final String LAST_LEADER_ELAPSED_TIME =
"lastLeaderElapsedTime";
- public static final String FOLLOWER_LAST_HEARTBEAT_ELAPSED_TIME_METRIC =
"follower-%s-lastHeartbeatElapsedTime";
+ public static final String
+ LEADER_METRIC_FOLLOWER_LAST_HEARTBEAT_ELAPSED_TIME_METRIC =
+ "follower_%s_lastHeartbeatElapsedTime";
+ public static final String LEADER_METRIC_PEER_COMMIT_INDEX =
+ "%s_peerCommitIndex";
public static final String STATEMACHINE_APPLIED_INDEX_GAUGE =
"statemachine_applied_index";
diff --git
a/ratis-server/src/main/java/org/apache/ratis/server/metrics/RatisMetrics.java
b/ratis-server/src/main/java/org/apache/ratis/server/metrics/RatisMetrics.java
index 950f43c..384b85f 100644
---
a/ratis-server/src/main/java/org/apache/ratis/server/metrics/RatisMetrics.java
+++
b/ratis-server/src/main/java/org/apache/ratis/server/metrics/RatisMetrics.java
@@ -33,8 +33,8 @@ public class RatisMetrics {
public final static String RATIS_APPLICATION_NAME_METRICS = "ratis_core";
public static final String RATIS_LEADER_ELECTION_METRICS = "leader_election";
public static final String RATIS_LEADER_ELECTION_METRICS_DESC = "Metrics for
Ratis Leader Election.";
- public static final String RATIS_HEARTBEAT_METRICS = "heartbeat";
- public static final String RATIS_HEARTBEAT_METRICS_DESC = "Metrics for Ratis
Heartbeat.";
+ public static final String RATIS_LEADER_METRICS = "ratis_leader";
+ public static final String RATIS_LEADER_METRICS_DESC = "Metrics for Ratis
Leader.";
public static final String RATIS_STATEMACHINE_METRICS =
"ratis_state_machine";
public static final String RATIS_STATEMACHINE_METRICS_DESC = "Metrics for
State Machine Updater";
@@ -61,9 +61,10 @@ public class RatisMetrics {
RATIS_LEADER_ELECTION_METRICS_DESC));
}
- public static RatisMetricRegistry getMetricRegistryForHeartbeat(String
serverId) {
- return create(new MetricRegistryInfo(serverId,
RATIS_APPLICATION_NAME_METRICS, RATIS_HEARTBEAT_METRICS,
- RATIS_HEARTBEAT_METRICS_DESC));
+ public static RatisMetricRegistry getMetricRegistryForRaftLeader(String
serverId) {
+ return create(new MetricRegistryInfo(serverId,
+ RATIS_APPLICATION_NAME_METRICS, RATIS_LEADER_METRICS,
+ RATIS_LEADER_METRICS_DESC));
}
public static RatisMetricRegistry getMetricRegistryForStateMachine(String
serverId) {
diff --git a/ratis-server/src/test/java/org/apache/ratis/LogAppenderTests.java
b/ratis-server/src/test/java/org/apache/ratis/LogAppenderTests.java
index af08a0c..7bd7ae7 100644
--- a/ratis-server/src/test/java/org/apache/ratis/LogAppenderTests.java
+++ b/ratis-server/src/test/java/org/apache/ratis/LogAppenderTests.java
@@ -141,8 +141,9 @@ public abstract class LogAppenderTests<CLUSTER extends
MiniRaftCluster>
throw e;
}
- RatisMetricRegistry ratisMetricRegistry =
RatisMetrics.getMetricRegistryForHeartbeat(
- leaderServer.getMemberId().toString());
+ RatisMetricRegistry ratisMetricRegistry =
+ RatisMetrics.getMetricRegistryForRaftLeader(
+ leaderServer.getMemberId().toString());
// Get all last_heartbeat_elapsed_time metric gauges. Should be equal to
number of followers.
SortedMap<String, Gauge> heartbeatElapsedTimeGauges =
ratisMetricRegistry.getGauges((s, metric) ->
@@ -158,8 +159,9 @@ public abstract class LogAppenderTests<CLUSTER extends
MiniRaftCluster>
// Metric in nanos > 0.
assertTrue((long)metric.getValue() > 0);
// Try to get Heartbeat metrics for follower.
- RatisMetricRegistry followerMetricsRegistry =
RatisMetrics.getMetricRegistryForHeartbeat(followerServer
- .getMemberId().toString());
+ RatisMetricRegistry followerMetricsRegistry =
+ RatisMetrics.getMetricRegistryForRaftLeader(
+ followerServer.getMemberId().toString());
// Metric should not exist. It only exists in leader.
assertTrue(followerMetricsRegistry.getGauges((s, m) ->
s.contains("last_heartbeat_elapsed_time")).isEmpty());
}
diff --git a/ratis-server/src/test/java/org/apache/ratis/RaftBasicTests.java
b/ratis-server/src/test/java/org/apache/ratis/RaftBasicTests.java
index ca61677..316634d 100644
--- a/ratis-server/src/test/java/org/apache/ratis/RaftBasicTests.java
+++ b/ratis-server/src/test/java/org/apache/ratis/RaftBasicTests.java
@@ -27,11 +27,7 @@ import org.apache.ratis.protocol.RaftClientReply;
import org.apache.ratis.protocol.RaftPeerId;
import org.apache.ratis.server.RaftServer;
import org.apache.ratis.server.RaftServerConfigKeys;
-import org.apache.ratis.server.impl.BlockRequestHandlingInjection;
-import org.apache.ratis.server.impl.RaftServerImpl;
-import org.apache.ratis.server.impl.RaftServerProxy;
-import org.apache.ratis.server.impl.RaftServerTestUtil;
-import org.apache.ratis.server.impl.RetryCacheTestUtil;
+import org.apache.ratis.server.impl.*;
import org.apache.ratis.server.metrics.RatisMetricNames;
import org.apache.ratis.server.metrics.RatisMetrics;
import org.apache.ratis.server.raftlog.RaftLog;
@@ -455,6 +451,7 @@ public abstract class RaftBasicTests<CLUSTER extends
MiniRaftCluster>
long appliedIndexBefore = (Long) appliedIndexGauge.getValue();
long smAppliedIndexBefore = (Long) smAppliedIndexGauge.getValue();
+ checkFollowerCommitLagsLeader(cluster);
if (async) {
CompletableFuture<RaftClientReply> replyFuture = client.sendAsync(new
SimpleMessage("abc"));
@@ -465,6 +462,7 @@ public abstract class RaftBasicTests<CLUSTER extends
MiniRaftCluster>
long appliedIndexAfter = (Long) appliedIndexGauge.getValue();
long smAppliedIndexAfter = (Long) smAppliedIndexGauge.getValue();
+ checkFollowerCommitLagsLeader(cluster);
Assert.assertTrue("StateMachine Applied Index not incremented",
appliedIndexAfter > appliedIndexBefore);
@@ -473,6 +471,25 @@ public abstract class RaftBasicTests<CLUSTER extends
MiniRaftCluster>
}
}
+ private static void checkFollowerCommitLagsLeader(MiniRaftCluster cluster) {
+ List<RaftServerImpl> followers = cluster.getFollowers();
+ RaftServerImpl leader = cluster.getLeader();
+
+ RatisMetricRegistry leaderMetricsRegistry =
+ RatisMetrics.getMetricRegistryForRaftLeader(
+ leader.getMemberId().toString());
+
+ Gauge leaderCommitGauge = RaftLeaderMetrics
+ .getPeerCommitIndexGauge(leader, leader);
+
+ for (RaftServerImpl follower : followers) {
+ Gauge followerCommitGauge = RaftLeaderMetrics
+ .getPeerCommitIndexGauge(leader, follower);
+ Assert.assertTrue((Long)leaderCommitGauge.getValue() >=
+ (Long)followerCommitGauge.getValue());
+ }
+ }
+
private static Gauge getStatemachineGaugeWithName(RaftServerImpl server,
String gaugeName) {
diff --git
a/ratis-test/src/test/java/org/apache/ratis/TestRaftServerSlownessDetection.java
b/ratis-test/src/test/java/org/apache/ratis/TestRaftServerSlownessDetection.java
index e4918a4..1f0586c 100644
---
a/ratis-test/src/test/java/org/apache/ratis/TestRaftServerSlownessDetection.java
+++
b/ratis-test/src/test/java/org/apache/ratis/TestRaftServerSlownessDetection.java
@@ -89,10 +89,12 @@ public class TestRaftServerSlownessDetection extends
BaseTest {
.slownessTimeout(cluster.getProperties()).toIntExact(TimeUnit.MILLISECONDS);
RaftServerImpl failedFollower = cluster.getFollowers().get(0);
- RatisMetricRegistry ratisMetricRegistry =
RatisMetrics.getMetricRegistryForHeartbeat(
- leaderServer.getMemberId().toString());
- SortedMap<String, Gauge> heartbeatElapsedTimeGauges =
ratisMetricRegistry.getGauges((s, metric) ->
- s.contains("lastHeartbeatElapsedTime"));
+ RatisMetricRegistry ratisMetricRegistry =
+ RatisMetrics.getMetricRegistryForRaftLeader(
+ leaderServer.getMemberId().toString());
+ SortedMap<String, Gauge> heartbeatElapsedTimeGauges =
+ ratisMetricRegistry.getGauges((s, metric) ->
+ s.contains("lastHeartbeatElapsedTime"));
String followerId = failedFollower.getId().toString();
Gauge metric =
heartbeatElapsedTimeGauges.entrySet().parallelStream().filter(e ->
e.getKey().contains(