Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove the properties from the host constructor
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 1 Apr 2016 19:08:33 +0000 (21:08 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 1 Apr 2016 19:08:33 +0000 (21:08 +0200)
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/sg_platf.cpp
src/surf/virtual_machine.cpp
src/surf/virtual_machine.hpp
src/surf/vm_hl13.cpp
src/surf/vm_hl13.hpp

index f990c45..646f093 100644 (file)
@@ -31,10 +31,10 @@ simgrid::xbt::Extension<simgrid::s4u::Host, HostImpl> HostImpl::EXTENSION_ID;
 /*********
  * Model *
  *********/
-HostImpl *HostModel::createHost(const char *name,NetCard *netElm, Cpu *cpu, xbt_dict_t props){
+HostImpl *HostModel::createHost(const char *name,NetCard *netElm, Cpu *cpu){
   xbt_dynar_t storageList = (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL);
 
-  HostImpl *host = new simgrid::surf::HostImpl(surf_host_model, name, props, storageList, cpu);
+  HostImpl *host = new simgrid::surf::HostImpl(surf_host_model, name, storageList, cpu);
   XBT_DEBUG("Create host %s with %ld mounted disks", name, xbt_dynar_length(host->p_storage));
   return host;
 }
@@ -123,19 +123,18 @@ void HostImpl::classInit()
   }
 }
 
-HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, xbt_dict_t props,
-                     xbt_dynar_t storage, Cpu *cpu)
+HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, xbt_dynar_t storage, Cpu *cpu)
  : Resource(model, name)
- , PropertyHolder(props)
+ , PropertyHolder(nullptr)
  , p_storage(storage), p_cpu(cpu)
 {
   p_params.ramsize = 0;
 }
 
-HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
+HostImpl::HostImpl(simgrid::surf::HostModel *model, const char *name, lmm_constraint_t constraint,
                  xbt_dynar_t storage, Cpu *cpu)
  : Resource(model, name, constraint)
- , PropertyHolder(props)
+ , PropertyHolder(nullptr)
  , p_storage(storage), p_cpu(cpu)
 {
   p_params.ramsize = 0;
index 6612221..058140b 100644 (file)
@@ -52,7 +52,7 @@ public:
   HostModel() : Model() {}
   ~HostModel() override {}
 
-  HostImpl *createHost(const char *name, NetCard *net, Cpu *cpu, xbt_dict_t props);
+  HostImpl *createHost(const char *name, NetCard *net, Cpu *cpu);
 
   virtual void adjustWeightOfDummyCpuActions();
   virtual Action *executeParallelTask(int host_nb, sg_host_t *host_list,
@@ -85,7 +85,7 @@ public:
    * @param storage The Storage associated to this Host
    * @param cpu The Cpu associated to this Host
    */
-  HostImpl(HostModel *model, const char *name, xbt_dict_t props, xbt_dynar_t storage, Cpu *cpu);
+  HostImpl(HostModel *model, const char *name, xbt_dynar_t storage, Cpu *cpu);
 
   /**
    * @brief Host constructor
@@ -97,7 +97,7 @@ public:
    * @param storage The Storage associated to this Host
    * @param cpu The Cpu associated to this Host
    */
-  HostImpl(HostModel *model, const char *name, xbt_dict_t props,
+  HostImpl(HostModel *model, const char *name,
       lmm_constraint_t constraint, xbt_dynar_t storage, Cpu *cpu);
 
   /* Host destruction logic */
index 1932e5a..9fa57c7 100644 (file)
@@ -151,7 +151,14 @@ void sg_platf_new_host(sg_platf_host_cbarg_t host)
     cpu->setStateTrace(host->state_trace);
   if (host->speed_trace)
     cpu->setSpeedTrace(host->speed_trace);
-  surf_host_model->createHost(host->id, netcard, cpu, host->properties)->attach(h);
+  surf_host_model->createHost(host->id, netcard, cpu)->attach(h);
+
+  if (host->properties) {
+    xbt_dict_cursor_t cursor=NULL;
+    char *key,*data;
+    xbt_dict_foreach(host->properties,cursor,key,data)
+      h->setProperty(key,data);
+  }
 
   if (host->pstate != 0)
     cpu->setPState(host->pstate);
index e640cc3..37e771c 100644 (file)
@@ -32,8 +32,8 @@ VMModel::vm_list_t VMModel::ws_vms;
  * Resource *
  ************/
 
-VirtualMachine::VirtualMachine(HostModel *model, const char *name, xbt_dict_t props, simgrid::s4u::Host *hostPM)
-: HostImpl(model, name, props, NULL, NULL, NULL)
+VirtualMachine::VirtualMachine(HostModel *model, const char *name, simgrid::s4u::Host *hostPM)
+: HostImpl(model, name, NULL, NULL, NULL)
 , p_hostPM(hostPM)
 {
   VMModel::ws_vms.push_back(*this);
index 5c6872e..4c64492 100644 (file)
@@ -58,10 +58,9 @@ public:
    *
    * @param model VMModel associated to this VM
    * @param name The name of the VM
-   * @param props Dictionary of properties associated to this VM
    * @param host The host
    */
-  VirtualMachine(simgrid::surf::HostModel *model, const char *name, xbt_dict_t props, simgrid::s4u::Host *host);
+  VirtualMachine(simgrid::surf::HostModel *model, const char *name, simgrid::s4u::Host *host);
 
   /** @brief Destructor */
   ~VirtualMachine();
index aee9b99..ad0151d 100644 (file)
@@ -33,7 +33,7 @@ void VMHL13Model::updateActionsState(double /*now*/, double /*delta*/) {}
 
 VirtualMachine *VMHL13Model::createVM(const char *name, sg_host_t host_PM)
 {
-  VirtualMachine* vm = new VMHL13(this, name, NULL, host_PM);
+  VirtualMachine* vm = new VMHL13(this, name, host_PM);
   VMCreatedCallbacks(vm);
   return vm;
 }
@@ -95,8 +95,8 @@ double VMHL13Model::next_occuring_event(double now)
 /************
  * Resource *
  ************/
-VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t host_PM)
- : VirtualMachine(model, name, props, host_PM)
+VMHL13::VMHL13(VMModel *model, const char* name, sg_host_t host_PM)
+ : VirtualMachine(model, name, host_PM)
 {
   /* Currently, we assume a VM has no storage. */
   p_storage = NULL;
index 7b66c2a..a901656 100644 (file)
@@ -45,7 +45,7 @@ public:
 
 class VMHL13 : public VirtualMachine {
 public:
-  VMHL13(VMModel *model, const char* name, xbt_dict_t props, sg_host_t host_PM);
+  VMHL13(VMModel *model, const char* name, sg_host_t host_PM);
   ~VMHL13() {}
 
   void suspend() override;