Back to index

nordugrid-arc-nox  1.1.0~rc6
info_files.h
Go to the documentation of this file.
00001 #ifndef GRID_MANAGER_INFO_FILES_H
00002 #define GRID_MANAGER_INFO_FILES_H
00003 
00004 #include <string>
00005 #include <list>
00006 
00007 #include "../jobs/states.h"
00008 #include "../jobs/users.h"
00009 #include "info_types.h"
00010 
00011 /*
00012   Definition of functions used to manipulate files used to stored
00013   information about jobs.
00014   Most used arguments:
00015    desc - description of job. Mostly used to obtain job identifier
00016      and directories associated with job.
00017    user - description of user (owner of job). Used to obtain directories
00018      associated with it.
00019    id - job identifier. Used to derive names of files.
00020 */
00021 /* 
00022   job status files:
00023    files           created by    modified by   read by     root?
00024   lrms_mark       helper        -             gm          yes/no
00025   cancel_mark     job_manager   gm            gm          no
00026   clean_mark      job_manager   gm            gm          no
00027   failed_mark     gm            gm            +           yes
00028   state           job_manager   gm            gm          no
00029   description     job_manager   -             gm          no
00030   input           gm            downloader    downloader  yes/no
00031   output          gm            uploader      uploader    yes/no
00032   local           job_manager   gm            +           no
00033 */
00034 
00035 /*
00036 extern job_state_rec_t states_all[JOB_STATE_UNDEFINED+1];
00037 */
00038 /*
00039   Set permissions of file 'fname' to -rw------- or if 'executable' is set
00040   to - -rwx--------- .
00041 */
00042 bool fix_file_permissions(const std::string &fname,bool executable = false);
00043 /*
00044   Set owner of file 'fname' to one specified in 'desc' or 'user'. 
00045   'desc' has priority if set.
00046 */
00047 bool fix_file_owner(const std::string &fname,const JobUser &user);
00048 bool fix_file_owner(const std::string &fname,const JobDescription &desc,const JobUser &user);
00049 /*
00050   Check if file is owned by user as configured in 'user'. If 'user' is
00051   special user (equivalent to root) any file is accepted.
00052   Returns:
00053    true - belongs
00054    false - does not belong or error.
00055    If file exists 'uid', 'gid' and 't' are set to uid, gid and creation
00056    of that file.
00057 */
00058 bool check_file_owner(const std::string &fname,const JobUser &user);
00059 bool check_file_owner(const std::string &fname,const JobUser &user,uid_t &uid,gid_t &gid);
00060 bool check_file_owner(const std::string &fname,const JobUser &user,uid_t &uid,gid_t &gid,time_t &t);
00061 
00062 /*
00063   Check existance, remove and read content of file used to mark 
00064   job finish in LRMS. This file is created by external script/executable
00065   after it detects job exited and contains exit code of that job.
00066 */
00067 bool job_lrms_mark_put(const JobDescription &desc,JobUser &user,int code);
00068 bool job_lrms_mark_put(const JobDescription &desc,JobUser &user,LRMSResult r);
00069 bool job_lrms_mark_check(JobId &id,JobUser &user);
00070 bool job_lrms_mark_remove(JobId &id,JobUser &user);
00071 LRMSResult job_lrms_mark_read(JobId &id,JobUser &user);
00072 
00073 /*
00074   Create, check existance and remove file used to mark cancelation
00075   request for specified job. The content of file is not important.
00076 */
00077 bool job_cancel_mark_put(const JobDescription &desc,JobUser &user);
00078 bool job_cancel_mark_check(JobId &id,JobUser &user);
00079 bool job_cancel_mark_remove(JobId &id,JobUser &user);
00080 
00081 /*
00082   Create, check existance and remove file used to mark request to
00083   restart job. The content of file is not important.
00084 */
00085 bool job_restart_mark_put(const JobDescription &desc,JobUser &user);
00086 bool job_restart_mark_check(JobId &id,JobUser &user);
00087 bool job_restart_mark_remove(JobId &id,JobUser &user);
00088 /*
00089   Same for file, which marks job cleaning/removal request
00090 */
00091 bool job_clean_mark_put(const JobDescription &desc,JobUser &user);
00092 bool job_clean_mark_check(JobId &id,JobUser &user);
00093 bool job_clean_mark_remove(JobId &id,JobUser &user);
00094 
00095 /*
00096   Create (with given content), add to content, check for existance, delete
00097   and read content of file used to mark failure of the job. 
00098   Content describes reason of failure (usually 1-2 strings).
00099 */
00100 bool job_failed_mark_put(const JobDescription &desc,JobUser &user,const std::string &content = "");
00101 bool job_failed_mark_add(const JobDescription &desc,JobUser &user,const std::string &content);
00102 bool job_failed_mark_check(const JobId &id,JobUser &user);
00103 bool job_failed_mark_remove(const JobId &id,JobUser &user);
00104 std::string job_failed_mark_read(const JobId &id,JobUser &user);
00105 
00106 /*
00107   Create, add content, delete and move from session to control directory
00108   file holding information about resources used by job while running.
00109   Content is normally produced by "time" utility.
00110 */
00111 bool job_controldiag_mark_put(const JobDescription &desc,JobUser &user,char const * const args[]);
00112 bool job_diagnostics_mark_put(const JobDescription &desc,JobUser &user);
00113 bool job_diagnostics_mark_add(const JobDescription &desc,JobUser &user,const std::string &content);
00114 bool job_diagnostics_mark_remove(const JobDescription &desc,JobUser &user);
00115 bool job_diagnostics_mark_move(const JobDescription &desc,JobUser &user);
00116 
00117 /*
00118   Create session directory for job
00119 */
00120 bool job_session_create(const JobDescription &desc,JobUser &user);
00121 
00122 /*
00123   Same (except add) for file containing messages from LRMS, which
00124   could give additional information about reason of job failure.
00125 */
00126 bool job_lrmsoutput_mark_put(const JobDescription &desc,JobUser &user);
00127 /*
00128   This functionality should now go into LRMS backend
00129 bool job_lrmsoutput_mark_remove(const JobDescription &desc,JobUser &user);
00130 bool job_lrmsoutput_mark_move(const JobDescription &desc,JobUser &user);
00131 bool job_lrmsoutput_mark_get(JobDescription &desc,JobUser &user);
00132 */
00133 
00134 /*
00135   Common purpose functions, used by previous functions.
00136 */
00137 std::string job_mark_read_s(const std::string &fname);
00138 long int job_mark_read_i(const std::string &fname);
00139 bool job_mark_write_s(const std::string &fname,const std::string &content);
00140 bool job_mark_add_s(const std::string &fname,const std::string &content);
00141 bool job_mark_put(const std::string &fname);
00142 bool job_mark_check(const std::string &fname);
00143 bool job_mark_remove(const std::string &fname);
00144 time_t job_mark_time(const std::string &fname);
00145 long int job_mark_size(const std::string &fname);
00146 bool job_dir_create(const std::string &dname);
00147 
00148 /*
00149   Create file to store stderr of external utilities used to stage-in/out
00150   data, submit/cancel job in LRMS.
00151 */
00152 bool job_errors_mark_put(const JobDescription &desc,JobUser &user);
00153 
00154 /*
00155   Get modification time of file used to store state of the job.
00156 */
00157 time_t job_state_time(const JobId &id,JobUser &user);
00158 
00159 /*
00160   Read and write file storing state of the job.
00161 */
00162 job_state_t job_state_read_file(const JobId &id,const JobUser &user);
00163 job_state_t job_state_read_file(const JobId &id,const JobUser &user,bool &pending);
00164 job_state_t job_state_read_file(const std::string &fname,bool &pending);
00165 bool job_state_write_file(const JobDescription &desc,JobUser &user,job_state_t state,bool pending = false);
00166 bool job_state_write_file(const std::string &fname,job_state_t state,bool pending = false);
00167 
00168 /*
00169   Read and write file used to store RSL description of job.
00170 */
00171 bool job_description_read_file(JobId &id,JobUser &user,std::string &rsl);
00172 bool job_description_read_file(const std::string &fname,std::string &rsl);
00173 bool job_description_write_file(const std::string &fname,std::string &rsl);
00174 bool job_description_write_file(const std::string &fname,const char* rsl);
00175 
00176 /*
00177   Read and write file used to store ACL of job.
00178 */
00179 bool job_acl_read_file(JobId &id,JobUser &user,std::string &acl);
00180 bool job_acl_write_file(JobId &id,JobUser &user,std::string &acl);
00181 
00182 /*
00183   Not used
00184 */
00185 bool job_cache_write_file(const JobDescription &desc,JobUser &user,std::list<FileData> &files);
00186 bool job_cache_read_file(const JobId &id,JobUser &user,std::list<FileData> &files);
00187 
00188 /*
00189   Write and read file containing list of output files. Each line of file
00190   contains name of output file relative to session directory and optionally
00191   destination, to which it should be transfered.
00192 */
00193 bool job_output_write_file(const JobDescription &desc,JobUser &user,std::list<FileData> &files);
00194 bool job_output_read_file(const JobId &id,JobUser &user,std::list<FileData> &files);
00195 
00196 /*
00197   Same for input files and their sources.
00198 */
00199 bool job_input_write_file(const JobDescription &desc,JobUser &user,std::list<FileData> &files);
00200 bool job_input_read_file(const JobId &id,JobUser &user,std::list<FileData> &files);
00201 
00202 std::string job_proxy_filename(const JobId &id, const JobUser &user);
00203 /*
00204   Same for RTEs.
00205 */
00206 bool job_rte_write_file(const JobDescription &desc,JobUser &user,std::list<std::string> &rtes);
00207 bool job_rte_read_file(const JobId &id,JobUser &user,std::list<std::string> &rtes);
00208 
00209 /*
00210   Functions used by previous functions.
00211 */
00212 bool job_Xput_write_file(const std::string &fname,std::list<FileData> &files);
00213 bool job_Xput_read_file(const std::string &fname,std::list<FileData> &files);
00214 bool job_Xput_read_file(std::list<FileData> &files);
00215 bool job_strings_write_file(const std::string &fname,std::list<std::string> &strs);
00216 bool job_strings_read_file(const std::string &fname,std::list<std::string> &strs);
00217 
00218 /*
00219   Write and read file, containing most important/needed job parameters.
00220   Information is passed to/from file through 'job_desc' object.
00221 */
00222 bool job_local_write_file(const JobDescription &desc,const JobUser &user,const JobLocalDescription &job_desc);
00223 bool job_local_write_file(const std::string &fname,const JobLocalDescription &job_desc);
00224 bool job_local_read_file(const JobId &id,const JobUser &user,JobLocalDescription &job_desc);
00225 bool job_local_read_file(const std::string &fname,JobLocalDescription &job_desc);
00226 // bool job_local_read_string(const std::string &fname,unsigned int num,std::string &str);
00227 
00228 /*
00229   Read only some attributes from previously mentioned file.
00230 */
00231 bool job_local_read_notify(const JobId &id,const JobUser &user,std::string &notify);
00232 bool job_local_read_lifetime(const JobId &id,const JobUser &user,time_t &lifetime);
00233 bool job_local_read_cleanuptime(const JobId &id,const JobUser &user,time_t &cleanuptime);
00234 
00235 /*
00236   Not used
00237 */
00238 bool job_diskusage_create_file(const JobDescription &desc,JobUser &user,unsigned long long int &requested);
00239 bool job_diskusage_read_file(const JobDescription &desc,JobUser &user,unsigned long long int &requested,unsigned long long int &used);
00240 bool job_diskusage_change_file(const JobDescription &desc,JobUser &user,signed long long int used,bool &result);
00241 bool job_diskusage_remove_file(const JobDescription &desc,JobUser &user);
00242 
00243 /*
00244   Concatenate files containing diagnostics and stderr of external utilities
00245   and write to separate file in jobs directories (as requested by user).  
00246 */
00247 bool job_stdlog_move(const JobDescription &desc,JobUser &user,const std::string &logname);
00248 
00249 /*
00250   Remove all files, which should be removed after job's state becomes FINISHED
00251 */
00252 bool job_clean_finished(const JobId &id,JobUser &user);
00253 
00254 /*
00255   Remove all files, which should be removed after job's state becomes DELETED
00256 */
00257 bool job_clean_deleted(const JobDescription &desc,JobUser &user, std::list<std::string> cache_per_job_dirs=std::list<std::string>());
00258 
00259 /*
00260   Remove all job's files.
00261 */
00262 bool job_clean_final(const JobDescription &desc,JobUser &user);
00263 
00264 #endif
00265