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

Add grpc service of cleaning up job shuffle data for the scheduler to make it able to be triggered by client explicitly #485

Merged
merged 1 commit into from
Nov 3, 2022
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
9 changes: 9 additions & 0 deletions ballista/core/proto/ballista.proto
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,13 @@ message CancelJobResult {
bool cancelled = 1;
}

message CleanJobDataParams {
string job_id = 1;
}

message CleanJobDataResult {
}

message LaunchTaskParams {
// Allow to launch a task set to an executor at once
repeated TaskDefinition tasks = 1;
Expand Down Expand Up @@ -1014,6 +1021,8 @@ service SchedulerGrpc {
rpc ExecutorStopped (ExecutorStoppedParams) returns (ExecutorStoppedResult) {}

rpc CancelJob (CancelJobParams) returns (CancelJobResult) {}

rpc CleanJobData (CleanJobDataParams) returns (CleanJobDataResult) {}
}

service ExecutorGrpc {
Expand Down
1 change: 1 addition & 0 deletions ballista/scheduler/src/scheduler_server/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ pub enum QueryStageSchedulerEvent {
JobRunningFailed(String, String),
JobUpdated(String),
JobCancel(String),
JobDataClean(String),
TaskUpdating(String, Vec<TaskStatus>),
ReservationOffering(Vec<ExecutorReservation>),
ExecutorLost(String, Option<String>),
Expand Down
36 changes: 30 additions & 6 deletions ballista/scheduler/src/scheduler_server/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ use std::convert::TryInto;
use ballista_core::serde::protobuf::executor_registration::OptionalHost;
use ballista_core::serde::protobuf::scheduler_grpc_server::SchedulerGrpc;
use ballista_core::serde::protobuf::{
executor_status, CancelJobParams, CancelJobResult, ExecuteQueryParams,
ExecuteQueryResult, ExecutorHeartbeat, ExecutorStatus, ExecutorStoppedParams,
ExecutorStoppedResult, GetFileMetadataParams, GetFileMetadataResult,
GetJobStatusParams, GetJobStatusResult, HeartBeatParams, HeartBeatResult,
PollWorkParams, PollWorkResult, RegisterExecutorParams, RegisterExecutorResult,
UpdateTaskStatusParams, UpdateTaskStatusResult,
executor_status, CancelJobParams, CancelJobResult, CleanJobDataParams,
CleanJobDataResult, ExecuteQueryParams, ExecuteQueryResult, ExecutorHeartbeat,
ExecutorStatus, ExecutorStoppedParams, ExecutorStoppedResult, GetFileMetadataParams,
GetFileMetadataResult, GetJobStatusParams, GetJobStatusResult, HeartBeatParams,
HeartBeatResult, PollWorkParams, PollWorkResult, RegisterExecutorParams,
RegisterExecutorResult, UpdateTaskStatusParams, UpdateTaskStatusResult,
};
use ballista_core::serde::scheduler::{ExecutorData, ExecutorMetadata};
use ballista_core::serde::AsExecutionPlan;
Expand Down Expand Up @@ -543,6 +543,30 @@ impl<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan> SchedulerGrpc
})?;
Ok(Response::new(CancelJobResult { cancelled: true }))
}

async fn clean_job_data(
&self,
request: Request<CleanJobDataParams>,
) -> Result<Response<CleanJobDataResult>, Status> {
let job_id = request.into_inner().job_id;
info!("Received clean data request for job {}", job_id);

self.query_stage_event_loop
.get_sender()
.map_err(|e| {
let msg = format!("Get query stage event loop error due to {:?}", e);
error!("{}", msg);
Status::internal(msg)
Comment on lines +557 to +559
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor nit: we could introduce a function to create these Status messages to avoid duplicating this block of code

})?
.post_event(QueryStageSchedulerEvent::JobDataClean(job_id))
.await
.map_err(|e| {
let msg = format!("Post to query stage event loop error due to {:?}", e);
error!("{}", msg);
Status::internal(msg)
})?;
Ok(Response::new(CleanJobDataResult {}))
}
}

#[cfg(all(test, feature = "sled"))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ impl<T: 'static + AsLogicalPlan, U: 'static + AsExecutionPlan>
.cancel_running_tasks(tasks)
.await?
}
QueryStageSchedulerEvent::JobDataClean(job_id) => {
self.state.executor_manager.clean_up_job_data(job_id);
}
}

Ok(())
Expand Down