diff --git a/src/datanode/src/datanode.rs b/src/datanode/src/datanode.rs index c19fb30a54b2..10e2f5dcb3af 100644 --- a/src/datanode/src/datanode.rs +++ b/src/datanode/src/datanode.rs @@ -67,7 +67,7 @@ pub struct Datanode { opts: DatanodeOptions, services: Option, heartbeat_task: Option, - event_receiver: Option, + region_event_receiver: Option, region_server: RegionServer, greptimedb_telemetry_task: Arc, } @@ -85,7 +85,7 @@ impl Datanode { pub async fn start_heartbeat(&mut self) -> Result<()> { if let Some(task) = &self.heartbeat_task { // Safety: The event_receiver must exist. - let receiver = self.event_receiver.take().unwrap(); + let receiver = self.region_event_receiver.take().unwrap(); task.start(receiver).await?; } Ok(()) @@ -194,7 +194,7 @@ impl DatanodeBuilder { let log_store = Self::build_log_store(&self.opts).await?; // TODO(weny): Adds a noop event listener for standalone mode. - let (tx, event_receiver) = match mode { + let (tx, region_event_receiver) = match mode { Mode::Distributed => { let (tx, rx) = new_region_server_event_channel(); (Box::new(tx) as RegionServerEventListenerRef, Some(rx)) @@ -239,7 +239,7 @@ impl DatanodeBuilder { heartbeat_task, region_server, greptimedb_telemetry_task, - event_receiver, + region_event_receiver, }) } diff --git a/src/datanode/src/event_listener.rs b/src/datanode/src/event_listener.rs index 78bc9b41bea4..771a482ccd48 100644 --- a/src/datanode/src/event_listener.rs +++ b/src/datanode/src/event_listener.rs @@ -23,10 +23,10 @@ pub enum RegionServerEvent { pub trait RegionServerEventListener: Sync + Send { /// Called *after* a new region was created/opened. - fn register_region(&self, _region_id: RegionId) {} + fn on_register_region(&self, _region_id: RegionId) {} /// Called *after* a region was closed. - fn deregister_region(&self, _region_id: RegionId) {} + fn on_deregister_region(&self, _region_id: RegionId) {} } pub type RegionServerEventListenerRef = Box; @@ -39,7 +39,7 @@ impl RegionServerEventListener for NoopRegionServerEventListener {} pub struct RegionServerEventSender(pub(crate) UnboundedSender); impl RegionServerEventListener for RegionServerEventSender { - fn register_region(&self, region_id: RegionId) { + fn on_register_region(&self, region_id: RegionId) { if let Err(e) = self.0.send(RegionServerEvent::Register(region_id)) { error!( "Failed to send registering region: {region_id} event, source: {}", @@ -48,7 +48,7 @@ impl RegionServerEventListener for RegionServerEventSender { } } - fn deregister_region(&self, region_id: RegionId) { + fn on_deregister_region(&self, region_id: RegionId) { if let Err(e) = self.0.send(RegionServerEvent::Deregister(region_id)) { error!( "Failed to send deregistering region: {region_id} event, source: {}", diff --git a/src/datanode/src/region_server.rs b/src/datanode/src/region_server.rs index 74b0dccd9c39..e7e8efafd7a9 100644 --- a/src/datanode/src/region_server.rs +++ b/src/datanode/src/region_server.rs @@ -266,14 +266,14 @@ impl RegionServerInner { RegionChange::Register(_) => { info!("Region {region_id} is registered to engine {engine_type}"); self.region_map.insert(region_id, engine); - self.event_listener.register_region(region_id); + self.event_listener.on_register_region(region_id); } RegionChange::Deregisters => { info!("Region {region_id} is deregistered from engine {engine_type}"); self.region_map .remove(®ion_id) .map(|(id, engine)| engine.set_writable(id, false)); - self.event_listener.deregister_region(region_id); + self.event_listener.on_deregister_region(region_id); } }