You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ratis.apache.org by GitBox <gi...@apache.org> on 2020/11/27 15:52:49 UTC

[GitHub] [incubator-ratis] szetszwo commented on a change in pull request #303: RATIS-1184. Move RaftServerMetrics to org.apache.ratis.server.metrics.

szetszwo commented on a change in pull request #303:
URL: https://github.com/apache/incubator-ratis/pull/303#discussion_r531673547



##########
File path: ratis-server/src/main/java/org/apache/ratis/server/metrics/RaftServerMetrics.java
##########
@@ -108,20 +118,18 @@ private RatisMetricRegistry getMetricRegistryForRaftServer(String serverId) {
         RATIS_SERVER_METRICS_DESC));
   }
 
-  private void addRetryCacheMetric(RaftServerImpl raftServer) {
-    registry.gauge(RETRY_CACHE_ENTRY_COUNT_METRIC, () -> () -> raftServer.getRetryCache().size());
-    registry.gauge(RETRY_CACHE_HIT_COUNT_METRIC, () -> () -> raftServer.getRetryCache().stats().hitCount());
-    registry.gauge(RETRY_CACHE_HIT_RATE_METRIC, () -> () -> raftServer.getRetryCache().stats().hitRate());
-    registry.gauge(RETRY_CACHE_MISS_COUNT_METRIC, () -> () -> raftServer.getRetryCache().stats().missCount());
-    registry.gauge(RETRY_CACHE_MISS_RATE_METRIC, () -> () -> raftServer.getRetryCache().stats().missRate());
+  private void addRetryCacheMetric(Supplier<RetryCache> retryCache) {
+    registry.gauge(RETRY_CACHE_ENTRY_COUNT_METRIC, () -> () -> retryCache.get().size());
+    registry.gauge(RETRY_CACHE_HIT_COUNT_METRIC  , () -> () -> retryCache.get().stats().hitCount());
+    registry.gauge(RETRY_CACHE_HIT_RATE_METRIC   , () -> () -> retryCache.get().stats().hitRate());
+    registry.gauge(RETRY_CACHE_MISS_COUNT_METRIC , () -> () -> retryCache.get().stats().missCount());
+    registry.gauge(RETRY_CACHE_MISS_RATE_METRIC  , () -> () -> retryCache.get().stats().missRate());

Review comment:
       No, just using vertical alignment (https://en.wikipedia.org/wiki/Programming_style#Vertical_alignment).  It is easier to read for situation like this.  Intellij supports a similar feature for javadoc.
   <img width="1115" alt="image" src="https://user-images.githubusercontent.com/907380/100466112-58d9c480-310b-11eb-94b1-66e2b563c594.png">
   




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org