Back to index

nordugrid-arc-nox  1.1.0~rc6
Submitter.h
Go to the documentation of this file.
00001 // -*- indent-tabs-mode: nil -*-
00002 
00003 #ifndef __ARC_SUBMITTER_H__
00004 #define __ARC_SUBMITTER_H__
00005 
00006 #include <list>
00007 #include <map>
00008 #include <string>
00009 
00010 #include <arc/URL.h>
00011 #include <arc/loader/Loader.h>
00012 #include <arc/loader/Plugin.h>
00013 
00014 namespace Arc {
00015 
00016   class Config;
00017   class ExecutionTarget;
00018   class JobDescription;
00019   class Logger;
00020   class UserConfig;
00021 
00023 
00029   class Submitter
00030     : public Plugin {
00031   protected:
00032     Submitter(const UserConfig& usercfg,
00033               const std::string& flavour);
00034   public:
00035     virtual ~Submitter();
00036 
00045     virtual URL Submit(const JobDescription& jobdesc,
00046                        const ExecutionTarget& et) const = 0;
00047 
00059     virtual URL Migrate(const URL& jobid, const JobDescription& jobdesc,
00060                         const ExecutionTarget& et,
00061                         bool forcemigration) const = 0;
00062 
00063     virtual bool ModifyJobDescription(JobDescription& jobdesc,
00064                                       const ExecutionTarget& et) const = 0;
00065     std::string GetCksum(const std::string& file) const { return GetCksum(file, usercfg); }
00066     static std::string GetCksum(const std::string& file, const UserConfig& usercfg);
00067   protected:
00068     bool PutFiles(const JobDescription& jobdesc, const URL& url) const;
00069     void AddJob(const JobDescription& job,
00070                 const URL& jobid,
00071                 const URL& cluster,
00072                 const URL& infoendpoint) const {
00073       std::map<std::string, std::string> additionalInfo;
00074       AddJob(job, jobid, cluster, infoendpoint, additionalInfo);
00075     }
00076     void AddJob(const JobDescription& job,
00077                 const URL& jobid,
00078                 const URL& cluster,
00079                 const URL& infoendpoint,
00080                 const std::map<std::string, std::string>& additionalInfo) const;
00081 
00082     const std::string flavour;
00083     const UserConfig& usercfg;
00084     static Logger logger;
00085   };
00086 
00090   class SubmitterLoader
00091     : public Loader {
00092 
00093   public:
00096     SubmitterLoader();
00097 
00101     ~SubmitterLoader();
00102 
00107     Submitter* load(const std::string& name, const UserConfig& usercfg);
00108 
00111     const std::list<Submitter*>& GetSubmitters() const {
00112       return submitters;
00113     }
00114 
00115   private:
00116     std::list<Submitter*> submitters;
00117   };
00118 
00119   class SubmitterPluginArgument
00120     : public PluginArgument {
00121   public:
00122     SubmitterPluginArgument(const UserConfig& usercfg)
00123       : usercfg(usercfg) {}
00124     ~SubmitterPluginArgument() {}
00125     operator const UserConfig&() {
00126       return usercfg;
00127     }
00128   private:
00129     const UserConfig& usercfg;
00130   };
00131 
00132 } // namespace Arc
00133 
00134 #endif // __ARC_SUBMITTER_H__