/* 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);
} 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) {
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());
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);
{
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 */
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);
}
}
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);
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_);
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);
}
{
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_),