Skip to content

Commit

Permalink
Merge pull request #26 from frs69wq/master
Browse files Browse the repository at this point in the history
Add capacity to retrieve host names on a per cluster basis
  • Loading branch information
henricasanova committed Mar 20, 2018
2 parents a51e2c8 + ded96f3 commit 8a611ae
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/wrench/simgrid_S4U_util/S4U_Simulation.h
Expand Up @@ -12,6 +12,7 @@
#define WRENCH_S4U_SIMULATION_H

#include <simgrid/s4u.hpp>
#include <simgrid/kernel/routing/ClusterZone.hpp>

namespace wrench {

Expand Down Expand Up @@ -40,6 +41,7 @@ namespace wrench {
bool isInitialized();
bool isPlatformSetup();
std::vector<std::string> getAllHostnames();
std::map<std::string, std::vector<std::string>> getAllHostnamesByCluster();
void shutdown();


Expand Down
1 change: 1 addition & 0 deletions include/wrench/simulation/Simulation.h
Expand Up @@ -41,6 +41,7 @@ namespace wrench {
void instantiatePlatform(std::string);

std::vector<std::string> getHostnameList();
std::map<std::string, std::vector<std::string>> getHostnameListByCluster();

bool hostExists(std::string hostname);

Expand Down
19 changes: 19 additions & 0 deletions src/wrench/simgrid_S4U_util/S4U_Simulation.cpp
Expand Up @@ -109,6 +109,25 @@ namespace wrench {
return hostname_list;
}

std::map<std::string, std::vector<std::string>> S4U_Simulation::getAllHostnamesByCluster() {
std::map<std::string, std::vector<std::string>> result;
std::vector<simgrid::kernel::routing::ClusterZone*>clusters;

this->engine->getNetzoneByType<simgrid::kernel::routing::ClusterZone>(&clusters);
for (auto c : clusters) {
std::vector<simgrid::s4u::Host*> host_list;
c->getHosts(&host_list);
std::vector<std::string> hostname_list;
hostname_list.reserve(host_list.size());
for (auto h : host_list) {
hostname_list.push_back(std::string(h->getCname()));
}
result.insert({c->getName(), hostname_list});
}

return result;
}

/**
* @brief Determines whether a host exists for a given hostname
* @param hostname: the hostname
Expand Down
10 changes: 9 additions & 1 deletion src/wrench/simulation/Simulation.cpp
Expand Up @@ -133,7 +133,15 @@ namespace wrench {
std::vector<std::string> Simulation::getHostnameList() {
return this->s4u_simulation->getAllHostnames();
}

/**
* @brief Retrieve the list of names of all the hosts in each cluster composing the platform
*
* @return a map of (clustername, hostnames)
*
*/
std::map<std::string, std::vector<std::string>> Simulation::getHostnameListByCluster() {
return this->s4u_simulation->getAllHostnamesByCluster();
}
/**
* @brief Check that a hostname exists in the platform
*
Expand Down

0 comments on commit 8a611ae

Please sign in to comment.