@@ -16,9 +16,12 @@ use std::time::{Duration, SystemTime};
1616
1717use anyhow:: { Context , Result , anyhow} ;
1818use arrow_array:: RecordBatch ;
19+ use protocol:: storage:: KafkaSourceSubtaskCheckpoint ;
20+ use tokio:: sync:: mpsc;
1921
2022use crate :: runtime:: memory:: { MemoryBlock , MemoryPool , get_array_memory_size} ;
2123use crate :: runtime:: streaming:: network:: endpoint:: PhysicalSender ;
24+ use crate :: runtime:: streaming:: protocol:: control:: JobMasterEvent ;
2225use crate :: runtime:: streaming:: protocol:: event:: { StreamEvent , TrackedEvent } ;
2326use crate :: runtime:: streaming:: state:: IoManager ;
2427
@@ -74,6 +77,9 @@ pub struct TaskContext {
7477
7578 /// Last globally-committed safe epoch for crash recovery.
7679 safe_epoch : u64 ,
80+
81+ /// When set, pipelines report checkpoint completion (and optional Kafka offsets) to the job coordinator.
82+ checkpoint_ack_tx : Option < mpsc:: Sender < JobMasterEvent > > ,
7783}
7884
7985impl TaskContext {
@@ -90,6 +96,7 @@ impl TaskContext {
9096 pipeline_state_memory_block : Option < Arc < MemoryBlock > > ,
9197 operator_state_memory_bytes : u64 ,
9298 safe_epoch : u64 ,
99+ checkpoint_ack_tx : Option < mpsc:: Sender < JobMasterEvent > > ,
93100 ) -> Self {
94101 let task_name = format ! (
95102 "Task-[{}]-Pipe[{}]-Sub[{}/{}]" ,
@@ -111,6 +118,7 @@ impl TaskContext {
111118 pipeline_state_memory_block,
112119 operator_state_memory_bytes,
113120 safe_epoch,
121+ checkpoint_ack_tx,
114122 }
115123 }
116124
@@ -119,6 +127,23 @@ impl TaskContext {
119127 self . safe_epoch
120128 }
121129
130+ /// Notify the job checkpoint coordinator that this pipeline has finished the barrier for `epoch`.
131+ pub async fn send_checkpoint_ack (
132+ & self ,
133+ epoch : u64 ,
134+ kafka_subtask : Option < KafkaSourceSubtaskCheckpoint > ,
135+ ) {
136+ if let Some ( tx) = & self . checkpoint_ack_tx {
137+ let _ = tx
138+ . send ( JobMasterEvent :: CheckpointAck {
139+ pipeline_id : self . pipeline_id ,
140+ epoch,
141+ kafka_subtask,
142+ } )
143+ . await ;
144+ }
145+ }
146+
122147 #[ inline]
123148 pub fn config ( & self ) -> & TaskContextConfig {
124149 & self . config
0 commit comments