Skip to content

Commit

Permalink
feat(dashboard): show vnode count for mv/table/internal-table (#19133)
Browse files Browse the repository at this point in the history
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao authored Oct 29, 2024
1 parent 661939a commit 55d42c8
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 39 deletions.
11 changes: 11 additions & 0 deletions dashboard/components/Relations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ export const primaryKeyColumn: Column<RwTable> = {
.join(", "),
}

export const vnodeCountColumn: Column<RwTable> = {
name: "Vnode Count",
width: 1,
// The table catalogs retrieved here are constructed from SQL models,
// where the `vnode_count` column has already been populated during migration.
// Therefore, it should always be present and no need to specify a fallback.
content: (r) => r.maybeVnodeCount ?? "?",
}

export const tableColumns = [primaryKeyColumn, vnodeCountColumn]

export const connectorColumnSource: Column<RwSource> = {
name: "Connector",
width: 3,
Expand Down
4 changes: 2 additions & 2 deletions dashboard/pages/indexes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
*/

import {
primaryKeyColumn,
Relations,
streamingJobColumns,
tableColumns,
} from "../components/Relations"
import { getIndexes } from "../lib/api/streaming"

export default function Indexes() {
return Relations("Indexes", getIndexes, [
...streamingJobColumns,
primaryKeyColumn,
...tableColumns,
])
}
4 changes: 2 additions & 2 deletions dashboard/pages/internal_tables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*
*/

import { primaryKeyColumn, Relations } from "../components/Relations"
import { Relations, tableColumns } from "../components/Relations"
import { getInternalTables } from "../lib/api/streaming"

export default function InternalTables() {
return Relations("Internal Tables", getInternalTables, [primaryKeyColumn])
return Relations("Internal Tables", getInternalTables, [...tableColumns])
}
4 changes: 2 additions & 2 deletions dashboard/pages/materialized_views.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
*/

import {
primaryKeyColumn,
Relations,
streamingJobColumns,
tableColumns,
} from "../components/Relations"
import { getMaterializedViews } from "../lib/api/streaming"

export default function MaterializedViews() {
return Relations("Materialized Views", getMaterializedViews, [
...streamingJobColumns,
primaryKeyColumn,
...tableColumns,
])
}
4 changes: 2 additions & 2 deletions dashboard/pages/tables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

import {
Column,
primaryKeyColumn,
Relations,
streamingJobColumns,
tableColumns,
} from "../components/Relations"
import { getTables } from "../lib/api/streaming"
import { Table } from "../proto/gen/catalog"
Expand All @@ -34,6 +34,6 @@ export default function Tables() {
return Relations("Tables", getTables, [
associatedSourceColumn,
...streamingJobColumns,
primaryKeyColumn,
...tableColumns,
])
}
52 changes: 21 additions & 31 deletions src/frontend/src/catalog/system_catalog/rw_catalog/rw_fragments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

use risingwave_common::types::Fields;
use risingwave_frontend_macro::system_catalog;
use risingwave_pb::meta::table_fragments::fragment::FragmentDistributionType;
use risingwave_pb::stream_plan::FragmentTypeFlag;

use crate::catalog::system_catalog::SysCatalogReaderImpl;
Expand Down Expand Up @@ -53,36 +52,27 @@ async fn read_rw_fragment(reader: &SysCatalogReaderImpl) -> Result<Vec<RwFragmen

Ok(distributions
.into_iter()
.map(|distribution| {
let distribution_type = distribution.distribution_type();
let max_parallelism = match distribution_type {
FragmentDistributionType::Single => 1,
FragmentDistributionType::Hash => distribution.vnode_count as i32,
FragmentDistributionType::Unspecified => unreachable!(),
};

RwFragment {
fragment_id: distribution.fragment_id as i32,
table_id: distribution.table_id as i32,
distribution_type: distribution.distribution_type().as_str_name().into(),
state_table_ids: distribution
.state_table_ids
.into_iter()
.map(|id| id as i32)
.collect(),
upstream_fragment_ids: distribution
.upstream_fragment_ids
.into_iter()
.map(|id| id as i32)
.collect(),
flags: extract_fragment_type_flag(distribution.fragment_type_mask)
.into_iter()
.flat_map(|t| t.as_str_name().strip_prefix("FRAGMENT_TYPE_FLAG_"))
.map(|s| s.into())
.collect(),
parallelism: distribution.parallelism as i32,
max_parallelism,
}
.map(|distribution| RwFragment {
fragment_id: distribution.fragment_id as i32,
table_id: distribution.table_id as i32,
distribution_type: distribution.distribution_type().as_str_name().into(),
state_table_ids: distribution
.state_table_ids
.into_iter()
.map(|id| id as i32)
.collect(),
upstream_fragment_ids: distribution
.upstream_fragment_ids
.into_iter()
.map(|id| id as i32)
.collect(),
flags: extract_fragment_type_flag(distribution.fragment_type_mask)
.into_iter()
.flat_map(|t| t.as_str_name().strip_prefix("FRAGMENT_TYPE_FLAG_"))
.map(|s| s.into())
.collect(),
parallelism: distribution.parallelism as i32,
max_parallelism: distribution.vnode_count as i32,
})
.collect())
}
Expand Down

0 comments on commit 55d42c8

Please sign in to comment.