Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove remaining mentions of RngStream.
[simgrid.git] / examples / s4u / dht-kademlia / node.cpp
index ead02fe..617f382 100644 (file)
@@ -33,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::by_name(std::to_string(id_));
+  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_));
   do {
     if (receive_comm == nullptr)
       receive_comm = mailbox->get_async(&received_msg);
@@ -57,7 +57,7 @@ bool Node::join(unsigned int known_id)
   } while (not got_answer);
 
   /* Second step: Send a FIND_NODE to a a random node in buckets */
-  unsigned int bucket_id = table->findBucket(known_id)->getId();
+  unsigned int bucket_id = table.findBucket(known_id)->getId();
   xbt_assert(bucket_id <= IDENTIFIER_SIZE);
   for (i = 0; ((bucket_id > i) || (bucket_id + i) <= IDENTIFIER_SIZE) && i < JOIN_BUCKETS_QUERIES; i++) {
     if (bucket_id > i) {
@@ -79,7 +79,7 @@ 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::by_name(std::to_string(id));
+  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id));
   /* Build the task */
   Message* msg = new Message(id_, destination, simgrid::s4u::Mailbox::by_name(std::to_string(id_)),
                              simgrid::s4u::Host::current()->get_cname());
@@ -118,7 +118,7 @@ unsigned int Node::sendFindNodeToBest(Answer* node_list)
 void Node::routingTableUpdate(unsigned int id)
 {
   // retrieval of the bucket in which the should be
-  Bucket* bucket = table->findBucket(id);
+  Bucket* bucket = table.findBucket(id);
 
   // check if the id is already in the bucket.
   auto id_pos = std::find(bucket->nodes.begin(), bucket->nodes.end(), id);
@@ -146,7 +146,7 @@ Answer* Node::findClosest(unsigned int destination_id)
 {
   Answer* answer = new Answer(destination_id);
   /* We find the corresponding bucket for the id */
-  Bucket* bucket = table->findBucket(destination_id);
+  const Bucket* bucket = table.findBucket(destination_id);
   int bucket_id  = bucket->getId();
   xbt_assert((bucket_id <= IDENTIFIER_SIZE), "Bucket found has a wrong identifier");
   /* So, we copy the contents of the bucket unsigned into our answer */
@@ -158,12 +158,12 @@ Answer* Node::findClosest(unsigned int destination_id)
   for (int i = 1; answer->getSize() < BUCKET_SIZE && ((bucket_id - i > 0) || (bucket_id + i < IDENTIFIER_SIZE)); i++) {
     /* We check the previous buckets */
     if (bucket_id - i >= 0) {
-      Bucket* bucket_p = table->buckets[bucket_id - i];
+      const Bucket* bucket_p = &table.buckets[bucket_id - i];
       answer->addBucket(bucket_p);
     }
     /* We check the next buckets */
     if (bucket_id + i <= IDENTIFIER_SIZE) {
-      Bucket* bucket_n = table->buckets[bucket_id + i];
+      const Bucket* bucket_n = &table.buckets[bucket_id + i];
       answer->addBucket(bucket_n);
     }
   }
@@ -200,7 +200,7 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
     steps++;
     double time_beginreceive = simgrid::s4u::Engine::get_clock();
 
-    simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_));
+    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_));
     do {
       if (receive_comm == nullptr)
         receive_comm = mailbox->get_async(&received_msg);
@@ -217,7 +217,7 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
 
           nodes_added = node_list->merge(msg->answer_);
           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());
+                    msg->issuer_host_name_.c_str(), msg->answer_->nodes.size());
         } else {
           if (msg->answer_) {
             routingTableUpdate(msg->sender_id_);
@@ -262,7 +262,7 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
 void Node::randomLookup()
 {
   unsigned int id_to_look = RANDOM_LOOKUP_NODE; // Totally random.
-  /* TODO: Use some pseudo-random generator like RngStream. */
+  /* TODO: Use some pseudo-random generator. */
   XBT_DEBUG("I'm doing a random lookup");
   findNode(id_to_look, true);
 }
@@ -272,7 +272,7 @@ 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_->get_cname(),
-           msg->issuer_host_name_, msg->destination_id_);
+           msg->issuer_host_name_.c_str(), msg->destination_id_);
   // Building the answer to the request
   Message* answer =
       new Message(id_, msg->destination_id_, findClosest(msg->destination_id_),