Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[java] fix some small issues found by SonarQube
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 4 Mar 2016 09:26:48 +0000 (10:26 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 4 Mar 2016 09:28:37 +0000 (10:28 +0100)
examples/java/bittorrent/Common.java
examples/java/kademlia/Contact.java
src/bindings/java/org/simgrid/NativeLib.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/Process.java
src/bindings/java/org/simgrid/msg/Storage.java

index 2f030f3..5833aaf 100644 (file)
@@ -8,29 +8,21 @@ package bittorrent;
 
 /* Common constants for use in the simulation */
 public class Common {
-  public static String TRACKER_MAILBOX = "tracker_mailbox";
-  public static int FILE_SIZE = 5120;
-  public static int FILE_PIECE_SIZE = 512;
-  public static int FILE_PIECES = 10;
-  public static int PIECES_BLOCKS = 5;
-  public static int BLOCKS_REQUESTED = 2;
-  public static int PIECE_COMM_SIZE = 1;
-  /* Information message size */
-  public static int MESSAGE_SIZE = 1;
-  /* Max number of peers sent by the tracker to clients */
-  public static int MAXIMUM_PEERS = 50;
-  /* Interval of time where the peer should send a request to the tracker */
-  public static int TRACKER_QUERY_INTERVAL = 1000;
-  /* Communication size for a task to the tracker */
-  public static double TRACKER_COMM_SIZE = 0.01;
-  /* Timeout for the get peers data */
-  public static int GET_PEERS_TIMEOUT = 10000;
-  public static int TIMEOUT_MESSAGE = 10;
-  public static int TRACKER_RECEIVE_TIMEOUT = 10;
-  /* Number of peers that can be unchocked at a given time */
-  public static int MAX_UNCHOKED_PEERS = 4;
-  /* Interval between each update of the choked peers */
-  public static int UPDATE_CHOKED_INTERVAL = 30;
-  /* Number of pieces the peer asks for simultaneously */
-  public static int MAX_PIECES = 1;
+  public static final String TRACKER_MAILBOX = "tracker_mailbox";
+  public static final int FILE_SIZE = 5120;
+  public static final int FILE_PIECE_SIZE = 512;
+  public static final int FILE_PIECES = 10;
+  public static final int PIECES_BLOCKS = 5;
+  public static final int BLOCKS_REQUESTED = 2;
+  public static final int PIECE_COMM_SIZE = 1;
+  public static final int MESSAGE_SIZE = 1; /* Information message size */
+  public static final int MAXIMUM_PEERS = 50;  /* Max number of peers sent by the tracker to clients */
+  public static final int TRACKER_QUERY_INTERVAL = 1000;  /* Interval of time where the peer should send a request to the tracker */
+  public static final double TRACKER_COMM_SIZE = 0.01;  /* Communication size for a task to the tracker */
+  public static final int GET_PEERS_TIMEOUT = 10000;  /* Timeout for the get peers data */
+  public static final int TIMEOUT_MESSAGE = 10;
+  public static final int TRACKER_RECEIVE_TIMEOUT = 10;
+  public static final int MAX_UNCHOKED_PEERS = 4;  /* Number of peers that can be unchocked at a given time */
+  public static final int UPDATE_CHOKED_INTERVAL = 30;  /* Interval between each update of the choked peers */
+  public static final int MAX_PIECES = 1;  /* Number of pieces the peer asks for simultaneously */
 }
index 76e155b..0f95358 100644 (file)
@@ -23,10 +23,12 @@ public class Contact implements Comparable<Object> {
     return distance;
   }
 
+  @Override
   public boolean equals(Object x) {
     return x.equals(id) ;
   }
 
+  @Override
   public int compareTo(Object o) {
     Contact c = (Contact)o;
     if (distance < c.distance) {
index c89c57f..71b1595 100644 (file)
@@ -129,6 +129,7 @@ public final class NativeLib {
                public FileCleaner(File dir) {
                        this.dir = dir;
                }
+               @Override
                public void run() {
                        try {
                            for (File f : dir.listFiles())
index 40b68dc..16c6889 100644 (file)
@@ -13,6 +13,7 @@ public class As {
        protected As() {
        };
 
+       @Override
        public String toString (){
                return this.getName(); 
        }
index 015d080..456e474 100644 (file)
@@ -20,6 +20,7 @@ public class File {
        public File(String path) {
                open(path);
        }
+       @Override
        protected void finalize() {
 
        }
index aa058cf..ae953ee 100644 (file)
@@ -66,6 +66,7 @@ public class Host {
                this.data = null;
        };
 
+       @Override
        public String toString (){
                return this.name; 
 
index 502348c..f408d16 100644 (file)
@@ -328,13 +328,11 @@ public abstract class Process implements Runnable {
                }
        }
 
-       /**
-        * This method runs the process. Il calls the method function that you must overwrite.
-        */
+       /** This method runs the process. Il calls the method function that you must overwrite. */
+       @Override
        public void run() {
 
                String[] args = null;      /* do not fill it before the signal or this.args will be empty */
-               //waitSignal(); /* wait for other people to fill the process in */
 
                try {
                        args = new String[this.args.size()];
index d9ccd5a..b6953bc 100644 (file)
@@ -17,23 +17,17 @@ public class Storage {
         */ 
        private long bind;
 
-       /**
-        * Storage name
-        */
+       /** Storage name */
        protected String name;
 
-       /**
-        * User data.
-        */ 
+       /** User data. */ 
        private Object data;
-       /**
-        *
-        */
        protected Storage() {
                this.bind = 0;
                this.data = null;
        };
 
+       @Override
        public String toString (){
                return this.name;