Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines with new year.
[simgrid.git] / examples / s4u / dht-chord / s4u-dht-chord-node.cpp
index 9ad0c03..0bd3256 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2020. 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. */
@@ -20,9 +20,9 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(s4u_chord);
  * @param id id to check
  * @param start lower bound
  * @param end upper bound
- * @return a non-zero value if id in in [start, end]
+ * @return true if id in in [start, end]
  */
-static int is_in_interval(int id, int start, int end)
+static bool is_in_interval(int id, int start, int end)
 {
   int i = id % nb_keys;
   int s = start % nb_keys;
@@ -52,7 +52,6 @@ Node::Node(std::vector<std::string> args)
 
   // initialize my node
   id_                = std::stoi(args[1]);
-  stream             = simgrid::s4u::this_actor::get_host()->extension<HostChord>()->getStream();
   mailbox_           = simgrid::s4u::Mailbox::by_name(std::to_string(id_));
   next_finger_to_fix = 0;
   fingers_.resize(nb_bits, id_);
@@ -135,7 +134,7 @@ void Node::notifyAndQuit()
 void Node::randomLookup()
 {
   int res          = id_;
-  int random_index = RngStream_RandInt(stream, 0, nb_bits - 1);
+  int random_index = simgrid::xbt::random::uniform_int(0, nb_bits - 1);
   int random_id    = fingers_[random_index];
   XBT_DEBUG("Making a lookup request for id %d", random_id);
   if (random_id != id_)
@@ -268,7 +267,7 @@ int Node::remoteGetPredecessor(int ask_to)
 
   try {
     comm->wait_for(timeout);
-    ChordMessage* answer = static_cast<ChordMessage*>(data);
+    const ChordMessage* answer = static_cast<ChordMessage*>(data);
     XBT_DEBUG("Received the answer to my 'Get Predecessor' request: the predecessor of node %d is %d", ask_to,
               answer->answer_id);
     predecessor_id = answer->answer_id;
@@ -338,7 +337,7 @@ int Node::remoteFindSuccessor(int ask_to, int id)
 
   try {
     comm->wait_for(timeout);
-    ChordMessage* answer = static_cast<ChordMessage*>(data);
+    const ChordMessage* answer = static_cast<ChordMessage*>(data);
     XBT_DEBUG("Received the answer to my 'Find Successor' request for id %d: the successor of key %d is %d",
               answer->request_id, id_, answer->answer_id);
     successor = answer->answer_id;