Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: engine name in heartbeat #2377

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
waynexia marked this conversation as resolved.
Show resolved Hide resolved
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
Loading