Version: 9.16.0
ResourcesManager.hxx
Go to the documentation of this file.
1// Copyright (C) 2007-2026 CEA, EDF, 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#ifndef __RESOURCESMANAGER_HXX__
24#define __RESOURCESMANAGER_HXX__
25
27
28#include <string>
29#include <fstream>
30#include <vector>
31#include <list>
34#include <sys/types.h>
35#include <sys/stat.h>
36#ifdef WIN32
37#else
38#include <unistd.h>
39#endif
40
41#ifdef WIN32
42#pragma warning(disable:4251) // Warning DLL Interface ...
43//#pragma warning(disable:4290) // Warning Exception ...
44#endif
45
46// --- WARNING ---
47// The call of BuildTempFileToLaunchRemoteContainer and RmTmpFile must be done
48// in a critical section to be sure to be clean.
49// Only one thread should use the SALOME_ResourcesManager class in a SALOME
50// session.
52{
54
55 std::string name;
56 std::string hostname;
59 std::string OS;
60 long nb_proc;
61 long nb_node;
64 long mem_mb;
65 std::vector<std::string> componentList;
66 std::vector<std::string> resourceList;
67};
68
70 {
71
72 public:
73
74 ResourcesManager_cpp(const char *xmlFilePath);
76
78
79 std::vector<std::string>
80 GetFittingResources(const resourceParams& params);
81
82 std::string Find(const std::string& policy, const std::vector<std::string>& listOfResources) const;
83
84 void AddResourceInCatalogNoQuestion (const ParserResourcesType & new_resource);
85
86 void AddResourceInCatalog (const ParserResourcesType & new_resource);
87
88 void DeleteAllResourcesInCatalog();
89
90 void DeleteResourceInCatalog(const char * name);
91
92 void WriteInXmlFile(std::string xml_file);
93
94 const MapOfParserResourcesType& ParseXmlFiles();
95
96 const MapOfParserResourcesType& GetList() const;
97
99 ParserResourcesType GetResourcesDescr(const std::string & name) const;
100
101 protected:
102
103 void SelectOnlyResourcesWithOS(std::vector<std::string>& resources, std::string OS);
104
105 void KeepOnlyResourcesWithComponent(std::vector<std::string>& resources,
106 const std::vector<std::string>& componentList);
107
111 void AddDefaultResourceInCatalog();
112
114 std::list<std::string> _path_resources;
115 std::list<std::string>::iterator _path_resources_it;
116
119
121 std::map<std::string , LoadRateManager*> _resourceManagerMap;
122
124 time_t _lasttime = 0;
125
127 static const std::string DEFAULT_RESOURCE_NAME;
128 };
129
130#endif // __RESOURCESMANAGER_HXX__
#define RESOURCESMANAGER_EXPORT
Definition: ResourcesManager_Defs.hxx:33
std::map< std::string, ParserResourcesType > MapOfParserResourcesType
Definition: SALOME_ResourcesCatalog_Parser.hxx:144
Definition: SALOME_ResourcesCatalog_Parser.hxx:90
Definition: ResourcesManager.hxx:70
std::list< std::string > _path_resources
will contain the path to the resources catalog
Definition: ResourcesManager.hxx:114
std::list< std::string >::iterator _path_resources_it
Definition: ResourcesManager.hxx:115
static const std::string DEFAULT_RESOURCE_NAME
the name of the default local resource
Definition: ResourcesManager.hxx:127
std::map< std::string, LoadRateManager * > _resourceManagerMap
a map that contains all the available load rate managers (the key is the name)
Definition: ResourcesManager.hxx:121
MapOfParserResourcesType _resourcesList
will contain the information on the data type catalog(after parsing)
Definition: ResourcesManager.hxx:118
string name
Definition: pythfilter.py:56
Definition: ResourcesManager.hxx:52
std::vector< std::string > resourceList
Definition: ResourcesManager.hxx:66
long mem_mb
Definition: ResourcesManager.hxx:64
std::string OS
Definition: ResourcesManager.hxx:59
long nb_node
Definition: ResourcesManager.hxx:61
long nb_proc
Definition: ResourcesManager.hxx:60
long cpu_clock
Definition: ResourcesManager.hxx:63
std::string name
Definition: ResourcesManager.hxx:55
bool can_launch_batch_jobs
Definition: ResourcesManager.hxx:57
std::vector< std::string > componentList
Definition: ResourcesManager.hxx:65
std::string hostname
Definition: ResourcesManager.hxx:56
long nb_proc_per_node
Definition: ResourcesManager.hxx:62
bool can_run_containers
Definition: ResourcesManager.hxx:58