1717
1818//! Ballista Rust executor binary.
1919
20- use std:: {
21- net:: { IpAddr , Ipv4Addr } ,
22- sync:: Arc ,
23- } ;
20+ use std:: sync:: Arc ;
2421
2522use anyhow:: { Context , Result } ;
2623use arrow_flight:: flight_service_server:: FlightServiceServer ;
27- use futures :: future :: MaybeDone ;
24+ use ballista_executor :: execution_loop ;
2825use log:: info;
2926use tempfile:: TempDir ;
3027use tonic:: transport:: Server ;
@@ -34,17 +31,11 @@ use ballista_core::serde::protobuf::{
3431 executor_registration, scheduler_grpc_client:: SchedulerGrpcClient ,
3532 ExecutorRegistration ,
3633} ;
37- use ballista_core:: {
38- print_version, serde:: protobuf:: scheduler_grpc_server:: SchedulerGrpcServer ,
39- BALLISTA_VERSION ,
40- } ;
34+ use ballista_core:: { print_version, BALLISTA_VERSION } ;
4135use ballista_executor:: executor:: Executor ;
4236use ballista_executor:: flight_service:: BallistaFlightService ;
43- use ballista_scheduler:: { state:: StandaloneClient , SchedulerServer } ;
4437use config:: prelude:: * ;
4538
46- mod execution_loop;
47-
4839#[ macro_use]
4940extern crate configure_me;
5041
@@ -82,11 +73,7 @@ async fn main() -> Result<()> {
8273 . parse ( )
8374 . with_context ( || format ! ( "Could not parse address: {}" , addr) ) ?;
8475
85- let scheduler_host = if opt. local {
86- "localhost" . to_string ( )
87- } else {
88- opt. scheduler_host
89- } ;
76+ let scheduler_host = opt. scheduler_host ;
9077 let scheduler_port = opt. scheduler_port ;
9178 let scheduler_url = format ! ( "http://{}:{}" , scheduler_host, scheduler_port) ;
9279
@@ -109,58 +96,6 @@ async fn main() -> Result<()> {
10996 port : port as u32 ,
11097 } ;
11198
112- if opt. local {
113- info ! ( "Running in local mode. Scheduler will be run in-proc" ) ;
114-
115- let client = match opt. scheduler_data_path {
116- Some ( v) => StandaloneClient :: try_new ( v)
117- . context ( "Could not create standalone config backend" ) ?,
118- None => StandaloneClient :: try_new_temporary ( )
119- . context ( "Could not create standalone config backend" ) ?,
120- } ;
121-
122- let server = SchedulerGrpcServer :: new ( SchedulerServer :: new (
123- Arc :: new ( client) ,
124- "ballista" . to_string ( ) ,
125- IpAddr :: V4 ( Ipv4Addr :: LOCALHOST ) ,
126- ) ) ;
127- let addr = format ! ( "localhost:{}" , scheduler_port) ;
128- let addr = addr
129- . parse ( )
130- . with_context ( || format ! ( "Could not parse {}" , addr) ) ?;
131- info ! (
132- "Ballista v{} Rust Scheduler listening on {:?}" ,
133- BALLISTA_VERSION , addr
134- ) ;
135- let scheduler_future =
136- tokio:: spawn ( Server :: builder ( ) . add_service ( server) . serve ( addr) ) ;
137- let mut scheduler_result = futures:: future:: maybe_done ( scheduler_future) ;
138-
139- // Ensure scheduler is ready to receive connections
140- while SchedulerGrpcClient :: connect ( scheduler_url. clone ( ) )
141- . await
142- . is_err ( )
143- {
144- let scheduler_future = match scheduler_result {
145- MaybeDone :: Future ( f) => f,
146- MaybeDone :: Done ( Err ( e) ) => return Err ( e) . context ( "Tokio error" ) ,
147- MaybeDone :: Done ( Ok ( Err ( e) ) ) => {
148- return Err ( e) . context ( "Scheduler failed to initialize correctly" )
149- }
150- MaybeDone :: Done ( Ok ( Ok ( ( ) ) ) ) => {
151- return Err ( anyhow:: format_err!(
152- "Scheduler unexpectedly finished successfully"
153- ) )
154- }
155- MaybeDone :: Gone => {
156- panic ! ( "Received Gone from recently created MaybeDone" )
157- }
158- } ;
159- tokio:: time:: sleep ( std:: time:: Duration :: from_millis ( 100 ) ) . await ;
160- scheduler_result = futures:: future:: maybe_done ( scheduler_future) ;
161- }
162- }
163-
16499 let scheduler = SchedulerGrpcClient :: connect ( scheduler_url)
165100 . await
166101 . context ( "Could not connect to scheduler" ) ?;
0 commit comments