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 
113  bool Retrieve(const std::string& downloaddirprefix, bool usejobname, bool force, std::list<std::string>& downloaddirectories);
114 
116 
147  bool Renew();
148 
150 
178  bool Resume();
179 
181 
238  bool Resubmit(int destination, const std::list<Endpoint>& services, std::list<Job>& resubmittedJobs, const std::list<std::string>& rejectedURLs = std::list<std::string>());
239 
241 
293  bool Migrate(bool forcemigration, const std::list<Endpoint>& services, std::list<Job>& migratedJobs, const std::list<std::string>& rejectedURLs = std::list<std::string>());
294 
296 
323  bool Cancel();
324 
326 
338  bool Clean();
339 
340  const std::list<Job>& GetAllJobs() const { return jobs; }
341  std::list<Job> GetSelectedJobs() const;
342 
343  void SelectValid();
344  void SelectByStatus(const std::list<std::string>& status);
345  void SelectByID(const std::list<std::string>& ids);
346 
347  void ClearSelection();
348 
349  const std::list<std::string>& GetIDsProcessed() const { return processed; }
350  const std::list<std::string>& GetIDsNotProcessed() const { return notprocessed; }
351 
352  private:
353  const UserConfig& usercfg;
354 
355  std::list<Job> jobs;
356  // Selected and non-selected jobs.
357  typedef std::map<JobControllerPlugin*, std::pair< std::list<Job*>, std::list<Job*> > > JobSelectionMap;
358  JobSelectionMap jcJobMap;
359  std::map<std::string, JobControllerPlugin*> loadedJCs;
360 
361  std::list<std::string> processed, notprocessed;
362 
363  JobControllerPluginLoader loader;
364 
365  static Logger logger;
366  };
367 
368 } //namespace ARC
369 
370 #endif // __ARC_JOBSUPERVISOR_H__