Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
spelling mistakes in include/ and examples/
[simgrid.git] / examples / deprecated / java / dht / kademlia / Node.java
index 5ce801c..6b0ca58 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2019. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -80,7 +80,7 @@ public class Node extends Process {
         Msg.debug("Caught exception: " + e);
       }
     }
-    Msg.info(findNodeSuccedded + "/"  + (findNodeSuccedded + findNodeFailed) + " FIND_NODE have succedded.");
+    Msg.info(findNodeSuccedded + "/"  + (findNodeSuccedded + findNodeFailed) + " FIND_NODE have succeeded.");
   }
 
   /**
@@ -218,7 +218,7 @@ public class Node extends Process {
       if (counts) {
         findNodeSuccedded++;
       }
-      Msg.debug("Find node on " + destination + " succedded");
+      Msg.debug("Find node on " + destination + " succeeded");
     } else {
       Msg.debug("Find node on " + destination + " failed");
       Msg.debug("Queried " + queries + " nodes to find "  + destination);
@@ -230,38 +230,6 @@ public class Node extends Process {
     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
@@ -291,7 +259,7 @@ public class Node extends Process {
   }
 
   /**
-   * @brief Handles an incomming task
+   * @brief Handles an incoming task
    * @param task The task we need to handle
    */
   public void handleTask(Task task) {
@@ -300,9 +268,6 @@ public class Node extends Process {
       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()));
   }
-
-  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()));
-  }
 }