WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
ComputeService.h
1 
10 #ifndef SIMULATION_COMPUTESERVICE_H
11 #define SIMULATION_COMPUTESERVICE_H
12 
13 #include <map>
14 
15 #include <iostream>
16 #include <cfloat>
17 #include <climits>
18 
19 #include "wrench/services/Service.h"
20 #include "wrench/job/Job.h"
21 #include "wrench/job/StandardJob.h"
22 #include "wrench/job/PilotJob.h"
23 #include "wrench/job/CompoundJob.h"
24 
25 namespace wrench {
26 
27  class Simulation;
28 
29  class StorageService;
30 
34  class ComputeService : public Service {
35 
36  /***********************/
38  /***********************/
39 
40  friend class Simulation;
41 
42  /***********************/
44  /***********************/
45 
46 
47  public:
48 
52  static constexpr unsigned long ALL_CORES = ULONG_MAX;
53 
57  static constexpr double ALL_RAM = DBL_MAX;
58 
59  /***********************/
61  /***********************/
62 
63 
68  TERMINATION_NONE,
69  TERMINATION_COMPUTE_SERVICE_TERMINATED,
70  TERMINATION_JOB_KILLED,
71  TERMINATION_JOB_TIMEOUT
72  };
73 
74 
75  virtual ~ComputeService() {}
76 
77  void stop() override;
78 
79  virtual void stop(bool send_failure_notifications, ComputeService::TerminationCause termination_cause);
80 
81  void terminateJob(std::shared_ptr<CompoundJob> job);
82 
87  virtual bool supportsStandardJobs() = 0;
88 
93  virtual bool supportsCompoundJobs() = 0;
94 
99  virtual bool supportsPilotJobs() = 0;
100 
101  virtual bool hasScratch() const;
102 
103  unsigned long getNumHosts();
104 
105  std::vector<std::string> getHosts();
106 
107  std::map<std::string, unsigned long> getPerHostNumCores();
108 
109  unsigned long getTotalNumCores();
110 
111  std::map<std::string, unsigned long> getPerHostNumIdleCores();
112 
113  virtual unsigned long getTotalNumIdleCores();
114 
115  virtual bool isThereAtLeastOneHostWithIdleResources(unsigned long num_cores, double ram);
116 
117  std::map<std::string, double> getMemoryCapacity();
118 
119  std::map<std::string, double> getPerHostAvailableMemoryCapacity();
120 
121  std::map<std::string, double> getCoreFlopRate();
122 
123  double getTTL();
124 
125  double getTotalScratchSpaceSize();
126 
127  double getFreeScratchSpaceSize();
128 
129 
130  /***********************/
132  /***********************/
133 
134  /***********************/
136  /***********************/
137 
138 
145  virtual void
146  submitCompoundJob(std::shared_ptr<CompoundJob> job, const std::map<std::string, std::string> &service_specific_arguments) = 0;
147 
148 
153  virtual void terminateCompoundJob(std::shared_ptr<CompoundJob> job) = 0;
154 
155  std::shared_ptr<StorageService> getScratch();
156 
157 
158 
159  ComputeService(const std::string &hostname,
160  std::string service_name,
161  std::string scratch_space_mount_point);
162 
163  protected:
164 
165 
166  friend class JobManager;
167 
168  void submitJob(std::shared_ptr<CompoundJob> job, const std::map<std::string, std::string>& = {});
169 
170  virtual void validateServiceSpecificArguments(std::shared_ptr<CompoundJob> job,
171  std::map<std::string, std::string> &service_specific_args) ;
172 
173  virtual void validateJobsUseOfScratch(std::map<std::string, std::string> &service_specific_args);
174 
175  ComputeService(const std::string &hostname,
176  std::string service_name,
177  std::shared_ptr<StorageService> scratch_space);
178 
180  std::shared_ptr<StorageService> scratch_space_storage_service;
181 
182 
183  /***********************/
185  /***********************/
186 
187  /***********************/
189  /***********************/
190 
191  std::shared_ptr<StorageService> getScratchSharedPtr();
192 
193  /***********************/
195  /***********************/
196 
197  private:
198 
199  std::shared_ptr<StorageService> scratch_space_storage_service_shared_ptr;
200 
201  std::map<std::string, double> getServiceResourceInformation(const std::string &desired_entries);
202 
203  };
204 
205 
206 };
207 
208 #endif //SIMULATION_COMPUTESERVICE_H
wrench::ComputeService::getTotalScratchSpaceSize
double getTotalScratchSpaceSize()
Get the total capacity of the compute service's scratch storage space.
Definition: ComputeService.cpp:527
wrench::ComputeService::getPerHostAvailableMemoryCapacity
std::map< std::string, double > getPerHostAvailableMemoryCapacity()
Get ram availability for each of the compute service's host.
Definition: ComputeService.cpp:325
wrench::ComputeService::TerminationCause
TerminationCause
Job termination cause enum.
Definition: ComputeService.h:67
wrench::ComputeService::getPerHostNumIdleCores
std::map< std::string, unsigned long > getPerHostNumIdleCores()
Get idle core counts for each of the compute service's host.
Definition: ComputeService.cpp:300
wrench::ComputeService::hasScratch
virtual bool hasScratch() const
Checks if the compute service has a scratch space.
Definition: ComputeService.cpp:561
wrench::ComputeService::terminateCompoundJob
virtual void terminateCompoundJob(std::shared_ptr< CompoundJob > job)=0
Method to terminate a compound job.
wrench::ComputeService::getTTL
double getTTL()
Get the time-to-live of the compute service.
Definition: ComputeService.cpp:468
wrench::ComputeService::getTotalNumIdleCores
virtual unsigned long getTotalNumIdleCores()
Get the total idle core count for all hosts of the compute service. Note that this doesn't mean that ...
Definition: ComputeService.cpp:353
wrench::ComputeService::getCoreFlopRate
std::map< std::string, double > getCoreFlopRate()
Get the per-core flop rate of the compute service's hosts.
Definition: ComputeService.cpp:421
wrench::ComputeService::supportsPilotJobs
virtual bool supportsPilotJobs()=0
Returns true if the service supports compound jobs.
wrench::ComputeService
The compute service base class.
Definition: ComputeService.h:34
wrench::ComputeService::getHosts
std::vector< std::string > getHosts()
Get the list of the compute service's compute host.
Definition: ComputeService.cpp:221
wrench::ComputeService::getScratch
std::shared_ptr< StorageService > getScratch()
Get the compute service's scratch storage space.
Definition: ComputeService.cpp:545
wrench::ComputeService::validateJobsUseOfScratch
virtual void validateJobsUseOfScratch(std::map< std::string, std::string > &service_specific_args)
Method to validate that a job's use of the scratch space if ok. Throws exception if not.
Definition: ComputeService.cpp:580
wrench
Definition: Action.cpp:28
wrench::ComputeService::getPerHostNumCores
std::map< std::string, unsigned long > getPerHostNumCores()
Get core counts for each of the compute service's host.
Definition: ComputeService.cpp:248
wrench::ComputeService::submitJob
void submitJob(std::shared_ptr< CompoundJob > job, const std::map< std::string, std::string > &={})
Submit a job to the compute service.
Definition: ComputeService.cpp:108
wrench::ComputeService::ComputeService
ComputeService(const std::string &hostname, std::string service_name, std::string scratch_space_mount_point)
Constructor.
Definition: ComputeService.cpp:155
wrench::ComputeService::getFreeScratchSpaceSize
double getFreeScratchSpaceSize()
Get the free space on the compute service's scratch storage space.
Definition: ComputeService.cpp:536
wrench::ComputeService::supportsStandardJobs
virtual bool supportsStandardJobs()=0
Returns true if the service supports standard jobs.
wrench::ComputeService::terminateJob
void terminateJob(std::shared_ptr< CompoundJob > job)
Terminate a previously-submitted job (which may or may not be running yet)
Definition: ComputeService.cpp:132
wrench::ComputeService::submitCompoundJob
virtual void submitCompoundJob(std::shared_ptr< CompoundJob > job, const std::map< std::string, std::string > &service_specific_arguments)=0
Method to submit a compound job to the service.
wrench::ComputeService::getScratchSharedPtr
std::shared_ptr< StorageService > getScratchSharedPtr()
Get a shared pointer to the compute service's scratch storage space.
Definition: ComputeService.cpp:553
wrench::ComputeService::stop
void stop() override
Stop the compute service.
Definition: ComputeService.cpp:32
wrench::ComputeService::getTotalNumCores
unsigned long getTotalNumCores()
Get the total core counts for all hosts of the compute service.
Definition: ComputeService.cpp:273
wrench::ComputeService::validateServiceSpecificArguments
virtual void validateServiceSpecificArguments(std::shared_ptr< CompoundJob > job, std::map< std::string, std::string > &service_specific_args)
Method the validates service-specific arguments (throws std::invalid_argument if invalid)
Definition: ComputeService.cpp:570
wrench::ComputeService::ALL_CORES
static constexpr unsigned long ALL_CORES
A convenient constant to mean "use all cores of a physical host" whenever a number of cores is needed...
Definition: ComputeService.h:52
wrench::S4U_Daemon::hostname
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:60
wrench::Simulation
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:48
wrench::ComputeService::scratch_space_storage_service
std::shared_ptr< StorageService > scratch_space_storage_service
A scratch storage service associated to the compute service.
Definition: ComputeService.h:180
wrench::ComputeService::supportsCompoundJobs
virtual bool supportsCompoundJobs()=0
Returns true if the service supports pilot jobs.
wrench::ComputeService::ALL_RAM
static constexpr double ALL_RAM
A convenient constant to mean "use all ram of a physical host" whenever a ram capacity is needed when...
Definition: ComputeService.h:57
wrench::Service
A service that can be added to the simulation and that can be used by a WMS when executing a workflow...
Definition: Service.h:31
wrench::ComputeService::isThereAtLeastOneHostWithIdleResources
virtual bool isThereAtLeastOneHostWithIdleResources(unsigned long num_cores, double ram)
Method to find out if, right now, the compute service has at least one host with some idle number of ...
Definition: ComputeService.cpp:380
wrench::ComputeService::getNumHosts
unsigned long getNumHosts()
Get the number of hosts that the compute service manages.
Definition: ComputeService.cpp:202
wrench::ComputeService::getMemoryCapacity
std::map< std::string, double > getMemoryCapacity()
Get the RAM capacities for each of the compute service's hosts.
Definition: ComputeService.cpp:444