Skip to content

Commit

Permalink
NodeListPage added
Browse files Browse the repository at this point in the history
  • Loading branch information
archeoss committed Feb 2, 2024
1 parent 478fe24 commit 6dc61ad
Show file tree
Hide file tree
Showing 26 changed files with 2,063 additions and 696 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ Bob Management GUI changelog
- Home page, frontend (#22)
- Node list page, frontend (#23)
- VDisk list page, backend (#20)
<<<<<<< HEAD
=======
- Detailed node information page, backend (#21)
>>>>>>> 67e5cea (NodeListPage added)
2 changes: 2 additions & 0 deletions backend/src/connector/dto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//!
use std::collections::HashMap;
use tsync::tsync;
#[cfg(all(feature = "swagger", debug_assertions))]
use utoipa::ToSchema;

Expand Down Expand Up @@ -365,6 +366,7 @@ impl std::str::FromStr for Error {
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[tsync]
pub struct MetricsEntryModel {
#[serde(rename = "value")]
pub value: u64,
Expand Down
3 changes: 3 additions & 0 deletions backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ impl Modify for SecurityAddon {
services::api::get_space,
services::api::raw_metrics_by_node,
services::api::raw_configuration_by_node,
services::api::get_detailed_node_info,
services::api::get_node_info,
services::api::get_nodes_list,
services::api::get_vdisk_info,
Expand All @@ -66,6 +67,8 @@ impl Modify for SecurityAddon {
models::api::SpaceInfo,
models::api::VDisk,
models::api::VDiskStatus,
models::api::DetailedNode,
models::api::DetailedNodeMetrics,
models::api::Operation,
models::api::RPS,
models::api::RawMetricEntry,
Expand Down
93 changes: 93 additions & 0 deletions backend/src/models/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,37 @@ pub struct Disk {
pub iops: u64,
}

impl Disk {
#[must_use]
pub fn from_metrics(
disk_name: String,
disk_path: String,
raw_metrics: &dto::MetricsSnapshotModel,
raw_space: &dto::SpaceInfo,
) -> Self {
let status = DiskStatus::from_space_info(raw_space, &disk_name);
let used_space = raw_space
.occupied_disk_space_by_disk
.get(&disk_name)
.copied()
.unwrap_or_default();
let iops = raw_metrics
.metrics
.get(&format!("hardware.disks.{:?}_iops", disk_name))
.cloned()
.unwrap_or_default()
.value;
Self {
name: disk_name,
path: disk_path,
status,
total_space: raw_space.total_disk_space_bytes,
used_space,
iops,
}
}
}

/// Defines kind of problem on disk
#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Serialize, Hash)]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
Expand Down Expand Up @@ -191,6 +222,12 @@ pub enum NodeStatus {
Offline,
}

impl Default for NodeStatus {
fn default() -> Self {
Self::Offline
}
}

impl NodeStatus {
#[must_use]
pub fn from_problems(problems: Vec<NodeProblem>) -> Self {
Expand Down Expand Up @@ -349,6 +386,62 @@ pub enum VDiskStatus {
Offline,
}

#[derive(Default, Debug, Clone, Serialize)]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[tsync]
pub struct DetailedNode {
pub name: String,

pub hostname: String,

pub vdisks: Vec<VDisk>,

// #[serde(flatten)]
pub status: NodeStatus,

pub metrics: DetailedNodeMetrics,

pub disks: Vec<Disk>,
}

#[derive(Default, Debug, Clone, Serialize)]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
#[serde(rename_all = "camelCase")]
#[tsync]
pub struct DetailedNodeMetrics {
pub rps: RPS,

pub alien_count: u64,

pub corrupted_count: u64,

pub space: SpaceInfo,

pub cpu_load: u64,

pub total_ram: u64,

pub used_ram: u64,

pub descr_amount: u64,
}

impl DetailedNodeMetrics {
#[must_use]
pub fn from_metrics(metrics: &TypedMetrics, space: SpaceInfo) -> Self {
Self {
rps: RPS::from_metrics(metrics),
alien_count: metrics[RawMetricEntry::BackendAlienCount].value,
corrupted_count: metrics[RawMetricEntry::BackendCorruptedBlobCount].value,
space,
cpu_load: metrics[RawMetricEntry::HardwareBobCpuLoad].value,
total_ram: metrics[RawMetricEntry::HardwareTotalRam].value,
used_ram: metrics[RawMetricEntry::HardwareUsedRam].value,
descr_amount: metrics[RawMetricEntry::HardwareDescrAmount].value,
}
}
}

/// Types of operations on BOB cluster
#[derive(Debug, Clone, Serialize, Hash, Eq, PartialEq, PartialOrd, Ord, EnumIter)]
#[cfg_attr(all(feature = "swagger", debug_assertions), derive(ToSchema))]
Expand Down
Loading

0 comments on commit 6dc61ad

Please sign in to comment.