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 
22 namespace wrench {
23 
24  class Simulation;
25 
26  class StandardJob;
27 
28  class PilotJob;
29 
30  class StorageService;
31 
35  class ComputeService : public Service {
36 
37  /***********************/
39  /***********************/
40 
41  friend class StandardJobExecutorTest;
42  friend class Simulation;
43 
44  /***********************/
46  /***********************/
47 
48 
49  public:
50 
54  static constexpr unsigned long ALL_CORES = ULONG_MAX;
55 
59  static constexpr double ALL_RAM = DBL_MAX;
60 
61  /***********************/
63  /***********************/
64 
65  virtual ~ComputeService() {}
66 
67  void stop() override;
68 
69  void submitJob(WorkflowJob *job, std::map<std::string, std::string> = {});
70 
71  void terminateJob(WorkflowJob *job);
72 
73  bool supportsStandardJobs();
74 
75  bool supportsPilotJobs();
76 
77  bool hasScratch();
78 
79  unsigned long getNumHosts();
80 
81  std::map<std::string, unsigned long> getPerHostNumCores();
82 
83  unsigned long getTotalNumCores();
84 
85  std::map<std::string, unsigned long> getPerHostNumIdleCores();
86 
87  virtual unsigned long getTotalNumIdleCores();
88 
89  std::map<std::string, double> getMemoryCapacity();
90 
91  std::map<std::string, double> getPerHostAvailableMemoryCapacity();
92 
93  std::map<std::string, double> getCoreFlopRate();
94 
95  double getTTL();
96 
97  double getTotalScratchSpaceSize();
98 
99  double getFreeScratchSpaceSize();
100 
101 
102  /***********************/
104  /***********************/
105 
106  /***********************/
108  /***********************/
109 
110 
117  virtual void
118  submitStandardJob(StandardJob *job, std::map<std::string, std::string> &service_specific_arguments) = 0;
119 
126  virtual void submitPilotJob(PilotJob *job, std::map<std::string, std::string> &service_specific_arguments) = 0;
127 
132  virtual void terminateStandardJob(StandardJob *job) = 0;
133 
138  virtual void terminatePilotJob(PilotJob *job) = 0;
139 
140  ComputeService(const std::string &hostname,
141  std::string service_name,
142  std::string mailbox_name_prefix,
143  std::string scratch_space_mount_point);
144 
145 
146  protected:
147 
148  std::shared_ptr<StorageService> getScratch();
149 
150  ComputeService(const std::string &hostname,
151  std::string service_name,
152  std::string mailbox_name_prefix,
153  std::shared_ptr<StorageService> scratch_space);
154 
156  std::shared_ptr<StorageService> scratch_space_storage_service;
157 
158  /***********************/
160  /***********************/
161 
162  /***********************/
164  /***********************/
165 
166  std::shared_ptr<StorageService> getScratchSharedPtr();
167 
168  /***********************/
170  /***********************/
171 
172  private:
173 
174  std::shared_ptr<StorageService> scratch_space_storage_service_shared_ptr;
175 
176  std::map<std::string, std::map<std::string, double>> getServiceResourceInformation();
177 
178  };
179 
180 
181 };
182 
183 #endif //SIMULATION_COMPUTESERVICE_H
std::map< std::string, unsigned long > getPerHostNumCores()
Get core counts for each of the compute service&#39;s host.
Definition: ComputeService.cpp:209
virtual unsigned long getTotalNumIdleCores()
Get the total idle core count for all hosts of the compute service.
Definition: ComputeService.cpp:316
std::shared_ptr< StorageService > getScratchSharedPtr()
Get a shared pointer to the compute service&#39;s scratch storage space.
Definition: ComputeService.cpp:475
virtual void submitStandardJob(StandardJob *job, std::map< std::string, std::string > &service_specific_arguments)=0
Method to submit a standard job to the 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:26
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:59
virtual void terminatePilotJob(PilotJob *job)=0
Method to terminate a running pilot job.
unsigned long getTotalNumCores()
Get the total core counts for all hosts of the compute service.
Definition: ComputeService.cpp:236
Abstraction of a job used for executing tasks in a Workflow.
Definition: WorkflowJob.h:34
unsigned long getNumHosts()
Get the number of hosts that the compute service manages.
Definition: ComputeService.cpp:185
virtual void submitPilotJob(PilotJob *job, std::map< std::string, std::string > &service_specific_arguments)=0
Method to submit a pilot job to the service.
void stop() override
Stop the compute service - must be called by the stop() method of derived classes.
Definition: ComputeService.cpp:32
double getFreeScratchSpaceSize()
Get the free space on the compute service&#39;s scratch storage space.
Definition: ComputeService.cpp:458
bool hasScratch()
Checks if the compute service has a scratch space.
Definition: ComputeService.cpp:483
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:51
bool supportsPilotJobs()
Get whether the compute service supports pilot jobs or not.
Definition: ComputeService.cpp:174
A pilot (i.e., non-standard) workflow job that can be submitted to a ComputeService by a WMS (via a J...
Definition: PilotJob.h:29
A standard (i.e., non-pilot) workflow job that can be submitted to a ComputeService by a WMS (via a J...
Definition: StandardJob.h:38
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:54
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:45
std::map< std::string, double > getCoreFlopRate()
Get the per-core flop rate of the compute service&#39;s hosts.
Definition: ComputeService.cpp:341
double getTotalScratchSpaceSize()
Get the total capacity of the compute service&#39;s scratch storage space.
Definition: ComputeService.cpp:449
The compute service base class.
Definition: ComputeService.h:35
void submitJob(WorkflowJob *job, std::map< std::string, std::string >={})
Submit a job to the compute service.
Definition: ComputeService.cpp:55
std::shared_ptr< StorageService > scratch_space_storage_service
A scratch storage service associated to the compute service.
Definition: ComputeService.h:156
std::shared_ptr< StorageService > getScratch()
Get the compute service&#39;s scratch storage space.
Definition: ComputeService.cpp:467
std::map< std::string, unsigned long > getPerHostNumIdleCores()
Get idle core counts for each of the compute service&#39;s host.
Definition: ComputeService.cpp:262
void terminateJob(WorkflowJob *job)
Terminate a previously-submitted job (which may or may not be running yet)
Definition: ComputeService.cpp:88
std::map< std::string, double > getPerHostAvailableMemoryCapacity()
Get ram availability for each of the compute service&#39;s host.
Definition: ComputeService.cpp:289
virtual void terminateStandardJob(StandardJob *job)=0
Method to terminate a running standard job.
std::map< std::string, double > getMemoryCapacity()
Get the RAM capacities for each of the compute service&#39;s hosts.
Definition: ComputeService.cpp:366
double getTTL()
Get the time-to-live of the compute service.
Definition: ComputeService.cpp:392
bool supportsStandardJobs()
Get whether the compute service supports standard jobs or not.
Definition: ComputeService.cpp:166
Definition: Alarm.cpp:19
ComputeService(const std::string &hostname, std::string service_name, std::string mailbox_name_prefix, std::string scratch_space_mount_point)
Constructor.
Definition: ComputeService.cpp:120