Salome HOME
89273d8acca198bb2310df6a91b3523c0819a694
[modules/jobmanager.git] / src / engine / BL_SALOMEServices.hxx
1 // Copyright (C) 2009-2022  CEA/DEN, 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, or (at your option) any later version.
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 #ifndef _BL_SALOMESERVICES_HXX_
21 #define _BL_SALOMESERVICES_HXX_
22
23 #include "BL_Engine.hxx"
24 #include "BL_Traces.hxx"
25 #include "BL_Job.hxx"
26 #include "BL_NamingService_Wrapper.hxx"
27
28 #include "SALOME_NamingService.hxx"
29 #include "SALOME_LifeCycleCORBA.hxx"
30 #include "SALOME_ContainerManager.hh"
31 #include "BL_JobsManager.hxx"
32
33 #include <map>
34 #include <list>
35 #include <string>
36
37 #include "JOBMANAGER_IDL.hh"
38
39
40 namespace BL{
41
42   class JobsManager;
43
44   struct BL_Engine_EXPORT ResourceDescr
45   {
46     std::string name;
47     std::string hostname;
48     std::string protocol;
49     std::string username;
50     std::string applipath;
51     std::list<std::string> componentList;
52
53     std::string OS;
54     unsigned int mem_mb;
55     unsigned int cpu_clock;
56     unsigned int nb_node;
57     unsigned int nb_proc_per_node;
58     std::string batch;
59     std::string mpiImpl;
60     std::string iprotocol;
61
62     bool can_launch_batch_jobs;
63     bool can_run_containers;
64     std::string working_directory;
65   };
66
67   class BL_Engine_EXPORT SALOMEServices :
68     public POA_JOBMANAGER::LauncherObserver
69   {
70     public:
71       SALOMEServices();
72       virtual ~SALOMEServices();
73
74       bool initNS();
75       void end();
76
77       void set_manager(BL::JobsManager * manager) {_manager = manager;}
78
79       std::list<std::string> getResourceList(bool batch_only);
80       BL::ResourceDescr getResourceDescr(const std::string& name);
81       void addResource(BL::ResourceDescr & new_resource);
82       void removeResource(const std::string & name);
83
84       std::string save_jobs(const std::string & file_name);
85       std::string load_jobs(const std::string & file_name);
86
87       std::string create_job(BL::Job * job);
88       std::string start_job(BL::Job * job);
89       std::string refresh_job(BL::Job * job);
90       std::string delete_job(BL::Job * job);
91       std::string stop_job(BL::Job * job);
92       std::string get_results_job(BL::Job * job);
93       std::string get_assigned_hostnames(BL::Job * job); // Get names or ids of hosts assigned to the job
94
95       BL::Job * get_new_job(int job_number);
96
97       virtual void notify(const char* event_name, const char * event_data);
98
99     private:
100       CORBA::ORB_var _orb;
101       BL_SALOME_NamingService_Wrapper * _salome_naming_service;
102       SALOME_LifeCycleCORBA * _lcc;
103       Engines::SalomeLauncher_var _salome_launcher;
104       Engines::ResourcesManager_var _resources_manager;
105
106       BL::JobsManager * _manager;
107
108       bool _state;
109   };
110
111 }
112
113 #endif
114
115