Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/smesh.git] / src / Tools / padder / meshjob / impl / MeshJobManager_i.cxx
1 // Copyright (C) 2011-2012  EDF R&D
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 // Authors : Guillaume Boulant (EDF) - 01/03/2011
20
21 #ifdef WIN32
22 #include <winsock2.h>
23 #include <windows.h> 
24 #else
25 #include <sys/time.h>
26 #endif
27
28 #include "MeshJobManager_i.hxx"
29
30 #include <SALOMEconfig.h>
31 #include CORBA_SERVER_HEADER(SALOME_Exception)
32
33
34 #include "Basics_Utils.hxx"         // For standard logging
35 #undef LOG
36 #include "SALOME_KernelServices.hxx"   // For CORBA logging
37 #undef LOG
38
39 #define LOG STDLOG
40
41 //
42 // ====================================================================
43 // General purpose helper functions (to put elsewhere at least)
44 // ====================================================================
45 //
46
47 /*!
48  * This function must be used to associate a datetime tag to a job
49  */
50
51 #ifndef WIN32
52 static long timetag() {
53   timeval tv;
54   gettimeofday(&tv,0);
55   long tag = tv.tv_usec + tv.tv_sec*1000000;
56   return tag;
57 }
58 #endif
59
60 /*!
61  * This function returns true if the string text starts with the string
62  * token.
63  */
64 static bool myStartsWith(const std::string& text,const std::string& token){     
65   if(text.length() < token.length())
66     return false;
67   return (text.compare(0, token.length(), token) == 0);
68 }
69
70 //
71 // ====================================================================
72 // Constructor/Destructor
73 // ====================================================================
74 //
75 MeshJobManager_i::MeshJobManager_i(CORBA::ORB_ptr orb,
76                                    PortableServer::POA_ptr poa,
77                                    PortableServer::ObjectId * contId,
78                                    const char *instanceName,
79                                    const char *interfaceName)
80   : Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
81 {
82   LOG("Activating MESHJOB::MeshJobManager object");
83   _thisObj = this ;
84   _id = _poa->activate_object(_thisObj);
85
86   _salomeLauncher   = KERNEL::getSalomeLauncher();
87   if(CORBA::is_nil(_salomeLauncher)){
88     LOG("The SALOME launcher can't be reached ==> STOP");
89     throw KERNEL::createSalomeException("SALOME launcher can't be reached");
90   }
91
92   _resourcesManager = KERNEL::getResourcesManager();
93   if(CORBA::is_nil(_resourcesManager)){
94     LOG("The SALOME resource manager can't be reached ==> STOP");
95     throw KERNEL::createSalomeException("The SALOME resource manager can't be reached");
96   }
97 }
98
99 MeshJobManager_i::~MeshJobManager_i() {
100   LOG("MeshJobManager_i::~MeshJobManager_i()");
101 }
102
103 //
104 // ====================================================================
105 // Helper functions to deals with the local and remote file systems
106 // ====================================================================
107 //
108 #include <fstream>     // to get the file streams
109 #ifdef WNT             
110 #include <stdlib.h>    // to get _splitpath
111 #include <direct.h>    // to get _mkdir
112 #else
113 #include <unistd.h>    // to get basename
114 #include <sys/stat.h>  // to get mkdir
115 #include <sys/types.h> // to get mkdir options
116 #endif
117
118 #include <stdlib.h>    // to get system and getenv
119
120 static std::string OUTPUTFILE("output.med");
121 static std::string DATAFILE("data.txt");
122 static std::string SCRIPTFILE("padder.sh");
123 static std::string SEPARATOR(" ");
124
125 static std::string USER(getenv("USER"));
126 static std::string LOCAL_INPUTDIR("/tmp/spadder.local.inputdir."+USER);
127 static std::string LOCAL_RESULTDIR("/tmp/spadder.local.resultdir."+USER);
128 static std::string REMOTE_WORKDIR("/tmp/spadder.remote.workdir."+USER);
129
130 /*!
131  * This function creates the padder text input file containing the
132  * input data (list of filenames and groupnames) and returns the path
133  * of the created file. This function is the one that knows the format
134  * of the padder input file. If the input file format changes, then
135  * this function (and only this one) should be updated.
136  */
137 const char * MeshJobManager_i::_writeDataFile(std::vector<MESHJOB::MeshJobParameter> listConcreteMesh,
138                                               std::vector<MESHJOB::MeshJobParameter> listSteelBarMesh) {
139 #ifdef WIN32
140   _mkdir(LOCAL_INPUTDIR.c_str());
141 #else
142   mkdir(LOCAL_INPUTDIR.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
143 #endif
144
145   // Make it static so that it's allocated once (constant name)
146   static std::string * dataFilename = new std::string(LOCAL_INPUTDIR+"/"+DATAFILE);
147   std::ofstream dataFile(dataFilename->c_str());
148   
149   // We first specify the concrete mesh data (filename and groupname)
150   std::string line;
151 #ifdef WIN32
152   char fname[ _MAX_FNAME ];
153   _splitpath( listConcreteMesh[0].file_name, NULL, NULL, fname, NULL );
154   char* bname = &fname[0];
155 #else
156   char* bname = basename(listConcreteMesh[0].file_name);
157 #endif
158   line = std::string(bname) + " " + std::string(listConcreteMesh[0].group_name);
159   dataFile << line.c_str() << std::endl;
160   // Note that we use here the basename because the files are supposed
161   // to be copied in the REMOTE_WORKDIR for execution.
162   
163   // The, we can specify the steelbar mesh data, starting by the
164   // number of meshes
165   int nbSteelBarMesh=listSteelBarMesh.size();
166   line = std::string("nbSteelbarMesh") + SEPARATOR + ToString(nbSteelBarMesh);
167   dataFile << line.c_str() << std::endl;
168   for (int i=0; i<nbSteelBarMesh; i++) {
169 #ifdef WIN32
170         char fname[ _MAX_FNAME ];
171         _splitpath( listSteelBarMesh[i].file_name, NULL, NULL, fname, NULL );
172         char* bname = &fname[0];
173 #else
174         char* bname = basename(listSteelBarMesh[i].file_name);
175 #endif
176     line = std::string(bname) + " " + std::string(listSteelBarMesh[i].group_name);
177     dataFile << line.c_str() << std::endl;
178   }
179   
180   // Finally, we conclude with the name of the output file
181   line = OUTPUTFILE;
182   dataFile << line.c_str() << std::endl;
183   dataFile.close();
184   return dataFilename->c_str();  
185 }
186
187 /*!
188  * This function creates a shell script that runs padder whith the
189  * specified data file, and returns the path of the created script
190  * file. The config id is used to retrieve the path to the binary file
191  * and other required files.
192  */
193 const char* MeshJobManager_i::_writeScriptFile(const char * dataFileName, const char * configId) {
194 #ifdef WIN32
195   _mkdir(LOCAL_INPUTDIR.c_str());
196 #else
197   mkdir(LOCAL_INPUTDIR.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
198 #endif
199
200   // Make it static so that it's allocated once (constant name)
201   static std::string * scriptFilename = new std::string(LOCAL_INPUTDIR+"/"+SCRIPTFILE);
202
203   char * binpath = _configMap[configId].binpath;
204   char * envpath = _configMap[configId].envpath;
205
206 #ifdef WIN32
207         char fname[ _MAX_FNAME ];
208         _splitpath( dataFileName, NULL, NULL, fname, NULL );
209         const char* bname = &fname[0];
210 #else
211         const char* bname = basename(dataFileName);
212 #endif
213
214
215   std::ofstream script(scriptFilename->c_str());
216   script << "#!/bin/sh"                                   << std::endl;
217   script << "here=$(dirname $0)"                          << std::endl;
218   script << ". " << envpath                               << std::endl;
219   script << binpath << " $here/" << bname                 << std::endl;
220   // Note that we use the basename of the datafile because all data
221   // files are supposed to have been copied in the REMOTE_WORKDIR.
222   script.close();
223   return scriptFilename->c_str();
224 }
225
226 //
227 // ====================================================================
228 // Functions to initialize and supervise the mesh computation job
229 // ====================================================================
230 //
231 bool MeshJobManager_i::configure(const char *configId,
232                                  const MESHJOB::ConfigParameter & configParameter)
233 {
234   beginService("MeshJobManager_i::configure");
235   
236   _configMap[configId] = configParameter;
237
238   LOG("Adding configuration for " << configId);
239   LOG("- binpath = " << _configMap[configId].binpath);
240   LOG("- envpath = " << _configMap[configId].envpath);
241
242   endService("MeshJobManager_i::configure");
243   return true;
244 }
245
246 long MeshJobManager_i::JOBID_UNDEFINED = -1;
247
248 /*! Initialize a smesh computation job and return the job identifier */
249 CORBA::Long MeshJobManager_i::initialize(const MESHJOB::MeshJobParameterList & meshJobParameterList,
250                                          const char * configId)
251 {
252   beginService("MeshJobManager_i::initialize");
253   std::cerr << "##################################### initialize" << std::endl;
254   std::cerr << "#####################################" << std::endl;
255
256   //
257   // We first analyse the CORBA sequence to store data in C++ vectors
258   //
259   std::vector<MESHJOB::MeshJobParameter> listConcreteMesh;
260   std::vector<MESHJOB::MeshJobParameter> listSteelBarMesh;
261   for(CORBA::ULong i=0; i<meshJobParameterList.length(); i++) {
262     MESHJOB::MeshJobParameter currentMesh = meshJobParameterList[i];
263     switch ( currentMesh.file_type ) {
264     case MESHJOB::MED_CONCRETE:
265       listConcreteMesh.push_back(currentMesh);
266       break;
267     case MESHJOB::MED_STEELBAR:
268       listSteelBarMesh.push_back(currentMesh);
269       break;
270     default:
271       LOG("The type of the file is not recognized");
272       return JOBID_UNDEFINED;
273     }
274   }
275   
276   if ( listConcreteMesh.size() != 1 ) {
277     // Not consistent with the specification
278     LOG("You specify more than one concrete mesh");
279     return JOBID_UNDEFINED;
280   }
281   
282   LOG("Nb. concrete mesh = " << listConcreteMesh.size());
283   LOG("Nb. steelbar mesh = " << listSteelBarMesh.size());
284
285   // We initiate here a datetime to tag the files and folder
286   // associated to this job.
287 #ifdef WIN32
288   DWORD jobDatetimeTag = timeGetTime();
289 #else
290   long jobDatetimeTag = timetag();
291 #endif
292   // And a MESHJOB::MeshJobPaths structure to hold the directories
293   // where to find data
294   MESHJOB::MeshJobPaths * jobPaths = new MESHJOB::MeshJobPaths();
295   jobPaths->local_inputdir  = LOCAL_INPUTDIR.c_str();
296   jobPaths->local_resultdir = (LOCAL_RESULTDIR + "." + ToString(jobDatetimeTag)).c_str();
297   jobPaths->remote_workdir  = (REMOTE_WORKDIR + "." + ToString(jobDatetimeTag)).c_str();  
298
299   //
300   // Then, we have to create the padder input data file. This input
301   // data is a text file containing the list of file names and group
302   // names.
303   //
304   const char * dataFilename = this->_writeDataFile(listConcreteMesh, listSteelBarMesh);
305   LOG("dataFilename = " << dataFilename);
306   const char * scriptFilename = this->_writeScriptFile(dataFilename, configId);
307   LOG("scriptFilename = " << scriptFilename);
308
309   //
310   // Then, the following instructions consists in preparing the job
311   // parameters to request the SALOME launcher for creating a new
312   // job.
313   //
314   Engines::JobParameters_var jobParameters = new Engines::JobParameters;
315   jobParameters->job_type = CORBA::string_dup("command");
316   // CAUTION: the job_file must be a single filename specifying a
317   // self-consistent script to be executed without any argument on the
318   // remote host.
319   jobParameters->job_file = CORBA::string_dup(scriptFilename);
320
321   //
322   // Specification of the working spaces:
323   //
324   // - local_directory: can be used to specify where to find the input
325   //   files on the local resource. It's optionnal if you specify the
326   //   absolute path name of input files.
327   //
328   // - result_directory: must be used to specify where to download the
329   //   output files on the local resources
330   //
331   // - work_directory: must be used to specify the remote directory
332   //   where to put all the stuff to run the job. Note that the job
333   //   will be executed from within this directory, i.e. a change
334   //   directory toward this working directory is done by the batch
335   //   system before running the specified job script.
336   //
337   jobParameters->local_directory  = CORBA::string_dup("");
338   jobParameters->result_directory = CORBA::string_dup(jobPaths->local_resultdir);
339   jobParameters->work_directory   = CORBA::string_dup(jobPaths->remote_workdir);
340
341   // We specify the input files that are required to execute the
342   // job_file. If basenames are specified, then the files are supposed
343   // to be located in local_directory.
344   int nbFiles = listSteelBarMesh.size()+2;
345   // The number of input file is: 
346   //   (nb. of steelbar meshfile)
347   // + (1 concrete meshfile)
348   // + (1 padder input file)
349   // = nb steelbar meshfile + 2
350   jobParameters->in_files.length(nbFiles);
351   jobParameters->in_files[0] = CORBA::string_dup(listConcreteMesh[0].file_name);
352   for (int i=0; i<listSteelBarMesh.size(); i++) {
353     jobParameters->in_files[1+i] = CORBA::string_dup(listSteelBarMesh[i].file_name);
354   }
355   jobParameters->in_files[1+listSteelBarMesh.size()] = CORBA::string_dup(dataFilename);
356   // Note that all these input files will be copied in the
357   // REMOTE_WORKDIR on the remote host
358   
359   // Then, we have to specify the existance of an output
360   // filenames. The path is supposed to be a path on the remote
361   // resource, i.e. where the job is executed.
362   jobParameters->out_files.length(1);
363   std::string outputfile_name = std::string(jobPaths->remote_workdir)+"/"+OUTPUTFILE;
364   jobParameters->out_files[0] = CORBA::string_dup(outputfile_name.c_str());
365
366   // CAUTION: the maximum duration has to be set with a format like "hh:mm"
367   jobParameters->maximum_duration = CORBA::string_dup("01:00");
368   jobParameters->queue = CORBA::string_dup("");
369
370   // Setting resource and additionnal properties (if needed)
371   // The resource parameters can be initiated from scratch, for
372   // example by specifying the values in hard coding:
373   // >>>
374   //jobParameters->resource_required.name = CORBA::string_dup("localhost");
375   //jobParameters->resource_required.hostname = CORBA::string_dup("localhost");
376   //jobParameters->resource_required.mem_mb = 1024 * 10;
377   //jobParameters->resource_required.nb_proc = 1;
378   // <<<
379   // But it's better to initiate these parameters from a resource
380   // definition known by the resource manager. This ensures that the
381   // resource will be available:
382   //const char * resourceName = "localhost";
383   //const char * resourceName = "boulant@claui2p1";
384   //const char * resourceName = "nepal@nepal";
385   const char * resourceName = _configMap[configId].resname;
386   Engines::ResourceDefinition * resourceDefinition = _resourcesManager->GetResourceDefinition(resourceName);
387   // CAUTION: This resource should have been defined in the
388   // CatalogResource.xml associated to the SALOME application.
389   //
390   // Then, the values can be used to initiate the resource parameters
391   // of the job:
392   jobParameters->resource_required.name     = CORBA::string_dup(resourceDefinition->name.in());
393   // CAUTION: the additionnal two following parameters MUST be
394   // specified explicitly, because they are not provided by the
395   // resource definition:
396   jobParameters->resource_required.mem_mb   = resourceDefinition->mem_mb;
397   jobParameters->resource_required.nb_proc  = resourceDefinition->nb_proc_per_node;
398   // CAUTION: the parameter mem_mb specifies the maximum memory value
399   // that could be allocated for executing the job. This takes into
400   // account not only the data that could be loaded by the batch
401   // process but also the linked dynamic library.
402   //
403   // A possible problem, for exemple in the case where you use the ssh
404   // emulation of a batch system, is to get an error message as below
405   // when libBatch try to run the ssh command:
406   //
407   // ## /usr/bin/ssh: error while loading shared libraries: libcrypto.so.0.9.8: failed
408   // ## to map segment from shared object: Cannot allocate memory
409   //
410   // In this exemple, the mem_mb was set to 1MB, value that is not
411   // sufficient to load the dynamic libraries linked to the ssh
412   // executable (libcrypto.so in the error message).
413   //
414   // So, even in the case of a simple test shell script, you should
415   // set this value at least to a standard threshold as 500MB
416
417   int jobId = JOBID_UNDEFINED;
418   try {
419     std::cerr << "#####################################" << std::endl;
420     std::cerr << "#####################################" << std::endl;
421     std::cerr << "jobUndef = " << JOBID_UNDEFINED << std::endl;
422     jobId = _salomeLauncher->createJob(jobParameters);
423     std::cerr << "#####################################" << std::endl;
424     std::cerr << "#####################################" << std::endl;
425     std::cerr << "#####################################" << std::endl;
426     std::cerr << "jobId = " << jobId << std::endl;
427     // We register the datetime tag of this job
428     _jobDateTimeMap[jobId]=jobDatetimeTag;
429     _jobPathsMap[jobId] = jobPaths;
430   }
431   catch (const SALOME::SALOME_Exception & ex) {
432     LOG("SALOME Exception in createJob !" <<ex.details.text.in());
433     //LOG(ex.details.text.in());
434     return JOBID_UNDEFINED;
435   }
436   catch (const CORBA::SystemException& ex) {
437     LOG("Receive SALOME System Exception: "<<ex);
438     LOG("Check SALOME servers...");
439     return JOBID_UNDEFINED;
440   }
441   
442   endService("MeshJobManager_i::initialize");
443   return jobId;
444 }
445
446 /*! Submit the job execution and return true if submission is OK */
447 bool MeshJobManager_i::start(CORBA::Long jobId) {
448   beginService("MeshJobManager_i::start");
449
450   try {
451     _salomeLauncher->launchJob(jobId);
452   }
453   catch (const SALOME::SALOME_Exception & ex) {
454     LOG("SALOME Exception in launchjob !" <<ex.details.text.in());
455     //LOG(ex.details.text.in());
456     return false;
457   }
458   catch (const CORBA::SystemException& ex) {
459     LOG("Receive SALOME System Exception: "<<ex);
460     LOG("Check SALOME servers...");
461     return false;
462   }
463
464   endService("MeshJobManager_i::initialize");
465   return true;
466 }
467
468 /*! Request the launch manager for the state of the specified job */
469 char* MeshJobManager_i::getState(CORBA::Long jobId) {
470   beginService("MeshJobManager_i::getState");
471
472   std::string state;
473   try
474   {
475     state = _salomeLauncher->getJobState(jobId);
476   }
477   catch (const SALOME::SALOME_Exception & ex)
478   {
479     LOG("SALOME Exception in getJobState !");
480     state = ex.details.text;
481   }
482   catch (const CORBA::SystemException& ex)
483   {
484     LOG("Receive SALOME System Exception: " << ex);
485     state="SALOME System Exception - see logs";
486   }
487   LOG("jobId="<<ToString(jobId)<<" state="<<state);
488   endService("MeshJobManager_i::getState");
489   return CORBA::string_dup(state.c_str());
490 }
491
492 MESHJOB::MeshJobPaths * MeshJobManager_i::getPaths(CORBA::Long jobId) {
493
494   MESHJOB::MeshJobPaths * jobPaths = _jobPathsMap[jobId];
495   if ( jobPaths == NULL ) {
496     LOG("You request the working paths for an undefined job (jobId="<<ToString(jobId)<<")");
497     return NULL; // Maybe raise an exception?
498   }
499   return jobPaths;
500 }
501
502
503 MESHJOB::MeshJobResults * MeshJobManager_i::finalize(CORBA::Long jobId) {
504   beginService("MeshJobManager_i::getResults");
505   MESHJOB::MeshJobResults * result = new MESHJOB::MeshJobResults();
506
507   MESHJOB::MeshJobPaths * jobPaths = this->getPaths(jobId);
508   std::string local_resultdir(jobPaths->local_resultdir);
509   result->results_dirname = local_resultdir.c_str();  
510   try
511   {
512     _salomeLauncher->getJobResults(jobId, local_resultdir.c_str());
513  
514     // __BUG__: to prevent from a bug of the MED driver (SALOME
515     // 5.1.5), we change the basename of the output file to force the
516     // complete reloading of data by the med driver.
517     long jobDatetimeTag = _jobDateTimeMap[jobId];
518     std::string outputFileName = "output"+ToString(jobDatetimeTag)+".med";
519     rename((local_resultdir+"/"+OUTPUTFILE).c_str(), (local_resultdir+"/"+outputFileName).c_str());
520
521     result->outputmesh_filename = outputFileName.c_str();
522     result->status = "OK";
523  }
524   catch (const SALOME::SALOME_Exception & ex)
525   {
526     LOG("SALOME Exception in getResults !");
527     result->status = "SALOME Exception in getResults !";
528   }
529   catch (const CORBA::SystemException& ex)
530   {
531     LOG("Receive CORBA System Exception: " << ex);
532     result->status = "Receive CORBA System Exception: see log";
533   }
534   endService("MeshJobManager_i::getResults");
535   return result;
536 }
537
538
539 /*! Clean all data associated to this job and remove the job from the launch manager */
540 bool MeshJobManager_i::clean(CORBA::Long jobId) {
541   beginService("MeshJobManager_i::clean");
542   
543   // __GBO__ WORK IN PROGRESS: we just clean the temporary local
544   // directories. The remote working directories are tag with the
545   // execution datetime and the we prevent the task from conflict
546   // with files of another task.
547   MESHJOB::MeshJobPaths * jobPaths = this->getPaths(jobId);
548   if ( jobPaths == NULL ) return false;
549
550   // WARN: !!!!!
551   // For safety reason (and prevent from bug that could erase the
552   // filesystem), we cancel the operation in the case where the
553   // directories to delete are not in the /tmp folder.
554   std::string shell_command("rm -rf ");
555   std::string inputdir(jobPaths->local_inputdir);
556   std::string resultdir(jobPaths->local_resultdir);
557   if ( !myStartsWith(inputdir,"/tmp/") )  {
558     LOG("WRN: The directory "<<inputdir<<" is not in /tmp. NO DELETE is done");
559   } else {
560     shell_command+=inputdir+" ";
561   }
562   if ( !myStartsWith(resultdir,"/tmp/"))  {
563     LOG("WRN: The directory "<<resultdir<<" is not in /tmp. NO DELETE is done");
564   } else {
565     shell_command+=resultdir;
566   }
567
568   LOG("DBG: clean shell command = "<<shell_command);
569
570   bool cleanOk = false;
571   int error = system(shell_command.c_str());
572   if (error == 0) cleanOk = true;
573
574   endService("MeshJobManager_i::clean");
575   return cleanOk;
576 }
577
578
579 std::vector<std::string> * MeshJobManager_i::_getResourceNames() {
580
581   //
582   // These part is just to control the available resources
583   //
584   Engines::ResourceParameters params;
585   KERNEL::getLifeCycleCORBA()->preSet(params);
586
587   Engines::ResourceList * resourceList = _resourcesManager->GetFittingResources(params);
588   Engines::ResourceDefinition * resourceDefinition = NULL;
589   LOG("### resource list:");
590   std::vector<std::string>* resourceNames = new std::vector<std::string>();
591   if (resourceList) {
592     for (int i = 0; i < resourceList->length(); i++) {
593       const char* aResourceName = (*resourceList)[i];
594       resourceNames->push_back(std::string(aResourceName));
595       LOG("resource["<<i<<"] = "<<aResourceName);
596       resourceDefinition = _resourcesManager->GetResourceDefinition(aResourceName);
597       LOG("protocol["<<i<<"] = "<<resourceDefinition->protocol);
598     }
599   }
600
601   // Note: a ResourceDefinition is used to create a batch configuration
602   // in the Launcher. This operation is done at Launcher startup from
603   // the configuration file CatalogResources.xml provided by the
604   // SALOME application.
605   // In the code instructions, you just have to choose a resource
606   // configuration by its name and then define the ResourceParameters
607   // that specify additionnal properties for a specific job submission
608   // (use the attribute resource_required of the JobParameters).
609
610   return resourceNames;
611 }
612
613
614 //
615 // ==========================================================================
616 // Factory services
617 // ==========================================================================
618 //
619 extern "C"
620 {
621   PortableServer::ObjectId * MeshJobManagerEngine_factory( CORBA::ORB_ptr orb,
622                                                            PortableServer::POA_ptr poa,
623                                                            PortableServer::ObjectId * contId,
624                                                            const char *instanceName,
625                                                            const char *interfaceName)
626   {
627     LOG("PortableServer::ObjectId * MeshJobManagerEngine_factory()");
628     MeshJobManager_i * myEngine = new MeshJobManager_i(orb, poa, contId, instanceName, interfaceName);
629     return myEngine->getId() ;
630   }
631 }