Back to index

nordugrid-arc-nox  1.1.0~rc6
job_log.h
Go to the documentation of this file.
00001 /* write essential inforamtion about job started/finished */
00002 #ifndef __GM_JOB_LOG_H__
00003 #define __GM_JOB_LOG_H__
00004 
00005 #include <string>
00006 #include <list>
00007 #include <fstream>
00008 #include "../misc/escaped.h"
00009 #include "../jobs/job.h"
00010 #include "../jobs/users.h"
00011 #include "../run/run_parallel.h"
00012 
00015 class JobLog {
00016  private:
00017   std::string filename;
00018   std::list<std::string> urls;
00019   std::list<std::string> report_config; // additional configuration for usage reporter
00020   std::string certificate_path;
00021   std::string ca_certificates_dir;
00022   Arc::Run *proc;
00023   time_t last_run;
00024   time_t ex_period;
00025   bool open_stream(std::ofstream &o);
00026  public:
00027   JobLog(void);
00028   JobLog(const char* fname);
00029   ~JobLog(void);
00030   /* chose name of log file */
00031   void SetOutput(const char* fname);
00032   /* log job start information */
00033   bool start_info(JobDescription &job,const JobUser &user);
00034   /* log job finish iformation */
00035   bool finish_info(JobDescription &job,const JobUser &user);
00036   /* read information stored by start_info and finish_info */
00037   static bool read_info(std::fstream &i,bool &processed,bool &jobstart,struct tm &t,JobId &jobid,JobLocalDescription &job_desc,std::string &failure);
00038   bool is_reporting(void) { return (urls.size() > 0); };
00039   /* Run external utility to report gathered information to logger service */
00040   bool RunReporter(JobUsers& users);
00041   /* Set url of service and local name to use */
00042   // bool SetReporter(const char* destination,const char* name = NULL);
00043   bool SetReporter(const char* destination);
00044   /* Set after which too old logger information is removed */
00045   void SetExpiration(time_t period = 0);
00046   /* Create data file for Reporter */
00047   bool make_file(JobDescription &job,JobUser &user);
00048   /* Set credential file names for accessing logging service */
00049   void set_credentials(std::string &key_path,std::string &certificate_path,std::string &ca_certificates_dir);
00050   /* Set accounting options (e.g. batch size for SGAS LUTS) */
00051   void set_options(std::string &options) { report_config.push_back(std::string("accounting_options=")+options); }
00052 };
00053 
00054 #endif