Skip to content

Commit 50d6163

Browse files
committed
after refactor
Signed-off-by: discord9 <discord9@163.com>
1 parent 23f7659 commit 50d6163

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/datanode/src/heartbeat/handler.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ impl RegionHeartbeatResponseHandler {
115115
Instruction::FlushRegions(_) => Ok(Box::new(FlushRegionsHandler.into())),
116116
Instruction::DowngradeRegions(_) => Ok(Box::new(DowngradeRegionsHandler.into())),
117117
Instruction::UpgradeRegion(_) => Ok(Box::new(UpgradeRegionsHandler.into())),
118+
Instruction::GetFileRefs(_) => Ok(Box::new(GetFileRefsHandler.into())),
119+
Instruction::GcRegions(_) => Ok(Box::new(GcRegionsHandler.into())),
118120
Instruction::InvalidateCaches(_) => InvalidHeartbeatResponseSnafu.fail(),
119-
Instruction::GetFileRefs(_) => Ok(Box::new(GetFileRefsHandler)),
120-
Instruction::GcRegions(_) => Ok(Box::new(GcRegionsHandler)),
121121
}
122122
}
123123
}
@@ -129,6 +129,8 @@ pub enum InstructionHandlers {
129129
FlushRegions(FlushRegionsHandler),
130130
DowngradeRegions(DowngradeRegionsHandler),
131131
UpgradeRegions(UpgradeRegionsHandler),
132+
GetFileRefs(GetFileRefsHandler),
133+
GcRegions(GcRegionsHandler),
132134
}
133135

134136
macro_rules! impl_from_handler {
@@ -148,7 +150,9 @@ impl_from_handler!(
148150
OpenRegionsHandler => OpenRegions,
149151
FlushRegionsHandler => FlushRegions,
150152
DowngradeRegionsHandler => DowngradeRegions,
151-
UpgradeRegionsHandler => UpgradeRegions
153+
UpgradeRegionsHandler => UpgradeRegions,
154+
GetFileRefsHandler => GetFileRefs,
155+
GcRegionsHandler => GcRegions
152156
);
153157

154158
macro_rules! dispatch_instr {
@@ -191,6 +195,8 @@ dispatch_instr!(
191195
FlushRegions => FlushRegions,
192196
DowngradeRegions => DowngradeRegions,
193197
UpgradeRegion => UpgradeRegions,
198+
GetFileRefs => GetFileRefs,
199+
GcRegions => GcRegions,
194200
);
195201

196202
#[async_trait]

src/datanode/src/heartbeat/handler/file_ref.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
use common_error::ext::ErrorExt;
16-
use common_meta::instruction::{GetFileRefsReply, Instruction, InstructionReply};
16+
use common_meta::instruction::{GetFileRefs, GetFileRefsReply, InstructionReply};
1717
use store_api::storage::FileRefsManifest;
1818

1919
use crate::heartbeat::handler::{HandlerContext, InstructionHandler};
@@ -22,12 +22,13 @@ pub struct GetFileRefsHandler;
2222

2323
#[async_trait::async_trait]
2424
impl InstructionHandler for GetFileRefsHandler {
25+
type Instruction = GetFileRefs;
26+
2527
async fn handle(
2628
&self,
2729
ctx: &HandlerContext,
28-
instruction: Instruction,
30+
get_file_refs: Self::Instruction,
2931
) -> Option<InstructionReply> {
30-
let get_file_refs = instruction.into_get_file_refs().unwrap();
3132
let region_server = &ctx.region_server;
3233

3334
// Get the MitoEngine

src/datanode/src/heartbeat/handler/gc_worker.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use common_meta::instruction::{GcRegionsReply, Instruction, InstructionReply};
15+
use common_meta::instruction::{GcRegions, GcRegionsReply, InstructionReply};
1616
use common_telemetry::{debug, warn};
1717
use mito2::gc::LocalGcWorker;
1818
use snafu::{OptionExt, ResultExt};
@@ -25,12 +25,13 @@ pub struct GcRegionsHandler;
2525

2626
#[async_trait::async_trait]
2727
impl InstructionHandler for GcRegionsHandler {
28+
type Instruction = GcRegions;
29+
2830
async fn handle(
2931
&self,
3032
ctx: &HandlerContext,
31-
instruction: Instruction,
33+
gc_regions: Self::Instruction,
3234
) -> Option<InstructionReply> {
33-
let gc_regions = instruction.into_gc_regions().unwrap();
3435
let region_ids = gc_regions.regions.clone();
3536
debug!("Received gc regions instruction: {:?}", region_ids);
3637

0 commit comments

Comments
 (0)