Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'actor-yield' of github.com:Takishipp/simgrid into actor-yield
[simgrid.git] / examples / java / dht / kademlia / Node.java
index 4e46ba0..a690a01 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016-2017. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -57,16 +57,16 @@ public class Node extends Process {
   }
 
   public void mainLoop() {
-    double next_lookup_time = Msg.getClock() + Common.RANDOM_LOOKUP_INTERVAL;
+    double nextLookupTime = Msg.getClock() + Common.RANDOM_LOOKUP_INTERVAL;
     while (Msg.getClock() < this.deadline) {
       try {
         if (comm == null) {
           comm = Task.irecv(Integer.toString(id));
         }
         if (!comm.test()) {
-          if (Msg.getClock() >= next_lookup_time) {
+          if (Msg.getClock() >= nextLookupTime) {
             randomLookup();
-            next_lookup_time += Common.RANDOM_LOOKUP_INTERVAL;
+            nextLookupTime += Common.RANDOM_LOOKUP_INTERVAL;
           } else {
             waitFor(1);
           }
@@ -77,6 +77,7 @@ public class Node extends Process {
         }
       }
       catch (Exception e) {
+        Msg.debug("Caught exception: " + e);
       }
     }
     Msg.info(findNodeSuccedded + "/"  + (findNodeSuccedded + findNodeFailed) + " FIND_NODE have succedded.");
@@ -256,6 +257,7 @@ public class Node extends Process {
         waitFor(1);
       }
       catch (Exception ex) {
+        Msg.debug("Caught exception: " + ex);
       }
     } while (Msg.getClock() < timeout && !destinationFound);
   }
@@ -275,7 +277,7 @@ public class Node extends Process {
   public int sendFindNodeToBest(Answer nodeList) {
     int destination = nodeList.getDestinationId();
     int i;
-    for (i = 0; i < Common.alpha && i < nodeList.size(); i++) {
+    for (i = 0; i < Common.ALPHA && i < nodeList.size(); i++) {
       Contact node = nodeList.getNodes().get(i);
       if (node.getId() != this.id) {
         this.sendFindNode(node.getId(),destination);