1 // Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef __LAUNCHER_HXX__
24 #define __LAUNCHER_HXX__
26 #include "Launcher_Utils.hxx"
27 #include "Launcher_Job.hxx"
29 #include "ResourcesManager.hxx"
30 #include <SALOME_ResourcesCatalog_Parser.hxx>
32 #include "SALOME_Launcher_Parser.hxx"
46 struct LAUNCHER_EXPORT JobParameters_cpp
51 std::string pre_command;
53 std::list<std::string> in_files;
54 std::list<std::string> out_files;
55 std::string work_directory;
56 std::string local_directory;
57 std::string result_directory;
58 std::string maximum_duration;
59 resourceParams resource_required;
61 std::string partition;
63 unsigned int mem_per_cpu;
65 std::string extra_params;
66 std::map<std::string, std::string> specific_parameters;
67 std::string launcher_file;
68 std::string launcher_args;
71 class LAUNCHER_EXPORT Launcher_cpp
75 virtual ~Launcher_cpp();
78 void createJob(Launcher::Job * new_job);
79 int createJob(const JobParameters_cpp& job_parameters);
80 void launchJob(int job_id);
81 std::string getJobState(int job_id);
82 std::string getAssignedHostnames(int job_id); // Get names or ids of hosts assigned to the job
83 void exportInputFiles(int job_id);
84 void getJobResults(int job_id, std::string directory);
85 void clearJobWorkingDir(int job_id);
86 bool getJobDumpState(int job_id, std::string directory);
87 bool getJobWorkFile(int job_id, std::string work_file, std::string directory);
88 void stopJob(int job_id);
89 void removeJob(int job_id);
90 std::string dumpJob(int job_id);
91 int restoreJob(const std::string& dumpedJob);
92 JobParameters_cpp getJobParameters(int job_id);
94 /*! Load the jobs from the file "jobs_file" and add them to the Launcher.
95 * Return a list with the IDs of the jobs that were successfully loaded.
97 std::list<int> loadJobs(const char* jobs_file);
99 //! Save the jobs of the Launcher to the file "jobs_file".
100 void saveJobs(const char* jobs_file);
103 long createJobWithFile(std::string xmlExecuteFile, std::string clusterName);
104 std::map<int, Launcher::Job *> getJobs();
105 void addJobDirectlyToMap(Launcher::Job * new_job);
106 Launcher::Job * findJob(int job_id);
109 void SetResourcesManager( std::shared_ptr<ResourcesManager_cpp>& rm ) {_ResManager = rm;}
113 // Used by SALOME_Launcher
114 std::shared_ptr<ResourcesManager_cpp> _ResManager;
116 virtual void notifyObservers(const std::string & /*event_name*/, const std::string & /*event_data*/) {}
117 int addJob(Launcher::Job * new_job);
119 // Methods used by user interface methods
121 Batch::BatchManager *FactoryBatchManager(ParserResourcesType& params);
122 std::map <int, Batch::BatchManager*> _batchmap;
123 Batch::BatchManager* getBatchManager(Launcher::Job * job);
125 ParserLauncherType ParseXmlFile(std::string xmlExecuteFile);
127 std::map <int, Launcher::Job *> _launcher_job_map;
128 int _job_cpt; // job number counter