bbeaudreault commented on code in PR #5012:
URL: https://github.com/apache/hbase/pull/5012#discussion_r1117076635


##########
hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsTableLatenciesImpl.java:
##########
@@ -26,14 +26,38 @@
 import org.apache.hadoop.metrics2.lib.DynamicMetricsRegistry;
 import org.apache.yetus.audience.InterfaceAudience;
 
+import org.apache.hbase.thirdparty.com.google.common.base.Ticker;
+import org.apache.hbase.thirdparty.com.google.common.cache.Cache;
+import org.apache.hbase.thirdparty.com.google.common.cache.CacheBuilder;
+
 /**
  * Implementation of {@link MetricsTableLatencies} to track latencies for one 
table in a
  * RegionServer.
  */
 @InterfaceAudience.Private
 public class MetricsTableLatenciesImpl extends BaseSourceImpl implements 
MetricsTableLatencies {
 
-  private final HashMap<TableName, TableHistograms> histogramsByTable = new 
HashMap<>();
+  public MockTicker getTicker() {
+    return ticker;
+  }
+
+  private final MockTicker ticker = new MockTicker();
+  private final Cache<TableName, TableHistograms> histogramsByTable =
+    CacheBuilder.newBuilder().ticker(ticker).expireAfterAccess(5, 
TimeUnit.MINUTES).build();
+
+  public static class MockTicker extends Ticker {
+    private long start = Ticker.systemTicker().read();

Review Comment:
   im not familiar with the internals of guava Cache... it looks like this 
ticker will always return the same value, whatever the time was when the ticker 
was created. are you sure this works outside the test context?



-- 
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: issues-unsubscr...@hbase.apache.org

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

Reply via email to