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/workflow/job/WorkflowJob.h"
21 #include "wrench/workflow/job/StandardJob.h"
22 #include "wrench/workflow/job/PilotJob.h"
23 
24 namespace wrench {
25 
26  class Simulation;
27 
28  class StorageService;
29 
33  class ComputeService : public Service {
34 
35  /***********************/
37  /***********************/
38 
39  friend class StandardJobExecutorTest;
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  virtual ~ComputeService() {}
64 
65  void stop() override;
66 
67 // void submitJob(WorkflowJob *job, const std::map<std::string, std::string>& = {});
68 
69  void terminateJob(std::shared_ptr<WorkflowJob> job);
70 
71  bool supportsStandardJobs();
72 
73  bool supportsPilotJobs();
74 
75  bool hasScratch();
76 
77  unsigned long getNumHosts();
78 
79  std::map<std::string, unsigned long> getPerHostNumCores();
80 
81  unsigned long getTotalNumCores();
82 
83  std::map<std::string, unsigned long> getPerHostNumIdleCores();
84 
85  virtual unsigned long getTotalNumIdleCores();
86 
87  std::map<std::string, double> getMemoryCapacity();
88 
89  std::map<std::string, double> getPerHostAvailableMemoryCapacity();
90 
91  std::map<std::string, double> getCoreFlopRate();
92 
93  double getTTL();
94 
95  double getTotalScratchSpaceSize();
96 
97  double getFreeScratchSpaceSize();
98 
99 
100  /***********************/
102  /***********************/
103 
104  /***********************/
106  /***********************/
107 
114  virtual void
115  submitStandardJob(std::shared_ptr<StandardJob> job, const std::map<std::string, std::string> &service_specific_arguments) = 0;
116 
123  virtual void submitPilotJob(std::shared_ptr<PilotJob> job, const std::map<std::string, std::string> &service_specific_arguments) = 0;
124 
129  virtual void terminateStandardJob(std::shared_ptr<StandardJob> job) = 0;
130 
135  virtual void terminatePilotJob(std::shared_ptr<PilotJob> job) = 0;
136 
141  std::shared_ptr<StorageService> getScratch();
142 
143 
144  ComputeService(const std::string &hostname,
145  std::string service_name,
146  std::string mailbox_name_prefix,
147  std::string scratch_space_mount_point);
148 
149  protected:
150 
151  friend class JobManager;
152 
153  void submitJob(std::shared_ptr<WorkflowJob> job, const std::map<std::string, std::string>& = {});
154 
155  ComputeService(const std::string &hostname,
156  std::string service_name,
157  std::string mailbox_name_prefix,
158  std::shared_ptr<StorageService> scratch_space);
159 
161  std::shared_ptr<StorageService> scratch_space_storage_service;
162 
163  /***********************/
165  /***********************/
166 
167  /***********************/
169  /***********************/
170 
171  std::shared_ptr<StorageService> getScratchSharedPtr();
172 
173  /***********************/
175  /***********************/
176 
177  private:
178 
179 
180  std::shared_ptr<StorageService> scratch_space_storage_service_shared_ptr;
181 
182  std::map<std::string, std::map<std::string, double>> getServiceResourceInformation();
183 
184  };
185 
186 
187 };
188 
189 #endif //SIMULATION_COMPUTESERVICE_H
double getTotalScratchSpaceSize()
Get the total capacity of the compute service's scratch storage space.
Definition: ComputeService.cpp:441
std::map< std::string, double > getPerHostAvailableMemoryCapacity()
Get ram availability for each of the compute service's host.
Definition: ComputeService.cpp:281
ComputeService(const std::string &hostname, std::string service_name, std::string mailbox_name_prefix, std::string scratch_space_mount_point)
Constructor.
Definition: ComputeService.cpp:112
bool hasScratch()
Checks if the compute service has a scratch space.
Definition: ComputeService.cpp:475
void submitJob(std::shared_ptr< WorkflowJob > job, const std::map< std::string, std::string > &={})
Submit a job to the compute service.
Definition: ComputeService.cpp:57
std::map< std::string, unsigned long > getPerHostNumIdleCores()
Get idle core counts for each of the compute service's host.
Definition: ComputeService.cpp:254
virtual void submitPilotJob(std::shared_ptr< PilotJob > job, const std::map< std::string, std::string > &service_specific_arguments)=0
Method to submit a pilot job to the service.
double getTTL()
Get the time-to-live of the compute service.
Definition: ComputeService.cpp:384
virtual unsigned long getTotalNumIdleCores()
Get the total idle core count for all hosts of the compute service.
Definition: ComputeService.cpp:308
A helper daemon (co-located with and explicitly started by a WMS), which is used to handle all job ex...
Definition: JobManager.h:40
std::map< std::string, double > getCoreFlopRate()
Get the per-core flop rate of the compute service's hosts.
Definition: ComputeService.cpp:333
The compute service base class.
Definition: ComputeService.h:33
std::shared_ptr< StorageService > getScratch()
Method that returns the computer service's scratch space's storage service.
Definition: ComputeService.cpp:459
Definition: Alarm.cpp:20
std::map< std::string, unsigned long > getPerHostNumCores()
Get core counts for each of the compute service's host.
Definition: ComputeService.cpp:201
virtual void submitStandardJob(std::shared_ptr< StandardJob > job, const std::map< std::string, std::string > &service_specific_arguments)=0
Method to submit a standard job to the service.
virtual void terminatePilotJob(std::shared_ptr< PilotJob > job)=0
Method to terminate a running pilot job.
double getFreeScratchSpaceSize()
Get the free space on the compute service's scratch storage space.
Definition: ComputeService.cpp:450
std::shared_ptr< StorageService > getScratchSharedPtr()
Get a shared pointer to the compute service's scratch storage space.
Definition: ComputeService.cpp:467
void stop() override
Stop the compute service - must be called by the stop() method of derived classes.
Definition: ComputeService.cpp:33
unsigned long getTotalNumCores()
Get the total core counts for all hosts of the compute service.
Definition: ComputeService.cpp:228
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
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:51
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:46
bool supportsStandardJobs()
Get whether the compute service supports standard jobs or not.
Definition: ComputeService.cpp:158
virtual void terminateStandardJob(std::shared_ptr< StandardJob > job)=0
Method to terminate a running standard job.
std::shared_ptr< StorageService > scratch_space_storage_service
A scratch storage service associated to the compute service.
Definition: ComputeService.h:161
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
A service that can be added to the simulation and that can be used by a WMS when executing a workflow...
Definition: Service.h:26
unsigned long getNumHosts()
Get the number of hosts that the compute service manages.
Definition: ComputeService.cpp:177
std::map< std::string, double > getMemoryCapacity()
Get the RAM capacities for each of the compute service's hosts.
Definition: ComputeService.cpp:358
void terminateJob(std::shared_ptr< WorkflowJob > job)
Terminate a previously-submitted job (which may or may not be running yet)
Definition: ComputeService.cpp:85
bool supportsPilotJobs()
Get whether the compute service supports pilot jobs or not.
Definition: ComputeService.cpp:166