Back to index

nordugrid-arc-nox  1.1.0~rc6
JobDescription.h
Go to the documentation of this file.
00001 #ifndef __ARC_JOBDESCRIPTION_H__
00002 #define __ARC_JOBDESCRIPTION_H__
00003 
00004 #include <list>
00005 #include <vector>
00006 #include <string>
00007 
00008 #include <arc/DateTime.h>
00009 #include <arc/XMLNode.h>
00010 #include <arc/URL.h>
00011 #include <arc/client/Software.h>
00012 
00029 namespace Arc {
00030 
00031   template<class T>
00032   class Range {
00033   public:
00034     Range<T>() {}
00035     Range<T>(const T& t) : min(t), max(t) {}
00036     operator T(void) const { return max; }
00037 
00038     Range<T>& operator=(const Range<T>& t) { min = t.min; max = t.max; return *this; };
00039     Range<T>& operator=(const T& t) { max = t; return *this; };
00040 
00041     T min;
00042     T max;
00043   };
00044 
00045   template<class T>
00046   class ScalableTime {
00047   public:
00048     ScalableTime<T>() : benchmark("", -1.) {}
00049     ScalableTime<T>(const T& t) : range(t) {}
00050 
00051     std::pair<std::string, double> benchmark;
00052     Range<T> range;
00053   };
00054 
00055   template<>
00056   class ScalableTime<int> {
00057   public:
00058     ScalableTime<int>() : benchmark("", -1.) {}
00059     ScalableTime<int>(const int& t) : range(t) {}
00060 
00061     std::pair<std::string, double> benchmark;
00062     Range<int> range;
00063 
00064     int scaleMin(double s) const { return (int)(range.min*benchmark.second/s); }
00065     int scaleMax(double s) const { return (int)(range.max*benchmark.second/s); }
00066   };
00067 
00068   enum ComputingActivityType {
00069     SINGLE = 0,
00070     COLLECTIONELEMENT = 1,
00071     PARALLELELEMENT = 2,
00072     WORKFLOWNODE = 3
00073   };
00074 
00075   class JobIdentificationType {
00076   public:
00077     JobIdentificationType() :
00078       JobType(SINGLE) {}
00079     std::string JobName;
00080     std::string Description;
00081     std::string JobVOName;
00082     ComputingActivityType JobType;
00083     std::list<std::string> UserTag;
00084     std::list<std::string> ActivityOldId;
00085   };
00086 
00087   class ExecutableType {
00088   public:
00089     std::string Name;
00090     std::list<std::string> Argument;
00091   };
00092 
00093   class NotificationType {
00094   public:
00095     std::string Email;
00096     std::list<std::string> States;
00097   };
00098 
00099   class ApplicationType {
00100   public:
00101     ApplicationType() :
00102       Join(false),
00103       Rerun(-1),
00104       ExpiryTime(-1),
00105       ProcessingStartTime(-1) {}
00106     ExecutableType Executable;
00107     std::string Input;
00108     std::string Output;
00109     std::string Error;
00110     bool Join;
00111     std::list< std::pair<std::string, std::string> > Environment;
00112     ExecutableType Prologue;
00113     ExecutableType Epilogue;
00114     std::string LogDir;
00115     std::list<URL> RemoteLogging;
00116     int Rerun;
00117     Time ExpiryTime;
00118     Time ProcessingStartTime;
00119     std::list<NotificationType> Notification;
00120     std::list<URL> CredentialService;
00121     XMLNode AccessControl;
00122   };
00123 
00124   class ResourceSlotType {
00125   public:
00126     ResourceSlotType() :
00127       NumberOfSlots(-1),
00128       ProcessPerHost(-1),
00129       ThreadsPerProcesses(-1) {}
00130     Range<int> NumberOfSlots;
00131     Range<int> ProcessPerHost;
00132     Range<int> ThreadsPerProcesses;
00133     std::string SPMDVariation;
00134   };
00135 
00136   class DiskSpaceRequirementType {
00137   public:
00138     DiskSpaceRequirementType() :
00139       DiskSpace(-1),
00140       CacheDiskSpace(-1),
00141       SessionDiskSpace(-1) {}
00142     Range<int64_t> DiskSpace;
00143     int64_t CacheDiskSpace;
00144     int64_t SessionDiskSpace;
00145   };
00146 
00147   class ResourceTargetType {
00148   public:
00149     URL EndPointURL;
00150     std::string QueueName;
00151   };
00152 
00153   enum SessionDirectoryAccessMode {
00154     SDAM_NONE = 0,
00155     SDAM_RO = 1,
00156     SDAM_RW = 2
00157   };
00158 
00159   enum NodeAccessType {
00160     NAT_NONE = 0,
00161     NAT_INBOUND = 1,
00162     NAT_OUTBOUND = 2,
00163     NAT_INOUTBOUND = 3
00164   };
00165 
00166   class ResourcesType {
00167   public:
00168     ResourcesType() :
00169       IndividualPhysicalMemory(-1),
00170       IndividualVirtualMemory(-1),
00171       SessionLifeTime(-1),
00172       SessionDirectoryAccess(SDAM_NONE),
00173       IndividualCPUTime(-1),
00174       TotalCPUTime(-1),
00175       IndividualWallTime(-1),
00176       TotalWallTime(-1),
00177       NodeAccess(NAT_NONE) {}
00178     SoftwareRequirement OperatingSystem;
00179     std::string Platform;
00180     std::string NetworkInfo;
00181     Range<int64_t> IndividualPhysicalMemory;
00182     Range<int64_t> IndividualVirtualMemory;
00183     DiskSpaceRequirementType DiskSpaceRequirement;
00184     Period SessionLifeTime;
00185     SessionDirectoryAccessMode SessionDirectoryAccess;
00186     ScalableTime<int> IndividualCPUTime;
00187     ScalableTime<int> TotalCPUTime;
00188     ScalableTime<int> IndividualWallTime;
00189     ScalableTime<int> TotalWallTime;
00190     NodeAccessType NodeAccess;
00191     SoftwareRequirement CEType;
00192     ResourceSlotType SlotRequirement;
00193     std::list<ResourceTargetType> CandidateTarget;
00194     SoftwareRequirement RunTimeEnvironment;
00195   };
00196 
00197   class DataSourceType {
00198   public:
00199     DataSourceType() :
00200       Threads(-1) {}
00201     URL URI;
00202     int Threads;
00203   };
00204 
00205   class DataTargetType {
00206   public:
00207     DataTargetType() :
00208       Threads(-1),
00209       Mandatory(false),
00210       NeededReplica(-1) {}
00211     URL URI;
00212     int Threads;
00213     bool Mandatory;
00214     int NeededReplica;
00215   };
00216 
00217   class DataType {
00218   public:
00219     DataType() :
00220       KeepData(false),
00221       IsExecutable(false),
00222       DownloadToCache(false) {}
00223     std::string Name;
00224     bool KeepData;
00225     bool IsExecutable;
00226     bool DownloadToCache;
00227     std::list<URL> DataIndexingService;
00228     std::list<DataSourceType> Source;
00229     std::list<DataTargetType> Target;
00230   };
00231 
00232   class FileType : public DataType {};
00233   class DirectoryType : public DataType {};
00234 
00235   class DataStagingType {
00236   public:
00237     std::list<FileType> File;
00238     std::list<DirectoryType> Directory;
00239   };
00240 
00241   class JobMetaType {
00242   public:
00243     JobMetaType() :
00244       DocumentExpiration(-1),
00245       FuzzyRank(false) {}
00246     std::string Author;
00247     Time DocumentExpiration;
00248     std::string Rank;
00249     bool FuzzyRank;
00250   };
00251 
00252   class JobDescription {
00253   public:
00254     JobDescription() {};
00255 
00256     // Language wrapper constructor
00257     JobDescription(const long int& ptraddr);
00258 
00259     operator bool() const {
00260       return (!Application.Executable.Name.empty());
00261     }
00262 
00263     // Try to parse the source string and store it.
00264     bool Parse(const std::string& source);
00265     // XMLNode is reference by itself - passing it as const& has no sense
00266     bool Parse(const XMLNode& xmlSource);
00267 
00268     // Transform the job description representation into a given format,
00269     // if it's known as a parser (JSDL as default)
00270     // If there is some error during this method, then return empty string.
00271     std::string UnParse(const std::string& format = "ARCJSDL") const;
00272 
00273     // Returns with the original job descriptions format as a string. Right now, this value is one of the following:
00274     // "jsdl", "jdl", "xrsl". If there is an other parser written for another language, then this set can be extended.
00275     bool getSourceFormat(std::string& _sourceFormat) const;
00276 
00277     // Print all value to the standard output.
00278     void Print(bool longlist = false) const;
00279 
00280     void AddHint(const std::string& key,const std::string& value);
00281 
00282     JobIdentificationType Identification;
00283     ApplicationType Application;
00284     ResourcesType Resources;
00285     DataStagingType DataStaging;
00286     JobMetaType JobMeta;
00287 
00288     // Other elements which is needed for submission using the respective languages.
00289     std::map<std::string, std::string> XRSL_elements;
00290     std::map<std::string, std::string> JDL_elements;
00291 
00292   private:
00293     std::string sourceFormat;
00294 
00295     static Logger logger;
00296 
00297     std::map<std::string,std::string> hints;
00298   };
00299 
00300 } // namespace Arc
00301 
00302 #endif // __ARC_JOBDESCRIPTION_H__