in desktop/src/app/components/pool/graphs/heatmap/state-counter.ts [23:57]
public updateCount(nodes: List<Node>, pool: Pool) {
const counts: CountMap = {};
for (const state of ObjectUtils.values(NodeState)) {
counts[state] = 0;
}
nodes.forEach((node) => {
if (node.state in counts) {
/**
* Only NodeState.running is a valid state from the service. The rest of the
* running states are for displaying task usage info on the UI side, not states
* from the service.
*/
if (node.state === NodeState.running) {
const percentTaskSlotUsage = NodeUtils.getTaskSlotsUsagePercent(node, pool);
if (percentTaskSlotUsage <= 25) {
counts[NodeState.running25]++;
} else if (percentTaskSlotUsage <= 50) {
counts[NodeState.running50]++;
} else if (percentTaskSlotUsage <= 75) {
counts[NodeState.running75]++;
} else if (percentTaskSlotUsage <= 99) {
counts[NodeState.running99]++;
} else {
counts[NodeState.running100]++;
}
}
counts[node.state]++;
} else {
log.error(`Node '${node.id}' has an unknown state '${node.state}'`);
}
});
for (const state of ObjectUtils.values(NodeState)) {
(this._data[state] as BehaviorSubject<number>).next(counts[state]);
}
}