Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill dead code in kademlia examples.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 29 Jan 2019 12:34:27 +0000 (13:34 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 29 Jan 2019 12:54:28 +0000 (13:54 +0100)
examples/deprecated/java/CMakeLists.txt
examples/deprecated/java/dht/kademlia/Common.java
examples/deprecated/java/dht/kademlia/Node.java
examples/deprecated/java/dht/kademlia/PingAnswerTask.java [deleted file]
examples/deprecated/java/dht/kademlia/PingTask.java [deleted file]
examples/deprecated/msg/dht-kademlia/common.h
examples/deprecated/msg/dht-kademlia/dht-kademlia.c
examples/deprecated/msg/dht-kademlia/dht-kademlia.h
examples/deprecated/msg/dht-kademlia/task.c
examples/deprecated/msg/dht-kademlia/task.h
examples/s4u/dht-kademlia/s4u-dht-kademlia.hpp

index 676d85d..c5a61b9 100644 (file)
@@ -11,7 +11,7 @@ set(cloud-migration_files       Main  Daemon Test XVM)
 set(dht-chord_files             Main  ChordTask  Common FindSuccessorAnswerTask  FindSuccessorTask
                                       GetPredecessorAnswerTask GetPredecessorTask Node  NotifyTask)
 set(dht-kademlia_files          Main  Answer  Bucket  Common Contact FindNodeAnswerTask  FindNodeTask
 set(dht-chord_files             Main  ChordTask  Common FindSuccessorAnswerTask  FindSuccessorTask
                                       GetPredecessorAnswerTask GetPredecessorTask Node  NotifyTask)
 set(dht-kademlia_files          Main  Answer  Bucket  Common Contact FindNodeAnswerTask  FindNodeTask
-                                      KademliaTask  Node  PingAnswerTask PingTask  RoutingTable)
+                                      KademliaTask  Node  RoutingTable)
 set(trace-pingpong_files        Main  PingPongTask Receiver Sender)
 set(energy-consumption_files    Main  EnergyConsumer)
 set(energy-pstate_files         Main  PstateRunner)
 set(trace-pingpong_files        Main  PingPongTask Receiver Sender)
 set(energy-consumption_files    Main  EnergyConsumer)
 set(energy-pstate_files         Main  PstateRunner)
index df5a30d..6f5a72b 100644 (file)
@@ -24,8 +24,6 @@ public class Common {
   public static final int FIND_NODE_TIMEOUT = 10;
   /* Global timeout for a FIND_NODE request */
   public static final int FIND_NODE_GLOBAL_TIMEOUT = 50;
   public static final int FIND_NODE_TIMEOUT = 10;
   /* Global timeout for a FIND_NODE request */
   public static final int FIND_NODE_GLOBAL_TIMEOUT = 50;
-  /* Timeout for a "PING" request */
-  public static final int PING_TIMEOUT = 35;
 
   public static final int MAX_STEPS = 10;
   public static final int JOIN_BUCKETS_QUERIES = 1;
 
   public static final int MAX_STEPS = 10;
   public static final int JOIN_BUCKETS_QUERIES = 1;
index 5ce801c..ebc43a7 100644 (file)
@@ -230,38 +230,6 @@ public class Node extends Process {
     return destinationFound;
   }
 
     return destinationFound;
   }
 
-  /**
-   * @brief Sends a "PING" request to a node
-   * @param destination Ping destination id.
-   */
-  public void ping(int destination) {
-    boolean destinationFound = false;
-    double timeout = Msg.getClock() + Common.PING_TIMEOUT;
-    PingTask pingTask = new PingTask(this.id);
-    /* Sending the ping task */
-    pingTask.dsend(Integer.toString(destination));
-    do {
-      try {
-        Task task = Task.receive(Integer.toString(this.id),Common.PING_TIMEOUT);
-        if (task instanceof PingAnswerTask) {
-          PingAnswerTask answerTask = (PingAnswerTask)task;
-          if (answerTask.getSenderId() == destination) {
-            this.table.update(destination);
-            destinationFound = true;
-          } else {
-            handleTask(task);
-          }
-        } else {
-          handleTask(task);
-        }
-        waitFor(1);
-      }
-      catch (Exception ex) {
-        Msg.debug("Caught exception: " + ex);
-      }
-    } while (Msg.getClock() < timeout && !destinationFound);
-  }
-
   /**
    * @brief Sends a "FIND_NODE" request (task) to a node we know.
    * @param id Id of the node we are querying
   /**
    * @brief Sends a "FIND_NODE" request (task) to a node we know.
    * @param id Id of the node we are querying
@@ -300,9 +268,6 @@ public class Node extends Process {
       if (task instanceof FindNodeTask) {
         handleFindNode((FindNodeTask)task);
       }
       if (task instanceof FindNodeTask) {
         handleFindNode((FindNodeTask)task);
       }
-      else if (task instanceof PingTask) {
-        handlePing((PingTask)task);
-      }
     }
   }
 
     }
   }
 
@@ -312,10 +277,4 @@ public class Node extends Process {
     FindNodeAnswerTask taskToSend = new FindNodeAnswerTask(this.id,task.getDestination(),answer);
     taskToSend.dsend(Integer.toString(task.getSenderId()));
   }
     FindNodeAnswerTask taskToSend = new FindNodeAnswerTask(this.id,task.getDestination(),answer);
     taskToSend.dsend(Integer.toString(task.getSenderId()));
   }
-
-  public void handlePing(PingTask task) {
-    Msg.debug("Received a PING from " + task.getSenderId());
-    PingAnswerTask taskToSend = new PingAnswerTask(this.id);
-    taskToSend.dsend(Integer.toString(task.getSenderId()));
-  }
 }
 }
diff --git a/examples/deprecated/java/dht/kademlia/PingAnswerTask.java b/examples/deprecated/java/dht/kademlia/PingAnswerTask.java
deleted file mode 100644 (file)
index ea6ed88..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Copyright (c) 2012-2019. 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. */
-
-package dht.kademlia;
-
-public class PingAnswerTask extends KademliaTask {
-  public PingAnswerTask(int senderId) {
-    super(senderId);
-  }
-}
diff --git a/examples/deprecated/java/dht/kademlia/PingTask.java b/examples/deprecated/java/dht/kademlia/PingTask.java
deleted file mode 100644 (file)
index 8deaf27..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Copyright (c) 2012-2019. 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. */
-
-package dht.kademlia;
-
-public class PingTask extends KademliaTask {
-  public PingTask(int senderId) {
-    super(senderId);
-  }
-}
index 870a412..bb101f6 100644 (file)
@@ -10,7 +10,6 @@
 
 #define RECEIVE_TIMEOUT 1
 
 
 #define RECEIVE_TIMEOUT 1
 
-#define ping_timeout 55
 #define find_node_timeout 10
 #define find_node_global_timeout 50
 
 #define find_node_timeout 10
 #define find_node_global_timeout 50
 
index 09afc14..49e4ffd 100644 (file)
@@ -268,59 +268,6 @@ unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_
   return destination_found;
 }
 
   return destination_found;
 }
 
-/** @brief Pings a node in the system to see if it is online.
-  * @param node Our node data
-  * @param id_to_ping the id of a node we want to see if it is online.
-  * @return if the ping succeded or not.
-  */
-unsigned int ping(node_t node, unsigned int id_to_ping)
-{
-  char mailbox[MAILBOX_NAME_SIZE];
-  snprintf(mailbox, MAILBOX_NAME_SIZE, "%u", id_to_ping);
-
-  double timeout = MSG_get_clock() + ping_timeout;
-
-  msg_task_t ping_task = task_new_ping(node->id, node->mailbox, MSG_host_get_name(MSG_host_self()));
-  msg_task_t task_received = NULL;
-
-  XBT_VERB("PING %08x", id_to_ping);
-
-  //Check that we aren't trying to ping ourselves
-  if (id_to_ping == node->id) {
-    return 1;
-  }
-
-  /* Sending the ping task */
-  MSG_task_dsend(ping_task, mailbox, task_free_v);
-  do {
-    task_received = NULL;
-    msg_error_t status =
-        MSG_task_receive_with_timeout(&task_received, node->mailbox, ping_timeout);
-    if (status == MSG_OK) {
-      xbt_assert((task_received != NULL), "Invalid task received");
-      //Checking if it's what we are waiting for or not.
-      task_data_t data = MSG_task_get_data(task_received);
-      xbt_assert((data != NULL), "didn't receive any data...");
-      if (data->type == TASK_PING_ANSWER && id_to_ping == data->sender_id) {
-        XBT_VERB("Ping to %s succeeded", mailbox);
-        node_routing_table_update(node, data->sender_id);
-        task_free(task_received);
-        return 1; // Destination found, ping succeeded!
-      } else {
-        //If it's not our answer, we answer the query anyway.
-        handle_task(node, task_received);
-      }
-    }
-  } while (MSG_get_clock() < timeout);
-
-  if (MSG_get_clock() >= timeout) {
-    XBT_DEBUG("Ping to %s has timeout.", mailbox);
-    return 0;
-  }
-  XBT_DEBUG("It seems that %s is offline...", mailbox);
-  return -1;
-}
-
 /** @brief Does a pseudo-random lookup for someone in the system
   * @param node caller node data
   */
 /** @brief Does a pseudo-random lookup for someone in the system
   * @param node caller node data
   */
@@ -385,9 +332,6 @@ void handle_task(node_t node, msg_task_t task)
   case TASK_FIND_NODE_ANSWER:
     XBT_DEBUG("Received a wrong answer for a FIND_NODE");
     break;
   case TASK_FIND_NODE_ANSWER:
     XBT_DEBUG("Received a wrong answer for a FIND_NODE");
     break;
-  case TASK_PING:
-    handle_ping(node, data);
-    break;
   default:
     break;
   }
   default:
     break;
   }
@@ -408,16 +352,6 @@ void handle_find_node(node_t node, task_data_t data)
   MSG_task_dsend(task, data->answer_to, task_free_v);
 }
 
   MSG_task_dsend(task, data->answer_to, task_free_v);
 }
 
-/** @brief handles the answer to a ping */
-void handle_ping(node_t node, task_data_t data)
-{
-  XBT_VERB("Received a PING request from %s (%s)", data->answer_to, data->issuer_host_name);
-  //Building the answer to the request
-  msg_task_t task = task_new_ping_answer(node->id, data->answer_to, MSG_host_get_name(MSG_host_self()));
-
-  MSG_task_dsend(task, data->answer_to, task_free_v);
-}
-
 /** @brief Main function */
 int main(int argc, char *argv[])
 {
 /** @brief Main function */
 int main(int argc, char *argv[])
 {
index 2992314..62f550c 100644 (file)
@@ -12,7 +12,6 @@
 //core kademlia functions
 unsigned int join(node_t node, unsigned int id_known);
 unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_in_stats);
 //core kademlia functions
 unsigned int join(node_t node, unsigned int id_known);
 unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_in_stats);
-unsigned int ping(node_t node, unsigned int id_to_ping);
 void random_lookup(node_t node);
 
 void send_find_node(node_t node, unsigned int id, unsigned int destination);
 void random_lookup(node_t node);
 
 void send_find_node(node_t node, unsigned int id, unsigned int destination);
@@ -20,6 +19,5 @@ unsigned int send_find_node_to_best(node_t node, answer_t node_list);
 
 void handle_task(node_t node, msg_task_t task);
 void handle_find_node(node_t node, task_data_t data);
 
 void handle_task(node_t node, msg_task_t task);
 void handle_find_node(node_t node, task_data_t data);
-void handle_ping(node_t node, task_data_t data);
 
 #endif                          /* _MSG_EXAMPLES_KADEMLIA_H */
 
 #endif                          /* _MSG_EXAMPLES_KADEMLIA_H */
index a1e39b1..126a15d 100644 (file)
@@ -53,48 +53,6 @@ msg_task_t task_new_find_node_answer(unsigned int sender_id, unsigned int destin
   return task;
 }
 
   return task;
 }
 
-/** @brief Creates a new "ping" task
-  * @param sender_id : sender node identifier
-  * @param mailbox : mailbox where we should respond
-  * @param hostname : hostname of the sender, for debugging purposes
-  */
-msg_task_t task_new_ping(unsigned int sender_id, char *mailbox, const char *hostname)
-{
-  task_data_t data = xbt_new(s_task_data_t, 1);
-
-  data->type = TASK_PING;
-  data->sender_id = sender_id;
-  data->destination_id = 0;
-  data->answer = NULL;
-  data->answer_to = mailbox;
-  data->issuer_host_name = hostname;
-
-  msg_task_t task = MSG_task_create(NULL, COMP_SIZE, COMM_SIZE, data);
-
-  return task;
-}
-
-/** @brief Creates a new "ping answer" task
-  * @param sender_id : sender node identifier
-  * @param mailbox : mailbox of the sender
-  * @param hostname : hostname of the sender, for debugging purposes
-  */
-msg_task_t task_new_ping_answer(unsigned int sender_id, char *mailbox, const char *hostname)
-{
-  task_data_t data = xbt_new(s_task_data_t, 1);
-
-  data->type = TASK_PING_ANSWER;
-  data->sender_id = sender_id;
-  data->destination_id = 0;
-  data->answer = NULL;
-  data->answer_to = mailbox;
-  data->issuer_host_name = hostname;
-
-  msg_task_t task = MSG_task_create(NULL, COMP_SIZE, COMM_SIZE, data);
-
-  return task;
-}
-
 /** @brief Destroys a task and its data
   * @param task the task that'll be destroyed
   */
 /** @brief Destroys a task and its data
   * @param task the task that'll be destroyed
   */
index a5aac15..8490388 100644 (file)
@@ -16,8 +16,6 @@ typedef enum {
   TASK_FIND_NODE_ANSWER,
   TASK_FIND_VALUE,
   TASK_FIND_VALUE_ANSWER,
   TASK_FIND_NODE_ANSWER,
   TASK_FIND_VALUE,
   TASK_FIND_VALUE_ANSWER,
-  TASK_PING,
-  TASK_PING_ANSWER,
   TASK_LEAVING
 } e_task_type_t;
 
   TASK_LEAVING
 } e_task_type_t;
 
@@ -37,8 +35,6 @@ typedef s_task_data_t *task_data_t;
 msg_task_t task_new_find_node(unsigned int sender_id, unsigned int destination_id, char *mailbox, const char *hostname);
 msg_task_t task_new_find_node_answer(unsigned int sender_id, unsigned int destination_id, answer_t answer,
                                      char *mailbox, const char *hostname);
 msg_task_t task_new_find_node(unsigned int sender_id, unsigned int destination_id, char *mailbox, const char *hostname);
 msg_task_t task_new_find_node_answer(unsigned int sender_id, unsigned int destination_id, answer_t answer,
                                      char *mailbox, const char *hostname);
-msg_task_t task_new_ping(unsigned int sender_id, char *mailbox, const char *hostname);
-msg_task_t task_new_ping_answer(unsigned int sender_id, char *mailbox, const char *hostname);
 void task_free(msg_task_t task);
 void task_free_v(void *task);
 #endif                          /* _MSG_KADEMLIA_EXAMPLES_TASK */
 void task_free(msg_task_t task);
 void task_free_v(void *task);
 #endif                          /* _MSG_KADEMLIA_EXAMPLES_TASK */
index 5e9f885..e1fedb7 100644 (file)
 namespace kademlia {
 class Answer;
 class Message;
 namespace kademlia {
 class Answer;
 class Message;
-class Ping;
 }
 
 #define max_join_trials 4
 
 #define RECEIVE_TIMEOUT 1
 
 }
 
 #define max_join_trials 4
 
 #define RECEIVE_TIMEOUT 1
 
-#define ping_timeout 55
 #define find_node_timeout 10
 #define find_node_global_timeout 50
 
 #define find_node_timeout 10
 #define find_node_global_timeout 50