Salome HOME
Add job parameter mem_per_cpu (EDF issue #2671)
[modules/kernel.git] / src / Launcher / Launcher_Job.cxx
1 // Copyright (C) 2009-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // Author: AndrĂ© RIBES - EDF R&D
21 //
22 #include "Launcher_Job.hxx"
23 #include "Launcher.hxx"
24
25 #ifdef WITH_LIBBATCH
26 #include <libbatch/Constants.hxx>
27 #endif
28
29 using namespace std;
30
31 Launcher::Job::Job()
32 {
33   _number = -1;
34   _state = "CREATED";
35   _launch_date = getLaunchDate();
36
37   _env_file = "";
38   _job_name = "";
39   _job_file = "";
40   _job_file_name = "";
41   _job_file_name_complete = "";
42   _work_directory = "";
43   _local_directory = "";
44   _result_directory = "";
45   _maximum_duration = "";
46   _maximum_duration_in_second = -1;
47   _resource_required_params.name = "";
48   _resource_required_params.hostname = "";
49   _resource_required_params.OS = "";
50   _resource_required_params.nb_proc = -1;
51   _resource_required_params.nb_node = -1;
52   _resource_required_params.nb_proc_per_node = -1;
53   _resource_required_params.cpu_clock = -1;
54   _resource_required_params.mem_mb = -1;
55   _queue = "";
56   _job_type = "";
57   _exclusive = false;
58   _mem_per_cpu = 0;
59
60   // Parameters for COORM
61   _launcher_file = "";
62   _launcher_args = "";
63
64 #ifdef WITH_LIBBATCH
65   _batch_job = new Batch::Job();
66 #endif
67 }
68
69 Launcher::Job::~Job() 
70 {
71   LAUNCHER_MESSAGE("Deleting job number: " << _number);
72 #ifdef WITH_LIBBATCH
73   if (_batch_job)
74     delete _batch_job;
75 #endif
76 }
77
78 void
79 Launcher::Job::stopJob()
80 {
81   LAUNCHER_MESSAGE("Stop resquested for job number: " << _number);
82   setState("FAILED");
83 #ifdef WITH_LIBBATCH
84   if (_batch_job_id.getReference() != "undefined")
85   {
86     try 
87     {
88       _batch_job_id.deleteJob();
89     }
90     catch (const Batch::GenericException &ex)
91     {
92       LAUNCHER_INFOS("WARNING: exception when stopping the job: " << ex.message);
93     }
94   }
95 #endif
96 }
97
98
99 void
100 Launcher::Job::removeJob()
101 {
102   LAUNCHER_MESSAGE("Removing job number: " << _number);
103 #ifdef WITH_LIBBATCH
104   if (_batch_job_id.getReference() != "undefined")
105   {
106     try 
107     {
108       _batch_job_id.deleteJob();
109     }
110     catch (const Batch::GenericException &ex)
111     {
112       LAUNCHER_INFOS("WARNING: exception when removing the job: " << ex.message);
113     }
114   }
115 #endif
116 }
117
118 std::string
119 Launcher::Job::getJobType()
120 {
121   return _job_type;
122 }
123
124 void
125 Launcher::Job::setJobName(const std::string & job_name)
126 {
127   _job_name = job_name;
128 }
129
130 std::string
131 Launcher::Job::getJobName()
132 {
133   return _job_name;
134 }
135
136 void 
137 Launcher::Job::setState(const std::string & state)
138 {
139   // State of a Job: CREATED, QUEUED, RUNNING, FINISHED, FAILED
140   if (state != "CREATED" &&
141       state != "IN_PROCESS" &&
142       state != "QUEUED" &&
143       state != "RUNNING" &&
144       state != "PAUSED" &&
145       state != "FINISHED" &&
146       state != "FAILED" &&
147       state != "ERROR")
148   {
149     throw LauncherException("Bad state, this state does not exist: " + state);
150   }
151   _state = state;
152 }
153
154 std::string 
155 Launcher::Job::getState()
156 {
157   return _state;
158 }
159
160 // Get names or ids of hosts assigned to the job
161 std::string
162 Launcher::Job::getAssignedHostnames()
163 {
164   return _assigned_hostnames;
165 }
166
167 void 
168 Launcher::Job::setNumber(const int & number)
169 {
170   if (_number != -1)
171     std::cerr << "Launcher::Job::setNumber -- Job number was already defined, before: " << _number << " now: " << number << std::endl;
172   _number = number;
173 }
174
175 int
176 Launcher::Job::getNumber()
177 {
178   return _number;
179 }
180
181 void 
182 Launcher::Job::setResourceDefinition(const ParserResourcesType & resource_definition)
183 {
184   // Check machine_definition
185   std::string user_name = "";
186   if (resource_definition.UserName == "")
187   {
188     user_name = getenv("USER");
189     if (user_name == "")
190     {
191       std::string mess = "You must define a user name: into your resource description or with env variable USER";
192       throw LauncherException(mess);
193     }
194   }
195   else
196     user_name = resource_definition.UserName;
197
198   _resource_definition = resource_definition;
199   _resource_definition.UserName = user_name;
200 }
201
202 ParserResourcesType 
203 Launcher::Job::getResourceDefinition()
204 {
205   return _resource_definition;
206 }
207
208 void 
209 Launcher::Job::setJobFile(const std::string & job_file)
210 {
211   // Check job file
212   if (job_file == "")
213   {
214     std::string mess = "Empty Job File is forbidden !";
215     throw LauncherException(mess);
216   }
217
218   _job_file = job_file;
219   std::string::size_type p1 = _job_file.find_last_of("/");
220   std::string::size_type p2 = _job_file.find_last_of(".");
221   _job_file_name_complete = _job_file.substr(p1+1);
222   _job_file_name = _job_file.substr(p1+1,p2-p1-1);
223 }
224
225 std::string
226 Launcher::Job::getJobFile()
227 {
228   return _job_file;
229 }
230 void 
231 Launcher::Job::setEnvFile(const std::string & env_file)
232 {
233   _env_file = env_file;
234 }
235
236 std::string
237 Launcher::Job::getEnvFile()
238 {
239   return _env_file;
240 }
241
242 void 
243 Launcher::Job::setWorkDirectory(const std::string & work_directory)
244 {
245   _work_directory = work_directory;
246 }
247
248 void 
249 Launcher::Job::setLocalDirectory(const std::string & local_directory)
250 {
251   _local_directory = local_directory;
252 }
253
254 void 
255 Launcher::Job::setResultDirectory(const std::string & result_directory)
256 {
257   _result_directory = result_directory;
258 }
259
260 void 
261 Launcher::Job::add_in_file(const std::string & file)
262 {
263   std::list<std::string>::iterator it = std::find(_in_files.begin(), _in_files.end(), file);
264   if (it == _in_files.end())
265     _in_files.push_back(file);
266   else
267     std::cerr << "Launcher::Job::add_in_file -- Warning file was already entered in in_files: " << file << std::endl;
268 }
269
270 void 
271 Launcher::Job::add_out_file(const std::string & file)
272 {
273   std::list<std::string>::iterator it = std::find(_out_files.begin(), _out_files.end(), file);
274   if (it == _out_files.end())
275     _out_files.push_back(file);
276   else
277     std::cerr << "Launcher::Job::add_out_file -- Warning file was already entered in out_files: " << file << std::endl;
278 }
279
280 void 
281 Launcher::Job::setMaximumDuration(const std::string & maximum_duration)
282 {
283   checkMaximumDuration(maximum_duration);
284   _maximum_duration_in_second = convertMaximumDuration(maximum_duration);
285   _maximum_duration = maximum_duration;
286 }
287
288 // For COORM
289 void
290 Launcher::Job::setLauncherFile(const std::string & launcher_file)
291 {
292         _launcher_file = launcher_file;
293 }
294 void
295 Launcher::Job::setLauncherArgs(const std::string & launcher_args)
296 {
297         _launcher_args = launcher_args;
298 }
299
300 void 
301 Launcher::Job::setResourceRequiredParams(const resourceParams & resource_required_params)
302 {
303   checkResourceRequiredParams(resource_required_params);
304   _resource_required_params = resource_required_params;
305 }
306
307 void 
308 Launcher::Job::setQueue(const std::string & queue)
309 {
310   _queue = queue;
311 }
312
313 void
314 Launcher::Job::setExclusive(bool exclusive)
315 {
316   _exclusive = exclusive;
317 }
318
319 void
320 Launcher::Job::setExclusiveStr(const std::string & exclusiveStr)
321 {
322   if (exclusiveStr == "true")
323     _exclusive = true;
324   else if (exclusiveStr == "false")
325     _exclusive = false;
326   else
327     throw LauncherException(std::string("Invalid boolean value for exclusive: ") + exclusiveStr);
328 }
329
330 void
331 Launcher::Job::setMemPerCpu(unsigned long mem_per_cpu)
332 {
333   _mem_per_cpu = mem_per_cpu;
334 }
335
336 std::string 
337 Launcher::Job::getWorkDirectory()
338 {
339   return _work_directory;
340 }
341
342 std::string 
343 Launcher::Job::getLocalDirectory()
344 {
345   return _local_directory;
346 }
347
348 std::string
349 Launcher::Job::getResultDirectory()
350 {
351   return _result_directory;
352 }
353
354 const std::list<std::string> & 
355 Launcher::Job::get_in_files()
356 {
357   return _in_files;
358 }
359
360 const std::list<std::string> & 
361 Launcher::Job::get_out_files()
362 {
363   return _out_files;
364 }
365
366 std::string 
367 Launcher::Job::getMaximumDuration()
368 {
369   return _maximum_duration;
370 }
371
372 // For COORM
373 std::string
374 Launcher::Job::getLauncherFile()
375 {
376         return _launcher_file;
377 }
378 std::string
379 Launcher::Job::getLauncherArgs()
380 {
381         return _launcher_args;
382 }
383
384 resourceParams 
385 Launcher::Job::getResourceRequiredParams()
386 {
387   return _resource_required_params;
388 }
389
390 std::string 
391 Launcher::Job::getQueue()
392 {
393   return _queue;
394 }
395
396 bool
397 Launcher::Job::getExclusive()
398 {
399   return _exclusive;
400 }
401
402 std::string
403 Launcher::Job::getExclusiveStr() const
404 {
405   return _exclusive ? "true" : "false";
406 }
407
408 unsigned long
409 Launcher::Job::getMemPerCpu() const
410 {
411   return _mem_per_cpu;
412 }
413
414 void 
415 Launcher::Job::checkMaximumDuration(const std::string & maximum_duration)
416 {
417   std::string result("");
418   std::string edt_value = maximum_duration;
419   std::size_t pos = edt_value.find(":");
420
421   if (edt_value != "") {
422     if (pos == edt_value.npos) {
423       throw LauncherException("[Launcher::Job::checkMaximumDuration] Error on definition: " + edt_value);
424     }
425     std::string begin_edt_value = edt_value.substr(0, pos);
426     std::string mid_edt_value = edt_value.substr(pos, 1);
427     std::string end_edt_value = edt_value.substr(pos + 1, edt_value.npos);
428   
429     long value;
430     std::istringstream iss(begin_edt_value);
431     if (!(iss >> value)) {
432       result = "[Launcher::Job::checkExpectedDuration] Error on definition ! : " + edt_value;
433     }
434     else if (value < 0) {
435       result = "[Launcher::Job::checkExpectedDuration] Error on definition time is negative ! : " + value;
436     }
437     std::istringstream iss_2(end_edt_value);
438     if (!(iss_2 >> value)) {
439       result = "[Launcher::Job::checkExpectedDuration] Error on definition ! : " + edt_value;
440     }
441     else if (value < 0) {
442       result = "[Launcher::Job::checkExpectedDuration] Error on definition time is negative ! : " + value;
443     }
444     if (mid_edt_value != ":") {
445       result = "[Launcher::Job::checkExpectedDuration] Error on definition ! :" + edt_value;
446     }
447   }
448   if (result != "")
449     throw LauncherException(result);
450 }
451
452 void 
453 Launcher::Job::checkResourceRequiredParams(const resourceParams & resource_required_params)
454 {
455   // nb_proc has be to > 0
456   if (resource_required_params.nb_proc <= 0)
457   {
458     std::string message("[Launcher::Job::checkResourceRequiredParams] proc number is not > 0 ! ");
459     throw LauncherException(message);
460   }
461 }
462
463 long 
464 Launcher::Job::convertMaximumDuration(const std::string & edt)
465 {
466   long hh, mm, ret;
467
468   if( edt.size() == 0 )
469     return -1;
470
471   std::string::size_type pos = edt.find(":");
472   std::string h = edt.substr(0,pos);
473   std::string m = edt.substr(pos+1,edt.size()-pos+1);
474   std::istringstream issh(h);
475   issh >> hh;
476   std::istringstream issm(m);
477   issm >> mm;
478   ret = hh*60 + mm;
479   ret = ret * 60;
480
481   return ret;
482 }
483
484 std::string 
485 Launcher::Job::getLaunchDate()
486 {
487   time_t rawtime;
488   time(&rawtime);
489   std::string launch_date = ctime(&rawtime);
490   int i = 0 ;
491   for (;i < launch_date.size(); i++) 
492     if (launch_date[i] == '/' ||
493         launch_date[i] == '-' ||
494         launch_date[i] == ':' ||
495         launch_date[i] == ' ') 
496       launch_date[i] = '_';
497   launch_date.erase(--launch_date.end()); // Last caracter is a \n
498
499   return launch_date;
500 }
501
502 std::string
503 Launcher::Job::updateJobState()
504 {
505
506   if (_state != "FINISHED" &&
507       _state != "ERROR"    &&
508       _state != "FAILED")
509   {
510 #ifdef WITH_LIBBATCH
511     if (_batch_job_id.getReference() != "undefined")
512     {
513       // A batch manager has been affected to the job
514       Batch::JobInfo job_info = _batch_job_id.queryJob();
515       Batch::Parametre par = job_info.getParametre();
516       _state = par[Batch::STATE].str();
517       _assigned_hostnames = (par.find(Batch::ASSIGNEDHOSTNAMES) == par.end())?
518                             "" : par[Batch::ASSIGNEDHOSTNAMES].str();
519       LAUNCHER_MESSAGE("State received is: " << par[Batch::STATE].str());
520     }
521 #endif
522   }
523   return _state;
524 }
525
526 #ifdef WITH_LIBBATCH
527 Batch::Job * 
528 Launcher::Job::getBatchJob()
529 {
530   update_job();
531   return _batch_job;
532 }
533
534 Batch::Parametre
535 Launcher::Job::common_job_params()
536 {
537   Batch::Parametre params;
538
539   params[Batch::NAME] = getJobName();
540   params[Batch::NBPROC] = _resource_required_params.nb_proc;
541   params[Batch::NBPROCPERNODE] = _resource_required_params.nb_proc_per_node;
542
543   // Memory in megabytes
544   if (_resource_required_params.mem_mb > 0)
545   {
546     params[Batch::MAXRAMSIZE] = _resource_required_params.mem_mb;
547   }
548   else if (_mem_per_cpu > 0)
549   {
550     params[Batch::MEMPERCPU] = (long)_mem_per_cpu;
551   }
552
553   // We define a default directory based on user time
554   if (_work_directory == "")
555   {
556     const size_t BUFSIZE = 32;
557     char date[BUFSIZE];
558     time_t curtime = time(NULL);
559     strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime));
560     _work_directory = std::string("$HOME/Batch/workdir_");
561     _work_directory += date;
562   }
563   params[Batch::WORKDIR] = _work_directory;
564
565   // Parameters for COORM
566   params[Batch::LAUNCHER_FILE] = _launcher_file;
567   params[Batch::LAUNCHER_ARGS] = _launcher_args;
568
569   // If result_directory is not defined, we use HOME environnement
570   if (_result_directory == "")
571     _result_directory = getenv("HOME");
572
573   // _in_files
574   std::list<std::string> in_files(_in_files);
575   in_files.push_back(_job_file);
576   if (_env_file != "")
577           in_files.push_back(_env_file);
578   for(std::list<std::string>::iterator it = in_files.begin(); it != in_files.end(); it++)
579   {
580     std::string file = *it;
581
582     // local file -> If file is not an absolute path, we apply _local_directory
583     std::string local_file;
584     if (file.substr(0, 1) == std::string("/"))
585       local_file = file;
586     else
587 #ifndef WIN32
588       local_file = _local_directory + "/" + file;
589 #else
590           local_file = file;
591 #endif
592     
593     // remote file -> get only file name from in_files
594     size_t found = file.find_last_of("/");
595     std::string remote_file = _work_directory + "/" + file.substr(found+1);
596
597     params[Batch::INFILE] += Batch::Couple(local_file, remote_file);
598   }
599    
600   // _out_files
601   for(std::list<std::string>::iterator it = _out_files.begin(); it != _out_files.end(); it++)
602   {
603     std::string file = *it;
604
605     // local file 
606     size_t found = file.find_last_of("/");
607     std::string local_file = _result_directory +  "/" + file.substr(found+1);
608
609     // remote file -> If file is not an absolute path, we apply _work_directory
610     std::string remote_file;
611     if (file.substr(0, 1) == std::string("/"))
612       remote_file = file;
613     else
614       remote_file = _work_directory + "/" + file;
615
616     params[Batch::OUTFILE] += Batch::Couple(local_file, remote_file);
617   }
618
619   // Time
620   if (_maximum_duration_in_second != -1)
621     params[Batch::MAXWALLTIME] = _maximum_duration_in_second / 60;
622
623   // Queue
624   if (_queue != "")
625     params[Batch::QUEUE] = _queue;
626
627   // Exclusive
628   if (getExclusive())
629     params[Batch::EXCLUSIVE] = true;
630
631   // Specific parameters
632   std::map<std::string, std::string>::iterator it = _specific_parameters.find("LoalLevelerJobType");
633   if (it != _specific_parameters.end())
634     params["LL_JOBTYPE"] = it->second;
635   return params;
636 }
637
638 void 
639 Launcher::Job::setBatchManagerJobId(Batch::JobId batch_manager_job_id)
640 {
641   _batch_job_id = batch_manager_job_id;
642 }
643
644 Batch::JobId 
645 Launcher::Job::getBatchManagerJobId()
646 {
647   return _batch_job_id;
648 }
649 #endif
650
651 void
652 Launcher::Job::addToXmlDocument(xmlNodePtr root_node)
653 {
654   // Begin job
655   xmlNodePtr job_node = xmlNewChild(root_node, NULL, xmlCharStrdup("job"), NULL);
656   xmlNewProp(job_node, xmlCharStrdup("type"), xmlCharStrdup(getJobType().c_str()));
657   xmlNewProp(job_node, xmlCharStrdup("name"), xmlCharStrdup(getJobName().c_str()));
658
659   // Add user part
660   xmlNodePtr node = xmlNewChild(job_node, NULL, xmlCharStrdup("user_part"), NULL);
661
662   xmlNewChild(node, NULL, xmlCharStrdup("job_file"),         xmlCharStrdup(getJobFile().c_str()));
663   xmlNewChild(node, NULL, xmlCharStrdup("env_file"),         xmlCharStrdup(getEnvFile().c_str()));
664   xmlNewChild(node, NULL, xmlCharStrdup("work_directory"),   xmlCharStrdup(getWorkDirectory().c_str()));
665   xmlNewChild(node, NULL, xmlCharStrdup("local_directory"),  xmlCharStrdup(getLocalDirectory().c_str()));
666   xmlNewChild(node, NULL, xmlCharStrdup("result_directory"), xmlCharStrdup(getResultDirectory().c_str()));
667
668   // Parameters for COORM
669   xmlNewChild(node, NULL, xmlCharStrdup("launcher_file"), xmlCharStrdup(getLauncherFile().c_str()));
670
671   // Files
672   xmlNodePtr files_node = xmlNewChild(node, NULL, xmlCharStrdup("files"), NULL);
673   std::list<std::string> in_files  = get_in_files();
674   std::list<std::string> out_files = get_out_files();
675   for(std::list<std::string>::iterator it = in_files.begin(); it != in_files.end(); it++)
676     xmlNewChild(files_node, NULL, xmlCharStrdup("in_file"), xmlCharStrdup((*it).c_str()));
677   for(std::list<std::string>::iterator it = out_files.begin(); it != out_files.end(); it++)
678     xmlNewChild(files_node, NULL, xmlCharStrdup("out_file"), xmlCharStrdup((*it).c_str()));
679
680   // Resource part
681   resourceParams resource_params = getResourceRequiredParams();
682   xmlNodePtr res_node = xmlNewChild(node, NULL, xmlCharStrdup("resource_params"), NULL);
683   xmlNewChild(res_node, NULL, xmlCharStrdup("name"),   xmlCharStrdup(resource_params.name.c_str()));
684   xmlNewChild(res_node, NULL, xmlCharStrdup("hostname"),   xmlCharStrdup(resource_params.hostname.c_str()));
685   xmlNewChild(res_node, NULL, xmlCharStrdup("OS"),   xmlCharStrdup(resource_params.OS.c_str()));
686   std::ostringstream nb_proc_stream;
687   std::ostringstream nb_node_stream;
688   std::ostringstream nb_proc_per_node_stream;
689   std::ostringstream cpu_clock_stream;
690   std::ostringstream mem_mb_stream;
691   nb_proc_stream << resource_params.nb_proc;
692   nb_node_stream << resource_params.nb_node;
693   nb_proc_per_node_stream << resource_params.nb_proc_per_node;
694   cpu_clock_stream << resource_params.cpu_clock;
695   mem_mb_stream << resource_params.mem_mb;
696   xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc"),            xmlCharStrdup(nb_proc_stream.str().c_str()));
697   xmlNewChild(res_node, NULL, xmlCharStrdup("nb_node"),            xmlCharStrdup(nb_node_stream.str().c_str()));
698   xmlNewChild(res_node, NULL, xmlCharStrdup("nb_proc_per_node"),   xmlCharStrdup(nb_proc_per_node_stream.str().c_str()));
699   xmlNewChild(res_node, NULL, xmlCharStrdup("cpu_clock"),          xmlCharStrdup(cpu_clock_stream.str().c_str()));
700   xmlNewChild(res_node, NULL, xmlCharStrdup("mem_mb"),             xmlCharStrdup(mem_mb_stream.str().c_str()));
701
702   xmlNewChild(node, NULL, xmlCharStrdup("maximum_duration"), xmlCharStrdup(getMaximumDuration().c_str()));
703   xmlNewChild(node, NULL, xmlCharStrdup("queue"),            xmlCharStrdup(getQueue().c_str()));
704   xmlNewChild(node, NULL, xmlCharStrdup("exclusive"),        xmlCharStrdup(getExclusiveStr().c_str()));
705   ostringstream mem_per_cpu_stream;
706   mem_per_cpu_stream << _mem_per_cpu;
707   xmlNewChild(node, NULL, xmlCharStrdup("mem_per_cpu"),      xmlCharStrdup(mem_per_cpu_stream.str().c_str()));
708
709   // For COORM
710   xmlNewChild(node, NULL, xmlCharStrdup("launcher_args"), xmlCharStrdup(getLauncherArgs().c_str()));
711
712   // Specific parameters part
713   xmlNodePtr specific_parameters_node = xmlNewChild(node, NULL, xmlCharStrdup("specific_parameters"), NULL);
714   std::map<std::string, std::string> specific_parameters = getSpecificParameters();
715   for(std::map<std::string, std::string>::iterator it = specific_parameters.begin(); it != specific_parameters.end(); it++)
716   {
717     xmlNodePtr specific_parameter_node = xmlNewChild(specific_parameters_node, NULL, xmlCharStrdup("specific_parameter"), NULL);
718     xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("name"), xmlCharStrdup((it->first).c_str()));
719     xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("value"), xmlCharStrdup((it->second).c_str()));
720   }
721
722   // Run part
723   xmlNodePtr run_node = xmlNewChild(job_node, NULL, xmlCharStrdup("run_part"), NULL);
724   xmlNewChild(run_node, NULL, xmlCharStrdup("job_state"), xmlCharStrdup(getState().c_str()));
725   ParserResourcesType resource_definition = getResourceDefinition();
726   xmlNewChild(run_node, NULL, xmlCharStrdup("resource_choosed_name"), xmlCharStrdup(resource_definition.Name.c_str()));
727
728 #ifdef WITH_LIBBATCH
729   Batch::JobId job_id = getBatchManagerJobId();
730   xmlNewChild(run_node, NULL, xmlCharStrdup("job_reference"), xmlCharStrdup(job_id.getReference().c_str()));
731 #endif
732 }
733
734 void 
735 Launcher::Job::addSpecificParameter(const std::string & name,
736                                       const std::string & value)
737 {
738   _specific_parameters[name] = value;
739 }
740
741 const std::map<std::string, std::string> &
742 Launcher::Job::getSpecificParameters()
743 {
744   return _specific_parameters;
745 }
746
747 void
748 Launcher::Job::checkSpecificParameters()
749 {
750 }