remote_submit.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. // This file is part of BOINC.
  2. // http://boinc.berkeley.edu
  3. // Copyright (C) 2013 University of California
  4. //
  5. // BOINC is free software; you can redistribute it and/or modify it
  6. // under the terms of the GNU Lesser General Public License
  7. // as published by the Free Software Foundation,
  8. // either version 3 of the License, or (at your option) any later version.
  9. //
  10. // BOINC is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. // See the GNU Lesser General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Lesser General Public License
  16. // along with BOINC. If not, see <http://www.gnu.org/licenses/>.
  17. // C++ interfaces to remote job submission and file management RPCs
  18. // See http://boinc.berkeley.edu/trac/wiki/RemoteJobs#Cinterface
  19. #ifndef BOINC_REMOTE_SUBMIT_H
  20. #define BOINC_REMOTE_SUBMIT_H
  21. #include <stdio.h>
  22. #include <string>
  23. #include <vector>
  24. #include <map>
  25. #include "parse.h"
  26. // Input file modes.
  27. // Only LOCAL_STAGED and REMOTE are implemented now.
  28. //
  29. #define FILE_MODE_LOCAL 1
  30. #define FILE_MODE_LOCAL_STAGED 2
  31. #define FILE_MODE_SEMILOCAL 3
  32. #define FILE_MODE_INLINE 4
  33. #define FILE_MODE_REMOTE 5
  34. struct INFILE {
  35. int mode; // see above
  36. char logical_name[256];
  37. // filename on execution machine.
  38. // Supplied by Condor, but not currently used.
  39. // could be used to check consistency w/ input template
  40. char src_path[256];
  41. // path on submit machine
  42. // used by Condor GAHP; not part of the API
  43. // the following used for LOCAL_STAGED
  44. char physical_name[256]; // BOINC physical name
  45. // the following used for REMOTE
  46. char url[256];
  47. double nbytes;
  48. char md5[256];
  49. };
  50. struct JOB {
  51. char job_name[256];
  52. std::string cmdline_args;
  53. std::vector<INFILE> infiles;
  54. };
  55. struct JOB_STATUS {
  56. std::string job_name;
  57. std::string status;
  58. JOB_STATUS(){}
  59. };
  60. struct JOB_PARAMS {
  61. // 0 means unspecified for all params
  62. double rsc_disk_bound;
  63. double rsc_fpops_est;
  64. double rsc_fpops_bound;
  65. double rsc_memory_bound;
  66. double delay_bound;
  67. JOB_PARAMS(): rsc_disk_bound(0), rsc_fpops_est(0),rsc_fpops_bound(0),
  68. rsc_memory_bound(0), delay_bound(0) {}
  69. };
  70. struct QUERY_BATCH_SET_REPLY {
  71. double server_time; // server time at start of query
  72. std::vector<int> batch_sizes; // how many jobs in each of the queried batches
  73. std::vector<JOB_STATUS> jobs; // the jobs, sequentially
  74. };
  75. struct OUTFILE {
  76. char src[256]; // logical name
  77. char dest[256]; // name or path on submit host
  78. };
  79. struct FETCH_OUTPUT_REQ {
  80. char job_name[256];
  81. char dir[256];
  82. bool fetch_all;
  83. std::string stderr_filename;
  84. std::vector<OUTFILE> file_descs;
  85. };
  86. struct TEMPLATE_DESC {
  87. std::vector<std::string> input_files;
  88. std::vector<std::string> output_files;
  89. int parse(XML_PARSER&);
  90. };
  91. // describes a job that's completed, successfully or not
  92. //
  93. struct COMPLETED_JOB_DESC {
  94. int canonical_resultid;
  95. int error_mask;
  96. int error_resultid; // if error_mask is nonzero, this may be set
  97. // the following fields describe either the canonical or error result
  98. int exit_status;
  99. double elapsed_time;
  100. double cpu_time;
  101. std::string stderr_out;
  102. int parse(XML_PARSER&);
  103. };
  104. //////////////////////////
  105. extern int query_files(
  106. const char* project_url,
  107. const char* authenticator,
  108. std::vector<std::string> &boinc_names,
  109. int batch_id,
  110. std::vector<int> &absent_files,
  111. std::string& error_msg
  112. );
  113. extern int upload_files (
  114. const char* project_url,
  115. const char* authenticator,
  116. std::vector<std::string> &paths,
  117. std::vector<std::string> &boinc_names,
  118. int batch_id,
  119. std::string& error_msg
  120. );
  121. extern int create_batch(
  122. const char* project_url,
  123. const char* authenticator,
  124. const char* batch_name,
  125. const char* app_name,
  126. double expire_time,
  127. int &batch_id,
  128. std::string& error_msg
  129. );
  130. extern int submit_jobs(
  131. const char* project_url,
  132. const char* authenticator,
  133. char app_name[256],
  134. int batch_id,
  135. std::vector<JOB> jobs,
  136. std::string& error_msg,
  137. int app_version_num = 0
  138. );
  139. extern int submit_jobs_params(
  140. const char* project_url,
  141. const char* authenticator,
  142. char app_name[256],
  143. int batch_id,
  144. std::vector<JOB> jobs,
  145. std::string& error_msg,
  146. JOB_PARAMS &job_params,
  147. int app_version_num
  148. );
  149. extern int estimate_batch(
  150. const char* project_url,
  151. const char* authenticator,
  152. char app_name[256],
  153. std::vector<JOB> jobs,
  154. double& est_makespan,
  155. std::string& error_msg
  156. );
  157. // Return the short status of the jobs in a given set of batches
  158. // Used by the Condor interface
  159. //
  160. extern int query_batch_set(
  161. const char* project_url,
  162. const char* authenticator,
  163. double min_mod_time,
  164. std::vector<std::string> &batch_names,
  165. QUERY_BATCH_SET_REPLY& reply,
  166. std::string& error_msg
  167. );
  168. struct BATCH_STATUS {
  169. int id;
  170. char name[256]; // name of batch
  171. char app_name[256];
  172. int state; // see lib/common_defs.h
  173. int njobs; // how many jobs in batch
  174. int nerror_jobs; // how many jobs errored out
  175. double fraction_done; // how much of batch is done (0..1)
  176. double create_time; // when batch was created
  177. double expire_time; // when it will expire
  178. double est_completion_time; // estimated completion time
  179. double completion_time; // if completed, actual completion time
  180. double credit_estimate; // original estimate for credit
  181. double credit_canonical; // if completed, granted credit
  182. BATCH_STATUS(){}
  183. int parse(XML_PARSER&);
  184. void print();
  185. };
  186. // Return a list of this user's batches
  187. //
  188. extern int query_batches(
  189. const char* project_url,
  190. const char* authenticator,
  191. std::vector<BATCH_STATUS>& batches,
  192. std::string& error_msg
  193. );
  194. struct JOB_STATE {
  195. int id;
  196. char name[256];
  197. int canonical_instance_id; // it job completed successfully,
  198. // the ID of the canonical instance
  199. int n_outfiles; // number of output files
  200. JOB_STATE(){}
  201. int parse(XML_PARSER&);
  202. void print();
  203. };
  204. // Return the state of jobs in a given batch
  205. // (can specify by either ID or name)
  206. //
  207. extern int query_batch(
  208. const char* project_url,
  209. const char* authenticator,
  210. int batch_id,
  211. const char batch_name[256],
  212. std::vector<JOB_STATE>& jobs,
  213. std::string& error_msg
  214. );
  215. extern int get_output_file(
  216. const char* project_url,
  217. const char* authenticator,
  218. const char* job_name,
  219. int file_num,
  220. const char* dst_path,
  221. std::string& error_msg
  222. );
  223. extern int abort_jobs(
  224. const char* project_url,
  225. const char* authenticator,
  226. std::vector<std::string> &job_names,
  227. std::string& error_msg
  228. );
  229. extern int query_completed_job(
  230. const char* project_url,
  231. const char* authenticator,
  232. const char* job_name,
  233. COMPLETED_JOB_DESC&,
  234. std::string& error_msg
  235. );
  236. extern int get_templates(
  237. const char* project_url,
  238. const char* authenticator,
  239. const char* app_name, // either this
  240. const char* job_name, // or this must be non-NULL
  241. TEMPLATE_DESC&,
  242. std::string& error_msg
  243. );
  244. extern int retire_batch(
  245. const char* project_url,
  246. const char* authenticator,
  247. const char* batch_name,
  248. std::string& error_msg
  249. );
  250. extern int set_expire_time(
  251. const char* project_url,
  252. const char* authenticator,
  253. const char* batch_name,
  254. double expire_time,
  255. std::string& error_msg
  256. );
  257. extern int ping_server(
  258. const char* project_url,
  259. std::string& error_msg
  260. );
  261. #endif