Skip to content

HBASE-30473 Expose Master switch states as numeric metrics - #8758

Open
junegunn wants to merge 5 commits into
apache:masterfrom
junegunn:HBASE-30473
Open

junegunn wants to merge 5 commits into
apache:masterfrom
junegunn:HBASE-30473

Conversation

@junegunn

@junegunn junegunn commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Jira: https://issues.apache.org/jira/browse/HBASE-30473

Rendered doc

image

Metric

{
   "name": "Hadoop:service=HBase,name=Master,sub=Server",
   "modelerType": "Master,sub=Server",
   "tag.liveRegionServers": "192.168.35.231,16020,1791788928190",
   "tag.deadRegionServers": "",
   "tag.drainingRegionServers": "",
   "tag.zookeeperQuorum": "127.0.0.1:2181",
   "tag.serverName": "192.168.35.231,16000,1791788926592",
   "tag.clusterId": "07aeab61-7d0f-487b-9f71-4bf8d38565c1",
   "tag.isActiveMaster": "true",
   "tag.Context": "master",
   "tag.Hostname": "AD02514045",
   "mergePlanCount": 0,
   "splitPlanCount": 0,
   "masterActiveTime": 1791788928555,
   "masterStartTime": 1791788926592,
   "masterFinishedInitializationTime": 1791788934045,
   "averageLoad": 6.0,
   "onlineRegionCount": 5,
   "offlineRegionCount": 0,
   "numRegionServers": 1,
   "numDeadRegionServers": 0,
   "numDrainingRegionServers": 0,
   "oldWALsDirSize": 0,
   "catalogJanitorEnabled": 1,
   "mergeEnabled": 1,
   "normalizerEnabled": 1,
   "snapshotCleanupEnabled": 1,
   "splitEnabled": 1,
   "replicationPeerModificationEnabled": 1,
   "cleanerChoreEnabled": 1,
   "rpcThrottleEnabled": 0,
   "balancerEnabled": 1,
   "clusterRequests": 19,
   "clusterWriteRequests": 10,
   "clusterReadRequests": 18,
   "ServerCrashTime_num_ops": 1,
   "ServerCrashTime_min": 0,
   "ServerCrashTime_max": 0,
   "ServerCrashTime_mean": 0,
   "ServerCrashTime_25th_percentile": 0,
   "ServerCrashTime_median": 0,
   "ServerCrashTime_75th_percentile": 0,
   "ServerCrashTime_90th_percentile": 0,
   "ServerCrashTime_95th_percentile": 0,
   "ServerCrashTime_98th_percentile": 0,
   "ServerCrashTime_99th_percentile": 0,
   "ServerCrashTime_99.9th_percentile": 0,
   "ServerCrashSubmittedCount": 1,
   "ServerCrashFailedCount": 0
}

@junegunn
junegunn requested a balanced review from Copilot October 12, 2026 07:26
@junegunn junegunn self-assigned this Oct 12, 2026

This comment was marked as off-topic.

@junegunn
junegunn requested a lite review from Copilot October 12, 2026 07:29
- Detect switches left disabled after maintenance.
- Avoid quota-table reads during metrics collection.
- Distinguish unavailable quota states from disabled states.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open findings

🧠 Review effort: Lite

@Override
public Map<String, Integer> getSwitchStates() {
if (!master.isActiveMaster() || !master.isInitialized()) {
return Collections.emptyMap();

@NihalJain NihalJain Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree on omitting these on backup masters, but for an active-but-not-yet-initialized master, would it be better to emit -1 for all keys? That matches the documented “unknown” semantics and keeps the series continuous across failover?

@junegunn junegunn Oct 13, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for review. You're right that it's more consistent.

keeps the series continuous across failover?

I think emitting -1 during master restart, which can be quite frequent in some cases, could make monitoring more complicated without giving much benefit.

So on second thought, how about removing -1 state altogether and also omitting rpcThrottleEnabled if it's not ready?

@junegunn junegunn Oct 13, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've prepared the change to remove -1 and omit unavailable states, keeping the metrics strictly boolean. Please take a look and let me know what you think.

5d9fd6c

Comment thread hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java Outdated
@Test
public void testEachSwitchChangesItsGauge() {
Map<String, Consumer<Boolean>> switches = new HashMap<>();
switches.put("balancerEnabled", enabled -> when(master.isBalancerOn()).thenReturn(enabled));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Use MetricsMasterSource.*_NAME constants instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, addressed in cd37bb7.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, b0d816b as well.

return Collections.emptyMap();
}
int rpcThrottleEnabled = 0;
if (QuotaUtil.isQuotaEnabled(master.getConfiguration())) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In maintenance mode finishActiveMasterInitialization returns before initQuotaManager(), so with quota enabled rpcThrottleEnabled stays -1 for the lifetime of the Master. The docs say “until the quota manager is ready”, which implies it’s transient. Could you document this case of maintenance, or report 0 like the other switches already do in maintenance mode?

Worth testing out the metrics in MAINTENANCE_MODE = "hbase.master.maintenance_mode"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5d9fd6c makes the metrics strictly boolean.

@NihalJain NihalJain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, just added few nit comments

@NihalJain
NihalJain requested a balanced review from Copilot October 12, 2026 17:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open findings
2 resolved since last review

🧠 Review effort: Lite

@NihalJain NihalJain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM!

@NihalJain
NihalJain requested a balanced review from Copilot October 13, 2026 10:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +289 to +290
states.put(MetricsMasterSource.SNAPSHOT_CLEANUP_ENABLED_NAME,
master.snapshotCleanupStateStore.get() ? 1 : 0);
Comment thread hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java Outdated
Comment on lines +118 to +120
Map<String, Integer> states = new MetricsMasterWrapperImpl(master).getSwitchStates();
assertEquals(8, states.size());
assertFalse(states.containsKey(MetricsMasterSource.RPC_THROTTLE_ENABLED_NAME));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants