Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
modifiers in right order
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 23 Jun 2016 08:52:08 +0000 (10:52 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 23 Jun 2016 09:31:14 +0000 (11:31 +0200)
remove useless imports
remove empty statements
make constant static

19 files changed:
examples/java/app/bittorrent/Peer.java
examples/java/app/centralizedmutex/Node.java
examples/java/app/masterworker/Master.java
examples/java/async/dsend/Receiver.java
examples/java/async/dsend/Sender.java
examples/java/cloud/migration/Main.java
examples/java/cloud/migration/TestHostOnOff.java
examples/java/dht/chord/Common.java
examples/java/dht/kademlia/Common.java
examples/java/dht/kademlia/Node.java
examples/java/process/suspend/DreamMaster.java
examples/java/trace/pingpong/Receiver.java
src/bindings/java/org/simgrid/msg/As.java
src/bindings/java/org/simgrid/msg/File.java
src/bindings/java/org/simgrid/msg/Host.java
src/bindings/java/org/simgrid/msg/Msg.java
src/bindings/java/org/simgrid/msg/Process.java
src/bindings/java/org/simgrid/msg/Storage.java
src/bindings/java/org/simgrid/trace/Trace.java

index b7ce0c3..f20881b 100644 (file)
@@ -426,9 +426,9 @@ public class Peer extends Process {
     } else {
       //Random optimistic unchoking
       if (round == 0) {
-        int j = 0, i;
+        int j = 0;
         do {
-          i = 0;
+          int i = 0;
           int idChosen = stream.randInt(0,peers.size() - 1);
           for (Connection connection : peers.values()) {
             if (i == idChosen) {
@@ -519,10 +519,9 @@ public class Peer extends Process {
       return;
     }
     for (Integer piece : currentPieces) {
-      //Getting the block to send.  
-      int blockIndex = -1, blockLength = 0;
-      blockIndex = getFirstBlock(piece);      
-      blockLength = Common.PIECES_BLOCKS - blockIndex ;
+      //Getting the block to send.
+      int blockIndex = getFirstBlock(piece);
+      int blockLength = Common.PIECES_BLOCKS - blockIndex ;
       blockLength = blockLength > Common.BLOCKS_REQUESTED ? Common.BLOCKS_REQUESTED : blockLength;    
       if (remotePeer.bitfield[piece] == '1') {
         sendRequest(remotePeer.mailbox, piece, blockIndex, blockLength);
index 511a95d..6d9a5da 100644 (file)
@@ -18,7 +18,7 @@ public class Node extends Process {
   }
   public void request(double CStime) throws MsgException {
     RequestTask req = new RequestTask(getName());
-    GrantTask grant= new GrantTask();;
+    GrantTask grant= new GrantTask();
     Msg.info("Send a request to the coordinator");
     req.send("coordinator");
     Msg.info("Wait for a grant from the coordinator");
index 08abb74..6de1072 100644 (file)
@@ -11,7 +11,7 @@ import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.MsgException;
 import org.simgrid.msg.Task;
-import org.simgrid.msg.Process;;
+import org.simgrid.msg.Process;
 
 public class Master extends Process {
   public Master(Host host, String name, String[]args) {
index 4f6c3f0..162a15e 100644 (file)
@@ -6,12 +6,10 @@
 
 package async.dsend;
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.Comm;
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Task;
 import org.simgrid.msg.Process;
 import org.simgrid.msg.HostFailureException;
-import org.simgrid.msg.TaskCancelledException;
 import org.simgrid.msg.TimeoutException;
 import org.simgrid.msg.TransferFailureException;
 
index 03e3f7a..ea14a66 100644 (file)
@@ -5,10 +5,8 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package async.dsend;
-import java.util.ArrayList;
 
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.Comm;
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Task;
 import org.simgrid.msg.Process;
index 2ae9be0..b03c4b4 100644 (file)
@@ -7,8 +7,6 @@
 package cloud.migration;
 
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.Host;
-import org.simgrid.msg.HostNotFoundException;
 import org.simgrid.msg.MsgException;
 
 public class Main {
index 5fccb0b..5e8246f 100644 (file)
@@ -6,8 +6,6 @@
 
 package cloud.migration;
 
-import java.util.Random; 
-
 import org.simgrid.msg.*;
 import org.simgrid.msg.Process;
 
index 66c9109..08e3126 100644 (file)
@@ -7,17 +7,17 @@
 package dht.chord;
 
 public class Common {
-  public final static int COMM_SIZE = 10;
-  public final static int COMP_SIZE = 0;
+  public static final int COMM_SIZE = 10;
+  public static final int COMP_SIZE = 0;
   
-  public final static int NB_BITS = 24;
-  public final static int NB_KEYS = 16777216;
-  public final static int TIMEOUT = 50;
-  public final static int MAX_SIMULATION_TIME = 1000;
-  public final static int PERIODIC_STABILIZE_DELAY = 20;
-  public final static int PERIODIC_FIX_FINGERS_DELAY = 120;
-  public final static int PERIODIC_CHECK_PREDECESSOR_DELAY = 120;
-  public final static int PERIODIC_LOOKUP_DELAY = 10;
+  public static final int NB_BITS = 24;
+  public static final int NB_KEYS = 16777216;
+  public static final int TIMEOUT = 50;
+  public static final int MAX_SIMULATION_TIME = 1000;
+  public static final int PERIODIC_STABILIZE_DELAY = 20;
+  public static final int PERIODIC_FIX_FINGERS_DELAY = 120;
+  public static final int PERIODIC_CHECK_PREDECESSOR_DELAY = 120;
+  public static final int PERIODIC_LOOKUP_DELAY = 10;
   private Common() {
     throw new IllegalAccessError("Utility class");
   }
index 890899f..381cf38 100644 (file)
@@ -8,27 +8,27 @@ package dht.kademlia;
 
 public class Common {
   /* Common constants used all over the simulation */
-  public final static int COMM_SIZE = 1;
-  public final static int COMP_SIZE = 0;
+  public static final int COMM_SIZE = 1;
+  public static final int COMP_SIZE = 0;
 
-  public final static int RANDOM_LOOKUP_INTERVAL = 100;
+  public static final int RANDOM_LOOKUP_INTERVAL = 100;
 
-  public final static int alpha = 3;
+  public static final int alpha = 3;
 
-  public final static int IDENTIFIER_SIZE = 32;
+  public static final int IDENTIFIER_SIZE = 32;
   /* Maximum size of the buckets */
-  public final static int BUCKET_SIZE = 20;
+  public static final int BUCKET_SIZE = 20;
   /* Maximum number of trials for the "JOIN" request */
-  public final static int MAX_JOIN_TRIALS = 4;
+  public static final int MAX_JOIN_TRIALS = 4;
   /* Timeout for a "FIND_NODE" request to a node */
-  public final static int FIND_NODE_TIMEOUT = 10;
+  public static final int FIND_NODE_TIMEOUT = 10;
   /* Global timeout for a FIND_NODE request */
-  public final static int FIND_NODE_GLOBAL_TIMEOUT = 50;
+  public static final int FIND_NODE_GLOBAL_TIMEOUT = 50;
   /* Timeout for a "PING" request */
-  public final static int PING_TIMEOUT = 35;
+  public static final int PING_TIMEOUT = 35;
 
-  public final static int MAX_STEPS = 10;
-  public final static int JOIN_BUCKETS_QUERIES = 1;
+  public static final int MAX_STEPS = 10;
+  public static final int JOIN_BUCKETS_QUERIES = 1;
   private Common() {
     throw new IllegalAccessError("Utility class");
   }
index 5b570ec..25124b6 100644 (file)
@@ -153,12 +153,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 queries;
+    int answers;
     int nodesAdded = 0;
     boolean destinationFound = false;
     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);
index 08459e4..d8013a5 100644 (file)
@@ -5,7 +5,6 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package process.suspend;
-import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Process;
 import org.simgrid.msg.MsgException;
index 2771655..54f24df 100644 (file)
@@ -5,7 +5,6 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package trace.pingpong;
-import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.MsgException;
 import org.simgrid.msg.NativeException;
@@ -15,8 +14,8 @@ import org.simgrid.msg.Process;
 import org.simgrid.trace.Trace;
 
 public class Receiver extends Process {
-  private  final double commSizeLat = 1;
-  private final double commSizeBw = 100000000;
+  private static final double commSizeLat = 1;
+  private static final double commSizeBw = 100000000;
 
   public Receiver(String hostname, String name, String[]args) throws HostNotFoundException, NativeException{
     super(hostname,name,args);
index 16c6889..92ee06b 100644 (file)
@@ -10,8 +10,7 @@ public class As {
 
        private long bind;
 
-       protected As() {
-       };
+       protected As() {}
 
        @Override
        public String toString (){
index b1f13f9..e37b1f4 100644 (file)
@@ -7,9 +7,9 @@
 package org.simgrid.msg;
 
 public class File {
-       public final int SEEK_SET = 0;
-       public final int SEEK_CUR = 1;
-       public final int SEEK_END = 2;
+       public static final int SEEK_SET = 0;
+       public static final int SEEK_CUR = 1;
+       public static final int SEEK_END = 2;
        /**
         * Represents the bind between the java comm and the
         * native C comm. You must never access it, since it is 
index 3dc1e5e..d4d336c 100644 (file)
@@ -56,7 +56,7 @@ public class Host {
        protected Host() {
                this.bind = 0;
                this.data = null;
-       };
+       }
 
        @Override
        public String toString (){
@@ -73,15 +73,15 @@ public class Host {
         * @exception           HostNotFoundException if the name of the host is not valid.
         *                                      NativeException if the native version of this method failed.
         */ 
-       public native static Host getByName(String name) throws HostNotFoundException, NullPointerException;
+       public static native Host getByName(String name) throws HostNotFoundException, NullPointerException;
        /** Counts the installed hosts. */ 
-       public native static int getCount();
+       public static native int getCount();
 
        /** Returns the host of the current process. */ 
-       public native static Host currentHost();
+       public static native Host currentHost();
 
        /** Returns all hosts of the installed platform. */ 
-       public native static Host[] all();
+       public static native Host[] all();
 
        /** 
         * This static method sets a mailbox to receive in asynchronous mode.
index 9c04644..b53f5b5 100644 (file)
@@ -7,8 +7,6 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package org.simgrid.msg;
-import org.simgrid.NativeLib;
-
 
 public final class Msg {
 
@@ -63,7 +61,7 @@ public final class Msg {
         * @param args
         * @throws MsgException
         */
-       static public void main(String[]args) throws MsgException {
+       public static void main(String[]args) throws MsgException {
                /* initialize the MSG simulation. Must be done before anything else (even logging). */
                Msg.init(args);
 
index d9b3b6e..d50a475 100644 (file)
@@ -368,6 +368,6 @@ public abstract class Process implements Runnable {
         *
         * @return                      The count of the running processes
         */ 
-       public native static int getCount();
+       public static native int getCount();
 
 }
index b6953bc..b4cac70 100644 (file)
@@ -25,7 +25,7 @@ public class Storage {
        protected Storage() {
                this.bind = 0;
                this.data = null;
-       };
+       }
 
        @Override
        public String toString (){
@@ -43,7 +43,7 @@ public class Storage {
         * @exception           StorageNotFoundException if the name of the storage is not valid.
         * @exception           NativeException if the native version of this method failed.
         */ 
-       public native static Storage getByName(String name) 
+       public static native Storage getByName(String name) 
                        throws HostNotFoundException, NullPointerException, NativeException, StorageNotFoundException;
 
        /**
@@ -104,7 +104,7 @@ public class Storage {
         * @return                      An array containing all the storages installed.
         *
         */ 
-       public native static Storage[] all();
+       public static native Storage[] all();
 
        /**
         * Class initializer, to initialize various JNI stuff
index 70cb9e0..9877a95 100644 (file)
@@ -25,7 +25,7 @@ public final class Trace {
         * @param variable
         * @param color
         */
-       public final static native      void hostVariableDeclareWithColor (String variable, String color);
+       public final static native void hostVariableDeclareWithColor (String variable, String color);
 
 
        /**
@@ -35,7 +35,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void hostVariableAdd (String host, String variable, double value);
+       public final static native void hostVariableAdd (String host, String variable, double value);
 
        /**
         * Subtract a value from a variable of a host. 
@@ -44,7 +44,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void hostVariableSub (String host, String variable, double value);
+       public final static native void hostVariableSub (String host, String variable, double value);
 
        /**
         * Set the value of a variable of a host at a given timestamp. 
@@ -54,7 +54,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void hostVariableSetWithTime (double time, String host, String variable, double value);
+       public final static native void hostVariableSetWithTime (double time, String host, String variable, double value);
 
        /**
         *      Add a value to a variable of a host at a given timestamp. 
@@ -64,7 +64,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void hostVariableAddWithTime (double time, String host, String variable, double value);
+       public final static native void hostVariableAddWithTime (double time, String host, String variable, double value);
 
        /**
         * Subtract a value from a variable of a host at a given timestamp.  
@@ -74,7 +74,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void hostVariableSubWithTime (double time, String host, String variable, double value);
+       public final static native void hostVariableSubWithTime (double time, String host, String variable, double value);
 
        /**
         *  Get declared user host variables. 
@@ -87,14 +87,14 @@ public final class Trace {
         *  
         * @param variable
         */
-       public final static native      void linkVariableDeclare (String variable);
+       public final static native void linkVariableDeclare (String variable);
 
        /**
         * Declare a new user variable associated to links with a color. 
         * @param variable
         * @param color
         */
-       public final static native      void linkVariableDeclareWithColor (String variable, String color);
+       public final static native void linkVariableDeclareWithColor (String variable, String color);
 
        /**
         *  Set the value of a variable of a link. 
@@ -103,7 +103,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkVariableSet (String link, String variable, double value);
+       public final static native void linkVariableSet (String link, String variable, double value);
 
        /**
         * Add a value to a variable of a link. 
@@ -112,7 +112,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkVariableAdd (String link, String variable, double value);
+       public final static native void linkVariableAdd (String link, String variable, double value);
 
        /**
         * Subtract a value from a variable of a link. 
@@ -121,7 +121,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkVariableSub (String link, String variable, double value);
+       public final static native void linkVariableSub (String link, String variable, double value);
 
        /**
         *  Set the value of a variable of a link at a given timestamp. 
@@ -131,7 +131,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkVariableSetWithTime (double time, String link, String variable, double value);
+       public final static native void linkVariableSetWithTime (double time, String link, String variable, double value);
 
        /**
         * Add a value to a variable of a link at a given timestamp.
@@ -141,7 +141,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkVariableAddWithTime (double time, String link, String variable, double value);
+       public final static native void linkVariableAddWithTime (double time, String link, String variable, double value);
 
 
        /**
@@ -152,7 +152,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkVariableSubWithTime (double time, String link, String variable, double value);
+       public final static native void linkVariableSubWithTime (double time, String link, String variable, double value);
 
        /**
         * Set the value of the variable present in the links connecting source and destination. 
@@ -162,7 +162,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkSrcDstVariableSet (String src, String dst, String variable, double value);
+       public final static native void linkSrcDstVariableSet (String src, String dst, String variable, double value);
 
        /**
         * Add a value to the variable present in the links connecting source and destination. 
@@ -172,7 +172,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkSrcDstVariableAdd (String src, String dst, String variable, double value);
+       public final static native void linkSrcDstVariableAdd (String src, String dst, String variable, double value);
 
        /**
         * Subtract a value from the variable present in the links connecting source and destination. 
@@ -182,7 +182,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkSrcDstVariableSub (String src, String dst, String variable, double value);
+       public final static native void linkSrcDstVariableSub (String src, String dst, String variable, double value);
 
        /**
         *  Set the value of the variable present in the links connecting source and destination at a given timestamp. 
@@ -193,7 +193,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkSrcDstVariableSetWithTime (double time, String src, String dst, String variable, double value);
+       public final static native void linkSrcDstVariableSetWithTime (double time, String src, String dst, String variable, double value);
 
        /**
         * Add a value to the variable present in the links connecting source and destination at a given timestamp. 
@@ -204,7 +204,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkSrcdstVariableAddWithTime (double time, String src, String dst, String variable, double value);
+       public final static native void linkSrcdstVariableAddWithTime (double time, String src, String dst, String variable, double value);
 
        /**
         * Subtract a value from the variable present in the links connecting source and destination at a given timestamp. 
@@ -215,7 +215,7 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void linkSrcDstVariableSubWithTime (double time, String src, String dst, String variable, double value);
+       public final static native void linkSrcDstVariableSubWithTime (double time, String src, String dst, String variable, double value);
 
        /**
         *  Get declared user link variables.  
@@ -279,7 +279,7 @@ public final class Trace {
         * 
         * @param variable
         */
-       public final static native      void hostVariableDeclare (String variable);
+       public final static native void hostVariableDeclare (String variable);
 
 
        /**
@@ -289,14 +289,14 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void hostVariableSet (String host, String variable, double value);
+       public final static native void hostVariableSet (String host, String variable, double value);
 
        /**
         * Declare a new user variable associated to VMs. 
         * 
         * @param variable
         */
-       public final static native      void vmVariableDeclare (String variable);
+       public final static native void vmVariableDeclare (String variable);
 
 
        /**
@@ -306,5 +306,5 @@ public final class Trace {
         * @param variable
         * @param value
         */
-       public final static native      void vmVariableSet (String vm, String variable, double value);
+       public final static native void vmVariableSet (String vm, String variable, double value);
 }