Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[surf] simgrid::surf::Host, add backlink and attach() method
authorGabriel Corona <gabriel.corona@loria.fr>
Thu, 17 Dec 2015 13:38:31 +0000 (14:38 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Thu, 17 Dec 2015 13:41:12 +0000 (14:41 +0100)
src/surf/host_clm03.cpp
src/surf/host_interface.cpp
src/surf/host_interface.hpp
src/surf/host_ptask_L07.cpp
src/surf/sg_platf.cpp

index fd7e445..3465f78 100644 (file)
@@ -51,9 +51,7 @@ Host *HostCLM03Model::createHost(const char *name,RoutingEdge *netElm, Cpu *cpu)
   Host *host = new simgrid::surf::HostCLM03(surf_host_model, name, NULL,
                  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
                  netElm, cpu);
   Host *host = new simgrid::surf::HostCLM03(surf_host_model, name, NULL,
                  (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
                  netElm, cpu);
-  surf_callback_emit(hostCreatedCallbacks, host);
   XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
   XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
-  simgrid::Host::by_name_or_null(name)->set_facet(host);
   return host;
 }
 
   return host;
 }
 
index 81037bc..e2eb602 100644 (file)
@@ -109,6 +109,15 @@ Host::~Host(){
   surf_callback_emit(hostDestructedCallbacks, this);
 }
 
   surf_callback_emit(hostDestructedCallbacks, this);
 }
 
+void Host::attach(simgrid::Host* host)
+{
+  if (p_host != nullptr)
+    xbt_die("Already attached to host %s", host->id().c_str());
+  host->set_facet(this);
+  p_host = host;
+  surf_callback_emit(hostCreatedCallbacks, this);
+}
+
 void Host::setState(e_surf_resource_state_t state){
   e_surf_resource_state_t old = Resource::getState();
   Resource::setState(state);
 void Host::setState(e_surf_resource_state_t state){
   e_surf_resource_state_t old = Resource::getState();
   Resource::setState(state);
index 915c14a..ed143b8 100644 (file)
@@ -129,6 +129,7 @@ public:
   /** @brief Host destructor */
   ~Host();
 
   /** @brief Host destructor */
   ~Host();
 
+  void attach(simgrid::Host* host);
   void setState(e_surf_resource_state_t state);
 
   /**
   void setState(e_surf_resource_state_t state);
 
   /**
@@ -267,6 +268,7 @@ public:
   xbt_dynar_t p_storage;
   RoutingEdge *p_netElm;
   Cpu *p_cpu;
   xbt_dynar_t p_storage;
   RoutingEdge *p_netElm;
   Cpu *p_cpu;
+  simgrid::Host* p_host = nullptr;
 
   /** @brief Get the list of virtual machines on the current Host */
   xbt_dynar_t getVms();
 
   /** @brief Get the list of virtual machines on the current Host */
   xbt_dynar_t getVms();
index 0fc243c..2f573c0 100644 (file)
@@ -272,12 +272,7 @@ Action *HostL07Model::executeParallelTask(int host_nb,
 
 Host *HostL07Model::createHost(const char *name,RoutingEdge *netElm, Cpu *cpu)
 {
 
 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::by_name_or_create(name)->set_facet<Host>(host);
-
-  return host;
+  return new HostL07(this, name, NULL, netElm, cpu);
 }
 
 Action *NetworkL07Model::communicate(RoutingEdge *src, RoutingEdge *dst,
 }
 
 Action *NetworkL07Model::communicate(RoutingEdge *src, RoutingEdge *dst,
index 8797417..bc674ce 100644 (file)
@@ -72,8 +72,7 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host)
         host->state_trace,
         host->properties);
   cpu->plug(h);
         host->state_trace,
         host->properties);
   cpu->plug(h);
-  surf_host_model->createHost(host->id, net, cpu);
-
+  surf_host_model->createHost(host->id, net, cpu)->attach(h);
   if (TRACE_is_enabled() && TRACE_needs_platform())
     sg_instr_new_host(host);
 }
   if (TRACE_is_enabled() && TRACE_needs_platform())
     sg_instr_new_host(host);
 }