/* 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. */
/* 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. */
/* Makes the current node join the ring, knowing the id of a node already in the ring
*
* @param known_id id of a node already in the ring
/* Makes the current node join the ring, knowing the id of a node already in the ring
*
* @param known_id id of a node already in the ring
XBT_DEBUG("Sending a 'PREDECESSOR_LEAVING' to my successor %d", fingers_[0]);
try {
simgrid::s4u::Mailbox::by_name(std::to_string(fingers_[0]))->put(pred_msg, 10, timeout);
XBT_DEBUG("Sending a 'PREDECESSOR_LEAVING' to my successor %d", fingers_[0]);
try {
simgrid::s4u::Mailbox::by_name(std::to_string(fingers_[0]))->put(pred_msg, 10, timeout);
- int random_index = RngStream_RandInt(stream, 0, nb_bits - 1);
+ // std::uniform_int_distribution<int> dist(0, nb_bits - 1);
+ // int random_index = dist(generator);
+ int random_index = generator() % nb_bits; // ensure reproducibility across platforms
int random_id = fingers_[random_index];
XBT_DEBUG("Making a lookup request for id %d", random_id);
if (random_id != id_)
int random_id = fingers_[random_index];
XBT_DEBUG("Making a lookup request for id %d", random_id);
if (random_id != id_)
- simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_));
- simgrid::s4u::MailboxPtr return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_is_alive");
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_));
+ simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_is_alive");
XBT_DEBUG("Sending a 'Predecessor Alive' request to my predecessor %d", pred_id_);
try {
mailbox->put(message, 10, timeout);
XBT_DEBUG("Sending a 'Predecessor Alive' request to my predecessor %d", pred_id_);
try {
mailbox->put(message, 10, timeout);
comm->wait_for(timeout);
XBT_DEBUG("Received the answer to my 'Predecessor Alive': my predecessor %d is alive", pred_id_);
delete static_cast<ChordMessage*>(data);
comm->wait_for(timeout);
XBT_DEBUG("Received the answer to my 'Predecessor Alive': my predecessor %d is alive", pred_id_);
delete static_cast<ChordMessage*>(data);
- simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
- simgrid::s4u::MailboxPtr return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_pred");
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
+ simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_pred");
XBT_DEBUG("Sending a 'Get Predecessor' request to %d", ask_to);
try {
mailbox->put(message, 10, timeout);
XBT_DEBUG("Sending a 'Get Predecessor' request to %d", ask_to);
try {
mailbox->put(message, 10, timeout);
XBT_DEBUG("Failed to receive the answer to my 'Get Predecessor' request");
delete static_cast<ChordMessage*>(data);
}
XBT_DEBUG("Failed to receive the answer to my 'Get Predecessor' request");
delete static_cast<ChordMessage*>(data);
}
- simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
- simgrid::s4u::MailboxPtr return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_succ");
+ simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
+ simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_succ");
XBT_DEBUG("Sending a 'Find Successor' request to %d for id %d", ask_to, id);
try {
mailbox->put(message, 10, timeout);
XBT_DEBUG("Sending a 'Find Successor' request to %d for id %d", ask_to, id);
try {
mailbox->put(message, 10, timeout);
answer->request_id, id_, answer->answer_id);
successor = answer->answer_id;
delete answer;
answer->request_id, id_, answer->answer_id);
successor = answer->answer_id;
delete answer;
XBT_DEBUG("Failed to receive the answer to my 'Find Successor' request");
delete static_cast<ChordMessage*>(data);
}
XBT_DEBUG("Failed to receive the answer to my 'Find Successor' request");
delete static_cast<ChordMessage*>(data);
}
// send a "Notify" request to notify_id
XBT_DEBUG("Sending a 'Notify' request to %d", notify_id);
// send a "Notify" request to notify_id
XBT_DEBUG("Sending a 'Notify' request to %d", notify_id);
int closest = closestPrecedingFinger(message->request_id);
XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
message->request_id, closest);
int closest = closestPrecedingFinger(message->request_id);
XBT_DEBUG("Forwarding the 'Find Successor' request for id %d to my closest preceding finger %d",
message->request_id, closest);