WRENCH  1.10
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/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 = {
70  };
71 
72  public:
73  CloudComputeService(const std::string &hostname,
74  std::vector<std::string> execution_hosts,
75  std::string scratch_space_mount_point,
76  std::map<std::string, std::string> property_list = {},
77  std::map<std::string, double> messagepayload_list = {});
78 
79  /***********************/
81  /***********************/
82 
83  virtual std::string createVM(unsigned long num_cores,
84  double ram_memory,
85  std::map<std::string, std::string> property_list = {},
86  std::map<std::string, double> messagepayload_list = {});
87 
88  virtual std::string createVM(unsigned long num_cores,
89  double ram_memory,
90  std::string desired_vm_name,
91  std::map<std::string, std::string> property_list = {},
92  std::map<std::string, double> messagepayload_list = {});
93 
94  virtual void shutdownVM(const std::string &vm_name);
95 
96  virtual std::shared_ptr<BareMetalComputeService> startVM(const std::string &vm_name);
97 
98  virtual std::shared_ptr<BareMetalComputeService> getVMComputeService(const std::string &vm_name);
99 
100  virtual std::string getVMPhysicalHostname(const std::string &vm_name);
101 
102  virtual void suspendVM(const std::string &vm_name);
103 
104  virtual void resumeVM(const std::string &vm_name);
105 
106  virtual void destroyVM(const std::string &vm_name);
107 
108  virtual bool isVMRunning(const std::string &vm_name);
109 
110  virtual bool isVMSuspended(const std::string &vm_name);
111 
112  virtual bool isVMDown(const std::string &vm_name);
113 
114 
115  std::vector<std::string> getExecutionHosts();
116 
117  /***********************/
119  /***********************/
120 
121  /***********************/
123  /***********************/
124  void submitStandardJob(std::shared_ptr<StandardJob> job,
125  const std::map<std::string, std::string> &service_specific_args) override;
126 
127  void submitPilotJob(std::shared_ptr<PilotJob> job,
128  const std::map<std::string, std::string> &service_specific_args) override;
129 
130  void terminateStandardJob(std::shared_ptr<StandardJob> job) override;
131 
132  void terminatePilotJob(std::shared_ptr<PilotJob> 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(std::string &answer_mailbox, ComputeServiceMessage *message);
152 
153  virtual bool processNextMessage();
154 
155  virtual void processGetResourceInformation(const std::string &answer_mailbox);
156 
157  virtual void processGetExecutionHosts(const std::string &answer_mailbox);
158 
159  virtual void processCreateVM(const std::string &answer_mailbox,
160  unsigned long requested_num_cores,
161  double requested_ram,
162  std::string desired_vm_name,
163  std::map<std::string, std::string> property_list,
164  std::map<std::string, double> messagepayload_list
165  );
166 
167  virtual void
168  processStartVM(const std::string &answer_mailbox, const std::string &vm_name, const std::string &pm_name);
169 
170  virtual void processShutdownVM(const std::string &answer_mailbox, const std::string &vm_name);
171 
172  virtual void processSuspendVM(const std::string &answer_mailbox, const std::string &vm_name);
173 
174  virtual void processResumeVM(const std::string &answer_mailbox, const std::string &vm_name);
175 
176  virtual void processDestroyVM(const std::string &answer_mailbox, const std::string &vm_name);
177 
178  virtual void processSubmitStandardJob(const std::string &answer_mailbox, std::shared_ptr<StandardJob> job,
179  std::map<std::string, std::string> &service_specific_args);
180 
181  virtual void processSubmitPilotJob(const std::string &answer_mailbox, std::shared_ptr<PilotJob> job,
182  std::map<std::string, std::string> &service_specific_args);
183 
184  virtual void
185  processBareMetalComputeServiceTermination(std::shared_ptr<BareMetalComputeService> cs, int exit_code);
186 
188  const std::string &answer_mailbox, unsigned long num_cores, double ram);
189 
190 
191  void stopAllVMs();
192 
194  static unsigned long VM_ID;
198  std::vector<std::string> execution_hosts;
199 
201  std::map<std::string, double> used_ram_per_execution_host;
202 
204  std::map<std::string, unsigned long> used_cores_per_execution_host;
205 
207  std::map<std::string, std::pair<std::shared_ptr<S4U_VirtualMachine>, std::shared_ptr<BareMetalComputeService>>> vm_list;
208 
209  /***********************/
211  /***********************/
212 
213  private:
214  std::string findHost(unsigned long desired_num_cores, double desired_ram, std::string desired_host);
215 
216  };
217 }
218 
219 #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:486
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:60
wrench::CloudComputeService::stopAllVMs
void stopAllVMs()
Terminate all VMs.
Definition: CloudComputeService.cpp:1287
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:26
wrench::CloudComputeService::submitStandardJob
void submitStandardJob(std::shared_ptr< StandardJob > job, const std::map< std::string, std::string > &service_specific_args) override
Submit a standard job to the cloud service.
Definition: CloudComputeService.cpp:403
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::ComputeServiceMessage
Top-level class for messages received/sent by a ComputeService.
Definition: ComputeServiceMessage.h:32
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:33
wrench::CloudComputeService::processBareMetalComputeServiceTermination
virtual void processBareMetalComputeServiceTermination(std::shared_ptr< BareMetalComputeService > cs, int exit_code)
Process a termination by a previously started bare_metal on a VM.
Definition: CloudComputeService.cpp:1334
wrench::CloudComputeService::terminateStandardJob
void terminateStandardJob(std::shared_ptr< StandardJob > job) override
Terminate a standard job to the compute service (virtual)
Definition: CloudComputeService.cpp:467
wrench::CloudComputeService::suspendVM
virtual void suspendVM(const std::string &vm_name)
Suspend a running VM.
Definition: CloudComputeService.cpp:295
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 ask it for information on its resour...
Definition: ComputeServiceMessagePayload.h:56
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:201
wrench::CloudComputeService::processCreateVM
virtual void processCreateVM(const std::string &answer_mailbox, unsigned long requested_num_cores, double requested_ram, std::string desired_vm_name, std::map< std::string, std::string > property_list, std::map< std::string, double > messagepayload_list)
Create a bare_metal VM on a physical machine.
Definition: CloudComputeService.cpp:711
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:204
wrench::CloudComputeService::processShutdownVM
virtual void processShutdownVM(const std::string &answer_mailbox, const std::string &vm_name)
: Process a VM shutdown request
Definition: CloudComputeService.cpp:805
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:62
wrench::CloudComputeService::processResumeVM
virtual void processResumeVM(const std::string &answer_mailbox, const std::string &vm_name)
: Process a VM resume request
Definition: CloudComputeService.cpp:1093
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:198
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:33
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::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:207
wrench
Definition: Alarm.cpp:20
wrench::CloudComputeService::validateProperties
void validateProperties()
Validate the service's properties.
Definition: CloudComputeService.cpp:1365
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:86
wrench::CloudComputeService::sendRequest
std::shared_ptr< SimulationMessage > sendRequest(std::string &answer_mailbox, ComputeServiceMessage *message)
Send a message request.
Definition: CloudComputeService.cpp:564
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:40
wrench::CloudComputeService::CloudComputeService
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:42
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::processSubmitPilotJob
virtual void processSubmitPilotJob(const std::string &answer_mailbox, std::shared_ptr< PilotJob > job, std::map< std::string, std::string > &service_specific_args)
Process a submit pilot job request.
Definition: CloudComputeService.cpp:1197
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()
Destructor.
Definition: CloudComputeService.cpp:74
wrench::CloudComputeService::isVMDown
virtual bool isVMDown(const std::string &vm_name)
Method to check whether a VM is currently down.
Definition: CloudComputeService.cpp:504
wrench::CloudComputeService::submitPilotJob
void submitPilotJob(std::shared_ptr< PilotJob > job, const std::map< std::string, std::string > &service_specific_args) override
Asynchronously submit a pilot job to the cloud service.
Definition: CloudComputeService.cpp:436
wrench::CloudComputeService::processDestroyVM
virtual void processDestroyVM(const std::string &answer_mailbox, const std::string &vm_name)
: Process a VM destruction request
Definition: CloudComputeService.cpp:1131
wrench::CloudComputeService::processIsThereAtLeastOneHostWithAvailableResources
virtual void processIsThereAtLeastOneHostWithAvailableResources(const std::string &answer_mailbox, unsigned long num_cores, double ram)
Process a host available resource request.
Definition: CloudComputeService.cpp:1322
wrench::CloudComputeService::processSubmitStandardJob
virtual void processSubmitStandardJob(const std::string &answer_mailbox, std::shared_ptr< StandardJob > job, std::map< std::string, std::string > &service_specific_args)
Process a submit standard job request.
Definition: CloudComputeService.cpp:1171
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:522
wrench::CloudComputeService::processNextMessage
virtual bool processNextMessage()
Wait for and react to any incoming message.
Definition: CloudComputeService.cpp:593
wrench::CloudComputeService::startVM
virtual std::shared_ptr< BareMetalComputeService > startVM(const std::string &vm_name)
Start a VM.
Definition: CloudComputeService.cpp:226
wrench::Service::messagepayload_list
std::map< std::string, double > messagepayload_list
The service's messagepayload list.
Definition: Service.h:112
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:58
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:31
wrench::CloudComputeService::destroyVM
virtual void destroyVM(const std::string &vm_name)
Destroy a VM.
Definition: CloudComputeService.cpp:366
wrench::S4U_Daemon::hostname
std::string hostname
The name of the host on which the daemon is running.
Definition: S4U_Daemon.h:51
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:28
wrench::Simulation
A class that provides basic simulation methods. Once the simulation object has been explicitly or imp...
Definition: Simulation.h:46
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:330
wrench::CloudComputeService::createVM
virtual std::string createVM(unsigned long num_cores, double ram_memory, std::map< std::string, std::string > property_list={}, std::map< std::string, double > messagepayload_list={})
Create a bare_metal VM (balances load on execution hosts)
Definition: CloudComputeService.cpp:121
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:38
wrench::CloudComputeService::processGetExecutionHosts
virtual void processGetExecutionHosts(const std::string &answer_mailbox)
Process a execution host list request.
Definition: CloudComputeService.cpp:690
wrench::ComputeServiceProperty::SUPPORTS_PILOT_JOBS
static const std::string SUPPORTS_PILOT_JOBS
Whether the compute service supports pilot jobs (true or false)
Definition: ComputeServiceProperty.h:26
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:263
wrench::CloudComputeService::processGetResourceInformation
virtual void processGetResourceInformation(const std::string &answer_mailbox)
Process a "get resource information message".
Definition: CloudComputeService.cpp:1218
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::main
int main() override
Main method of the daemon.
Definition: CloudComputeService.cpp:539
wrench::CloudComputeService::processSuspendVM
virtual void processSuspendVM(const std::string &answer_mailbox, const std::string &vm_name)
: Process a VM suspend request
Definition: CloudComputeService.cpp:1048
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:280
wrench::CloudComputeService::processStartVM
virtual void processStartVM(const std::string &answer_mailbox, const std::string &vm_name, const std::string &pm_name)
: Process a VM start request by startibnng a VM on a host (using best fit for RAM first,...
Definition: CloudComputeService.cpp:948
wrench::Service::property_list
std::map< std::string, std::string > property_list
The service's property list.
Definition: Service.h:109
wrench::CloudComputeService::terminatePilotJob
void terminatePilotJob(std::shared_ptr< PilotJob > job) override
non-implemented
Definition: CloudComputeService.cpp:475
wrench::ComputeServiceProperty::SUPPORTS_STANDARD_JOBS
static const std::string SUPPORTS_STANDARD_JOBS
Whether the compute service supports standard jobs (true or false)
Definition: ComputeServiceProperty.h:24