@@ -5,6 +5,7 @@ import {getLoadSeverityForNode} from '../../store/reducers/nodes/utils';
55import type { TPoolStats } from '../../types/api/nodes' ;
66import type { TTabletStateInfo } from '../../types/api/tablet' ;
77import { valueIsDefined } from '../../utils' ;
8+ import { cn } from '../../utils/cn' ;
89import { EMPTY_DATA_PLACEHOLDER } from '../../utils/constants' ;
910import {
1011 formatStorageValues ,
@@ -26,6 +27,10 @@ import {NODES_COLUMNS_IDS, NODES_COLUMNS_TITLES} from './constants';
2627import i18n from './i18n' ;
2728import type { GetNodesColumnsParams } from './types' ;
2829
30+ import './NodesColumns.scss' ;
31+
32+ const b = cn ( 'ydb-nodes-columns' ) ;
33+
2934export function getNodeIdColumn < T extends { NodeId ?: string | number } > ( ) : Column < T > {
3035 return {
3136 name : NODES_COLUMNS_IDS . NodeId ,
@@ -157,15 +162,15 @@ export function getRAMColumn<T extends {MemoryUsed?: string; MemoryLimit?: strin
157162 formatValues = { ( value , total ) =>
158163 formatStorageValues ( value , total , 'gb' , undefined , true )
159164 }
165+ className = { b ( 'column-ram' ) }
160166 colorizeProgress
161- vertical
162167 hideCapacity
163168 />
164169 </ CellWithPopover >
165170 ) ;
166171 } ,
167172 align : DataTable . LEFT ,
168- width : 85 ,
173+ width : 80 ,
169174 resizeMinWidth : 40 ,
170175 } ;
171176}
@@ -188,10 +193,10 @@ export function getSharedCacheUsageColumn<
188193 resizeMinWidth : 170 ,
189194 } ;
190195}
191- export function getCpuColumn < T extends { PoolStats ?: TPoolStats [ ] } > ( ) : Column < T > {
196+ export function getPoolsColumn < T extends { PoolStats ?: TPoolStats [ ] } > ( ) : Column < T > {
192197 return {
193- name : NODES_COLUMNS_IDS . CPU ,
194- header : NODES_COLUMNS_TITLES . CPU ,
198+ name : NODES_COLUMNS_IDS . Pools ,
199+ header : NODES_COLUMNS_TITLES . Pools ,
195200 sortAccessor : ( { PoolStats = [ ] } ) => Math . max ( ...PoolStats . map ( ( { Usage} ) => Number ( Usage ) ) ) ,
196201 defaultOrder : DataTable . DESCENDING ,
197202 render : ( { row} ) =>
@@ -201,18 +206,33 @@ export function getCpuColumn<T extends {PoolStats?: TPoolStats[]}>(): Column<T>
201206 resizeMinWidth : 60 ,
202207 } ;
203208}
204- export function getTotalCpuColumn < T extends { PoolStats ?: TPoolStats [ ] } > ( ) : Column < T > {
209+ export function getCpuColumn <
210+ T extends { PoolStats ?: TPoolStats [ ] ; CoresUsed ?: number ; CoresTotal ?: number } ,
211+ > ( ) : Column < T > {
205212 return {
206- name : NODES_COLUMNS_IDS . TotalCPU ,
207- header : NODES_COLUMNS_TITLES . TotalCPU ,
213+ name : NODES_COLUMNS_IDS . CPU ,
214+ header : NODES_COLUMNS_TITLES . CPU ,
208215 sortAccessor : ( { PoolStats = [ ] } ) => Math . max ( ...PoolStats . map ( ( { Usage} ) => Number ( Usage ) ) ) ,
209216 defaultOrder : DataTable . DESCENDING ,
210217 render : ( { row} ) => {
211218 if ( ! row . PoolStats ) {
212219 return EMPTY_DATA_PLACEHOLDER ;
213220 }
214221
215- const totalPoolUsage = row . PoolStats . reduce ( ( acc , pool ) => acc + ( pool . Usage || 0 ) , 0 ) ;
222+ let totalPoolUsage =
223+ isNumeric ( row . CoresUsed ) && isNumeric ( row . CoresTotal )
224+ ? row . CoresUsed / row . CoresTotal
225+ : undefined ;
226+
227+ if ( totalPoolUsage === undefined ) {
228+ let totalThreadsCount = 0 ;
229+ totalPoolUsage = row . PoolStats . reduce ( ( acc , pool ) => {
230+ totalThreadsCount += Number ( pool . Threads ) ;
231+ return acc + Number ( pool . Usage ) * Number ( pool . Threads ) ;
232+ } , 0 ) ;
233+
234+ totalPoolUsage = totalPoolUsage / totalThreadsCount ;
235+ }
216236
217237 return (
218238 < CellWithPopover
@@ -231,17 +251,17 @@ export function getTotalCpuColumn<T extends {PoolStats?: TPoolStats[]}>(): Colum
231251 }
232252 >
233253 < ProgressViewer
254+ className = { b ( 'column-cpu' ) }
234255 value = { totalPoolUsage }
235256 capacity = { 1 }
236257 colorizeProgress
237258 percents
238- vertical
239259 />
240260 </ CellWithPopover >
241261 ) ;
242262 } ,
243263 align : DataTable . LEFT ,
244- width : 85 ,
264+ width : 80 ,
245265 resizeMinWidth : 40 ,
246266 } ;
247267}
0 commit comments