spacemonkd commented on code in PR #10900:
URL: https://github.com/apache/ozone/pull/10900#discussion_r3956152084


##########
ozone-ui/packages/om/src/api/overview.ts:
##########
@@ -0,0 +1,340 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import moment from 'moment';
+
+/**
+ * JMX MBean queries used by the Overview sections. Kept in one place so each
+ * section references a query by name; sections that share a query (e.g. the OM
+ * ServerRuntime bean) are de-duplicated to a single request by the JMX cache.
+ */
+export const JMX_QUERY = {
+  /** OM ServerRuntime bean: RPC port, ratis roles, data dirs, version, build. 
*/
+  omInfo: 'Hadoop:service=*,name=*,component=ServerRuntime',
+  /** This node's Ratis RaftServer bean: id, leader, role, group. */
+  ratisServer: 'Ratis:service=RaftServer,group=*,id=*',
+  /** JVM runtime bean: input arguments and system properties. */
+  runtime: 'java.lang:type=Runtime',
+  /**
+   * Ratis leader-election metrics for the current node. The name patterns are
+   * matched by the mock; a live cluster may need the node id/group 
interpolated
+   * (e.g. `ratis:name=ratis.leader_election.<id>@<group>.electionCount`).
+   */
+  leaderElectionCount: 'ratis:name=ratis.leader_election.*electionCount',
+  leaderElectionElapsed: 
'ratis:name=ratis.leader_election.*lastLeaderElectionElapsedTime',
+} as const;
+
+/* --------------------------------- Beans ---------------------------------- 
*/
+
+export interface OzoneManagerInfoBean {
+  RpcPort: string;
+  Namespace: string;
+  /**
+   * OM Ratis peers, one row per node. Each row is a tuple
+   * `[hostName, nodeId, ratisPort, role, leaderReadiness]` (see
+   * `OMMXBean.getRatisRoles` / `OmUtils.format`). On error the bean returns a
+   * single-element row `[message]`.
+   */
+  RatisRoles: string[][];
+  RatisLogDirectory: string;
+  RocksDbDirectory: string;
+  Version: string;
+  SoftwareVersion: string;
+  StartedTimeInMillis: number;
+}
+
+export interface RatisServerBean {
+  Id: string;
+  LeaderId: string;
+  Role: string;
+  GroupId: string;
+  CurrentTerm: number;
+}
+
+/** Ratis leader-election count metric (current node). */
+export interface LeaderElectionCountBean {
+  Count: number;
+}
+
+/** Ratis last-leader-election elapsed-time metric in milliseconds (current 
node). */
+export interface LeaderElectionElapsedBean {
+  Value: number;
+}
+
+export interface SystemProperty {
+  key: string;
+  value: string;
+}
+
+export interface RuntimeBean {
+  VmName: string;
+  VmVendor: string;
+  VmVersion: string;
+  Name: string;
+  InputArguments: string[];
+  SystemProperties: SystemProperty[];
+}
+
+/* ------------------------------ View models ------------------------------- 
*/
+
+export interface KeyValue {
+  key: string;
+  label: string;
+  value: string;
+  copyable?: boolean;
+  tooltip?: string;
+}
+
+export type RatisRoleName = 'LEADER' | 'FOLLOWER' | string;
+
+export interface RatisRole {
+  key: string;
+  hostName: string;
+  nodeId: string;
+  ratisPort: string;
+  role: RatisRoleName;
+  /** Derived follower sync state; `null` for the leader row. */
+  readiness: 'Synced' | 'Lagging' | null;
+  /** True for the node serving this JMX endpoint. */
+  isCurrent: boolean;
+}
+
+export type JvmParameterCategory = 'System & Framework' | 'Memory & GC' | 
'System Property';
+
+export interface JvmParameter {
+  key: string;
+  parameter: string;
+  value: string;
+  category: JvmParameterCategory;
+}
+
+/* -------------------------------- Parsers --------------------------------- 
*/
+
+/**
+ * Parse the OM `RatisRoles` bean — an array of
+ * `[hostName, nodeId, ratisPort, role, leaderReadiness]` tuples. Rows that 
don't
+ * carry at least the first four fields (e.g. the single-element error row the
+ * bean returns when there is no leader) are skipped.
+ */
+export function parseRatisRoles(rows: string[][] | undefined, currentNodeId?: 
string): RatisRole[] {
+  return (rows ?? [])
+    .filter((row) => Array.isArray(row) && row.length >= 4)
+    .map((row, index) => {
+      const [hostName = '', nodeId = '', ratisPort = '', roleRaw = ''] = row;
+      const role = roleRaw.toUpperCase();
+      return {
+        key: nodeId || String(index),
+        hostName,
+        nodeId,
+        ratisPort,
+        role,
+        // The leader has no "readiness"; followers are shown as synced with 
the leader.
+        readiness: role === 'LEADER' ? null : 'Synced',

Review Comment:
   Addressed in the latest commit, mapping the READINESS states to more 
readable format and returning.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to