X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f5b4648bcb7aa3c1174e25c9f3cd28867b3b2871..5f4329821ed097d617ccb739e1dd1b22caaadf92:/src/kernel/routing/NetZoneImpl.cpp diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index da9e717214..4dd41beb6d 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -7,6 +7,9 @@ #include "simgrid/kernel/routing/NetPoint.hpp" #include "simgrid/s4u/Engine.hpp" #include "simgrid/s4u/Host.hpp" +#include "src/kernel/EngineImpl.hpp" +#include "src/kernel/resource/DiskImpl.hpp" +#include "src/surf/HostImpl.hpp" #include "src/surf/cpu_interface.hpp" #include "src/surf/network_interface.hpp" #include "src/surf/xml/platf_private.hpp" @@ -18,19 +21,11 @@ namespace simgrid { namespace kernel { namespace routing { -NetZoneImpl::NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model) - : piface_(this), father_(father), name_(name), network_model_(network_model) +NetZoneImpl::NetZoneImpl(const std::string& name) : piface_(this), name_(name) { xbt_assert(nullptr == s4u::Engine::get_instance()->netpoint_by_name_or_null(get_name()), "Refusing to create a second NetZone called '%s'.", get_cname()); - - netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone, father_); - if (models_by_type[simgrid::kernel::resource::Model::Type::CPU_VM].size() > 0) { - cpu_model_vm_ = static_cast( - models_by_type[simgrid::kernel::resource::Model::Type::CPU_VM][0]); - } - cpu_model_pm_ = static_cast( - models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM][0]); + netpoint_ = new NetPoint(name_, NetPoint::Type::NetZone); XBT_DEBUG("NetZone '%s' created with the id '%u'", get_cname(), netpoint_->id()); } @@ -71,6 +66,13 @@ int NetZoneImpl::get_host_count() const return count; } +s4u::Disk* NetZoneImpl::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth) +{ + auto* l = disk_model_->create_disk(name, read_bandwidth, write_bandwidth); + + return l->get_iface(); +} + s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector& bandwidths, s4u::Link::SharingPolicy policy) { @@ -86,7 +88,7 @@ s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vectorset_netpoint(new NetPoint(name, NetPoint::Type::Host, this)); + res->set_netpoint((new NetPoint(name, NetPoint::Type::Host))->set_englobing_zone(this)); cpu_model_pm_->create_cpu(res, speed_per_pstate)->set_core_count(core_amount)->seal(); @@ -389,6 +391,50 @@ void NetZoneImpl::get_global_route(NetPoint* src, NetPoint* dst, if (route.gw_dst != dst) get_global_route(route.gw_dst, dst, links, latency); } + +void NetZoneImpl::seal() +{ + do_seal(); // derived class' specific sealing procedure + sealed_ = true; +} + +void NetZoneImpl::set_parent(NetZoneImpl* parent) +{ + xbt_assert(sealed_ == false, "Impossible to set parent to an already sealed NetZone(%s)", this->get_cname()); + father_ = parent; + netpoint_->set_englobing_zone(father_); +} + +void NetZoneImpl::set_network_model(std::shared_ptr netmodel) +{ + xbt_assert(sealed_ == false, "Impossible to set network model to an already sealed NetZone(%s)", this->get_cname()); + network_model_ = std::move(netmodel); +} + +void NetZoneImpl::set_cpu_vm_model(std::shared_ptr cpu_model) +{ + xbt_assert(sealed_ == false, "Impossible to set CPU model to an already sealed NetZone(%s)", this->get_cname()); + cpu_model_vm_ = std::move(cpu_model); +} + +void NetZoneImpl::set_cpu_pm_model(std::shared_ptr cpu_model) +{ + xbt_assert(sealed_ == false, "Impossible to set CPU model to an already sealed NetZone(%s)", this->get_cname()); + cpu_model_pm_ = std::move(cpu_model); +} + +void NetZoneImpl::set_disk_model(std::shared_ptr disk_model) +{ + xbt_assert(sealed_ == false, "Impossible to set disk model to an already sealed NetZone(%s)", this->get_cname()); + disk_model_ = std::move(disk_model); +} + +void NetZoneImpl::set_host_model(std::shared_ptr host_model) +{ + xbt_assert(sealed_ == false, "Impossible to set host model to an already sealed NetZone(%s)", this->get_cname()); + host_model_ = std::move(host_model); +} + } // namespace routing } // namespace kernel } // namespace simgrid