Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
chase a few more rules
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 23 Jun 2016 16:19:20 +0000 (18:19 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 23 Jun 2016 16:19:20 +0000 (18:19 +0200)
examples/java/app/bittorrent/Connection.java
examples/java/app/bittorrent/MessageTask.java
examples/java/app/bittorrent/Peer.java
examples/java/app/pingpong/Sender.java
examples/java/cloud/migration/Test.java
examples/java/dht/chord/Node.java
examples/java/trace/pingpong/Sender.java
src/bindings/java/org/simgrid/msg/RngStream.java

index 3143889..668283a 100644 (file)
@@ -9,7 +9,7 @@ import java.util.Arrays;
 
 public class Connection {
   protected int id;
 
 public class Connection {
   protected int id;
-  protected char bitfield[];
+  protected char[] bitfield;
   protected String mailbox;
   // Indicates if we are interested in something this peer has
   protected boolean amInterested = false;
   protected String mailbox;
   // Indicates if we are interested in something this peer has
   protected boolean amInterested = false;
index 4ff0204..d0bac8f 100644 (file)
@@ -24,7 +24,7 @@ public class MessageTask extends Task {
   protected String issuerHostname;
   protected String mailbox;
   protected int peerId;
   protected String issuerHostname;
   protected String mailbox;
   protected int peerId;
-  protected char bitfield[];
+  protected char[] bitfield;
   protected int index;
   protected int blockIndex;
   protected int blockLength;
   protected int index;
   protected int blockIndex;
   protected int blockLength;
index f20881b..58b4b48 100644 (file)
@@ -365,7 +365,7 @@ public class Peer extends Process {
    * @brief Updates the list of who has a piece from a bitfield
    * @param bitfield bitfield
    */
    * @brief Updates the list of who has a piece from a bitfield
    * @param bitfield bitfield
    */
-  private void updatePiecesCountFromBitfield(char bitfield[]) {
+  private void updatePiecesCountFromBitfield(char[] bitfield) {
     for (int i = 0; i < Common.FILE_PIECES; i++) {
       if (bitfield[i] == '1') {
         piecesCount[i]++;
     for (int i = 0; i < Common.FILE_PIECES; i++) {
       if (bitfield[i] == '1') {
         piecesCount[i]++;
index ab23c66..5f00d6f 100644 (file)
@@ -25,7 +25,7 @@ public class Sender extends Process {
     int hostCount = args.length;
 
     Msg.info("host count: " + hostCount);
     int hostCount = args.length;
 
     Msg.info("host count: " + hostCount);
-    String mailboxes[] = new String[hostCount]; 
+    String[] mailboxes = new String[hostCount]; 
     double time;
     double computeDuration = 0;
     PingPongTask task;
     double time;
     double computeDuration = 0;
     PingPongTask task;
index 279917e..d3d6a09 100644 (file)
@@ -8,7 +8,6 @@ package cloud.migration;
 import java.util.ArrayList;
 import java.util.List;
 
 import java.util.ArrayList;
 import java.util.List;
 
-
 import org.simgrid.msg.*;
 import org.simgrid.msg.Process;
 
 import org.simgrid.msg.*;
 import org.simgrid.msg.Process;
 
index 0216108..275c75e 100644 (file)
@@ -22,7 +22,7 @@ public class Node extends Process {
   protected Comm commReceive;
   ///Last time I changed a finger or my predecessor
   protected double lastChangeDate;
   protected Comm commReceive;
   ///Last time I changed a finger or my predecessor
   protected double lastChangeDate;
-  int fingers[];
+  int[] fingers;
 
   public Node(Host host, String name, String[] args) {
     super(host,name,args);
 
   public Node(Host host, String name, String[] args) {
     super(host,name,args);
@@ -36,7 +36,7 @@ public class Node extends Process {
     }
     double initTime = Msg.getClock();
     int i;
     }
     double initTime = Msg.getClock();
     int i;
-    boolean joinSuccess = false;
+    boolean joinSuccess;
     double deadline;
 
     double nextStabilizeDate = initTime + Common.PERIODIC_STABILIZE_DELAY;
     double deadline;
 
     double nextStabilizeDate = initTime + Common.PERIODIC_STABILIZE_DELAY;
@@ -55,7 +55,7 @@ public class Node extends Process {
 
     //First node
     if (args.length == 2) {
 
     //First node
     if (args.length == 2) {
-      deadline = Integer.valueOf(args[1]);
+      deadline = Integer.parseInt(args[1]);
       create();
       joinSuccess = true;
     } else {
       create();
       joinSuccess = true;
     } else {
@@ -115,13 +115,13 @@ public class Node extends Process {
       Msg.debug("Receiving a 'Find Successor' request from " + fTask.issuerHostName + " for id " + fTask.requestId);
       // is my successor the successor?
       if (isInInterval(fTask.requestId, this.id + 1, fingers[0])) {
       Msg.debug("Receiving a 'Find Successor' request from " + fTask.issuerHostName + " for id " + fTask.requestId);
       // is my successor the successor?
       if (isInInterval(fTask.requestId, this.id + 1, fingers[0])) {
-        //Msg.info("Send the request to " + fTask.answerTo + " with answer " + fingers[0]);
+        Msg.debug("Send the request to " + fTask.answerTo + " with answer " + fingers[0]);
         FindSuccessorAnswerTask answer = new FindSuccessorAnswerTask(getHost().getName(), mailbox, fingers[0]);
         answer.dsend(fTask.answerTo);
       } else {
         // otherwise, forward the request to the closest preceding finger in my table
         int closest = closestPrecedingNode(fTask.requestId);
         FindSuccessorAnswerTask answer = new FindSuccessorAnswerTask(getHost().getName(), mailbox, fingers[0]);
         answer.dsend(fTask.answerTo);
       } else {
         // otherwise, forward the request to the closest preceding finger in my table
         int closest = closestPrecedingNode(fTask.requestId);
-        //Msg.info("Forward the request to " + closest);
+        Msg.debug("Forward the request to " + closest);
         fTask.dsend(Integer.toString(closest));
       }
     } else if (task instanceof GetPredecessorTask) {
         fTask.dsend(Integer.toString(closest));
       }
     } else if (task instanceof GetPredecessorTask) {
@@ -241,11 +241,11 @@ public class Node extends Process {
   int remoteFindSuccessor(int askTo, int id) {
     int successor = -1;
     boolean stop = false;
   int remoteFindSuccessor(int askTo, int id) {
     int successor = -1;
     boolean stop = false;
-    String mailbox = Integer.toString(askTo);
+    String askToMailbox = Integer.toString(askTo);
     Task sendTask = new FindSuccessorTask(getHost().getName(), this.mailbox, id);
     Task sendTask = new FindSuccessorTask(getHost().getName(), this.mailbox, id);
-    Msg.debug("Sending a 'Find Successor' request to " + mailbox + " for id " + id);
+    Msg.debug("Sending a 'Find Successor' request to " + askToMailbox + " for id " + id);
     try {
     try {
-      sendTask.send(mailbox, Common.TIMEOUT);
+      sendTask.send(askToMailbox, Common.TIMEOUT);
       do {
         if (commReceive == null) {
           commReceive = Task.irecv(this.mailbox);
       do {
         if (commReceive == null) {
           commReceive = Task.irecv(this.mailbox);
@@ -324,10 +324,10 @@ public class Node extends Process {
   void fixFingers() {
     Msg.debug("Fixing fingers");
     int i = this.nextFingerToFix;
   void fixFingers() {
     Msg.debug("Fixing fingers");
     int i = this.nextFingerToFix;
-    int id = this.findSuccessor(this.id + (int)Math.pow(2,i)); //FIXME: SLOW
-    if (id != -1) {
-      if (id != fingers[i]) {
-        setFinger(i, id);
+    int successorId = this.findSuccessor(this.id + (int)Math.pow(2,i)); //FIXME: SLOW
+    if (successorId != -1) {
+      if (successorId != fingers[i]) {
+        setFinger(i, successorId);
       }
       nextFingerToFix = (i + 1) % Common.NB_BITS;
     }
       }
       nextFingerToFix = (i + 1) % Common.NB_BITS;
     }
@@ -352,8 +352,7 @@ public class Node extends Process {
    * @return the closest preceding finger of that id
    */
   int closestPrecedingNode(int id) {
    * @return the closest preceding finger of that id
    */
   int closestPrecedingNode(int id) {
-    int i;
-    for (i = Common.NB_BITS - 1; i >= 0; i--) {
+    for (int i = Common.NB_BITS - 1; i >= 0; i--) {
       if (isInInterval(fingers[i], this.id + 1, id - 1)) {
         return fingers[i];
       }
       if (isInInterval(fingers[i], this.id + 1, id - 1)) {
         return fingers[i];
       }
@@ -378,18 +377,18 @@ public class Node extends Process {
    * @return a non-zero value if id in in [start, end]
    */
   static boolean isInInterval(int id, int start, int end) {
    * @return a non-zero value if id in in [start, end]
    */
   static boolean isInInterval(int id, int start, int end) {
-    id = normalize(id);
-    start = normalize(start);
-    end = normalize(end);
+    int normId = normalize(id);
+    int normStart = normalize(start);
+    int normEnd = normalize(end);
 
     // make sure end >= start and id >= start
 
     // make sure end >= start and id >= start
-    if (end < start) {
-      end += Common.NB_KEYS;
+    if (normEnd < normStart) {
+      normEnd += Common.NB_KEYS;
     }
     }
-    if (id < start) {
-      id += Common.NB_KEYS;
+    if (normId < normStart) {
+      normId += Common.NB_KEYS;
     }
     }
-    return (id <= end);
+    return (normId <= normEnd);
   }
 
   /**
   }
 
   /**
index 5fe2760..0204316 100644 (file)
@@ -29,7 +29,7 @@ public class Sender extends Process {
 
     int hostCount = args.length;
     Msg.info("host count: " + hostCount);
 
     int hostCount = args.length;
     Msg.info("host count: " + hostCount);
-    String mailboxes[] = new String[hostCount]; 
+    String[] mailboxes = new String[hostCount]; 
     double time;
     double computeDuration = 0;
     PingPongTask ping;
     double time;
     double computeDuration = 0;
     PingPongTask ping;
index 23e95cb..7e6fecc 100644 (file)
@@ -61,7 +61,7 @@ public class RngStream {
         * must all be less than m1 = 4294967087, and not all 0; and the last 3 values must all be less
         * than m2 = 4294944443, and not all 0. Returns false for invalid seeds, and true otherwise.
         */
         * must all be less than m1 = 4294967087, and not all 0; and the last 3 values must all be less
         * than m2 = 4294944443, and not all 0. Returns false for invalid seeds, and true otherwise.
         */
-       public static native boolean setPackageSeed(int seed[]);
+       public static native boolean setPackageSeed(int[] seed);
        /**
         * Reinitializes the stream g to its initial state: Cg and Bg are set to Ig .
         */
        /**
         * Reinitializes the stream g to its initial state: Cg and Bg are set to Ig .
         */
@@ -87,7 +87,7 @@ public class RngStream {
         * the initial seeds of the streams are no longer spaced Z values apart. We discourage the use of
         * this procedure. Returns false for invalid seeds, and true otherwise.
         */
         * the initial seeds of the streams are no longer spaced Z values apart. We discourage the use of
         * this procedure. Returns false for invalid seeds, and true otherwise.
         */
-       public native boolean setSeed(int seed[]);
+       public native boolean setSeed(int[] seed);
        /**
         * Advances the state of the stream by k values, without modifying the states of other streams (as
         * in RngStream_SetSeed), nor the values of Bg and Ig associated with this stream. If e &gt; 0, then
        /**
         * Advances the state of the stream by k values, without modifying the states of other streams (as
         * in RngStream_SetSeed), nor the values of Bg and Ig associated with this stream. If e &gt; 0, then