Skip to content

Commit

Permalink
HBASE-25460 : Expose drainingServers as cluster metric (#2995)
Browse files Browse the repository at this point in the history
Signed-off-by: Viraj Jasani <[email protected]>
  • Loading branch information
rahulLiving authored Mar 4, 2021
1 parent f93c9c6 commit 830d289
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -76,6 +78,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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ public void getMetrics(MetricsCollector metricsCollector, boolean all) {
.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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,24 @@ public int getNumDeadRegionServers() {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public void testDefaultMasterMetrics() throws Exception {
metricsHelper.assertGauge("numRegionServers", 1 + (tablesOnMaster ? 1 : 0), masterSource);
metricsHelper.assertGauge("averageLoad", 1, masterSource);
metricsHelper.assertGauge("numDeadRegionServers", 0, masterSource);
metricsHelper.assertGauge("numDrainingRegionServers", 0, masterSource);

metricsHelper.assertGauge("masterStartTime", master.getMasterStartTime(), masterSource);
metricsHelper.assertGauge("masterActiveTime", master.getMasterActiveTime(), masterSource);
Expand Down

0 comments on commit 830d289

Please sign in to comment.