Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/wrench-project/wrench
Browse files Browse the repository at this point in the history
  • Loading branch information
mesurajpandey committed Sep 27, 2017
2 parents 9bab03e + 22495f0 commit d0afc38
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 14 deletions.
5 changes: 2 additions & 3 deletions examples/simple-wms/main.cpp
Expand Up @@ -96,9 +96,8 @@ int main(int argc, char **argv) {
// {{wrench::MulticoreComputeServiceProperty::STOP_DAEMON_MESSAGE_PAYLOAD, "666"}})));

std::unique_ptr<wrench::CloudService> cloud_service(new wrench::CloudService(wms_host));
simulation.add(cloud_service.get()->createVM(executor_host, 1, storage_service));
simulation.add(cloud_service.get()->createVM(executor_host, 1, storage_service));
simulation.add(cloud_service.get()->createVM(executor_host, 1, storage_service));
simulation.add(cloud_service->createVM(executor_host, 1, true, true, storage_service,
{{wrench::MulticoreComputeServiceProperty::STOP_DAEMON_MESSAGE_PAYLOAD, "666"}}));

// simulation.add(
// std::unique_ptr<wrench::VMComputeService>(
Expand Down
9 changes: 7 additions & 2 deletions include/wrench/services/cloud/CloudService.h
Expand Up @@ -27,14 +27,19 @@ namespace wrench {
public:
explicit CloudService(std::string &hostname);

std::unique_ptr<ComputeService> createVM(std::string pm_hostname,
std::unique_ptr<ComputeService> createVM(std::string &pm_hostname,
int num_cores,
StorageService *default_storage_service);
bool supports_standard_jobs,
bool supports_pilot_jobs,
StorageService *default_storage_service,
std::map<std::string, std::string> plist);


private:
int main();

void terminate();

std::map<std::string, std::string> default_property_values = {};

std::map<std::string, simgrid::s4u::VirtualMachine *> vm_list;
Expand Down
2 changes: 1 addition & 1 deletion include/wrench/services/compute/MulticoreComputeService.h
Expand Up @@ -106,7 +106,7 @@ namespace wrench {
/** \endcond */
/***********************/

protected:
private:

friend class Simulation;

Expand Down
10 changes: 8 additions & 2 deletions src/wrench/services/batch_service/BatchService.cpp
Expand Up @@ -23,9 +23,12 @@ namespace wrench {
* @brief Constructor
* @param hostname: the hostname on which to start the service
* @param nodes_in_network: the hosts running in the network
* @param supports_standard_jobs: true if the compute service should support standard jobs
* @param supports_pilot_jobs: true if the compute service should support pilot jobs
* @param plist: a property list ({} means "use all defaults")
*/
BatchService::BatchService(std::string hostname, std::vector<std::string> nodes_in_network,
BatchService::BatchService(std::string hostname,
std::vector<std::string> nodes_in_network,
StorageService *default_storage_service,
bool supports_standard_jobs,
bool supports_pilot_jobs,
Expand All @@ -39,10 +42,13 @@ namespace wrench {
* @brief Constructor
* @param hostname: the hostname on which to start the service
* @param nodes_in_network: the hosts running in the network
* @param supports_standard_jobs: true if the compute service should support standard jobs
* @param supports_pilot_jobs: true if the compute service should support pilot jobs
* @param plist: a property list ({} means "use all defaults")
* @param suffix: suffix to append to the service name and mailbox
*/
BatchService::BatchService(std::string hostname, std::vector<std::string> nodes_in_network,
BatchService::BatchService(std::string hostname,
std::vector<std::string> nodes_in_network,
StorageService *default_storage_service,
bool supports_standard_jobs,
bool supports_pilot_jobs,
Expand Down
34 changes: 28 additions & 6 deletions src/wrench/services/cloud/CloudService.cpp
Expand Up @@ -18,6 +18,8 @@ namespace wrench {

/**
* @brief Constructor
*
* @param hostname: the hostname on which to start the service
*/
CloudService::CloudService(std::string &hostname) :
Service("cloud_service", "cloud_service") {
Expand All @@ -26,18 +28,25 @@ namespace wrench {
}

/**
* @brief
* @brief Create a multicore executor VM in a physical machine
*
* @param pm_hostname: the name of the physical machine host
* @param num_cores: the number of cores the service can use (0 means "use as many as there are cores on the host")
* @param supports_standard_jobs: true if the compute service should support standard jobs
* @param supports_pilot_jobs: true if the compute service should support pilot jobs
* @param default_storage_service: a storage service
* @param plist: a property list ({} means "use all defaults")
* @return
*/
std::unique_ptr<ComputeService> CloudService::createVM(std::string pm_hostname,
std::unique_ptr<ComputeService> CloudService::createVM(std::string &pm_hostname,
int num_cores,
StorageService *default_storage_service) {
bool supports_standard_jobs,
bool supports_pilot_jobs,
StorageService *default_storage_service,
std::map<std::string, std::string> plist) {

std::string vm_name = "vm" + std::to_string(VM_ID++) + "_" + pm_hostname;

if (simgrid::s4u::Host::by_name_or_null(vm_name) == nullptr) {

if (num_cores <= 0) {
Expand All @@ -49,9 +58,8 @@ namespace wrench {
num_cores);

return std::unique_ptr<MulticoreComputeService>(
new MulticoreComputeService(vm_name, true, true,
default_storage_service,
{{wrench::MulticoreComputeServiceProperty::STOP_DAEMON_MESSAGE_PAYLOAD, "666"}}));
new MulticoreComputeService(vm_name, supports_standard_jobs, supports_pilot_jobs,
default_storage_service, plist));
}
//TODO: launch exception if vm already created or cannot be created
return nullptr;
Expand All @@ -60,4 +68,18 @@ namespace wrench {
int CloudService::main() {
return 0;
}

/**
* @brief Terminate the daemon.
*/
void CloudService::terminate() {
this->setStateToDown();

//TODO: call terminate for multicore executors

// destroy VMs
for (auto &vm : this->vm_list) {
vm.second->destroy();
}
}
}

0 comments on commit d0afc38

Please sign in to comment.