Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://github.com/mpoquet/simgrid
[simgrid.git] / examples / java / dht / kademlia / Node.java
index 5b570ec..4e46ba0 100644 (file)
@@ -33,13 +33,13 @@ public class Node extends Process {
       Msg.info("Wrong argument count.");
       return;
     }
-    this.id = Integer.valueOf(args[0]);
+    this.id = Integer.parseInt(args[0]);
     this.table = new RoutingTable(this.id);
 
     if (args.length == 3) {
-      this.deadline = Integer.valueOf(args[2]).intValue();
+      this.deadline = Integer.parseInt(args[2]);
       Msg.info("Hi, I'm going to join the network with the id " + id + "!");
-      if (joinNetwork(Integer.valueOf(args[1]))) {
+      if (joinNetwork(Integer.parseInt(args[1]))) {
         this.mainLoop();
       }
       else {
@@ -47,7 +47,7 @@ public class Node extends Process {
       }
     }
     else {
-      this.deadline = Integer.valueOf(args[1]).intValue();
+      this.deadline = Integer.parseInt(args[1]);
       Msg.info("Hi, I'm going to create the network with the id " + id + "!");
       table.update(this.id);
       this.mainLoop();
@@ -109,12 +109,10 @@ public class Node extends Process {
           } else {
             Task task = comm.getTask();
             if (task instanceof FindNodeAnswerTask) {
-              answerGot = true;
               //Retrieve the node list and ping them
               FindNodeAnswerTask answerTask = (FindNodeAnswerTask)task;
               Answer answer = answerTask.getAnswer();
               answerGot = true;
-              //answersGotten++;
               if (answer.getDestinationId() == this.id) {
                 //Ping everyone in the list
                 for (Contact c : answer.getNodes()) {
@@ -153,12 +151,14 @@ public class Node extends Process {
 
   /* Send a request to find a node in the node's routing table. */
   public boolean findNode(int destination, boolean counts) {
-    int queries, answers;
-    int nodesAdded = 0;
-    boolean destinationFound = false;
+    int queries;
+    int answers;
+    int nodesAdded;
+    boolean destinationFound;
     int steps = 0;
     double timeBeginReceive;
-    double timeout, globalTimeout = Msg.getClock() + Common.FIND_NODE_GLOBAL_TIMEOUT;
+    double timeout;
+    double globalTimeout = Msg.getClock() + Common.FIND_NODE_GLOBAL_TIMEOUT;
     //Build a list of the closest nodes we already know.
     Answer nodeList = table.findClosest(destination);
     Msg.verb("Doing a FIND_NODE on " + destination);