class XBT_PUBLIC Host : public xbt::Extendable<Host> {
friend vm::VMModel; // Use the pimpl_cpu to compute the VM sharing
friend vm::VirtualMachineImpl; // creates the the pimpl_cpu
+ friend kernel::routing::NetZoneImpl;
public:
explicit Host(const std::string& name);
/** Host destruction logic */
protected:
virtual ~Host();
+ void set_netpoint(kernel::routing::NetPoint* netpoint) { pimpl_netpoint_ = netpoint; }
private:
bool currently_destroying_ = false;
/** Retrieves the name of that host as a C string */
const char* get_cname() const { return name_.c_str(); }
+ kernel::routing::NetPoint* get_netpoint() const { return pimpl_netpoint_; }
+
int get_actor_count();
std::vector<ActorPtr> get_all_actors();
private:
xbt::string name_{"noname"};
std::unordered_map<std::string, Storage*>* mounts_ = nullptr; // caching
+ kernel::routing::NetPoint* pimpl_netpoint_ = nullptr;
public:
#ifndef DOXYGEN
kernel::resource::Cpu* pimpl_cpu = nullptr;
// TODO, this could be a unique_ptr
surf::HostImpl* pimpl_ = nullptr;
- /** DO NOT USE DIRECTLY (@todo: these should be protected, once our code is clean) */
- kernel::routing::NetPoint* pimpl_netpoint = nullptr;
#endif
};
} // namespace s4u
{
xbt_assert(father, "Only the Root container has no father");
- netpoint_ = host.pimpl_netpoint;
+ netpoint_ = host.get_netpoint();
xbt_assert(netpoint_, "Element '%s' not found", host.get_cname());
trivaNodeTypes.insert(type_->get_name());
if (hierarchy_ == RoutingMode::unset)
hierarchy_ = RoutingMode::base;
- res->pimpl_netpoint = new NetPoint(name, NetPoint::Type::Host, this);
+ res->set_netpoint(new NetPoint(name, NetPoint::Type::Host, this));
surf_cpu_model_pm->create_cpu(res, speed_per_pstate, coreAmount);
std::string pm_name_dst = destination->get_name();
/* update net_elm with that of the destination physical host */
- piface_->pimpl_netpoint = destination->pimpl_netpoint;
+ piface_->pimpl_netpoint_ = destination->get_netpoint();
physical_host_ = destination;
XBT_DEBUG("Create VM %s", get_cname());
/* Currently, a VM uses the network resource of its physical host */
- pimpl_netpoint = physical_host->pimpl_netpoint;
+ set_netpoint(physical_host->get_netpoint());
// Create a VCPU for this VM
std::vector<double> speeds;
XBT_DEBUG("destroy %s", get_cname());
/* Don't free these things twice: they are the ones of my physical host */
- pimpl_netpoint = nullptr;
+ set_netpoint(nullptr);
}
void VirtualMachine::start()
xbt_assert(currently_destroying_, "Please call h->destroy() instead of manually deleting it.");
delete pimpl_;
- if (pimpl_netpoint != nullptr) // not removed yet by a children class
- Engine::get_instance()->netpoint_unregister(pimpl_netpoint);
+ if (pimpl_netpoint_ != nullptr) // not removed yet by a children class
+ Engine::get_instance()->netpoint_unregister(pimpl_netpoint_);
delete pimpl_cpu;
delete mounts_;
}
/** @brief Just like Host::routeTo, but filling an array of link implementations */
void Host::route_to(Host* dest, std::vector<kernel::resource::LinkImpl*>& links, double* latency)
{
- kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint, dest->pimpl_netpoint, links, latency);
+ kernel::routing::NetZoneImpl::get_global_route(pimpl_netpoint_, dest->get_netpoint(), links, latency);
if (XBT_LOG_ISENABLED(surf_route, xbt_log_priority_debug)) {
XBT_CDEBUG(surf_route, "Route from '%s' to '%s' (latency: %f):", get_cname(), dest->get_cname(),
(latency == nullptr ? -1 : *latency));
/** @brief Returns the networking zone englobing that host */
NetZone* Host::get_englobing_zone()
{
- return pimpl_netpoint->get_englobing_zone()->get_iface();
+ return pimpl_netpoint_->get_englobing_zone()->get_iface();
}
void Host::send_to(Host* dest, double byte_amount)
std::vector<simgrid::s4u::Host*> list = simgrid::s4u::Engine::get_instance()->get_all_hosts();
auto last = std::remove_if(begin(list), end(list), [](const simgrid::s4u::Host* host) {
- return not host || not host->pimpl_netpoint || not host->pimpl_netpoint->is_host();
+ return not host || not host->get_netpoint() || not host->get_netpoint()->is_host();
});
std::sort(begin(list), last,
[](const simgrid::s4u::Host* a, const simgrid::s4u::Host* b) { return a->get_name() < b->get_name(); });
// Create private link
std::string host_id = cluster.prefix + std::to_string(i) + cluster.suffix;
- auto* host_src = simgrid::s4u::Host::by_name(host_id)->pimpl_netpoint->extension<NetPointNs3>();
+ auto* host_src = simgrid::s4u::Host::by_name(host_id)->get_netpoint()->extension<NetPointNs3>();
xbt_assert(host_src, "Cannot find a ns-3 host of name %s", host_id.c_str());
// Any ns-3 route is symmetrical
static int port_number = 1025; // Port number is limited from 1025 to 65 000
- unsigned int node1 = src->pimpl_netpoint->extension<NetPointNs3>()->node_num;
- unsigned int node2 = dst->pimpl_netpoint->extension<NetPointNs3>()->node_num;
+ unsigned int node1 = src->get_netpoint()->extension<NetPointNs3>()->node_num;
+ unsigned int node2 = dst->get_netpoint()->extension<NetPointNs3>()->node_num;
ns3::Ptr<ns3::Node> src_node = src->pimpl_netpoint->extension<NetPointNs3>()->ns3_node_;
ns3::Ptr<ns3::Node> dst_node = dst->pimpl_netpoint->extension<NetPointNs3>()->ns3_node_;
if (args->pstate != 0)
host->set_pstate(args->pstate);
if (not args->coord.empty())
- new simgrid::kernel::routing::vivaldi::Coords(host->pimpl_netpoint, args->coord);
+ new simgrid::kernel::routing::vivaldi::Coords(host->get_netpoint(), args->coord);
}
/** @brief Add a "router" to the network element list */
speed_per_pstate.push_back(peer->speed);
simgrid::s4u::Host* host = as->create_host(peer->id.c_str(), speed_per_pstate, 1, nullptr);
- as->set_peer_link(host->pimpl_netpoint, peer->bw_in, peer->bw_out, peer->coord);
+ as->set_peer_link(host->get_netpoint(), peer->bw_in, peer->bw_out, peer->coord);
/* Change from the defaults */
if (peer->state_trace)
/** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
void sg_platf_new_hostlink(simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
{
- simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->pimpl_netpoint;
+ simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint();
xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str());
xbt_assert(dynamic_cast<simgrid::kernel::routing::ClusterZone*>(current_routing),
"Only hosts from Cluster and Vivaldi ASes can get a host_link.");
for (unsigned int it_src = 0; it_src < totalHosts; it_src++) { // Routes from host
simgrid::s4u::Host* host1 = hosts[it_src];
- simgrid::kernel::routing::NetPoint* src = host1->pimpl_netpoint;
+ simgrid::kernel::routing::NetPoint* src = host1->get_netpoint();
for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
simgrid::s4u::Host* host2 = hosts[it_dst];
std::vector<simgrid::kernel::resource::LinkImpl*> route;
- simgrid::kernel::routing::NetPoint* dst = host2->pimpl_netpoint;
+ simgrid::kernel::routing::NetPoint* dst = host2->get_netpoint();
simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr);
if (not route.empty()) {
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", host1->get_cname(), host2->get_cname());
simgrid::s4u::Host* host2 = hosts[it_dst];
std::printf(" <route src=\"%s\" dst=\"%s\">\n ", value1->get_cname(), host2->get_cname());
std::vector<simgrid::kernel::resource::LinkImpl*> route;
- simgrid::kernel::routing::NetPoint* netcardDst = host2->pimpl_netpoint;
+ simgrid::kernel::routing::NetPoint* netcardDst = host2->get_netpoint();
simgrid::kernel::routing::NetZoneImpl::get_global_route(value1, netcardDst, route, nullptr);
for (auto const& link : route)
std::printf("<link_ctn id=\"%s\"/>", link->get_cname());
int it;
sg_host_t host;
xbt_dynar_foreach(hosts, it, host) {
- simgrid::kernel::routing::NetPoint* nc = host->pimpl_netpoint;
+ simgrid::kernel::routing::NetPoint* nc = host->get_netpoint();
const char *type = "buggy";
if (nc->is_router())
type = "router";