std::map<std::pair<NetPoint*, NetPoint*>, BypassRoute*> bypass_routes_; // src x dst -> route
routing::NetPoint* netpoint_ = nullptr; // Our representative in the father NetZone
- std::shared_ptr<resource::NetworkModel> network_model_;
- std::shared_ptr<resource::CpuModel> cpu_model_vm_;
- std::shared_ptr<resource::CpuModel> cpu_model_pm_;
- std::shared_ptr<resource::DiskModel> disk_model_;
- std::shared_ptr<simgrid::surf::HostModel> host_model_;
- /** @brief Perform sealing procedure for derived classes, if necessary */
- virtual void do_seal(){};
- void add_child(NetZoneImpl* new_zone);
protected:
explicit NetZoneImpl(const std::string& name);
public:
enum class RoutingMode {
- unset = 0, /**< Undefined type */
- base, /**< Base case: use simple link lists for routing */
- recursive /**< Recursive case: also return gateway information */
+ base, /**< Base case: use simple link lists for routing */
+ recursive /**< Recursive case: also return gateway information */
};
- /* FIXME: protect the following fields once the construction madness is sorted out */
- RoutingMode hierarchy_ = RoutingMode::unset;
-
/** @brief Retrieves the network model associated to this NetZone */
const std::shared_ptr<resource::NetworkModel>& get_network_model() const { return network_model_; }
/** @brief Retrieves the CPU model for virtual machines associated to this NetZone */
/** @brief Returns the list of direct children (no grand-children). This returns the internal data, no copy.
* Don't mess with it.*/
std::vector<NetZoneImpl*>* get_children() { return &children_; }
+ /** @brief Get current netzone hierarchy */
+ RoutingMode get_hierarchy() const { return hierarchy_; }
/** @brief Retrieves the name of that netzone as a C++ string */
const std::string& get_name() const { return name_; }
virtual void get_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* nodes,
std::map<std::string, xbt_edge_t, std::less<>>* edges) = 0;
+
+private:
+ RoutingMode hierarchy_ = RoutingMode::base;
+ std::shared_ptr<resource::NetworkModel> network_model_;
+ std::shared_ptr<resource::CpuModel> cpu_model_vm_;
+ std::shared_ptr<resource::CpuModel> cpu_model_pm_;
+ std::shared_ptr<resource::DiskModel> disk_model_;
+ std::shared_ptr<simgrid::surf::HostModel> host_model_;
+ /** @brief Perform sealing procedure for derived classes, if necessary */
+ virtual void do_seal(){};
+ void add_child(NetZoneImpl* new_zone);
};
} // namespace routing
} // namespace kernel
xbt_node_t node = nullptr;
/* Add the loopback if needed */
- if (get_network_model()->loopback_ && hierarchy_ == RoutingMode::base) {
+ if (get_network_model()->loopback_ && get_hierarchy() == RoutingMode::base) {
xbt_dynar_foreach (xbt_graph_get_nodes(route_graph_.get()), cursor, node) {
bool found = false;
xbt_edge_t edge = nullptr;
if (v == dst_node_id)
first_gw = gw_dst;
- if (hierarchy_ == RoutingMode::recursive && v != dst_node_id && gw_dst->get_name() != prev_gw_src->get_name()) {
+ if (get_hierarchy() == RoutingMode::recursive && v != dst_node_id &&
+ gw_dst->get_name() != prev_gw_src->get_name()) {
std::vector<resource::LinkImpl*> e_route_as_to_as;
NetPoint* gw_dst_net_elm = nullptr;
}
}
- if (hierarchy_ == RoutingMode::recursive) {
+ if (get_hierarchy() == RoutingMode::recursive) {
route->gw_src = gw_src;
route->gw_dst = first_gw;
}
{
add_route_check_params(src, dst, gw_src, gw_dst, link_list, symmetrical);
- new_edge(src->id(), dst->id(), new_extended_route(hierarchy_, gw_src, gw_dst, link_list, true));
+ new_edge(src->id(), dst->id(), new_extended_route(get_hierarchy(), gw_src, gw_dst, link_list, true));
if (symmetrical)
- new_edge(dst->id(), src->id(), new_extended_route(hierarchy_, gw_dst, gw_src, link_list, false));
+ new_edge(dst->id(), src->id(), new_extended_route(get_hierarchy(), gw_dst, gw_src, link_list, false));
}
void DijkstraZone::new_edge(int src_id, int dst_id, RouteCreationArgs* route)
cur = pred;
} while (cur != src->id());
- if (hierarchy_ == RoutingMode::recursive) {
+ if (get_hierarchy() == RoutingMode::recursive) {
route->gw_src = route_stack.back()->gw_src;
route->gw_dst = route_stack.front()->gw_dst;
}
while (not route_stack.empty()) {
const RouteCreationArgs* e_route = route_stack.back();
route_stack.pop_back();
- if (hierarchy_ == RoutingMode::recursive && prev_dst_gw != nullptr &&
+ if (get_hierarchy() == RoutingMode::recursive && prev_dst_gw != nullptr &&
prev_dst_gw->get_cname() != e_route->gw_src->get_cname()) {
get_global_route(prev_dst_gw, e_route->gw_src, route->link_list, lat);
}
"The route between %s and %s already exists (Rq: routes are symmetrical by default).", src->get_cname(),
dst->get_cname());
- TO_FLOYD_LINK(src->id(), dst->id()) = new_extended_route(hierarchy_, gw_src, gw_dst, link_list, true);
+ TO_FLOYD_LINK(src->id(), dst->id()) = new_extended_route(get_hierarchy(), gw_src, gw_dst, link_list, true);
TO_FLOYD_PRED(src->id(), dst->id()) = src->id();
TO_FLOYD_COST(src->id(), dst->id()) = (TO_FLOYD_LINK(src->id(), dst->id()))->link_list.size();
XBT_DEBUG("Load NetzoneRoute from \"%s(%s)\" to \"%s(%s)\"", dst->get_cname(), gw_src->get_cname(),
src->get_cname(), gw_dst->get_cname());
- TO_FLOYD_LINK(dst->id(), src->id()) = new_extended_route(hierarchy_, gw_src, gw_dst, link_list, false);
+ TO_FLOYD_LINK(dst->id(), src->id()) = new_extended_route(get_hierarchy(), gw_src, gw_dst, link_list, false);
TO_FLOYD_PRED(dst->id(), src->id()) = dst->id();
TO_FLOYD_COST(dst->id(), src->id()) =
(TO_FLOYD_LINK(dst->id(), src->id()))->link_list.size(); /* count of links, old model assume 1 */
init_tables(table_size);
/* Add the loopback if needed */
- if (get_network_model()->loopback_ && hierarchy_ == RoutingMode::base) {
+ if (get_network_model()->loopback_ && get_hierarchy() == RoutingMode::base) {
for (unsigned int i = 0; i < table_size; i++) {
RouteCreationArgs* route = TO_FLOYD_LINK(i, i);
if (not route) {
routing_table_.resize(table_size * table_size, nullptr);
/* Add the loopback if needed */
- if (get_network_model()->loopback_ && hierarchy_ == RoutingMode::base) {
+ if (get_network_model()->loopback_ && get_hierarchy() == RoutingMode::base) {
for (unsigned int i = 0; i < table_size; i++) {
RouteCreationArgs* route = TO_ROUTE_FULL(i, i);
if (not route) {
dst->get_cname());
/* Add the route to the base */
- TO_ROUTE_FULL(src->id(), dst->id()) = new_extended_route(hierarchy_, gw_src, gw_dst, link_list, true);
+ TO_ROUTE_FULL(src->id(), dst->id()) = new_extended_route(get_hierarchy(), gw_src, gw_dst, link_list, true);
if (symmetrical && src != dst) {
if (gw_dst && gw_src) {
"The route between %s and %s already exists. You should not declare the reverse path as symmetrical.",
dst->get_cname(), src->get_cname());
- TO_ROUTE_FULL(dst->id(), src->id()) = new_extended_route(hierarchy_, gw_src, gw_dst, link_list, false);
+ TO_ROUTE_FULL(dst->id(), src->id()) = new_extended_route(get_hierarchy(), gw_src, gw_dst, link_list, false);
}
}
} // namespace routing
void NetZoneImpl::add_child(NetZoneImpl* new_zone)
{
xbt_assert(not sealed_, "Cannot add a new child to the sealed zone %s", get_cname());
+ /* set the father behavior */
+ hierarchy_ = RoutingMode::recursive;
children_.push_back(new_zone);
}
s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate)
{
- if (hierarchy_ == RoutingMode::unset)
- hierarchy_ = RoutingMode::base;
-
auto* res = (new surf::HostImpl(name))->get_iface();
res->set_netpoint((new NetPoint(name, NetPoint::Type::Host))->set_englobing_zone(this));
{
auto* result = new RouteCreationArgs();
- xbt_assert(hierarchy == RoutingMode::base || hierarchy == RoutingMode::recursive,
- "The hierarchy of this netzone is neither BASIC nor RECURSIVE, I'm lost here.");
-
if (hierarchy == RoutingMode::recursive) {
xbt_assert(gw_src && gw_dst, "nullptr is obviously a deficient gateway");
/** @brief Add a "router" to the network element list */
simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, const char* coords)
{
- if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset)
- current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::base;
xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name),
"Refusing to create a router named '%s': this name already describes a node.", name.c_str());
}
new_zone->set_parent(current_routing);
- if (current_routing) {
- /* set the father behavior */
- if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset)
- current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::recursive;
- }
return new_zone;
}