@Test(timeout = 300000) public void testClusterRequests() throws Exception { // sending fake request to master to see how metric value has changed RegionServerStatusProtos.RegionServerReportRequest.Builder request = RegionServerStatusProtos.RegionServerReportRequest.newBuilder(); ServerName serverName = cluster.getMaster(0).getServerName(); request.setServer(ProtobufUtil.toServerName(serverName)); MetricsMasterSource masterSource = master.getMasterMetrics().getMetricsSource(); ClusterStatusProtos.ServerLoad sl = ClusterStatusProtos.ServerLoad.newBuilder().setTotalNumberOfRequests(10000).build(); masterSource.init(); request.setLoad(sl); master.getMasterRpcServices().regionServerReport(null, request.build()); metricsHelper.assertCounter("cluster_requests", 10000, masterSource); sl = ClusterStatusProtos.ServerLoad.newBuilder().setTotalNumberOfRequests(15000).build(); request.setLoad(sl); master.getMasterRpcServices().regionServerReport(null, request.build()); metricsHelper.assertCounter("cluster_requests", 15000, masterSource); master.getMasterRpcServices().regionServerReport(null, request.build()); metricsHelper.assertCounter("cluster_requests", 15000, masterSource); master.stopMaster(); }
@Test public void testDefaultMasterMetrics() throws Exception { MetricsMasterSource masterSource = master.getMasterMetrics().getMetricsSource(); metricsHelper.assertGauge("numRegionServers", 2, masterSource); metricsHelper.assertGauge("averageLoad", 2, masterSource); metricsHelper.assertGauge("numDeadRegionServers", 0, masterSource); metricsHelper.assertGauge("masterStartTime", master.getMasterStartTime(), masterSource); metricsHelper.assertGauge("masterActiveTime", master.getMasterActiveTime(), masterSource); metricsHelper.assertTag("isActiveMaster", "true", masterSource); metricsHelper.assertTag("serverName", master.getServerName().toString(), masterSource); metricsHelper.assertTag("clusterId", master.getClusterId(), masterSource); metricsHelper.assertTag("zookeeperQuorum", master.getZooKeeper().getQuorum(), masterSource); }