Back to index

nordugrid-arc-nox  1.1.0~rc6
JobController.h
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #ifndef __ARC_JOBCONTROLLER_H__
00004 #define __ARC_JOBCONTROLLER_H__
00005 
00006 #include <list>
00007 #include <string>
00008 
00009 #include <arc/ArcConfig.h>
00010 #include <arc/URL.h>
00011 #include <arc/client/Job.h>
00012 #include <arc/loader/Plugin.h>
00013 #include <arc/loader/Loader.h>
00014 
00015 namespace Arc {
00016 
00017   class Broker;
00018   class Logger;
00019   class TargetGenerator;
00020   class UserConfig;
00021 
00023 
00037 
00038   class JobController
00039     : public Plugin {
00040   protected:
00041     JobController(const UserConfig& usercfg,
00042                   const std::string& flavour);
00043   public:
00044     virtual ~JobController();
00045 
00047 
00055     void FillJobStore(const std::list<URL>& jobids);
00056     void FillJobStore(const Job& job);
00057 
00058     bool Get(const std::list<std::string>& status,
00059              const std::string& downloaddir,
00060              const bool keep);
00061 
00062     bool Kill(const std::list<std::string>& status,
00063               const bool keep);
00064 
00065     bool Clean(const std::list<std::string>& status,
00066                const bool force);
00067 
00068     bool Cat(const std::list<std::string>& status,
00069              const std::string& whichfile);
00070 
00072 
00095     bool PrintJobStatus(const std::list<std::string>& status,
00096                         const bool longlist);
00097 
00099 
00111     bool Migrate(TargetGenerator& targetGen,
00112                  Broker *broker,
00113                  const UserConfig& usercfg,
00114                  const bool forcemigration,
00115                  std::list<URL>& migratedJobIDs);
00116 
00117     bool Renew(const std::list<std::string>& status);
00118 
00119     bool Resume(const std::list<std::string>& status);
00120 
00121     bool RemoveJobs(const std::list<URL>& jobids);
00122 
00123     std::list<std::string> GetDownloadFiles(const URL& dir);
00124     bool ARCCopyFile(const URL& src, const URL& dst);
00125 
00126     std::list<Job> GetJobDescriptions(const std::list<std::string>& status,
00127                                       const bool getlocal);
00128 
00129     void CheckLocalDescription(std::list<Job>& jobs);
00130 
00131     const std::list<Job>& GetJobs() const {
00132       return jobstore;
00133     }
00134 
00135     // Implemented by specialized classes
00136     virtual void GetJobInformation() = 0;
00137     virtual bool GetJob(const Job& job, const std::string& downloaddir) = 0;
00138     virtual bool CleanJob(const Job& job, bool force) = 0;
00139     virtual bool CancelJob(const Job& job) = 0;
00140     virtual bool RenewJob(const Job& job) = 0;
00141     virtual bool ResumeJob(const Job& job) = 0;
00142     virtual URL GetFileUrlForJob(const Job& job,
00143                                  const std::string& whichfile) = 0;
00144     virtual bool GetJobDescription(const Job& job, std::string& desc_str) = 0;
00145 
00146   protected:
00147     const std::string flavour;
00148     const UserConfig& usercfg;
00149     std::list<Job> jobstore;
00150     Config jobstorage;
00151     static Logger logger;
00152   };
00153 
00157   class JobControllerLoader
00158     : public Loader {
00159 
00160   public:
00163     JobControllerLoader();
00164 
00168     ~JobControllerLoader();
00169 
00174     JobController* load(const std::string& name, const UserConfig& usercfg);
00175 
00178     const std::list<JobController*>& GetJobControllers() const {
00179       return jobcontrollers;
00180     }
00181 
00182   private:
00183     std::list<JobController*> jobcontrollers;
00184   };
00185 
00186   class JobControllerPluginArgument
00187     : public PluginArgument {
00188   public:
00189     JobControllerPluginArgument(const UserConfig& usercfg)
00190       : usercfg(usercfg) {}
00191     ~JobControllerPluginArgument() {}
00192     operator const UserConfig&() {
00193       return usercfg;
00194     }
00195   private:
00196     const UserConfig& usercfg;
00197   };
00198 
00199 } // namespace Arc
00200 
00201 #endif // __ARC_JOBCONTROLLER_H__