Skip to content

Commit

Permalink
feat: engine name in heartbeat (#2377)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengjiachun authored Sep 13, 2023
1 parent de723d9 commit 6f4779b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
4 changes: 1 addition & 3 deletions src/datanode/src/datanode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
18 changes: 6 additions & 12 deletions src/datanode/src/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RegionServer>,
) -> Result<Self> {
pub async fn try_new(opts: &DatanodeOptions, region_server: RegionServer) -> Result<Self> {
let meta_client = new_metasrv_client(
opts.node_id.context(MissingNodeIdSnafu)?,
opts.meta_client_options
Expand All @@ -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,
Expand Down Expand Up @@ -258,13 +252,13 @@ impl HeartbeatTask {
}

async fn load_region_stats(region_server: &RegionServer) -> Vec<RegionStat> {
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::<Vec<_>>()
Expand Down
8 changes: 6 additions & 2 deletions src/datanode/src/region_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,12 @@ impl RegionServer {
self.inner.handle_read(request).await
}

pub fn opened_region_ids(&self) -> Vec<RegionId> {
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<Runtime> {
Expand Down

0 comments on commit 6f4779b

Please sign in to comment.