CloudComputeService.h
1 
11 #ifndef WRENCH_CLOUDSERVICE_H
12 #define WRENCH_CLOUDSERVICE_H
13 
14 #include <map>
15 #include <simgrid/s4u/VirtualMachine.hpp>
16 
17 #include "wrench/simulation/Simulation.h"
18 #include "wrench/services/compute/ComputeServiceMessage.h"
19 #include "wrench/services/compute/cloud/CloudComputeServiceProperty.h"
20 #include "wrench/services/compute/cloud/CloudComputeServiceMessagePayload.h"
21 #include "wrench/simgrid_S4U_util/S4U_VirtualMachine.h"
22 #include "wrench/workflow/job/PilotJob.h"
23 
24 
25 namespace wrench {
26 
27  class Simulation;
28 
29  class BareMetalComputeService;
30 
37  private:
38  std::map<std::string, std::string> default_property_values = {
43  };
44 
45  std::map<std::string, double> default_messagepayload_values = {
68  };
69 
70  public:
71  CloudComputeService(const std::string &hostname,
72  std::vector<std::string> execution_hosts,
73  std::string scratch_space_mount_point,
74  std::map<std::string, std::string> property_list = {},
75  std::map<std::string, double> messagepayload_list = {});
76 
77  /***********************/
79  /***********************/
80 
81  virtual std::string createVM(unsigned long num_cores,
82  double ram_memory,
83  std::map<std::string, std::string> property_list = {},
84  std::map<std::string, double> messagepayload_list = {});
85 
86  virtual std::string createVM(unsigned long num_cores,
87  double ram_memory,
88  std::string desired_vm_name,
89  std::map<std::string, std::string> property_list = {},
90  std::map<std::string, double> messagepayload_list = {});
91 
92  virtual void shutdownVM(const std::string &vm_name);
93 
94  virtual std::shared_ptr<BareMetalComputeService> startVM(const std::string &vm_name);
95 
96  virtual std::shared_ptr<BareMetalComputeService> getVMComputeService(const std::string &vm_name);
97 
98  virtual std::string getVMPhysicalHostname(const std::string &vm_name);
99 
100  virtual void suspendVM(const std::string &vm_name);
101 
102  virtual void resumeVM(const std::string &vm_name);
103 
104  virtual void destroyVM(const std::string &vm_name);
105 
106  virtual bool isVMRunning(const std::string &vm_name);
107 
108  virtual bool isVMSuspended(const std::string &vm_name);
109 
110  virtual bool isVMDown(const std::string &vm_name);
111 
112 
113  std::vector<std::string> getExecutionHosts();
114 
115  /***********************/
117  /***********************/
118 
119  /***********************/
121  /***********************/
122  void submitStandardJob(std::shared_ptr<StandardJob> job,
123  const std::map<std::string, std::string> &service_specific_args) override;
124 
125  void submitPilotJob(std::shared_ptr<PilotJob> job,
126  const std::map<std::string, std::string> &service_specific_args) override;
127 
128  void terminateStandardJob(std::shared_ptr<StandardJob> job) override;
129 
130  void terminatePilotJob(std::shared_ptr<PilotJob> job) override;
131 
132  void validateProperties();
133 
135 
136  /***********************/
138  /***********************/
139 
140  protected:
141  /***********************/
143  /***********************/
144 
145  friend class Simulation;
146 
147  int main() override;
148 
149  std::shared_ptr<SimulationMessage> sendRequest(std::string &answer_mailbox, ComputeServiceMessage *message);
150 
151  virtual bool processNextMessage();
152 
153  virtual void processGetResourceInformation(const std::string &answer_mailbox);
154 
155  virtual void processGetExecutionHosts(const std::string &answer_mailbox);
156 
157  virtual void processCreateVM(const std::string &answer_mailbox,
158  unsigned long requested_num_cores,
159  double requested_ram,
160  std::string desired_vm_name,
161  std::map<std::string, std::string> property_list,
162  std::map<std::string, double> messagepayload_list
163  );
164 
165  virtual void
166  processStartVM(const std::string &answer_mailbox, const std::string &vm_name, const std::string &pm_name);
167 
168  virtual void processShutdownVM(const std::string &answer_mailbox, const std::string &vm_name);
169 
170  virtual void processSuspendVM(const std::string &answer_mailbox, const std::string &vm_name);
171 
172  virtual void processResumeVM(const std::string &answer_mailbox, const std::string &vm_name);
173 
174  virtual void processDestroyVM(const std::string &answer_mailbox, const std::string &vm_name);
175 
176  virtual void processSubmitStandardJob(const std::string &answer_mailbox, std::shared_ptr<StandardJob> job,
177  std::map<std::string, std::string> &service_specific_args);
178 
179  virtual void processSubmitPilotJob(const std::string &answer_mailbox, std::shared_ptr<PilotJob> job,
180  std::map<std::string, std::string> &service_specific_args);
181 
182  virtual void
183  processBareMetalComputeServiceTermination(std::shared_ptr<BareMetalComputeService> cs, int exit_code);
184 
185  void stopAllVMs();
186 
188  static unsigned long VM_ID;
192  std::vector<std::string> execution_hosts;
193 
195  std::map<std::string, double> used_ram_per_execution_host;
196 
198  std::map<std::string, unsigned long> used_cores_per_execution_host;
199 
201  std::map<std::string, std::pair<std::shared_ptr<S4U_VirtualMachine>, std::shared_ptr<BareMetalComputeService>>> vm_list;
202 
203  /***********************/
205  /***********************/
206 
207  private:
208  std::string findHost(unsigned long desired_num_cores, double desired_ram, std::string desired_host);
209 
210  };
211 }
212 
213 #endif //WRENCH_CLOUDSERVICE_H
static const std::string CREATE_VM_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the service in answer to a VM creation request.
Definition: CloudComputeServiceMessagePayload.h:30
static const std::string SUBMIT_STANDARD_JOB_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to submit a standard job.
Definition: ComputeServiceMessagePayload.h:26
static const std::string SHUTDOWN_VM_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the service in answer to a VM shutdown request.
Definition: CloudComputeServiceMessagePayload.h:34
static const std::string DAEMON_STOPPED_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to confirm it has terminated.
Definition: ServiceMessagePayload.h:33
static const std::string RESOURCE_DESCRIPTION_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to ask it for information on its resour...
Definition: ComputeServiceMessagePayload.h:56
static const std::string SHUTDOWN_VM_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the service to request a VM shutdown.
Definition: CloudComputeServiceMessagePayload.h:32
std::map< std::string, double > used_ram_per_execution_host
Map of used RAM at the hosts.
Definition: CloudComputeService.h:195
std::map< std::string, unsigned long > used_cores_per_execution_host
Map of number of used cores at the hosts.
Definition: CloudComputeService.h:198
static const std::string START_VM_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the service in answer to a VM start request.
Definition: CloudComputeServiceMessagePayload.h:38
std::vector< std::string > execution_hosts
List of execution host names.
Definition: CloudComputeService.h:192
static const std::string SUSPEND_VM_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the service in answer to a VM suspend request.
Definition: CloudComputeServiceMessagePayload.h:42
The compute service base class.
Definition: ComputeService.h:33
static const std::string RESUME_VM_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the service to request a VM resume.
Definition: CloudComputeServiceMessagePayload.h:44
A cloud-based compute service that manages a set of physical hosts and controls access to their resou...
Definition: CloudComputeService.h:36
static const std::string GET_EXECUTION_HOSTS_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the service to request a get execution hosts.
Definition: CloudComputeServiceMessagePayload.h:24
std::map< std::string, std::pair< std::shared_ptr< S4U_VirtualMachine >, std::shared_ptr< BareMetalComputeService > > > vm_list
A map of VMs.
Definition: CloudComputeService.h:201
Definition: Alarm.cpp:20
static const std::string GET_EXECUTION_HOSTS_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the service in answer to a get execution hosts req...
Definition: CloudComputeServiceMessagePayload.h:26
static const std::string SUBMIT_PILOT_JOB_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent from the daemon to acknowledge a pilot job submission...
Definition: ComputeServiceMessagePayload.h:40
CloudComputeService(const std::string &hostname, std::vector< std::string > execution_hosts, std::string scratch_space_mount_point, std::map< std::string, std::string > property_list={}, std::map< std::string, double > messagepayload_list={})
Constructor.
Definition: CloudComputeService.cpp:43
static const std::string VM_RESOURCE_ALLOCATION_ALGORITHM
The VM resource allocation algorithm by which VMs are started on physical hosts. Possible values are:
Definition: CloudComputeServiceProperty.h:33
static const std::string VM_BOOT_OVERHEAD_IN_SECONDS
The overhead, in seconds, to boot a VM.
Definition: CloudComputeServiceProperty.h:24
static const std::string DESTROY_VM_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the service in answer to a VM destruction request.
Definition: CloudComputeServiceMessagePayload.h:50
static const std::string CREATE_VM_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the service to request a VM creation.
Definition: CloudComputeServiceMessagePayload.h:28
static const std::string RESOURCE_DESCRIPTION_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to state information on its resources.
Definition: ComputeServiceMessagePayload.h:58
static const std::string STOP_DAEMON_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to terminate it.
Definition: ServiceMessagePayload.h:31
static const std::string SUBMIT_STANDARD_JOB_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the daemon to acknowledge a standard job submissio...
Definition: ComputeServiceMessagePayload.h:28
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:46
static const std::string START_VM_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the service to request a VM start.
Definition: CloudComputeServiceMessagePayload.h:36
static const std::string DESTROY_VM_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the service to request a VM destruction.
Definition: CloudComputeServiceMessagePayload.h:48
static const std::string SUSPEND_VM_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the service to request a VM suspend.
Definition: CloudComputeServiceMessagePayload.h:40
static const std::string SUBMIT_PILOT_JOB_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to submit a pilot job.
Definition: ComputeServiceMessagePayload.h:38
static const std::string SUPPORTS_PILOT_JOBS
Whether the compute service supports pilot jobs (true or false)
Definition: ComputeServiceProperty.h:26
static const std::string RESUME_VM_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent by the service in answer to a VM resume request.
Definition: CloudComputeServiceMessagePayload.h:46
static const std::string SUPPORTS_STANDARD_JOBS
Whether the compute service supports standard jobs (true or false)
Definition: ComputeServiceProperty.h:24