diff --git a/src/datanode/src/datanode.rs b/src/datanode/src/datanode.rs index 927510408703..07c42d6c04de 100644 --- a/src/datanode/src/datanode.rs +++ b/src/datanode/src/datanode.rs @@ -438,9 +438,7 @@ impl Datanode { Mode::Standalone => None, }; let heartbeat_task = match opts.mode { - Mode::Distributed => { - Some(HeartbeatTask::try_new(&opts, Some(region_server.clone())).await?) - } + Mode::Distributed => Some(HeartbeatTask::try_new(&opts, region_server.clone()).await?), Mode::Standalone => None, }; let greptimedb_telemetry_task = get_greptimedb_telemetry_task( diff --git a/src/datanode/src/heartbeat.rs b/src/datanode/src/heartbeat.rs index 72c00192d857..92843e7630aa 100644 --- a/src/datanode/src/heartbeat.rs +++ b/src/datanode/src/heartbeat.rs @@ -62,11 +62,7 @@ impl Drop for HeartbeatTask { impl HeartbeatTask { /// Create a new heartbeat task instance. - pub async fn try_new( - opts: &DatanodeOptions, - // TODO: remove optional - region_server: Option, - ) -> Result { + pub async fn try_new(opts: &DatanodeOptions, region_server: RegionServer) -> Result { let meta_client = new_metasrv_client( opts.node_id.context(MissingNodeIdSnafu)?, opts.meta_client_options @@ -75,8 +71,6 @@ impl HeartbeatTask { ) .await?; - let region_server = region_server.unwrap(); - let region_alive_keeper = Arc::new(RegionAliveKeeper::new( region_server.clone(), opts.heartbeat.interval_millis, @@ -258,13 +252,13 @@ impl HeartbeatTask { } async fn load_region_stats(region_server: &RegionServer) -> Vec { - let region_ids = region_server.opened_region_ids(); - region_ids + let regions = region_server.opened_regions(); + regions .into_iter() - .map(|region_id| RegionStat { - // TODO(ruihang): scratch more info + .map(|(region_id, engine)| RegionStat { region_id: region_id.as_u64(), - engine: "MitoEngine".to_string(), + engine, + // TODO(ruihang): scratch more info ..Default::default() }) .collect::>() diff --git a/src/datanode/src/region_server.rs b/src/datanode/src/region_server.rs index 7580a8307ffc..15c295933735 100644 --- a/src/datanode/src/region_server.rs +++ b/src/datanode/src/region_server.rs @@ -88,8 +88,12 @@ impl RegionServer { self.inner.handle_read(request).await } - pub fn opened_region_ids(&self) -> Vec { - self.inner.region_map.iter().map(|e| *e.key()).collect() + pub fn opened_regions(&self) -> Vec<(RegionId, String)> { + self.inner + .region_map + .iter() + .map(|e| (*e.key(), e.value().name().to_string())) + .collect() } pub fn runtime(&self) -> Arc {