HBASE-10587 Master metrics clusterRequests is wrong
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1571354 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7e1ac02210
commit
9582b9b34d
|
@ -1351,10 +1351,13 @@ MasterServices, Server {
|
||||||
RpcController controller, RegionServerReportRequest request) throws ServiceException {
|
RpcController controller, RegionServerReportRequest request) throws ServiceException {
|
||||||
try {
|
try {
|
||||||
ClusterStatusProtos.ServerLoad sl = request.getLoad();
|
ClusterStatusProtos.ServerLoad sl = request.getLoad();
|
||||||
this.serverManager.regionServerReport(ProtobufUtil.toServerName(request.getServer()), new ServerLoad(sl));
|
ServerName serverName = ProtobufUtil.toServerName(request.getServer());
|
||||||
|
ServerLoad oldLoad = serverManager.getLoad(serverName);
|
||||||
|
this.serverManager.regionServerReport(serverName, new ServerLoad(sl));
|
||||||
if (sl != null && this.metricsMaster != null) {
|
if (sl != null && this.metricsMaster != null) {
|
||||||
// Up our metrics.
|
// Up our metrics.
|
||||||
this.metricsMaster.incrementRequests(sl.getTotalNumberOfRequests());
|
this.metricsMaster.incrementRequests(sl.getTotalNumberOfRequests()
|
||||||
|
- (oldLoad != null ? oldLoad.getTotalNumberOfRequests() : 0));
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
throw new ServiceException(ioe);
|
throw new ServiceException(ioe);
|
||||||
|
|
|
@ -19,14 +19,15 @@ package org.apache.hadoop.hbase.master;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.CompatibilityFactory;
|
import org.apache.hadoop.hbase.CompatibilityFactory;
|
||||||
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
import org.apache.hadoop.hbase.HBaseTestingUtility;
|
||||||
import org.apache.hadoop.hbase.MediumTests;
|
import org.apache.hadoop.hbase.MediumTests;
|
||||||
import org.apache.hadoop.hbase.MiniHBaseCluster;
|
import org.apache.hadoop.hbase.MiniHBaseCluster;
|
||||||
|
import org.apache.hadoop.hbase.ServerName;
|
||||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos;
|
import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos;
|
||||||
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos;
|
import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegionServer;
|
|
||||||
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
|
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
@ -49,6 +50,9 @@ public class TestMasterMetrics {
|
||||||
public static void startCluster() throws Exception {
|
public static void startCluster() throws Exception {
|
||||||
LOG.info("Starting cluster");
|
LOG.info("Starting cluster");
|
||||||
TEST_UTIL = new HBaseTestingUtility();
|
TEST_UTIL = new HBaseTestingUtility();
|
||||||
|
Configuration conf = TEST_UTIL.getConfiguration();
|
||||||
|
// Prevent region server report any load during the test
|
||||||
|
conf.setInt("hbase.regionserver.msginterval", 3000000);
|
||||||
TEST_UTIL.startMiniCluster(1, 1);
|
TEST_UTIL.startMiniCluster(1, 1);
|
||||||
cluster = TEST_UTIL.getHBaseCluster();
|
cluster = TEST_UTIL.getHBaseCluster();
|
||||||
LOG.info("Waiting for active/ready master");
|
LOG.info("Waiting for active/ready master");
|
||||||
|
@ -69,18 +73,30 @@ public class TestMasterMetrics {
|
||||||
// sending fake request to master to see how metric value has changed
|
// sending fake request to master to see how metric value has changed
|
||||||
RegionServerStatusProtos.RegionServerReportRequest.Builder request =
|
RegionServerStatusProtos.RegionServerReportRequest.Builder request =
|
||||||
RegionServerStatusProtos.RegionServerReportRequest.newBuilder();
|
RegionServerStatusProtos.RegionServerReportRequest.newBuilder();
|
||||||
HRegionServer rs = cluster.getRegionServer(0);
|
ServerName serverName = cluster.getRegionServer(0).getServerName();
|
||||||
request.setServer(ProtobufUtil.toServerName(rs.getServerName()));
|
request.setServer(ProtobufUtil.toServerName(serverName));
|
||||||
|
|
||||||
|
MetricsMasterSource masterSource = master.getMetrics().getMetricsSource();
|
||||||
ClusterStatusProtos.ServerLoad sl = ClusterStatusProtos.ServerLoad.newBuilder()
|
ClusterStatusProtos.ServerLoad sl = ClusterStatusProtos.ServerLoad.newBuilder()
|
||||||
.setTotalNumberOfRequests(10000)
|
.setTotalNumberOfRequests(10000)
|
||||||
.build();
|
.build();
|
||||||
master.getMetrics().getMetricsSource().init();
|
masterSource.init();
|
||||||
request.setLoad(sl);
|
request.setLoad(sl);
|
||||||
master.regionServerReport(null, request.build());
|
master.regionServerReport(null, request.build());
|
||||||
|
|
||||||
metricsHelper.assertCounter("cluster_requests", 10000,
|
metricsHelper.assertCounter("cluster_requests", 10000, masterSource);
|
||||||
master.getMetrics().getMetricsSource());
|
|
||||||
|
sl = ClusterStatusProtos.ServerLoad.newBuilder()
|
||||||
|
.setTotalNumberOfRequests(15000)
|
||||||
|
.build();
|
||||||
|
request.setLoad(sl);
|
||||||
|
master.regionServerReport(null, request.build());
|
||||||
|
|
||||||
|
metricsHelper.assertCounter("cluster_requests", 15000, masterSource);
|
||||||
|
|
||||||
|
master.regionServerReport(null, request.build());
|
||||||
|
|
||||||
|
metricsHelper.assertCounter("cluster_requests", 15000, masterSource);
|
||||||
master.stopMaster();
|
master.stopMaster();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +114,5 @@ public class TestMasterMetrics {
|
||||||
metricsHelper.assertTag("serverName", master.getServerName().toString(), masterSource);
|
metricsHelper.assertTag("serverName", master.getServerName().toString(), masterSource);
|
||||||
metricsHelper.assertTag("clusterId", master.getClusterId(), masterSource);
|
metricsHelper.assertTag("clusterId", master.getClusterId(), masterSource);
|
||||||
metricsHelper.assertTag("zookeeperQuorum", master.getZooKeeper().getQuorum(), masterSource);
|
metricsHelper.assertTag("zookeeperQuorum", master.getZooKeeper().getQuorum(), masterSource);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue