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