Copilot commented on code in PR #8758:
URL: https://github.com/apache/hbase/pull/8758#discussion_r4245719604
##########
hbase-website/app/pages/_docs/docs/_mdx/(multi-page)/operational-management/metrics-and-monitoring.mdx:
##########
@@ -133,6 +133,39 @@ The number of regions that have been in transition longer
than a threshold time
**hbase.master.ritOldestAge**
The age of the longest region in transition, in milliseconds
+#### Master switch states
+
+The active, initialized Master exposes numeric switch-state gauges under
+`Hadoop:service=HBase,name=Master,sub=Server`. A value of `1` means enabled and
+`0` means disabled. A value of `-1` means the state is unknown. The gauges are
+absent on backup Masters and before the Master is initialized.
+Enabled states indicate that an operation is permitted, rather than that it is
+currently running.
+
+Replace `true|false` with `true` to enable or `false` to disable.
+
+| Gauge | HBase shell command
|
+| ------------------------------------ |
---------------------------------------------- |
+| `balancerEnabled` | `balance_switch true\|false`
|
+| `normalizerEnabled` | `normalizer_switch true\|false`
|
+| `splitEnabled` | `splitormerge_switch 'SPLIT',
true\|false` |
+| `mergeEnabled` | `splitormerge_switch 'MERGE',
true\|false` |
+| `cleanerChoreEnabled` | `cleaner_chore_switch true\|false`
|
+| `catalogJanitorEnabled` | `catalogjanitor_switch true\|false`
|
+| `snapshotCleanupEnabled` | `snapshot_cleanup_switch true\|false`
|
Review Comment:
The table rows start with `||` which will render as an extra empty first
column in Markdown/MDX tables. Use single leading pipes (`|`) for standard
two-column table formatting so the table renders correctly.
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/MetricsMasterWrapperImpl.java:
##########
@@ -267,4 +269,31 @@ public long getOldWALsDirSize() {
}
return master.getMasterWalManager().getOldWALsDirSize();
}
+
+ @Override
+ public Map<String, Integer> getSwitchStates() {
+ if (!master.isActiveMaster() || !master.isInitialized()) {
+ return Collections.emptyMap();
+ }
+ int rpcThrottleEnabled = 0;
+ if (QuotaUtil.isQuotaEnabled(master.getConfiguration())) {
+ rpcThrottleEnabled = -1;
+ if (master.getMasterQuotaManager() != null) {
+ rpcThrottleEnabled = master.getRpcThrottleStateStore().get() ? 1 : 0;
+ }
+ }
+ return Map.of(MetricsMasterSource.BALANCER_ENABLED_NAME,
master.isBalancerOn() ? 1 : 0,
+ MetricsMasterSource.NORMALIZER_ENABLED_NAME, master.isNormalizerOn() ? 1
: 0,
+ MetricsMasterSource.SPLIT_ENABLED_NAME,
+ master.isSplitOrMergeEnabled(MasterSwitchType.SPLIT) ? 1 : 0,
+ MetricsMasterSource.MERGE_ENABLED_NAME,
+ master.isSplitOrMergeEnabled(MasterSwitchType.MERGE) ? 1 : 0,
+ MetricsMasterSource.CLEANER_CHORE_ENABLED_NAME,
master.isCleanerChoreEnabled() ? 1 : 0,
+ MetricsMasterSource.CATALOG_JANITOR_ENABLED_NAME,
master.isCatalogJanitorEnabled() ? 1 : 0,
+ MetricsMasterSource.SNAPSHOT_CLEANUP_ENABLED_NAME,
+ master.snapshotCleanupStateStore.get() ? 1 : 0,
+ MetricsMasterSource.REPLICATION_PEER_MODIFICATION_ENABLED_NAME,
+ master.isReplicationPeerModificationEnabled() ? 1 : 0,
+ MetricsMasterSource.RPC_THROTTLE_ENABLED_NAME, rpcThrottleEnabled);
Review Comment:
`getSwitchStates()` allocates a new `Map` on every metrics collection. Since
metrics can be scraped frequently, this creates avoidable GC churn. Consider
reusing a preallocated mutable map (cleared/refilled per call) or changing the
source to emit these gauges directly without constructing an intermediate map.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]