ARC SDK
JobSupervisor.h
1 // -*- indent-tabs-mode: nil -*-
2 
3 #ifndef __ARC_JOBSUPERVISOR_H__
4 #define __ARC_JOBSUPERVISOR_H__
5 
6 #include <list>
7 #include <string>
8 
9 #include <arc/URL.h>
10 #include <arc/compute/JobControllerPlugin.h>
11 #include <arc/compute/EntityRetriever.h>
12 
13 namespace Arc {
14 
15  class Logger;
16  class Endpoint;
17  class UserConfig;
18 
20 
27  class JobSupervisor : public EntityConsumer<Job> {
28  public:
30 
55  JobSupervisor(const UserConfig& usercfg, const std::list<Job>& jobs = std::list<Job>());
56 
57  ~JobSupervisor() {}
58 
60 
69  bool AddJob(const Job& job);
70 
71  void addEntity(const Job& job) { AddJob(job); }
72 
74 
80  void Update();
81 
83 
121  bool Retrieve(const std::string& downloaddirprefix, bool usejobname, bool force, std::list<std::string>& downloaddirectories);
122 
124 
155  bool Renew();
156 
158 
186  bool Resume();
187 
189 
246  bool Resubmit(int destination, const std::list<Endpoint>& services, std::list<Job>& resubmittedJobs, const std::list<std::string>& rejectedURLs = std::list<std::string>());
247 
249 
301  bool Migrate(bool forcemigration, const std::list<Endpoint>& services, std::list<Job>& migratedJobs, const std::list<std::string>& rejectedURLs = std::list<std::string>());
302 
304 
331  bool Cancel();
332 
334 
346  bool Clean();
347 
348  const std::list<Job>& GetAllJobs() const { return jobs; }
349  std::list<Job> GetSelectedJobs() const;
350 
351  void SelectValid();
352  void SelectByStatus(const std::list<std::string>& status);
353  void SelectByID(const std::list<std::string>& ids);
354 
355  void ClearSelection();
356 
357  const std::list<std::string>& GetIDsProcessed() const { return processed; }
358  const std::list<std::string>& GetIDsNotProcessed() const { return notprocessed; }
359 
360  private:
361  const UserConfig& usercfg;
362 
363  std::list<Job> jobs;
364  // Selected and non-selected jobs.
365  typedef std::map<JobControllerPlugin*, std::pair< std::list<Job*>, std::list<Job*> > > JobSelectionMap;
366  JobSelectionMap jcJobMap;
367  std::map<std::string, JobControllerPlugin*> loadedJCs;
368 
369  std::list<std::string> processed, notprocessed;
370 
371  JobControllerPluginLoader loader;
372 
373  static Logger logger;
374  };
375 
376 } //namespace ARC
377 
378 #endif // __ARC_JOBSUPERVISOR_H__