HBASE-15068 Add metrics for region normalization plans

This commit is contained in:
tedyu 2016-01-07 03:13:16 -08:00
parent d65978fceb
commit 5266b07708
6 changed files with 51 additions and 1 deletions

View File

@ -57,6 +57,8 @@ public interface MetricsMasterSource extends BaseSource {
String SERVER_NAME_NAME = "serverName";
String CLUSTER_ID_NAME = "clusterId";
String IS_ACTIVE_MASTER_NAME = "isActiveMaster";
String SPLIT_PLAN_COUNT_NAME = "splitPlanCount";
String MERGE_PLAN_COUNT_NAME = "mergePlanCount";
String CLUSTER_REQUESTS_NAME = "clusterRequests";
String MASTER_ACTIVE_TIME_DESC = "Master Active Time";
@ -70,7 +72,8 @@ public interface MetricsMasterSource extends BaseSource {
String SERVER_NAME_DESC = "Server Name";
String CLUSTER_ID_DESC = "Cluster Id";
String IS_ACTIVE_MASTER_DESC = "Is Active Master";
String SPLIT_PLAN_COUNT_DESC = "Number of Region Split Plans executed";
String MERGE_PLAN_COUNT_DESC = "Number of Region Merge Plans executed";
/**

View File

@ -112,4 +112,13 @@ public interface MetricsMasterWrapper {
*/
long getNumWALFiles();
/**
* Get the number of region split plans executed.
*/
long getSplitPlanCount();
/**
* Get the number of region merge plans executed.
*/
long getMergePlanCount();
}

View File

@ -74,6 +74,10 @@ public class MetricsMasterSourceImpl
// masterWrapper can be null because this function is called inside of init.
if (masterWrapper != null) {
metricsRecordBuilder
.addGauge(Interns.info(MERGE_PLAN_COUNT_NAME, MERGE_PLAN_COUNT_DESC),
masterWrapper.getMergePlanCount())
.addGauge(Interns.info(SPLIT_PLAN_COUNT_NAME, SPLIT_PLAN_COUNT_DESC),
masterWrapper.getSplitPlanCount())
.addGauge(Interns.info(MASTER_ACTIVE_TIME_NAME,
MASTER_ACTIVE_TIME_DESC), masterWrapper.getActiveTime())
.addGauge(Interns.info(MASTER_START_TIME_NAME,

View File

@ -333,6 +333,9 @@ public class HMaster extends HRegionServer implements MasterServices {
// handle table states
private TableStateManager tableStateManager;
private long splitPlanCount;
private long mergePlanCount;
/** flag used in test cases in order to simulate RS failures during master initialization */
private volatile boolean initializationBeforeMetaAssignment = false;
@ -1340,6 +1343,11 @@ public class HMaster extends HRegionServer implements MasterServices {
}
NormalizationPlan plan = this.normalizer.computePlanForTable(table, types);
plan.execute(clusterConnection.getAdmin());
if (plan.getType() == PlanType.SPLIT) {
splitPlanCount++;
} else if (plan.getType() == PlanType.MERGE) {
mergePlanCount++;
}
}
}
// If Region did not generate any plans, it means the cluster is already balanced.
@ -2335,6 +2343,20 @@ public class HMaster extends HRegionServer implements MasterServices {
}
return regionStates.getAverageLoad();
}
/*
* @return the count of region split plans executed
*/
public long getSplitPlanCount() {
return splitPlanCount;
}
/*
* @return the count of region merge plans executed
*/
public long getMergePlanCount() {
return mergePlanCount;
}
@Override
public boolean registerService(Service instance) {

View File

@ -39,6 +39,16 @@ public class MetricsMasterWrapperImpl implements MetricsMasterWrapper {
return master.getAverageLoad();
}
@Override
public long getSplitPlanCount() {
return master.getSplitPlanCount();
}
@Override
public long getMergePlanCount() {
return master.getMergePlanCount();
}
@Override
public String getClusterId() {
return master.getClusterId();

View File

@ -50,6 +50,8 @@ public class TestMasterMetricsWrapper {
public void testInfo() {
HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
MetricsMasterWrapperImpl info = new MetricsMasterWrapperImpl(master);
assertEquals(master.getSplitPlanCount(), info.getSplitPlanCount(), 0);
assertEquals(master.getMergePlanCount(), info.getMergePlanCount(), 0);
assertEquals(master.getAverageLoad(), info.getAverageLoad(), 0);
assertEquals(master.getClusterId(), info.getClusterId());
assertEquals(master.getMasterActiveTime(), info.getActiveTime());