yahoNanJing commented on a change in pull request #1560:
URL: https://github.com/apache/arrow-datafusion/pull/1560#discussion_r787443197



##########
File path: ballista/rust/scheduler/src/lib.rs
##########
@@ -112,17 +140,171 @@ impl SchedulerServer {
         tokio::spawn(async move { 
state_clone.synchronize_job_status_loop().await });
 
         Self {
-            caller_ip,
             state,
             start_time: SystemTime::now()
                 .duration_since(UNIX_EPOCH)
                 .unwrap()
                 .as_millis(),
+            policy,
+            scheduler_env,
+            executors_client: Arc::new(RwLock::new(HashMap::new())),
         }
     }
 
-    pub fn set_caller_ip(&mut self, ip: IpAddr) {
-        self.caller_ip = ip;
+    async fn schedule_job(&self, job_id: String) -> Result<(), BallistaError> {
+        let alive_executors = self
+            .state
+            .get_alive_executors_metadata_within_one_minute()
+            .await?;
+        let alive_executors: HashMap<String, ExecutorMeta> = alive_executors
+            .into_iter()
+            .map(|e| (e.id.clone(), e))
+            .collect();
+        let available_executors = 
self.state.get_available_executors_data().await?;
+        let mut available_executors: Vec<ExecutorData> = available_executors
+            .into_iter()
+            .filter(|e| alive_executors.contains_key(&e.executor_id))
+            .collect();
+
+        // In case of there's no enough resources, reschedule the tasks of the 
job
+        if available_executors.is_empty() {
+            let tx_job = self.scheduler_env.as_ref().unwrap().tx_job.clone();
+            // TODO
+            tokio::spawn(async move {
+                warn!("Not enough available executors for task running");
+                tokio::time::sleep(Duration::from_millis(100)).await;
+                tx_job.send(job_id).await.unwrap();
+            });
+            return Ok(());
+        }
+
+        let tasks_assigment = self.fetch_tasks(&mut available_executors, 
&job_id).await?;
+        if !tasks_assigment.is_empty() {
+            let available_executors: HashMap<String, ExecutorData> = 
available_executors

Review comment:
       Thanks for pointing this out. Let me improve this.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to