WRENCH  1.11
Cyberinfrastructure Simulation Workbench
Overview Installation Getting Started WRENCH 101 WRENCH 102
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/job/PilotJob.h"
23 
24 
25 namespace wrench {
26 
27  class Simulation;
28 
29  class BareMetalComputeService;
30 
37  private:
38  WRENCH_PROPERTY_COLLECTION_TYPE default_property_values = {
41  };
42 
43 WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE 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  WRENCH_PROPERTY_COLLECTION_TYPE property_list = {},
75  WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list = {});
76 
77  virtual bool supportsStandardJobs() override;
78  virtual bool supportsCompoundJobs() override;
79  virtual bool supportsPilotJobs() override;
80 
81  /***********************/
83  /***********************/
84 
85  virtual std::string createVM(unsigned long num_cores,
86  double ram_memory,
87  WRENCH_PROPERTY_COLLECTION_TYPE property_list = {},
88  WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list = {});
89 
90  virtual std::string createVM(unsigned long num_cores,
91  double ram_memory,
92  std::string desired_vm_name,
93  WRENCH_PROPERTY_COLLECTION_TYPE property_list = {},
94  WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list = {});
95 
96  virtual void shutdownVM(const std::string &vm_name);
97 
98  virtual void shutdownVM(const std::string &vm_name, bool send_failure_notifications, ComputeService::TerminationCause termination_cause);
99 
100  virtual std::shared_ptr<BareMetalComputeService> startVM(const std::string &vm_name);
101 
102  virtual std::shared_ptr<BareMetalComputeService> getVMComputeService(const std::string &vm_name);
103 
104  virtual std::string getVMPhysicalHostname(const std::string &vm_name);
105 
106  virtual void suspendVM(const std::string &vm_name);
107 
108  virtual void resumeVM(const std::string &vm_name);
109 
110  virtual void destroyVM(const std::string &vm_name);
111 
112  virtual bool isVMRunning(const std::string &vm_name);
113 
114  virtual bool isVMSuspended(const std::string &vm_name);
115 
116  virtual bool isVMDown(const std::string &vm_name);
117 
118 
119  std::vector<std::string> getExecutionHosts();
120 
121  /***********************/
123  /***********************/
124 
125  /***********************/
127  /***********************/
128 
129  void submitCompoundJob(std::shared_ptr<CompoundJob> job,
130  const std::map<std::string, std::string> &service_specific_args) override {};
131 
132  void terminateCompoundJob(std::shared_ptr<CompoundJob> job) override {};
133 
134  void validateProperties();
135 
137 
138  /***********************/
140  /***********************/
141 
142  protected:
143  /***********************/
145  /***********************/
146 
147  friend class Simulation;
148 
149  int main() override;
150 
151  std::shared_ptr<SimulationMessage> sendRequest(simgrid::s4u::Mailbox *answer_mailbox, ComputeServiceMessage *message);
152 
153  virtual bool processNextMessage();
154 
155  virtual void processGetResourceInformation(simgrid::s4u::Mailbox *answer_mailbox,
156  const std::string &key);
157 
158  virtual void processGetExecutionHosts(simgrid::s4u::Mailbox *answer_mailbox);
159 
160  virtual void processCreateVM(simgrid::s4u::Mailbox *answer_mailbox,
161  unsigned long requested_num_cores,
162  double requested_ram,
163  std::string desired_vm_name,
164  WRENCH_PROPERTY_COLLECTION_TYPE property_list,
165  WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list
166  );
167 
168  virtual void
169  processStartVM(simgrid::s4u::Mailbox *answer_mailbox, const std::string &vm_name, const std::string &pm_name);
170 
171  virtual void processShutdownVM(simgrid::s4u::Mailbox *answer_mailbox,
172  const std::string &vm_name,
173  bool send_failure_notifications,
174  ComputeService::TerminationCause termination_cause);
175 
176  virtual void processSuspendVM(simgrid::s4u::Mailbox *answer_mailbox, const std::string &vm_name);
177 
178  virtual void processResumeVM(simgrid::s4u::Mailbox *answer_mailbox, const std::string &vm_name);
179 
180  virtual void processDestroyVM(simgrid::s4u::Mailbox *answer_mailbox, const std::string &vm_name);
181 
182 // virtual void processSubmitStandardJob(const std::string &answer_mailbox, std::shared_ptr<StandardJob> job,
183 // std::map<std::string, std::string> &service_specific_args);
184 //
185 // virtual void processSubmitPilotJob(const std::string &answer_mailbox, std::shared_ptr<PilotJob> job,
186 // std::map<std::string, std::string> &service_specific_args);
187 
188  virtual void
189  processBareMetalComputeServiceTermination(std::shared_ptr<BareMetalComputeService> cs, int exit_code);
190 
191  virtual void processIsThereAtLeastOneHostWithAvailableResources(
192  simgrid::s4u::Mailbox *answer_mailbox, unsigned long num_cores, double ram);
193 
194 
195  void stopAllVMs(bool send_failure_notifications, ComputeService::TerminationCause termination_cause);
196 
198  static unsigned long VM_ID;
202  std::vector<std::string> execution_hosts;
203 
205  std::map<std::string, double> used_ram_per_execution_host;
206 
208  std::map<std::string, unsigned long> used_cores_per_execution_host;
209 
211  std::map<std::string, std::pair<std::shared_ptr<S4U_VirtualMachine>, std::shared_ptr<BareMetalComputeService>>> vm_list;
212 
213  /***********************/
215  /***********************/
216 
217  private:
218  std::string findHost(unsigned long desired_num_cores, double desired_ram, std::string desired_host);
219 
220  };
221 }
222 
223 #endif //WRENCH_CLOUDSERVICE_H
wrench::CloudComputeService::isVMRunning
virtual bool isVMRunning(const std::string &vm_name)
Method to check whether a VM is currently running.
Definition: CloudComputeService.cpp:415
wrench::ComputeServiceMessagePayload::IS_THERE_AT_LEAST_ONE_HOST_WITH_AVAILABLE_RESOURCES_ANSWER_MESSAGE_PAYLOAD
static const std::string IS_THERE_AT_LEAST_ONE_HOST_WITH_AVAILABLE_RESOURCES_ANSWER_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to ask is one host has some resources a...
Definition: ComputeServiceMessagePayload.h:78
wrench::CloudComputeServiceMessagePayload::CREATE_VM_ANSWER_MESSAGE_PAYLOAD
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
wrench::ComputeServiceMessagePayload::SUBMIT_STANDARD_JOB_REQUEST_MESSAGE_PAYLOAD
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:27
wrench::ComputeService::TerminationCause
TerminationCause
Job termination cause enum.
Definition: ComputeService.h:67
wrench::CloudComputeServiceMessagePayload::SHUTDOWN_VM_ANSWER_MESSAGE_PAYLOAD
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
wrench::ServiceMessagePayload::DAEMON_STOPPED_MESSAGE_PAYLOAD
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:37
wrench::CloudComputeService::suspendVM
virtual void suspendVM(const std::string &vm_name)
Suspend a running VM.
Definition: CloudComputeService.cpp:311
wrench::ComputeServiceMessagePayload::RESOURCE_DESCRIPTION_REQUEST_MESSAGE_PAYLOAD
static const std::string RESOURCE_DESCRIPTION_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message sent to the daemon to request information on its resources...
Definition: ComputeServiceMessagePayload.h:74
wrench::CloudComputeServiceMessagePayload::SHUTDOWN_VM_REQUEST_MESSAGE_PAYLOAD
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
wrench::CloudComputeService::used_ram_per_execution_host
std::map< std::string, double > used_ram_per_execution_host
Map of used RAM at the hosts.
Definition: CloudComputeService.h:205
wrench::CloudComputeService::supportsStandardJobs
virtual bool supportsStandardJobs() override
Returns true if the service supports standard jobs.
Definition: CloudComputeService.cpp:1288
wrench::CloudComputeService::used_cores_per_execution_host
std::map< std::string, unsigned long > used_cores_per_execution_host
Map of number of used cores at the hosts.
Definition: CloudComputeService.h:208
wrench::ComputeServiceMessagePayload::IS_THERE_AT_LEAST_ONE_HOST_WITH_AVAILABLE_RESOURCES_REQUEST_MESSAGE_PAYLOAD
static const std::string IS_THERE_AT_LEAST_ONE_HOST_WITH_AVAILABLE_RESOURCES_REQUEST_MESSAGE_PAYLOAD
The number of bytes in the control message by the the daemon to state whether one host has some resou...
Definition: ComputeServiceMessagePayload.h:80
wrench::CloudComputeServiceMessagePayload::START_VM_ANSWER_MESSAGE_PAYLOAD
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
wrench::CloudComputeService::execution_hosts
std::vector< std::string > execution_hosts
List of execution host names.
Definition: CloudComputeService.h:202
wrench::CloudComputeServiceMessagePayload::SUSPEND_VM_ANSWER_MESSAGE_PAYLOAD
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
wrench::ComputeService
The compute service base class.
Definition: ComputeService.h:34
wrench::CloudComputeServiceMessagePayload::RESUME_VM_REQUEST_MESSAGE_PAYLOAD
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
wrench::CloudComputeService
A cloud-based compute service that manages a set of physical hosts and controls access to their resou...
Definition: CloudComputeService.h:36
wrench::CloudComputeService::createVM
virtual std::string createVM(unsigned long num_cores, double ram_memory, WRENCH_PROPERTY_COLLECTION_TYPE property_list={}, WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list={})
Create a BareMetalComputeService VM (balances load on execution hosts)
Definition: CloudComputeService.cpp:120
wrench::CloudComputeServiceMessagePayload::GET_EXECUTION_HOSTS_REQUEST_MESSAGE_PAYLOAD
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
wrench::CloudComputeService::vm_list
std::map< std::string, std::pair< std::shared_ptr< S4U_VirtualMachine >, std::shared_ptr< BareMetalComputeService > > > vm_list
A map of VMs.
Definition: CloudComputeService.h:211
wrench
Definition: Action.cpp:28
wrench::CloudComputeServiceMessagePayload::GET_EXECUTION_HOSTS_ANSWER_MESSAGE_PAYLOAD
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
wrench::CloudComputeService::getExecutionHosts
std::vector< std::string > getExecutionHosts()
Get the list of execution hosts available to run VMs.
Definition: CloudComputeService.cpp:85
wrench::ComputeServiceMessagePayload::SUBMIT_PILOT_JOB_ANSWER_MESSAGE_PAYLOAD
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:56
wrench::CloudComputeServiceProperty::VM_RESOURCE_ALLOCATION_ALGORITHM
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
wrench::CloudComputeService::supportsPilotJobs
virtual bool supportsPilotJobs() override
Returns true if the service supports pilot jobs.
Definition: CloudComputeService.cpp:1304
wrench::CloudComputeServiceProperty::VM_BOOT_OVERHEAD_IN_SECONDS
static const std::string VM_BOOT_OVERHEAD_IN_SECONDS
The overhead, in seconds, to boot a VM.
Definition: CloudComputeServiceProperty.h:24
wrench::CloudComputeService::CloudComputeService
CloudComputeService(const std::string &hostname, std::vector< std::string > execution_hosts, std::string scratch_space_mount_point, WRENCH_PROPERTY_COLLECTION_TYPE property_list={}, WRENCH_MESSAGE_PAYLOADCOLLECTION_TYPE messagepayload_list={})
Constructor.
Definition: CloudComputeService.cpp:41
wrench::CloudComputeService::isVMDown
virtual bool isVMDown(const std::string &vm_name)
Method to check whether a VM is currently down.
Definition: CloudComputeService.cpp:433
wrench::CloudComputeServiceMessagePayload::DESTROY_VM_ANSWER_MESSAGE_PAYLOAD
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
wrench::CloudComputeService::isVMSuspended
virtual bool isVMSuspended(const std::string &vm_name)
Method to check whether a VM is currently running.
Definition: CloudComputeService.cpp:451
wrench::CloudComputeService::startVM
virtual std::shared_ptr< BareMetalComputeService > startVM(const std::string &vm_name)
Start a VM.
Definition: CloudComputeService.cpp:242
wrench::CloudComputeServiceMessagePayload::CREATE_VM_REQUEST_MESSAGE_PAYLOAD
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
wrench::ComputeServiceMessagePayload::RESOURCE_DESCRIPTION_ANSWER_MESSAGE_PAYLOAD
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:76
wrench::ServiceMessagePayload::STOP_DAEMON_MESSAGE_PAYLOAD
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:35
wrench::CloudComputeService::destroyVM
virtual void destroyVM(const std::string &vm_name)
Destroy a VM.
Definition: CloudComputeService.cpp:382
wrench::ComputeServiceMessagePayload::SUBMIT_STANDARD_JOB_ANSWER_MESSAGE_PAYLOAD
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:29
wrench::Simulation
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:48
wrench::CloudComputeServiceMessagePayload::START_VM_REQUEST_MESSAGE_PAYLOAD
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
wrench::CloudComputeService::resumeVM
virtual void resumeVM(const std::string &vm_name)
Resume a suspended VM.
Definition: CloudComputeService.cpp:346
wrench::CloudComputeServiceMessagePayload::DESTROY_VM_REQUEST_MESSAGE_PAYLOAD
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
wrench::CloudComputeServiceMessagePayload::SUSPEND_VM_REQUEST_MESSAGE_PAYLOAD
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
wrench::ComputeServiceMessagePayload::SUBMIT_PILOT_JOB_REQUEST_MESSAGE_PAYLOAD
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:54
wrench::CloudComputeService::getVMComputeService
virtual std::shared_ptr< BareMetalComputeService > getVMComputeService(const std::string &vm_name)
Get the compute service running on a VM, if any.
Definition: CloudComputeService.cpp:279
wrench::CloudComputeServiceMessagePayload::RESUME_VM_ANSWER_MESSAGE_PAYLOAD
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
wrench::CloudComputeService::supportsCompoundJobs
virtual bool supportsCompoundJobs() override
Returns true if the service supports compound jobs.
Definition: CloudComputeService.cpp:1296
wrench::CloudComputeService::shutdownVM
virtual void shutdownVM(const std::string &vm_name)
Shutdown an active VM.
Definition: CloudComputeService.cpp:189
wrench::CloudComputeService::getVMPhysicalHostname
virtual std::string getVMPhysicalHostname(const std::string &vm_name)
Get the name of the physical host on which a VM is running.
Definition: CloudComputeService.cpp:296