@@ -32,6 +32,7 @@ use ballista_core::serde::protobuf::{
3232use protobuf:: CompletedTask ;
3333
3434use crate :: executor:: Executor ;
35+ use ballista_core:: execution_plans:: ShuffleWriterExec ;
3536
3637pub async fn poll_loop (
3738 mut scheduler : SchedulerGrpcClient < Channel > ,
@@ -108,19 +109,35 @@ async fn run_received_tasks(
108109 available_tasks_slots. fetch_sub ( 1 , Ordering :: SeqCst ) ;
109110 let plan: Arc < dyn ExecutionPlan > = ( & task. plan . unwrap ( ) ) . try_into ( ) . unwrap ( ) ;
110111
111- tokio:: spawn ( async move {
112- let execution_result = executor
113- . execute_shuffle_write ( plan, task_id. partition_id as usize )
114- . await ;
115- info ! ( "Done with task {}" , task_id_log) ;
116- debug ! ( "Statistics: {:?}" , execution_result) ;
117- available_tasks_slots. fetch_add ( 1 , Ordering :: SeqCst ) ;
118- let _ = task_status_sender. send ( as_task_status (
119- execution_result. map ( |_| ( ) ) ,
120- executor_id,
121- task_id,
122- ) ) ;
123- } ) ;
112+ if let Some ( shuffle_writer) = plan. as_any ( ) . downcast_ref :: < ShuffleWriterExec > ( ) {
113+ //TODO this is a hacky way to set the working directory for the shuffle writer
114+ let exec: Arc < dyn ExecutionPlan > = Arc :: new (
115+ ShuffleWriterExec :: try_new (
116+ shuffle_writer. job_id ( ) . to_string ( ) ,
117+ shuffle_writer. stage_id ( ) ,
118+ shuffle_writer. children ( ) [ 0 ] . clone ( ) ,
119+ executor. work_dir . clone ( ) ,
120+ Some ( shuffle_writer. output_partitioning ( ) ) ,
121+ )
122+ . unwrap ( ) ,
123+ ) ; //TODO unwrap
124+ tokio:: spawn ( async move {
125+ let execution_result = executor
126+ . execute_shuffle_write ( exec, task_id. partition_id as usize )
127+ . await ;
128+ info ! ( "Done with task {}" , task_id_log) ;
129+ debug ! ( "Statistics: {:?}" , execution_result) ;
130+ available_tasks_slots. fetch_add ( 1 , Ordering :: SeqCst ) ;
131+ let _ = task_status_sender. send ( as_task_status (
132+ execution_result. map ( |_| ( ) ) ,
133+ executor_id,
134+ task_id,
135+ ) ) ;
136+ } ) ;
137+ } else {
138+ //TODO error handling
139+ unreachable ! ( )
140+ }
124141}
125142
126143fn as_task_status (
0 commit comments