Salome HOME
Add command_salome job type.
[modules/yacs.git] / src / Launcher / SALOME_Launcher.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "SALOME_Launcher.hxx"
24 #include "BatchTest.hxx"
25 #include "OpUtil.hxx"
26 #include "SALOME_ContainerManager.hxx"
27 #include "SALOME_NamingService.hxx"
28 #include "SALOME_ResourcesManager.hxx"
29 #include "Utils_CorbaException.hxx"
30
31
32 #include "Launcher_Job_Command.hxx"
33 #include "Launcher_Job_YACSFile.hxx"
34 #include "Launcher_Job_PythonSALOME.hxx"
35 #include "Launcher_Job_CommandSALOME.hxx"
36
37 #include "utilities.h"
38
39 #ifdef WIN32
40 # include <process.h>
41 #else
42 # include <unistd.h>
43 #endif
44 #include <sys/types.h>
45 #include <vector>
46 #include <list>
47
48 #include <stdio.h>
49 #include <sstream>
50
51 using namespace std;
52
53 const char *SALOME_Launcher::_LauncherNameInNS = "/SalomeLauncher";
54
55 //=============================================================================
56 /*! 
57  *  Constructor
58  *  \param orb
59  */
60 //=============================================================================
61 SALOME_Launcher::SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa) : _l()
62 {
63   MESSAGE("SALOME_Launcher constructor");
64   _NS = new SALOME_NamingService(orb);
65   _ResManager = new SALOME_ResourcesManager(orb,poa,_NS);
66   _l.SetResourcesManager(_ResManager->GetImpl());
67   _ContManager = new SALOME_ContainerManager(orb,poa,_NS);
68   _ResManager->_remove_ref();
69   _ContManager->_remove_ref();
70
71   _orb = CORBA::ORB::_duplicate(orb) ;
72   _poa = PortableServer::POA::_duplicate(poa) ;
73   PortableServer::ObjectId_var id = _poa->activate_object(this);
74   CORBA::Object_var obj = _poa->id_to_reference(id);
75   Engines::SalomeLauncher_var refContMan = Engines::SalomeLauncher::_narrow(obj);
76
77   _NS->Register(refContMan,_LauncherNameInNS);
78   MESSAGE("SALOME_Launcher constructor end");
79 }
80
81 //=============================================================================
82 /*! 
83  * destructor
84  */
85 //=============================================================================
86 SALOME_Launcher::~SALOME_Launcher()
87 {
88   MESSAGE("SALOME_Launcher destructor");
89   delete _NS;
90   MESSAGE("SALOME_Launcher destructor end");
91 }
92
93
94 CORBA::Long 
95 SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters)
96 {
97   std::string job_type = job_parameters.job_type.in();
98
99   Launcher::Job * new_job; // It is Launcher_cpp that is going to destroy it
100
101   if (job_type == Launcher::Job_Command::TYPE_NAME)
102     new_job = new Launcher::Job_Command();
103   else if (job_type == Launcher::Job_CommandSALOME::TYPE_NAME)
104     new_job = new Launcher::Job_CommandSALOME();
105   else if (job_type == Launcher::Job_YACSFile::TYPE_NAME)
106     new_job = new Launcher::Job_YACSFile();
107   else if (job_type == Launcher::Job_PythonSALOME::TYPE_NAME)
108     new_job = new Launcher::Job_PythonSALOME();
109   else
110   {
111     std::string message("SALOME_Launcher::createJob: bad job type: ");
112     message += job_type;
113     THROW_SALOME_CORBA_EXCEPTION(message.c_str(), SALOME::INTERNAL_ERROR);
114   }
115
116   // Name
117   new_job->setJobName(job_parameters.job_name.in());
118
119   // Directories
120   std::string work_directory = job_parameters.work_directory.in();
121   std::string local_directory = job_parameters.local_directory.in();
122   std::string result_directory = job_parameters.result_directory.in();
123   new_job->setWorkDirectory(work_directory);
124   new_job->setLocalDirectory(local_directory);
125   new_job->setResultDirectory(result_directory);
126
127   // Parameters for COORM
128   std::string launcher_file = job_parameters.launcher_file.in();
129   std::string launcher_args = job_parameters.launcher_args.in();
130   new_job->setLauncherFile(launcher_file);
131   new_job->setLauncherArgs(launcher_args);
132
133   // Job File
134   std::string job_file = job_parameters.job_file.in();
135   try
136   {
137     new_job->setJobFile(job_file);
138   }
139   catch(const LauncherException &ex)
140   {
141     INFOS(ex.msg.c_str());
142     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
143   }
144   new_job->setPreCommand(job_parameters.pre_command.in());
145
146   // Files
147   std::string env_file = job_parameters.env_file.in();
148   new_job->setEnvFile(env_file);
149   for (CORBA::ULong i = 0; i < job_parameters.in_files.length(); i++)
150     new_job->add_in_file(job_parameters.in_files[i].in());
151   for (CORBA::ULong i = 0; i < job_parameters.out_files.length(); i++)
152     new_job->add_out_file(job_parameters.out_files[i].in());
153
154   // Expected During Time
155   try
156   {
157     std::string maximum_duration = job_parameters.maximum_duration.in();
158     new_job->setMaximumDuration(maximum_duration);
159   }
160   catch(const LauncherException &ex){
161     INFOS(ex.msg.c_str());
162     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
163   }
164
165   // Queue
166   std::string queue = job_parameters.queue.in();
167   new_job->setQueue(queue);
168
169   // Partition
170   std::string partition = job_parameters.partition.in();
171   new_job->setPartition(partition);
172
173   // Exclusive
174   new_job->setExclusive(job_parameters.exclusive);
175
176   // Memory required per CPU
177   new_job->setMemPerCpu(job_parameters.mem_per_cpu);
178
179   // WC Key
180   std::string wckey = job_parameters.wckey.in();
181   new_job->setWCKey(wckey);
182
183   // Extra params
184   std::string extra_params = job_parameters.extra_params.in();
185   new_job->setExtraParams(extra_params);
186
187   // Resources requirements
188   try
189   {
190     resourceParams p;
191     p.name = job_parameters.resource_required.name;
192     p.hostname = job_parameters.resource_required.hostname;
193     p.OS = job_parameters.resource_required.OS;
194     p.nb_proc = job_parameters.resource_required.nb_proc;
195     p.nb_node = job_parameters.resource_required.nb_node;
196     p.nb_proc_per_node = job_parameters.resource_required.nb_proc_per_node;
197     p.cpu_clock = job_parameters.resource_required.cpu_clock;
198     p.mem_mb = job_parameters.resource_required.mem_mb;
199     new_job->setResourceRequiredParams(p);
200   }
201   catch(const LauncherException &ex){
202     INFOS(ex.msg.c_str());
203     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
204   }
205
206   // Adding specific parameters to the job
207   for (CORBA::ULong i = 0; i < job_parameters.specific_parameters.length(); i++)
208     new_job->addSpecificParameter(job_parameters.specific_parameters[i].name.in(),
209                                   job_parameters.specific_parameters[i].value.in());
210   try
211   {
212     new_job->checkSpecificParameters();
213   }
214   catch(const LauncherException &ex)
215   {
216     INFOS(ex.msg.c_str());
217     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
218   }
219
220   try
221   {
222     _l.createJob(new_job);
223     std::ostringstream job_id;
224     job_id << new_job->getNumber();
225     notifyObservers("NEW_JOB", job_id.str());
226   }
227   catch(const LauncherException &ex)
228   {
229     INFOS(ex.msg.c_str());
230     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
231   }
232   return new_job->getNumber();
233 }
234
235 void 
236 SALOME_Launcher::launchJob(CORBA::Long job_id)
237 {
238   try
239   {
240     _l.launchJob(job_id);
241   }
242   catch(const LauncherException &ex)
243   {
244     INFOS(ex.msg.c_str());
245     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
246   }
247 }
248
249 char *
250 SALOME_Launcher::getJobState(CORBA::Long job_id)
251 {
252   std::string result;
253   try
254   {
255     result = _l.getJobState(job_id);
256   }
257   catch(const LauncherException &ex)
258   {
259     INFOS(ex.msg.c_str());
260     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
261   }
262   return CORBA::string_dup(result.c_str());
263 }
264
265 // Get names or ids of hosts assigned to the job
266 char *
267 SALOME_Launcher::getAssignedHostnames(CORBA::Long job_id)
268 {
269   std::string result;
270   try
271   {
272     result = _l.getAssignedHostnames(job_id);
273   }
274   catch(const LauncherException &ex)
275   {
276     INFOS(ex.msg.c_str());
277     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
278   }
279   return CORBA::string_dup(result.c_str());
280 }
281
282 void
283 SALOME_Launcher::getJobResults(CORBA::Long job_id, const char * directory)
284 {
285   try
286   {
287     _l.getJobResults(job_id, directory);
288   }
289   catch(const LauncherException &ex)
290   {
291     INFOS(ex.msg.c_str());
292     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
293   }
294 }
295
296 void
297 SALOME_Launcher::clearJobWorkingDir(CORBA::Long job_id)
298 {
299   try
300   {
301     _l.clearJobWorkingDir(job_id);
302   }
303   catch(const LauncherException &ex)
304   {
305     INFOS(ex.msg.c_str());
306     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
307   }
308 }
309
310 CORBA::Boolean
311 SALOME_Launcher::getJobDumpState(CORBA::Long job_id, const char * directory)
312 {
313   CORBA::Boolean rtn = false;
314   try
315   {
316     rtn = _l.getJobDumpState(job_id, directory);
317   }
318   catch(const LauncherException &ex)
319   {
320     INFOS(ex.msg.c_str());
321     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
322   }
323   return rtn;
324 }
325
326 CORBA::Boolean
327 SALOME_Launcher::getJobWorkFile(CORBA::Long job_id, const char * work_file, const char * directory)
328 {
329   CORBA::Boolean rtn = false;
330   try
331   {
332     rtn = _l.getJobWorkFile(job_id, work_file, directory);
333   }
334   catch(const LauncherException &ex)
335   {
336     INFOS(ex.msg.c_str());
337     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
338   }
339   return rtn;
340 }
341
342 void 
343 SALOME_Launcher::removeJob(CORBA::Long job_id)
344 {
345   try
346   {
347     _l.removeJob(job_id);
348     std::ostringstream job_id_str;
349     job_id_str << job_id;
350     notifyObservers("REMOVE_JOB", job_id_str.str());
351   }
352   catch(const LauncherException &ex)
353   {
354     INFOS(ex.msg.c_str());
355     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
356   }
357 }
358
359 void 
360 SALOME_Launcher::stopJob(CORBA::Long job_id)
361 {
362   try
363   {
364     _l.stopJob(job_id);
365     std::ostringstream job_id_str;
366     job_id_str << job_id;
367     notifyObservers("UPDATE_JOB_STATE", job_id_str.str());
368   }
369   catch(const LauncherException &ex)
370   {
371     INFOS(ex.msg.c_str());
372     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
373   }
374 }
375
376 //=============================================================================
377 /*! CORBA Method:
378  *  Create a job in the launcher with a file
379  *  \param xmlExecuteFile     : .xml to parse that contains job description
380  *  \param clusterName        : machine choosed
381  */
382 //=============================================================================
383 CORBA::Long 
384 SALOME_Launcher::createJobWithFile(const char * xmlExecuteFile,
385                                    const char * clusterName)
386 {
387   CORBA::Long jobId;
388   try{
389     jobId = _l.createJobWithFile(xmlExecuteFile, clusterName);
390   }
391   catch(const LauncherException &ex){
392     INFOS(ex.msg.c_str());
393     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
394   }
395
396   return jobId;
397 }
398
399 //=============================================================================
400 /*! CORBA Method:
401  *  the test batch configuration 
402  *  \param params             : The batch cluster
403  */
404 //=============================================================================
405 CORBA::Boolean 
406 SALOME_Launcher::testBatch(const Engines::ResourceParameters& params)
407 {
408   MESSAGE("BEGIN OF SALOME_Launcher::testBatch");
409   CORBA::Boolean rtn = false;
410   try
411   {
412     // Consider only resources that can run batch jobs
413     Engines::ResourceParameters new_params(params);
414     new_params.can_launch_batch_jobs = true;
415
416     // find a resource matching the required parameters
417     Engines::ResourceList *aMachineList = _ResManager->GetFittingResources(new_params);
418     if (aMachineList->length() == 0)
419       throw SALOME_Exception("No resources have been found with your parameters");
420
421     const Engines::ResourceDefinition* p = _ResManager->GetResourceDefinition((*aMachineList)[0]);
422         std::string resource_name(p->name);
423     INFOS("Choose resource for test: " <<  resource_name);
424     
425     BatchTest t(*p);
426     if (t.test()) 
427     {
428       rtn = true;
429     }
430   }
431   catch(const LauncherException &ex){
432     INFOS(ex.msg.c_str());
433     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
434   }
435   return rtn;
436 }
437
438 //=============================================================================
439 /*! CORBA method:
440  *  shutdown all the containers, then the ContainerManager servant
441  */
442 //=============================================================================
443 void SALOME_Launcher::Shutdown()
444 {
445   MESSAGE("Shutdown");
446   _NS->Destroy_Name(_LauncherNameInNS);
447   _ContManager->Shutdown();
448   _ResManager->Shutdown();
449   PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
450   _poa->deactivate_object(oid);
451   if(!CORBA::is_nil(_orb))
452     _orb->shutdown(0);
453 }
454
455 //=============================================================================
456 /*! CORBA Method:
457  *  Returns the PID of the process
458  */
459 //=============================================================================
460 CORBA::Long SALOME_Launcher::getPID()
461 {
462   return 
463 #ifndef WIN32
464     (CORBA::Long)getpid();
465 #else
466     (CORBA::Long)_getpid();
467 #endif
468 }
469
470 //=============================================================================
471 /*! CORBA Method:
472  *  Returns current launcher jobs list
473  */
474 //=============================================================================
475 Engines::JobsList *
476 SALOME_Launcher::getJobsList()
477 {
478   Engines::JobsList_var jobs_list = new Engines::JobsList();
479   std::map<int, Launcher::Job *> cpp_jobs = _l.getJobs();
480   std::map<int, Launcher::Job *>::const_iterator it_job;
481   int list_id = 0;
482   for(it_job = cpp_jobs.begin(); it_job != cpp_jobs.end(); it_job++)
483   {
484     int number          = it_job->first;
485     try
486     {
487       // Prepare CORBA job description
488       Engines::JobDescription_var job_descr = new Engines::JobDescription();
489       Engines::JobParameters_var job_parameters = getJobParameters(number);
490       job_descr->job_id = number;
491       job_descr->job_parameters = job_parameters;
492
493       // Add job description to the sequence
494       jobs_list->length(list_id + 1);
495       jobs_list[list_id] = job_descr;
496       list_id++;
497     }
498     catch (...) {}
499   }
500   return jobs_list._retn();
501 }
502
503 //=============================================================================
504 /*! CORBA Method:
505  * Returns the job description
506  */
507 //=============================================================================
508 Engines::JobParameters *
509 SALOME_Launcher::getJobParameters(CORBA::Long job_id)
510 {
511   std::map<int, Launcher::Job *> cpp_jobs = _l.getJobs();
512   std::map<int, Launcher::Job *>::const_iterator it_job = cpp_jobs.find(job_id);
513   if (it_job == cpp_jobs.end())
514   {
515     INFOS("Cannot find the job, is it created ? job number: " << job_id);
516     THROW_SALOME_CORBA_EXCEPTION("Job does not exist", SALOME::INTERNAL_ERROR);
517   }
518
519   Launcher::Job * job = it_job->second;
520   Engines::JobParameters_var job_parameters = new Engines::JobParameters;
521   job_parameters->job_name         = CORBA::string_dup(job->getJobName().c_str());
522   job_parameters->job_type         = CORBA::string_dup(job->getJobType().c_str());
523   job_parameters->job_file         = CORBA::string_dup(job->getJobFile().c_str());
524   job_parameters->env_file         = CORBA::string_dup(job->getEnvFile().c_str());
525   job_parameters->work_directory   = CORBA::string_dup(job->getWorkDirectory().c_str());
526   job_parameters->local_directory  = CORBA::string_dup(job->getLocalDirectory().c_str());
527   job_parameters->result_directory = CORBA::string_dup(job->getResultDirectory().c_str());
528   job_parameters->pre_command      = CORBA::string_dup(job->getPreCommand().c_str());
529
530   // Parameters for COORM
531   job_parameters->launcher_file = CORBA::string_dup(job->getLauncherFile().c_str());
532   job_parameters->launcher_args = CORBA::string_dup(job->getLauncherArgs().c_str());
533
534   int i = 0;
535   int j = 0;
536   std::list<std::string> in_files  = job->get_in_files();
537   std::list<std::string> out_files = job->get_out_files();
538   job_parameters->in_files.length(in_files.size());
539   for(std::list<std::string>::iterator it = in_files.begin(); it != in_files.end(); it++)
540   {
541     job_parameters->in_files[i] = CORBA::string_dup((*it).c_str());
542     i++;
543   }
544   job_parameters->out_files.length(out_files.size());
545   for(std::list<std::string>::iterator it = out_files.begin(); it != out_files.end(); it++)
546   {
547     job_parameters->out_files[j] = CORBA::string_dup((*it).c_str());
548     j++;
549   }
550
551   job_parameters->maximum_duration = CORBA::string_dup(job->getMaximumDuration().c_str());
552   job_parameters->queue            = CORBA::string_dup(job->getQueue().c_str());
553   job_parameters->partition        = CORBA::string_dup(job->getPartition().c_str());
554   job_parameters->exclusive        = job->getExclusive();
555   job_parameters->mem_per_cpu      = job->getMemPerCpu();
556   job_parameters->wckey            = CORBA::string_dup(job->getWCKey().c_str());
557   job_parameters->extra_params     = CORBA::string_dup(job->getExtraParams().c_str());
558
559   resourceParams resource_params = job->getResourceRequiredParams();
560   job_parameters->resource_required.name             = CORBA::string_dup(resource_params.name.c_str());
561   job_parameters->resource_required.hostname         = CORBA::string_dup(resource_params.hostname.c_str());
562   job_parameters->resource_required.OS               = CORBA::string_dup(resource_params.OS.c_str());
563   job_parameters->resource_required.nb_proc          = resource_params.nb_proc;
564   job_parameters->resource_required.nb_node          = resource_params.nb_node;
565   job_parameters->resource_required.nb_proc_per_node = resource_params.nb_proc_per_node;
566   job_parameters->resource_required.cpu_clock        = resource_params.cpu_clock;
567   job_parameters->resource_required.mem_mb           = resource_params.mem_mb;
568
569   std::map<std::string, std::string> specific_parameters = job->getSpecificParameters();
570   if (!specific_parameters.empty())
571   {
572     job_parameters->specific_parameters.length(specific_parameters.size());
573     std::map<std::string, std::string>::const_iterator it_specific;
574     CORBA::ULong i = 0;
575     for (it_specific = specific_parameters.begin() ; it_specific != specific_parameters.end(); it_specific++)
576     {
577       Engines::Parameter_var new_param = new Engines::Parameter;
578       new_param->name  = CORBA::string_dup((it_specific->first).c_str());
579       new_param->value = CORBA::string_dup((it_specific->second).c_str());
580       job_parameters->specific_parameters[i] = new_param;
581       i++;
582     }
583   }
584
585   return job_parameters._retn();
586 }
587
588 //=============================================================================
589 /*! CORBA Method:
590  *  Loads jobs saved in jobs_file
591  */
592 //=============================================================================
593 void
594 SALOME_Launcher::loadJobs(const char* jobs_file)
595 {
596   list<int> new_jobs_id_list;
597   try
598   {
599     // Load the jobs in Launcher
600     new_jobs_id_list = _l.loadJobs(jobs_file);
601   }
602   catch (const LauncherException & ex)
603   {
604     INFOS(ex.msg.c_str());
605     THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(), SALOME::INTERNAL_ERROR);
606   }
607
608   // Notify observers of the new jobs
609   list<int>::const_iterator it_jobs_id;
610   for (it_jobs_id = new_jobs_id_list.begin(); it_jobs_id != new_jobs_id_list.end(); it_jobs_id++)
611   {
612     ostringstream job_id_sstr;
613     job_id_sstr << *it_jobs_id;
614     notifyObservers("NEW_JOB", job_id_sstr.str());
615   }
616   notifyObservers("LOAD_JOBS", jobs_file);
617 }
618
619 //=============================================================================
620 /*! CORBA Method:
621  *  Save jobs of Launcher (in any steps) in file jobs_file
622  */
623 //=============================================================================
624 void
625 SALOME_Launcher::saveJobs(const char* jobs_file)
626 {
627   _l.saveJobs(jobs_file);
628   notifyObservers("SAVE_JOBS", jobs_file);
629 }
630
631 //=============================================================================
632 /*! CORBA Method:
633  *  Add a new observer to the launcher
634  */
635 //=============================================================================
636 void
637 SALOME_Launcher::addObserver(Engines::SalomeLauncherObserver_ptr observer)
638 {
639   bool new_observer = true;
640   std::list<Engines::SalomeLauncherObserver_var>::iterator iter = _observers.begin();
641   while(iter != _observers.end())
642   {
643     if (std::string(_orb->object_to_string(*iter)) ==
644         std::string(_orb->object_to_string(observer)))
645     {
646       new_observer = false;
647       break;
648     }
649     iter++;
650   }
651   if (new_observer)
652     _observers.push_back(Engines::SalomeLauncherObserver::_duplicate(observer));
653
654   // We notify the new observer with all jobs that are currently in the Launcher
655   std::map<int, Launcher::Job *> cpp_jobs = _l.getJobs();
656   std::map<int, Launcher::Job *>::const_iterator it_job;
657   for(it_job = cpp_jobs.begin(); it_job != cpp_jobs.end(); it_job++)
658   {
659     int number = it_job->first;
660     std::ostringstream job_id;
661     job_id << number;
662     try
663     {
664       observer->notify("NEW_JOB", job_id.str().c_str());
665     }
666     catch (...) 
667     {
668        MESSAGE("Notify Observer, exception catch");
669     }
670
671   }
672 }
673
674 //=============================================================================
675 /*! CORBA Method:
676  *  Add a new observer to the launcher
677  */
678 //=============================================================================
679 void
680 SALOME_Launcher::removeObserver(Engines::SalomeLauncherObserver_ptr observer)
681 {
682   std::list<Engines::SalomeLauncherObserver_var>::iterator iter = _observers.begin();
683   while(iter != _observers.end())
684   {
685     if (std::string(_orb->object_to_string(*iter)) ==
686         std::string(_orb->object_to_string(observer)))
687     {
688       // Observer found
689       iter =_observers.erase(iter++);
690     }
691     else
692     {
693       iter++;
694     }
695   }
696 }
697
698 //=============================================================================
699 /*! Internal Method:
700  *  Notify observers on a new event
701  */
702 //=============================================================================
703 void
704 SALOME_Launcher::notifyObservers(const std::string & event_name,
705                                  const std::string & event_data)
706 {
707   std::list<Engines::SalomeLauncherObserver_var>::iterator iter = _observers.begin();
708   while(iter != _observers.end())
709   {
710     try
711     {
712       (*iter)->notify(CORBA::string_dup(event_name.c_str()),
713                       CORBA::string_dup(event_data.c_str()));
714     }
715     catch (...) 
716     {
717        MESSAGE("Notify Observer, exception catch");
718     }
719     iter++;
720   }
721
722 }