goiri commented on code in PR #5497:
URL: https://github.com/apache/hadoop/pull/5497#discussion_r1148236769


##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/store/driver/TestStateStoreDriverBase.java:
##########
@@ -574,6 +580,38 @@ private static Map<String, Class<?>> getFields(BaseRecord 
record) {
     return getters;
   }
 
+  public long getMountTableCacheLoadSamples(StateStoreDriver driver) throws 
IOException {
+    final MutableRate mountTableCache = getMountTableCache(driver);
+    return mountTableCache.lastStat().numSamples();
+  }
+
+  private static MutableRate getMountTableCache(StateStoreDriver driver) 
throws IOException {
+    StateStoreMetrics metrics = stateStore.getMetrics();
+    final Query<MountTable> query = new Query<>(MountTable.newInstance());
+    driver.getMultiple(MountTable.class, query);
+    final Map<String, MutableRate> cacheLoadMetrics = 
metrics.getCacheLoadMetrics();
+    final MutableRate mountTableCache = 
cacheLoadMetrics.get("CacheMountTableLoad");
+    assertNotNull("CacheMountTableLoad should be present in the state store 
metrics",
+        mountTableCache);
+    return mountTableCache;
+  }
+
+  public void testCacheLoadMetrics(StateStoreDriver driver, long numRefresh)
+      throws IOException, IllegalArgumentException {
+    final MutableRate mountTableCache = getMountTableCache(driver);
+    // CacheMountTableLoadNumOps
+    final long mountTableCacheLoadNumOps = 
getMountTableCacheLoadSamples(driver);
+    assertEquals("Num of samples collected should match", numRefresh, 
mountTableCacheLoadNumOps);
+    // CacheMountTableLoadAvgTime
+    final double mountTableCacheLoadAvgTime = 
mountTableCache.lastStat().mean();

Review Comment:
   Add the unit "ms"



##########
hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/store/driver/TestStateStoreDriverBase.java:
##########
@@ -574,6 +580,38 @@ private static Map<String, Class<?>> getFields(BaseRecord 
record) {
     return getters;
   }
 
+  public long getMountTableCacheLoadSamples(StateStoreDriver driver) throws 
IOException {
+    final MutableRate mountTableCache = getMountTableCache(driver);
+    return mountTableCache.lastStat().numSamples();
+  }
+
+  private static MutableRate getMountTableCache(StateStoreDriver driver) 
throws IOException {
+    StateStoreMetrics metrics = stateStore.getMetrics();
+    final Query<MountTable> query = new Query<>(MountTable.newInstance());
+    driver.getMultiple(MountTable.class, query);
+    final Map<String, MutableRate> cacheLoadMetrics = 
metrics.getCacheLoadMetrics();
+    final MutableRate mountTableCache = 
cacheLoadMetrics.get("CacheMountTableLoad");
+    assertNotNull("CacheMountTableLoad should be present in the state store 
metrics",
+        mountTableCache);
+    return mountTableCache;
+  }
+
+  public void testCacheLoadMetrics(StateStoreDriver driver, long numRefresh)
+      throws IOException, IllegalArgumentException {
+    final MutableRate mountTableCache = getMountTableCache(driver);
+    // CacheMountTableLoadNumOps
+    final long mountTableCacheLoadNumOps = 
getMountTableCacheLoadSamples(driver);
+    assertEquals("Num of samples collected should match", numRefresh, 
mountTableCacheLoadNumOps);
+    // CacheMountTableLoadAvgTime
+    final double mountTableCacheLoadAvgTime = 
mountTableCache.lastStat().mean();
+    // 2000 ms is pretty high enough value for the test, hence we expect mount 
table cache

Review Comment:
   ```
   // 2 seconds is a high enough value for the test, hence we expect mount 
table cache
   ```



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to