symious commented on code in PR #1587:
URL: https://github.com/apache/ratis/pull/1587#discussion_r4011094466


##########
ratis-server/src/main/java/org/apache/ratis/server/metrics/LogAppenderMetrics.java:
##########
@@ -47,8 +47,16 @@ private static RatisMetricRegistry createRegistry(String 
serverId) {
 
   public void addFollowerGauges(RaftPeerId id, LongSupplier getNextIndex, 
LongSupplier getMatchIndex,
       Supplier<Timestamp> getLastRpcTime) {
+    // The registry does not replace an existing gauge; remove it so that the 
new suppliers take effect.
+    removeFollowerGauges(id);
     getRegistry().gauge(String.format(FOLLOWER_NEXT_INDEX, id), () -> 
getNextIndex::getAsLong);
     getRegistry().gauge(String.format(FOLLOWER_MATCH_INDEX, id), () -> 
getMatchIndex::getAsLong);
     getRegistry().gauge(String.format(FOLLOWER_RPC_RESP_TIME, id), () -> () -> 
getLastRpcTime.get().elapsedTimeMs());
   }
+
+  public void removeFollowerGauges(RaftPeerId id) {
+    getRegistry().remove(String.format(FOLLOWER_NEXT_INDEX, id));
+    getRegistry().remove(String.format(FOLLOWER_MATCH_INDEX, id));
+    getRegistry().remove(String.format(FOLLOWER_RPC_RESP_TIME, id));
+  }

Review Comment:
   Updated, PTAL.



##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -698,6 +698,7 @@ private void stopAndRemoveSenders(Predicate<LogAppender> 
predicate) {
   private void stopAndRemoveSenders(Collection<LogAppender> toStop) {
     toStop.forEach(LogAppender::stopAsync);
     senders.removeAll(toStop);
+    toStop.forEach(s -> 
logAppenderMetrics.removeFollowerGauges(s.getFollowerId()));

Review Comment:
   Updated, PTAL.



-- 
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]

Reply via email to