@Test public void testCustomMetrics() throws Exception { TEST_UTIL.getConfiguration().setInt("hbase.regionserver.port", 0); TestRegionServer rs = new TestRegionServer(TEST_UTIL.getConfiguration()); rs.incTest(5); String metricName = HBaseRpcMetrics.getMetricName(TestMetrics.class, "test"); long start = EnvironmentEdgeManager.currentTimeMillis(); while (!wasSet(metricName + "_num_ops")) { if (EnvironmentEdgeManager.currentTimeMillis() - start > 60000) { assertTrue("Metric should have set incremented for "+metricName, wasSet(metricName + "_num_ops")); } Thread.sleep(200); } }
@Test public void testCustomMetrics() throws Exception { TEST_UTIL.getConfiguration().setInt("hbase.regionserver.port", 0); TestRegionServer rs = new TestRegionServer(TEST_UTIL.getConfiguration()); rs.incTest(5); // wait for metrics context update Thread.sleep(1000); String metricName = HBaseRpcMetrics.getMetricName(TestMetrics.class, "test"); assertTrue("Metric should have set incremented for "+metricName, wasSet(metricName + "_num_ops")); }
public void incTest(int amt) { HBaseRpcMetrics metrics = getRpcMetrics(); // force an increment so we have something to check for metrics.inc(metrics.getMetricName(TestMetrics.class, "test"), amt); }
/** * Return a reference to the metrics instance used for counting RPC calls. * @return Metrics instance. */ public HBaseRpcMetrics getRpcMetrics() { return rpcServer.getRpcMetrics(); }