HBASE-25460 : Expose drainingServers as cluster metric (#2994) (#2995)

Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
Rahul Kumar 2021-03-04 12:48:57 +05:30 committed by Viraj Jasani
parent ddbb3e4b69
commit eb640a6f0f
No known key found for this signature in database
GPG Key ID: B3D6C0B41C8ADFD5
5 changed files with 41 additions and 0 deletions

View File

@ -55,8 +55,10 @@ public interface MetricsMasterSource extends BaseSource {
String AVERAGE_LOAD_NAME = "averageLoad";
String LIVE_REGION_SERVERS_NAME = "liveRegionServers";
String DEAD_REGION_SERVERS_NAME = "deadRegionServers";
String DRAINING_REGION_SERVER_NAME = "draininigRegionServers";
String NUM_REGION_SERVERS_NAME = "numRegionServers";
String NUM_DEAD_REGION_SERVERS_NAME = "numDeadRegionServers";
String NUM_DRAINING_REGION_SERVERS_NAME = "numDrainingRegionServers";
String ZOOKEEPER_QUORUM_NAME = "zookeeperQuorum";
String SERVER_NAME_NAME = "serverName";
String CLUSTER_ID_NAME = "clusterId";
@ -73,6 +75,8 @@ public interface MetricsMasterSource extends BaseSource {
String NUMBER_OF_REGION_SERVERS_DESC = "Number of RegionServers";
String DEAD_REGION_SERVERS_DESC = "Names of dead RegionServers";
String NUMBER_OF_DEAD_REGION_SERVERS_DESC = "Number of dead RegionServers";
String DRAINING_REGION_SERVER_DESC = "Names of draining RegionServers";
String NUMBER_OF_DRAINING_REGION_SERVERS_DESC = "Number of draining RegionServers";
String ZOOKEEPER_QUORUM_DESC = "ZooKeeper Quorum";
String SERVER_NAME_DESC = "Server Name";
String CLUSTER_ID_DESC = "Cluster Id";

View File

@ -117,6 +117,20 @@ public interface MetricsMasterWrapper {
*/
int getNumDeadRegionServers();
/**
* Get the draining region servers
*
* @return Draining region server
*/
String getDrainingRegionServers();
/**
* Get the number of draining region servers
*
* @return number of draining region servers
*/
int getNumDrainingRegionServers();
/**
* Get the number of master WAL files.
*/

View File

@ -108,6 +108,10 @@ public class MetricsMasterSourceImpl
.addGauge(Interns.info(NUM_DEAD_REGION_SERVERS_NAME,
NUMBER_OF_DEAD_REGION_SERVERS_DESC),
masterWrapper.getNumDeadRegionServers())
.tag(Interns.info(DRAINING_REGION_SERVER_NAME, DRAINING_REGION_SERVER_DESC),
masterWrapper.getDrainingRegionServers())
.addGauge(Interns.info(NUM_DRAINING_REGION_SERVERS_NAME, NUMBER_OF_REGION_SERVERS_DESC),
masterWrapper.getNumDrainingRegionServers())
.tag(Interns.info(ZOOKEEPER_QUORUM_NAME, ZOOKEEPER_QUORUM_DESC),
masterWrapper.getZookeeperQuorum())
.tag(Interns.info(SERVER_NAME_NAME, SERVER_NAME_DESC), masterWrapper.getServerName())

View File

@ -133,6 +133,24 @@ public class MetricsMasterWrapperImpl implements MetricsMasterWrapper {
return !(master.isStopped() || master.isStopping());
}
@Override
public String getDrainingRegionServers() {
ServerManager serverManager = this.master.getServerManager();
if (serverManager == null) {
return "";
}
return StringUtils.join(serverManager.getDrainingServersList() , ";");
}
@Override
public int getNumDrainingRegionServers() {
ServerManager serverManager = this.master.getServerManager();
if (serverManager == null) {
return 0;
}
return serverManager.getDrainingServersList().size();
}
@Override
public String getServerName() {
ServerName serverName = master.getServerName();

View File

@ -139,6 +139,7 @@ public class TestMasterMetrics {
metricsHelper.assertGauge( "numRegionServers",1 + (tablesOnMaster? 1: 0), masterSource);
metricsHelper.assertGauge( "averageLoad", 1 + (tablesOnMaster? 0: 1), masterSource);
metricsHelper.assertGauge( "numDeadRegionServers", 0, masterSource);
metricsHelper.assertGauge("numDrainingRegionServers", 0, masterSource);
metricsHelper.assertGauge("masterStartTime", master.getMasterStartTime(), masterSource);
metricsHelper.assertGauge("masterActiveTime", master.getMasterActiveTime(), masterSource);