Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
give informative names to Host methods
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 15 Dec 2015 21:07:51 +0000 (22:07 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 15 Dec 2015 21:07:51 +0000 (22:07 +0100)
include/simgrid/Host.hpp
src/msg/msg_host.cpp
src/simgrid/host.cpp
src/surf/host_clm03.cpp
src/surf/host_ptask_L07.cpp
src/surf/network_ns3.cpp
src/surf/surf_routing.cpp
src/surf/surf_routing_vivaldi.cpp
src/surf/virtual_machine.cpp
src/surf/vm_hl13.cpp

index a4e8ec5..e914303 100644 (file)
@@ -23,8 +23,8 @@ public:
   Host(std::string id);
   ~Host();
   std::string const& id() const { return id_; }
-  static Host* find_host(const char* name);
-  static Host* get_host(const char* name);
+  static Host* by_name_or_null(const char* name);
+  static Host* by_name_or_create(const char* name);
 };
 
 }
index 209e296..552ae8b 100644 (file)
@@ -73,7 +73,7 @@ msg_host_t __MSG_host_create(sg_host_t host) // FIXME: don't return our paramete
  */
 msg_host_t MSG_host_by_name(const char *name)
 {
-  return simgrid::Host::find_host(name);
+  return simgrid::Host::by_name_or_null(name);
 }
 
 /** \ingroup m_host_management
index 376392a..1c3cb95 100644 (file)
@@ -31,12 +31,12 @@ size_t sg_host_add_level(void(*deleter)(void*))
 
 sg_host_t sg_host_by_name(const char *name)
 {
-  return simgrid::Host::find_host(name);
+  return simgrid::Host::by_name_or_null(name);
 }
 
 sg_host_t sg_host_by_name_or_create(const char *name)
 {
-  return simgrid::Host::get_host(name);
+  return simgrid::Host::by_name_or_create(name);
 }
 
 xbt_dynar_t sg_hosts_as_dynar(void)
@@ -211,14 +211,14 @@ Host::~Host()
 {
 }
 
-Host* Host::find_host(const char* name)
+Host* Host::by_name_or_null(const char* name)
 {
   return (Host*) xbt_dict_get_or_null(host_list, name);
 }
 
-Host* Host::get_host(const char* name)
+Host* Host::by_name_or_create(const char* name)
 {
-  Host* host = find_host(name);
+  Host* host = by_name_or_null(name);
   if (host == nullptr) {
     host = new Host(name);
     xbt_dict_set(host_list, name, host, NULL);
index 955331a..a54d733 100644 (file)
@@ -53,7 +53,7 @@ Host *HostCLM03Model::createHost(const char *name,RoutingEdge *netElm, Cpu *cpu)
                  netElm, cpu);
   surf_callback_emit(hostCreatedCallbacks, host);
   XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
-  simgrid::Host::find_host(name)->set_facet(SURF_HOST_LEVEL, host);
+  simgrid::Host::by_name_or_null(name)->set_facet(SURF_HOST_LEVEL, host);
   return host;
 }
 
index 20b4d50..82a0951 100644 (file)
@@ -275,7 +275,7 @@ Host *HostL07Model::createHost(const char *name,RoutingEdge *netElm, Cpu *cpu)
   HostL07 *host = new HostL07(this, name, NULL, netElm, cpu);
 
   surf_callback_emit(hostCreatedCallbacks, host);
-  simgrid::Host::get_host(name)->set_facet(SURF_HOST_LEVEL, host);
+  simgrid::Host::by_name_or_create(name)->set_facet(SURF_HOST_LEVEL, host);
 
   return host;
 }
index 40fbd0b..84996b1 100644 (file)
@@ -41,7 +41,7 @@ static void simgrid_ns3_add_host(simgrid::surf::Host* host)
 {
   const char* id = host->getName();
   XBT_DEBUG("NS3_ADD_HOST '%s'", id);
-  simgrid::Host::get_host(id)->set_facet(NS3_HOST_LEVEL, ns3_add_host(id));
+  simgrid::Host::by_name_or_create(id)->set_facet(NS3_HOST_LEVEL, ns3_add_host(id));
 }
 
 static void parse_ns3_add_link(sg_platf_link_cbarg_t link)
@@ -108,7 +108,7 @@ static void parse_ns3_add_cluster(sg_platf_cluster_cbarg_t cluster)
       start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
       xbt_dynar_push_as(tab_elements_num, int, start);
       router_id = bprintf("ns3_%s%d%s", cluster_prefix, start, cluster_suffix);
-      simgrid::Host::get_host(router_id)
+      simgrid::Host::by_name_or_create(router_id)
         ->set_facet(NS3_HOST_LEVEL, ns3_add_host_cluster(router_id));
       XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);
       free(router_id);
@@ -120,7 +120,7 @@ static void parse_ns3_add_cluster(sg_platf_cluster_cbarg_t cluster)
       for (i = start; i <= end; i++){
         xbt_dynar_push_as(tab_elements_num, int, i);
         router_id = bprintf("ns3_%s%d%s", cluster_prefix, i, cluster_suffix);
-        simgrid::Host::get_host(router_id)
+        simgrid::Host::by_name_or_create(router_id)
           ->set_facet(NS3_HOST_LEVEL, ns3_add_host_cluster(router_id));
         XBT_DEBUG("NS3_ADD_ROUTER '%s'",router_id);
         free(router_id);
index 433de56..b267423 100644 (file)
@@ -196,7 +196,7 @@ simgrid::surf::RoutingEdge *routing_add_host(
     }
     xbt_dynar_shrink(ctn, 0);
     xbt_dynar_free(&ctn_str);
-    simgrid::Host::get_host(host->id)->set_facet(COORD_HOST_LEVEL, (void *) ctn);
+    simgrid::Host::by_name_or_create(host->id)->set_facet(COORD_HOST_LEVEL, (void *) ctn);
     XBT_DEBUG("Having set host coordinates for '%s'",host->id);
   }
 
@@ -1339,7 +1339,7 @@ xbt_dynar_t surf_AS_get_hosts(simgrid::surf::As *as)
   for (int index = 0; index < count; index++) {
      sg_routing_edge_t relm =
       xbt_dynar_get_as(elms, index, simgrid::surf::RoutingEdge*);
-     sg_host_t delm = simgrid::Host::find_host(relm->getName());
+     sg_host_t delm = simgrid::Host::by_name_or_null(relm->getName());
      if (delm!=NULL) {
        xbt_dynar_push(res, &delm);
      }
index 315369c..3281f1e 100644 (file)
@@ -57,9 +57,9 @@ void AsVivaldi::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_
           *lat += static_cast<Link*>(info.link_up)->getLatency();
       }
     }
-    src_ctn = (xbt_dynar_t) simgrid::Host::get_host(tmp_src_name)->facet(COORD_HOST_LEVEL);
+    src_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(tmp_src_name)->facet(COORD_HOST_LEVEL);
     if (src_ctn == nullptr)
-      src_ctn = (xbt_dynar_t) simgrid::Host::get_host(src->getName())->facet(COORD_HOST_LEVEL);
+      src_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(src->getName())->facet(COORD_HOST_LEVEL);
   }
   else if(src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_AS){
     tmp_src_name = ROUTER_PEER(src->getName());
@@ -80,10 +80,10 @@ void AsVivaldi::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_
           *lat += static_cast<Link*>(info.link_down)->getLatency();
       }
     }
-    dst_ctn = (xbt_dynar_t) simgrid::Host::get_host(tmp_dst_name)
+    dst_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(tmp_dst_name)
       ->facet(COORD_HOST_LEVEL);
     if (dst_ctn == nullptr)
-      dst_ctn = (xbt_dynar_t) simgrid::Host::get_host(dst->getName())
+      dst_ctn = (xbt_dynar_t) simgrid::Host::by_name_or_create(dst->getName())
         ->facet(COORD_HOST_LEVEL);
   }
   else if(dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || dst->getRcType() == SURF_NETWORK_ELEMENT_AS){
index eaac5bb..9be8a78 100644 (file)
@@ -38,7 +38,7 @@ VirtualMachine::VirtualMachine(Model *model, const char *name, xbt_dict_t props,
 : Host(model, name, props, NULL, netElm, cpu)
 {
   VMModel::ws_vms.push_back(*this);
-  simgrid::Host::get_host(name)->set_facet(SURF_HOST_LEVEL, this);
+  simgrid::Host::by_name_or_create(name)->set_facet(SURF_HOST_LEVEL, this);
 }
 
 /*
@@ -62,7 +62,7 @@ void VirtualMachine::setState(e_surf_resource_state_t state){
  **/
 sg_host_t VirtualMachine::getPm()
 {
-  return simgrid::Host::find_host(p_subWs->getName());
+  return simgrid::Host::by_name_or_null(p_subWs->getName());
 }
 
 /**********
index c2ff00a..c0f76ca 100644 (file)
@@ -338,7 +338,7 @@ void VMHL13::setAffinity(Cpu *cpu, unsigned long mask){
 sg_host_t VMHL13::getPm()
 {
   // TODO, store pointer to the PM?
-  return simgrid::Host::find_host(p_subWs->getName());
+  return simgrid::Host::by_name_or_null(p_subWs->getName());
 }
 
 /* Adding a task to a VM updates the VCPU task on its physical machine. */