This is an automated email from the ASF dual-hosted git repository.
agrove pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-ballista.git
The following commit(s) were added to refs/heads/main by this push:
new 4ed0de00 make rest-api optional feature ... (#1084)
4ed0de00 is described below
commit 4ed0de007f068b9ba1815561dcda73acf5c70a42
Author: Marko Milenković <[email protected]>
AuthorDate: Fri Oct 18 15:12:43 2024 +0100
make rest-api optional feature ... (#1084)
---
ballista/scheduler/Cargo.toml | 1 +
ballista/scheduler/src/lib.rs | 2 +-
ballista/scheduler/src/scheduler_process.rs | 13 +++++++++++--
ballista/scheduler/src/scheduler_server/mod.rs | 5 ++++-
.../scheduler/src/scheduler_server/query_stage_scheduler.rs | 2 +-
ballista/scheduler/src/state/task_manager.rs | 1 +
6 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/ballista/scheduler/Cargo.toml b/ballista/scheduler/Cargo.toml
index 1367f17b..a1d59735 100644
--- a/ballista/scheduler/Cargo.toml
+++ b/ballista/scheduler/Cargo.toml
@@ -38,6 +38,7 @@ default = []
flight-sql = []
keda-scaler = []
prometheus-metrics = ["prometheus", "once_cell"]
+rest-api = []
[dependencies]
anyhow = "1"
diff --git a/ballista/scheduler/src/lib.rs b/ballista/scheduler/src/lib.rs
index 946e475f..1e1c4246 100644
--- a/ballista/scheduler/src/lib.rs
+++ b/ballista/scheduler/src/lib.rs
@@ -16,7 +16,7 @@
// under the License.
#![doc = include_str ! ("../README.md")]
-
+#[cfg(feature = "rest-api")]
pub mod api;
pub mod cluster;
pub mod config;
diff --git a/ballista/scheduler/src/scheduler_process.rs
b/ballista/scheduler/src/scheduler_process.rs
index 5d1671a0..5666fee7 100644
--- a/ballista/scheduler/src/scheduler_process.rs
+++ b/ballista/scheduler/src/scheduler_process.rs
@@ -26,6 +26,7 @@ use datafusion_proto::protobuf::{LogicalPlanNode,
PhysicalPlanNode};
use log::info;
use std::{net::SocketAddr, sync::Arc};
+#[cfg(feature = "rest-api")]
use crate::api::get_routes;
use crate::cluster::BallistaCluster;
use crate::config::SchedulerConfig;
@@ -82,13 +83,21 @@ pub async fn start_server(
let tonic = tonic_builder.into_service().into_axum_router();
+ #[cfg(feature = "rest-api")]
let axum = get_routes(Arc::new(scheduler_server));
- let merged = axum
+ #[cfg(feature = "rest-api")]
+ let final_route = axum
.merge(tonic)
.into_make_service_with_connect_info::<SocketAddr>();
+ #[cfg(not(feature = "rest-api"))]
+ let final_route = tonic;
+
let listener = tokio::net::TcpListener::bind(&addr)
.await
.map_err(Error::from)?;
- axum::serve(listener, merged).await.map_err(Error::from)
+
+ axum::serve(listener, final_route)
+ .await
+ .map_err(Error::from)
}
diff --git a/ballista/scheduler/src/scheduler_server/mod.rs
b/ballista/scheduler/src/scheduler_server/mod.rs
index 59b988bc..3e2da13b 100644
--- a/ballista/scheduler/src/scheduler_server/mod.rs
+++ b/ballista/scheduler/src/scheduler_server/mod.rs
@@ -64,6 +64,7 @@ pub struct SchedulerServer<T: 'static + AsLogicalPlan, U:
'static + AsExecutionP
pub start_time: u128,
pub state: Arc<SchedulerState<T, U>>,
pub(crate) query_stage_event_loop: EventLoop<QueryStageSchedulerEvent>,
+ #[cfg(feature = "rest-api")]
query_stage_scheduler: Arc<QueryStageScheduler<T, U>>,
config: Arc<SchedulerConfig>,
}
@@ -98,6 +99,7 @@ impl<T: 'static + AsLogicalPlan, U: 'static +
AsExecutionPlan> SchedulerServer<T
start_time: timestamp_millis() as u128,
state,
query_stage_event_loop,
+ #[cfg(feature = "rest-api")]
query_stage_scheduler,
config,
}
@@ -135,6 +137,7 @@ impl<T: 'static + AsLogicalPlan, U: 'static +
AsExecutionPlan> SchedulerServer<T
start_time: timestamp_millis() as u128,
state,
query_stage_event_loop,
+ #[cfg(feature = "rest-api")]
query_stage_scheduler,
config,
}
@@ -155,7 +158,7 @@ impl<T: 'static + AsLogicalPlan, U: 'static +
AsExecutionPlan> SchedulerServer<T
pub fn running_job_number(&self) -> usize {
self.state.task_manager.running_job_number()
}
-
+ #[cfg(feature = "rest-api")]
pub(crate) fn metrics_collector(&self) -> &dyn SchedulerMetricsCollector {
self.query_stage_scheduler.metrics_collector()
}
diff --git a/ballista/scheduler/src/scheduler_server/query_stage_scheduler.rs
b/ballista/scheduler/src/scheduler_server/query_stage_scheduler.rs
index df74ad6b..c3f3e7eb 100644
--- a/ballista/scheduler/src/scheduler_server/query_stage_scheduler.rs
+++ b/ballista/scheduler/src/scheduler_server/query_stage_scheduler.rs
@@ -57,7 +57,7 @@ impl<T: 'static + AsLogicalPlan, U: 'static +
AsExecutionPlan> QueryStageSchedul
config,
}
}
-
+ #[cfg(feature = "rest-api")]
pub(crate) fn metrics_collector(&self) -> &dyn SchedulerMetricsCollector {
self.metrics_collector.as_ref()
}
diff --git a/ballista/scheduler/src/state/task_manager.rs
b/ballista/scheduler/src/state/task_manager.rs
index 1c9d8dd6..445e65b9 100644
--- a/ballista/scheduler/src/state/task_manager.rs
+++ b/ballista/scheduler/src/state/task_manager.rs
@@ -275,6 +275,7 @@ impl<T: 'static + AsLogicalPlan, U: 'static +
AsExecutionPlan> TaskManager<T, U>
/// Get the execution graph of of a job. First look in the active cache.
/// If no one found, then in the Active/Completed jobs.
+ #[cfg(feature = "rest-api")]
pub(crate) async fn get_job_execution_graph(
&self,
job_id: &str,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]