X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/8a18a39ea4a00e51fc7c6d2f06a4c0c98fb79759..71d4334465ce8d44107336c35e5968f5342ae7d0:/examples/s4u/dht-kademlia/node.cpp diff --git a/examples/s4u/dht-kademlia/node.cpp b/examples/s4u/dht-kademlia/node.cpp index b5e10fec82..7e41353802 100644 --- a/examples/s4u/dht-kademlia/node.cpp +++ b/examples/s4u/dht-kademlia/node.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2010, 2012-2018. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -34,7 +33,7 @@ bool Node::join(unsigned int known_id) /* First step: Send a "FIND_NODE" request to the node we know */ sendFindNode(known_id, id_); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(id_)); + simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_)); do { if (receive_comm == nullptr) receive_comm = mailbox->get_async(&received_msg); @@ -80,10 +79,10 @@ bool Node::join(unsigned int known_id) void Node::sendFindNode(unsigned int id, unsigned int destination) { /* Gets the mailbox to send to */ - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(id)); + simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id)); /* Build the task */ - Message* msg = new Message(id_, destination, simgrid::s4u::Mailbox::byName(std::to_string(id_)), - simgrid::s4u::Host::current()->getCname()); + Message* msg = new Message(id_, destination, simgrid::s4u::Mailbox::by_name(std::to_string(id_)), + simgrid::s4u::Host::current()->get_cname()); /* Send the task */ mailbox->put_init(msg, 1)->detach(kademlia::destroy); @@ -184,7 +183,7 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats) unsigned int answers; bool destination_found = false; unsigned int nodes_added = 0; - double global_timeout = simgrid::s4u::Engine::getClock() + find_node_global_timeout; + double global_timeout = simgrid::s4u::Engine::get_clock() + find_node_global_timeout; unsigned int steps = 0; /* First we build a list of who we already know */ @@ -197,11 +196,11 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats) answers = 0; queries = sendFindNodeToBest(node_list); nodes_added = 0; - double timeout = simgrid::s4u::Engine::getClock() + find_node_timeout; + double timeout = simgrid::s4u::Engine::get_clock() + find_node_timeout; steps++; - double time_beginreceive = simgrid::s4u::Engine::getClock(); + double time_beginreceive = simgrid::s4u::Engine::get_clock(); - simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::byName(std::to_string(id_)); + simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_)); do { if (receive_comm == nullptr) receive_comm = mailbox->get_async(&received_msg); @@ -217,7 +216,7 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats) answers++; nodes_added = node_list->merge(msg->answer_); - XBT_DEBUG("Received an answer from %s (%s) with %zu nodes on it", msg->answer_to_->getCname(), + XBT_DEBUG("Received an answer from %s (%s) with %zu nodes on it", msg->answer_to_->get_cname(), msg->issuer_host_name_, msg->answer_->nodes.size()); } else { if (msg->answer_) { @@ -227,8 +226,8 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats) handleFindNode(msg); } // Update the timeout if we didn't have our answer - timeout += simgrid::s4u::Engine::getClock() - time_beginreceive; - time_beginreceive = simgrid::s4u::Engine::getClock(); + timeout += simgrid::s4u::Engine::get_clock() - time_beginreceive; + time_beginreceive = simgrid::s4u::Engine::get_clock(); } delete msg->answer_; delete msg; @@ -236,10 +235,10 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats) } else { simgrid::s4u::this_actor::sleep_for(1); } - } while (simgrid::s4u::Engine::getClock() < timeout && answers < queries); + } while (simgrid::s4u::Engine::get_clock() < timeout && answers < queries); destination_found = node_list->destinationFound(); } while (not destination_found && (nodes_added > 0 || answers == 0) && - simgrid::s4u::Engine::getClock() < global_timeout && steps < MAX_STEPS); + simgrid::s4u::Engine::get_clock() < global_timeout && steps < MAX_STEPS); if (destination_found) { if (count_in_stats) @@ -272,12 +271,12 @@ void Node::randomLookup() void Node::handleFindNode(Message* msg) { routingTableUpdate(msg->sender_id_); - XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x", msg->answer_to_->getCname(), + XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x", msg->answer_to_->get_cname(), msg->issuer_host_name_, msg->destination_id_); // Building the answer to the request Message* answer = new Message(id_, msg->destination_id_, findClosest(msg->destination_id_), - simgrid::s4u::Mailbox::byName(std::to_string(id_)), simgrid::s4u::Host::current()->getCname()); + simgrid::s4u::Mailbox::by_name(std::to_string(id_)), simgrid::s4u::Host::current()->get_cname()); // Sending the answer msg->answer_to_->put_init(answer, 1)->detach(kademlia::destroy); }