From 93e85f8a83f003639d16dbb90c084e297600906e Mon Sep 17 00:00:00 2001 From: anwebanSalesforce Date: Thu, 16 Jun 2022 12:23:02 +0530 Subject: [PATCH] HBASE-18678 --- .../hbase/master/MetricsMasterProcSource.java | 11 +++++++++++ .../master/MetricsMasterProcSourceImpl.java | 12 ++++++++++++ .../hbase/master/MetricsMasterWrapper.java | 17 +++++++++++++++++ .../hbase/procedure2/ProcedureExecutor.java | 4 ++-- .../master/MetricsMasterWrapperImpl.java | 19 +++++++++++++++++++ 5 files changed, 61 insertions(+), 2 deletions(-) diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterProcSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterProcSource.java index 07ceaaf2e24..f1fd4c01d85 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterProcSource.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterProcSource.java @@ -51,4 +51,15 @@ public interface MetricsMasterProcSource extends BaseSource { String NUM_MASTER_WALS_DESC = "Number of master WAL files"; + String NUM_COMPLETED_PROCS_NAME = "numCompletedProcs"; + + String NUM_COMPLETED_PROCS_DESC = "Number of Completed Procedures"; + + String NUM_ACTIVE_PROCS_NAME = "numActiveProcs"; + + String NUM_ACTIVE_PROCS_DESC = "Number of Active Procedures"; + + String LATEST_PROC_ID_NAME = "latestProcId"; + + String LATEST_PROC_ID_DESC = "Latest Procedure Id"; } diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterProcSourceImpl.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterProcSourceImpl.java index 001ab016814..f3a8790d728 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterProcSourceImpl.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterProcSourceImpl.java @@ -56,6 +56,18 @@ public class MetricsMasterProcSourceImpl extends BaseSourceImpl implements Metri if (masterWrapper != null) { metricsRecordBuilder.addGauge(Interns.info(NUM_MASTER_WALS_NAME, NUM_MASTER_WALS_DESC), masterWrapper.getNumWALFiles()); + + metricsRecordBuilder + .addGauge(Interns.info(NUM_COMPLETED_PROCS_NAME, NUM_COMPLETED_PROCS_DESC), + masterWrapper.getNumberOfCompletedProcs()); + + metricsRecordBuilder + .addGauge(Interns.info(NUM_ACTIVE_PROCS_NAME, NUM_ACTIVE_PROCS_DESC), + masterWrapper.getNumberOfActiveProcs()); + + metricsRecordBuilder + .addGauge(Interns.info(LATEST_PROC_ID_NAME, LATEST_PROC_ID_DESC), + masterWrapper.getLatestProcId()); } metricsRegistry.snapshot(metricsRecordBuilder, all); diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterWrapper.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterWrapper.java index a900edf115e..95b17cfeae6 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterWrapper.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterWrapper.java @@ -153,4 +153,21 @@ public interface MetricsMasterWrapper { * @return pair of count for online regions and offline regions */ PairOfSameType getRegionCounts(); + + /** + * Get the number of completed procedures + */ + + long getNumberOfCompletedProcs(); + + /** + * Get the number of active procedures + */ + + long getNumberOfActiveProcs(); + + /** + * Get latest proc Id + */ + long getLatestProcId(); } diff --git a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java index 9cc78212863..efe5d30c402 100644 --- a/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java +++ b/hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java @@ -1316,7 +1316,7 @@ public class ProcedureExecutor { return procId; } - protected long getLastProcId() { + public long getLastProcId() { return lastProcId.get(); } @@ -1922,7 +1922,7 @@ public class ProcedureExecutor { return scheduler; } - int getCompletedSize() { + public int getCompletedSize() { return completed.size(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterWrapperImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterWrapperImpl.java index 923c663807f..0d416eabdf2 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterWrapperImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterWrapperImpl.java @@ -29,6 +29,7 @@ import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.RegionInfo; import org.apache.hadoop.hbase.client.TableDescriptor; +import org.apache.hadoop.hbase.procedure2.ProcedureExecutor; import org.apache.hadoop.hbase.quotas.QuotaObserverChore; import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot; import org.apache.hadoop.hbase.util.PairOfSameType; @@ -211,6 +212,24 @@ public class MetricsMasterWrapperImpl implements MetricsMasterWrapper { return convertedData; } + @Override + public long getNumberOfCompletedProcs(){ + ProcedureExecutor procedureExecutor = master.getMasterProcedureExecutor(); + return procedureExecutor.getCompletedSize(); + } + + @Override + public long getNumberOfActiveProcs(){ + ProcedureExecutor procedureExecutor = master.getMasterProcedureExecutor(); + return procedureExecutor.getActiveExecutorCount(); + } + + @Override + public long getLatestProcId(){ + ProcedureExecutor procedureExecutor = master.getMasterProcedureExecutor(); + return procedureExecutor.getLastProcId(); + } + Entry convertSnapshot(SpaceQuotaSnapshot snapshot) { return new SimpleImmutableEntry(snapshot.getUsage(), snapshot.getLimit()); }