Repository navigation
Conversation
- Detect switches left disabled after maintenance. - Avoid quota-table reads during metrics collection. - Distinguish unavailable quota states from disabled states.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| @Test | ||
| public void testEachSwitchChangesItsGauge() { | ||
| Map<String, Consumer<Boolean>> switches = new HashMap<>(); | ||
| switches.put("balancerEnabled", enabled -> when(master.isBalancerOn()).thenReturn(enabled)); |
There was a problem hiding this comment.
nit: Use MetricsMasterSource.*_NAME constants instead?
| return Collections.emptyMap(); | ||
| } | ||
| int rpcThrottleEnabled = 0; | ||
| if (QuotaUtil.isQuotaEnabled(master.getConfiguration())) { |
There was a problem hiding this comment.
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"
NihalJain
left a comment
There was a problem hiding this comment.
Overall LGTM, just added few nit comments
There was a problem hiding this comment.
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
The backslash escapes (\\|) are inside inline code spans, where the backslash typically renders… · New The test hard-codes metric names as string literals. To reduce brittleness and ensure refactors… · NewverifyNoInteractions(master.getMasterQuotaManager())callsgetMasterQuotaManager()as part of… · New
2 resolved since last review
🧠 Review effort: Lite
Keep switch values boolean during initialization and maintenance mode.
There was a problem hiding this comment.
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
4 open findings
This directly dereferencesmaster.snapshotCleanupStateStoreand will throw if it is ever… · New The test hard-codes metric names as string literals even though this PR introduces… · NewassertEquals(8, states.size())is brittle: it will fail if new switch-state gauges are added in… · New The Markdown table uses a double leading pipe (||), which typically renders as an extra empty… · New
3 resolved since last review
🧠 Review effort: Lite
| states.put(MetricsMasterSource.SNAPSHOT_CLEANUP_ENABLED_NAME, | ||
| master.snapshotCleanupStateStore.get() ? 1 : 0); |
| Map<String, Integer> states = new MetricsMasterWrapperImpl(master).getSwitchStates(); | ||
| assertEquals(8, states.size()); | ||
| assertFalse(states.containsKey(MetricsMasterSource.RPC_THROTTLE_ENABLED_NAME)); |


Jira: https://issues.apache.org/jira/browse/HBASE-30473
Rendered doc
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 }