HBASE-10436 restore regionserver lists removed from hbase 0.96.0 jmx
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1571887 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f52a5144ee
commit
fb349b084e
|
@ -49,6 +49,8 @@ public interface MetricsMasterSource extends BaseSource {
|
|||
String MASTER_ACTIVE_TIME_NAME = "masterActiveTime";
|
||||
String MASTER_START_TIME_NAME = "masterStartTime";
|
||||
String AVERAGE_LOAD_NAME = "averageLoad";
|
||||
String LIVE_REGION_SERVERS_NAME = "liveRegionServers";
|
||||
String DEAD_REGION_SERVERS_NAME = "deadRegionServers";
|
||||
String NUM_REGION_SERVERS_NAME = "numRegionServers";
|
||||
String NUM_DEAD_REGION_SERVERS_NAME = "numDeadRegionServers";
|
||||
String ZOOKEEPER_QUORUM_NAME = "zookeeperQuorum";
|
||||
|
@ -61,7 +63,9 @@ public interface MetricsMasterSource extends BaseSource {
|
|||
String MASTER_ACTIVE_TIME_DESC = "Master Active Time";
|
||||
String MASTER_START_TIME_DESC = "Master Start Time";
|
||||
String AVERAGE_LOAD_DESC = "AverageLoad";
|
||||
String LIVE_REGION_SERVERS_DESC = "Names of live RegionServers";
|
||||
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 ZOOKEEPER_QUORUM_DESC = "Zookeeper Quorum";
|
||||
String SERVER_NAME_DESC = "Server Name";
|
||||
|
|
|
@ -83,12 +83,28 @@ public interface MetricsMasterWrapper {
|
|||
*
|
||||
* @return Live region servers
|
||||
*/
|
||||
int getRegionServers();
|
||||
String getRegionServers();
|
||||
|
||||
/**
|
||||
* Get the number of live region servers
|
||||
*
|
||||
* @return number of Live region servers
|
||||
*/
|
||||
|
||||
int getNumRegionServers();
|
||||
|
||||
/**
|
||||
* Get the dead region servers
|
||||
*
|
||||
* @return Dead region Servers
|
||||
*/
|
||||
int getDeadRegionServers();
|
||||
String getDeadRegionServers();
|
||||
|
||||
/**
|
||||
* Get the number of dead region servers
|
||||
*
|
||||
* @return number of Dead region Servers
|
||||
*/
|
||||
int getNumDeadRegionServers();
|
||||
|
||||
}
|
||||
|
|
|
@ -18,26 +18,21 @@
|
|||
|
||||
package org.apache.hadoop.hbase.master;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.metrics.BaseSourceImpl;
|
||||
import org.apache.hadoop.metrics2.MetricsBuilder;
|
||||
import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
||||
import org.apache.hadoop.metrics2.lib.MetricMutableCounterLong;
|
||||
import org.apache.hadoop.metrics2.lib.MetricMutableGaugeLong;
|
||||
import org.apache.hadoop.metrics2.lib.MetricMutableHistogram;
|
||||
import org.apache.hadoop.metrics2.lib.MetricMutableStat;
|
||||
|
||||
/**
|
||||
* Hadoop1 implementation of MetricsMasterSource.
|
||||
*
|
||||
* Implements BaseSource through BaseSourceImpl, following the pattern
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
public class MetricsMasterSourceImpl
|
||||
extends BaseSourceImpl implements MetricsMasterSource {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(MetricsMasterSourceImpl.class.getName());
|
||||
|
||||
private final MetricsMasterWrapper masterWrapper;
|
||||
private MetricMutableCounterLong clusterRequestsCounter;
|
||||
|
||||
|
@ -85,11 +80,15 @@ public class MetricsMasterSourceImpl
|
|||
.addGauge(MASTER_START_TIME_NAME,
|
||||
MASTER_START_TIME_DESC, masterWrapper.getStartTime())
|
||||
.addGauge(AVERAGE_LOAD_NAME, AVERAGE_LOAD_DESC, masterWrapper.getAverageLoad())
|
||||
.tag(LIVE_REGION_SERVERS_NAME, LIVE_REGION_SERVERS_DESC,
|
||||
masterWrapper.getRegionServers())
|
||||
.addGauge(NUM_REGION_SERVERS_NAME,
|
||||
NUMBER_OF_REGION_SERVERS_DESC, masterWrapper.getRegionServers())
|
||||
NUMBER_OF_REGION_SERVERS_DESC, masterWrapper.getNumRegionServers())
|
||||
.tag(DEAD_REGION_SERVERS_NAME, DEAD_REGION_SERVERS_DESC,
|
||||
masterWrapper.getDeadRegionServers())
|
||||
.addGauge(NUM_DEAD_REGION_SERVERS_NAME,
|
||||
NUMBER_OF_DEAD_REGION_SERVERS_DESC,
|
||||
masterWrapper.getDeadRegionServers())
|
||||
masterWrapper.getNumDeadRegionServers())
|
||||
.tag(ZOOKEEPER_QUORUM_NAME, ZOOKEEPER_QUORUM_DESC, masterWrapper.getZookeeperQuorum())
|
||||
.tag(SERVER_NAME_NAME, SERVER_NAME_DESC, masterWrapper.getServerName())
|
||||
.tag(CLUSTER_ID_NAME, CLUSTER_ID_DESC, masterWrapper.getClusterId())
|
||||
|
|
|
@ -80,11 +80,15 @@ public class MetricsMasterSourceImpl
|
|||
MASTER_START_TIME_DESC), masterWrapper.getStartTime())
|
||||
.addGauge(Interns.info(AVERAGE_LOAD_NAME, AVERAGE_LOAD_DESC),
|
||||
masterWrapper.getAverageLoad())
|
||||
.tag(Interns.info(LIVE_REGION_SERVERS_NAME, LIVE_REGION_SERVERS_DESC),
|
||||
masterWrapper.getRegionServers())
|
||||
.addGauge(Interns.info(NUM_REGION_SERVERS_NAME,
|
||||
NUMBER_OF_REGION_SERVERS_DESC), masterWrapper.getRegionServers())
|
||||
NUMBER_OF_REGION_SERVERS_DESC), masterWrapper.getNumRegionServers())
|
||||
.tag(Interns.info(DEAD_REGION_SERVERS_NAME, DEAD_REGION_SERVERS_DESC),
|
||||
masterWrapper.getDeadRegionServers())
|
||||
.addGauge(Interns.info(NUM_DEAD_REGION_SERVERS_NAME,
|
||||
NUMBER_OF_DEAD_REGION_SERVERS_DESC),
|
||||
masterWrapper.getDeadRegionServers())
|
||||
masterWrapper.getNumDeadRegionServers())
|
||||
.tag(Interns.info(ZOOKEEPER_QUORUM_NAME, ZOOKEEPER_QUORUM_DESC),
|
||||
masterWrapper.getZookeeperQuorum())
|
||||
.tag(Interns.info(SERVER_NAME_NAME, SERVER_NAME_DESC), masterWrapper.getServerName())
|
||||
|
|
|
@ -17,14 +17,15 @@
|
|||
*/
|
||||
package org.apache.hadoop.hbase.master;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.ServerName;
|
||||
import org.apache.hadoop.hbase.master.HMaster;
|
||||
import org.apache.hadoop.hbase.master.MetricsMasterWrapper;
|
||||
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
||||
|
||||
/**
|
||||
* Impl for exposing HMaster Information through JMX
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
public class MetricsMasterWrapperImpl implements MetricsMasterWrapper {
|
||||
|
||||
private final HMaster master;
|
||||
|
@ -68,7 +69,16 @@ public class MetricsMasterWrapperImpl implements MetricsMasterWrapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getRegionServers() {
|
||||
public String getRegionServers() {
|
||||
ServerManager serverManager = this.master.getServerManager();
|
||||
if (serverManager == null) {
|
||||
return "";
|
||||
}
|
||||
return StringUtils.join(serverManager.getOnlineServers().keySet(), ";");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumRegionServers() {
|
||||
ServerManager serverManager = this.master.getServerManager();
|
||||
if (serverManager == null) {
|
||||
return 0;
|
||||
|
@ -77,7 +87,17 @@ public class MetricsMasterWrapperImpl implements MetricsMasterWrapper {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getDeadRegionServers() {
|
||||
public String getDeadRegionServers() {
|
||||
ServerManager serverManager = this.master.getServerManager();
|
||||
if (serverManager == null) {
|
||||
return "";
|
||||
}
|
||||
return StringUtils.join(serverManager.getDeadServers().copyServerNames(), ";");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getNumDeadRegionServers() {
|
||||
ServerManager serverManager = this.master.getServerManager();
|
||||
if (serverManager == null) {
|
||||
return 0;
|
||||
|
|
|
@ -56,8 +56,8 @@ public class TestMasterMetricsWrapper {
|
|||
assertEquals(master.getMasterActiveTime(), info.getActiveTime());
|
||||
assertEquals(master.getMasterStartTime(), info.getStartTime());
|
||||
assertEquals(master.getCoprocessors().length, info.getCoprocessors().length);
|
||||
assertEquals(master.getServerManager().getOnlineServersList().size(), info.getRegionServers());
|
||||
assertTrue(info.getRegionServers() == 4);
|
||||
assertEquals(master.getServerManager().getOnlineServersList().size(), info.getNumRegionServers());
|
||||
assertTrue(info.getNumRegionServers() == 4);
|
||||
|
||||
String zkServers = info.getZookeeperQuorum();
|
||||
assertEquals(zkServers.split(",").length, TEST_UTIL.getZkCluster().getZooKeeperServerNum());
|
||||
|
@ -72,7 +72,7 @@ public class TestMasterMetricsWrapper {
|
|||
index) {
|
||||
Threads.sleep(10);
|
||||
}
|
||||
assertTrue(info.getRegionServers() == 3);
|
||||
assertTrue(info.getDeadRegionServers() == 1);
|
||||
assertTrue(info.getNumRegionServers() == 3);
|
||||
assertTrue(info.getNumDeadRegionServers() == 1);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue