Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 17 Feb 2016 10:43:02 +0000 (11:43 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 17 Feb 2016 10:43:02 +0000 (11:43 +0100)
55 files changed:
examples/java/kademlia/Answer.java
examples/java/kademlia/Bucket.java
examples/java/kademlia/CMakeLists.txt
examples/java/kademlia/Common.java
examples/java/kademlia/Contact.java
examples/java/kademlia/FindNodeAnswerTask.java
examples/java/kademlia/FindNodeTask.java
examples/java/kademlia/Kademlia.java
examples/java/kademlia/KademliaTask.java
examples/java/kademlia/Node.java
examples/java/kademlia/PingAnswerTask.java
examples/java/kademlia/PingTask.java
examples/java/kademlia/RoutingTable.java
examples/java/kademlia/kademlia.xml
examples/java/migration/CMakeLists.txt
examples/java/migration/Emigrant.java
examples/java/migration/Migration.java
examples/java/migration/Policeman.java
examples/java/mutualExclusion/CMakeLists.txt
examples/java/mutualExclusion/Coordinator.java
examples/java/mutualExclusion/GrantTask.java
examples/java/mutualExclusion/MutexCentral.java
examples/java/mutualExclusion/Node.java
examples/java/mutualExclusion/ReleaseTask.java
examples/java/mutualExclusion/RequestTask.java
examples/java/mutualExclusion/mutex_centralized_deployment.xml
examples/java/pingPong/CMakeLists.txt
examples/java/pingPong/PingPongTask.java
examples/java/pingPong/PingPongTest.java
examples/java/pingPong/README [deleted file]
examples/java/pingPong/Receiver.java
examples/java/pingPong/Sender.java
examples/java/pingPong/pingPongDeployment.xml
examples/java/priority/CMakeLists.txt
examples/java/priority/Priority.java
examples/java/priority/Test.java
examples/java/startKillTime/CMakeLists.txt
examples/java/startKillTime/Master.java
examples/java/startKillTime/Slave.java
examples/java/startKillTime/StartKillTime.java
examples/java/startKillTime/deployment.xml [deleted file]
examples/java/startKillTime/deployment_kill.xml [deleted file]
examples/java/startKillTime/deployment_start.xml [deleted file]
examples/java/startKillTime/deployment_start_kill.xml
examples/java/suspend/CMakeLists.txt
examples/java/suspend/DreamMaster.java
examples/java/suspend/LazyGuy.java
examples/java/suspend/Suspend.java
examples/java/tracing/CMakeLists.txt
examples/java/tracing/PingPongTask.java
examples/java/tracing/README [deleted file]
examples/java/tracing/Receiver.java
examples/java/tracing/Sender.java
examples/java/tracing/TracingTest.java
examples/java/tracing/tracingPingPongDeployment.xml

index ff0a25b..24164a4 100644 (file)
@@ -1,98 +1,73 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package kademlia;
-
 import java.util.ArrayList;
 import java.util.Collections;
 
-/**
- * Answer to a "FIND_NODE" query. Contains the nodes closest to
- * an id given.
- */
+/* Answer to a "FIND_NODE" query. Contains the nodes closest to an id given */
 public class Answer {
-       /**
-        * Id of the node we're trying to find
-        */
-       private int destinationId;
-       /**
-        * Closest nodes in the answer.
-        */
-       private ArrayList<Contact> nodes;
-       
-       /**
-        * Constructor
-        */
-       public Answer(int destinationId) {
-               this.destinationId = destinationId;
-               nodes = new ArrayList<Contact>();
-       }
-       /**
-        * Returns the destination id
-        */
-       int getDestinationId() {
-               return destinationId;
-       }
-       /**
-        * Returns the list of the nodes in the answer
-        */
-       ArrayList<Contact> getNodes() {
-               return nodes;
-       }
-       /**
-        * Returns the answer array size
-        */
-       int size() {
-               return nodes.size();
-       }
-       /**
-        * Remove an element from the answer.
-        */
-       public void remove(int index) {
-               nodes.remove(index);
-       }
-       /**
-        * Add a contact to the answer.
-        */
-       public void add(Contact contact) {
-               nodes.add(contact);
-       }
-       /**
-        * Merge the contents of this answer with another answer
-        */
-       public int merge(Answer answer) {
-               int nbAdded = 0;
-               
-               for (Contact c: answer.getNodes()) {
-                       if (!nodes.contains(c)) {
-                               nbAdded++;
-                               nodes.add(c);
-                       }
-               }
-               Collections.sort(nodes);
-               //Trim the list
-               while (answer.size() > Common.BUCKET_SIZE) {
-                       answer.remove(answer.size() - 1);
-               }
-               return nbAdded;
-       }
-       /**
-        * Returns if the destination has been found
-        */
-       public boolean destinationFound() {
-               if (nodes.size() < 1) {
-                       return false;
-               }
-               Contact tail = nodes.get(0);
-               return tail.getDistance() == 0;
-       }
-       @Override
-       public String toString() {
-               return "Answer [destinationId=" + destinationId + ", nodes=" + nodes
-                               + "]";
-       }
-       
+  private int destinationId;
+  /* Closest nodes in the answer. */
+  private ArrayList<Contact> nodes;
+
+  public Answer(int destinationId) {
+    this.destinationId = destinationId;
+    nodes = new ArrayList<Contact>();
+  }
+
+  int getDestinationId() {
+    return destinationId;
+  }
+
+  ArrayList<Contact> getNodes() {
+    return nodes;
+  }
+
+  int size() {
+    return nodes.size();
+  }
+
+  public void remove(int index) {
+    nodes.remove(index);
+  }
+
+  public void add(Contact contact) {
+    nodes.add(contact);
+  }
+
+  /* Merge the contents of this answer with another answer */
+  public int merge(Answer answer) {
+    int nbAdded = 0;
+
+    for (Contact c: answer.getNodes()) {
+      if (!nodes.contains(c)) {
+        nbAdded++;
+        nodes.add(c);
+      }
+    }
+    Collections.sort(nodes);
+    //Trim the list
+    while (answer.size() > Common.BUCKET_SIZE) {
+      answer.remove(answer.size() - 1);
+    }
+    return nbAdded;
+  }
+
+  /* Returns if the destination has been found */
+  public boolean destinationFound() {
+    if (nodes.size() < 1) {
+      return false;
+    }
+    Contact tail = nodes.get(0);
+    return tail.getDistance() == 0;
+  }
+
+  @Override
+  public String toString() {
+    return "Answer [destinationId=" + destinationId + ", nodes=" + nodes + "]";
+  }
 }
index 8ad2326..41d391d 100644 (file)
@@ -1,77 +1,58 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package kademlia;
-
 import java.util.ArrayList;
 
-/**
- * Stores the information held in a bucket
- */
 public class Bucket {
-       private ArrayList<Integer> nodes;
-       private int id;
-       
-       /**
-        * Constructor
-        */
-       public Bucket(int id) {
-               this.nodes = new ArrayList<Integer>();
-               this.id = id;
-       }
-       /**
-        * Returns the bucket's id.
-        */
-       public int getId() {
-               return this.id;
-       }
-       /**
-        * Returns how many nodes there is in the bucket
-        */
-       public int size() {
-               return nodes.size();
-       }
-       /**
-        * Returns if the bucket contains the element
-        */
-       public boolean contains(int id) {
-               return nodes.contains(id);
-       }
-       /**
-        * Add an to the front of the bucket
-        */
-       public void add(int id) {
-               nodes.add(0,id);
-       }
-       /**
-        * Pushs an element into the front of a bucket.
-        */
-       public void pushToFront(int id) {
-               int i = nodes.indexOf(id);
-               nodes.remove(i);
-               nodes.add(0, id);
-       }
-       /**
-        * Returns a node
-        */
-       public int getNode(int id) {
-               return nodes.get(id);
-       }
-       /**
-        * Adds the content of the bucket into a answer object.
-        */
-       public void addToAnswer(Answer answer, int destination) {
-               for (int id : this.nodes) {
-                       answer.getNodes().add(new Contact(id,id ^ destination));
-               }
-       }
-       
-       @Override
-       public String toString() {
-               return "Bucket [id= " + id + " nodes=" + nodes + "]";
-       }
-       
+  private ArrayList<Integer> nodes;
+  private int id;
+
+  public Bucket(int id) {
+    this.nodes = new ArrayList<Integer>();
+    this.id = id;
+  }
+
+  public int getId() {
+    return this.id;
+  }
+
+  public int size() {
+    return nodes.size();
+  }
+
+  public boolean contains(int id) {
+    return nodes.contains(id);
+  }
+
+  /* Add a node to the front of the bucket */
+  public void add(int id) {
+    nodes.add(0,id);
+  }
+
+  /* Push a node to the front of a bucket */
+  public void pushToFront(int id) {
+    int i = nodes.indexOf(id);
+    nodes.remove(i);
+    nodes.add(0, id);
+  }
+
+  public int getNode(int id) {
+    return nodes.get(id);
+  }
+
+  /* Add the content of the bucket into a answer object. */
+  public void addToAnswer(Answer answer, int destination) {
+    for (int id : this.nodes) {
+      answer.getNodes().add(new Contact(id,id ^ destination));
+    }
+  }
+
+  @Override
+  public String toString() {
+    return "Bucket [id= " + id + " nodes=" + nodes + "]";
+  }
 }
index d49e24f..5767cd2 100644 (file)
@@ -39,9 +39,3 @@ set(examples_src
   ${examples_src}
   ${sources}
   PARENT_SCOPE)
-set(bin_files
-  ${bin_files}
-  PARENT_SCOPE)
-set(txt_files
-  ${txt_files}
-  PARENT_SCOPE)
index 7df08e7..0c3d425 100644 (file)
@@ -1,46 +1,32 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package kademlia;
-/**
- * Common constants used all over the simulation
- */
+
 public class Common {
-       public final static int COMM_SIZE = 1;
-       public final static int COMP_SIZE = 0;
-       
-       public final static int RANDOM_LOOKUP_INTERVAL = 100;
-       
-       public final static int alpha = 3;
-       /**
-        * Size of the nodes identifier
-        */
-       public final static int IDENTIFIER_SIZE = 32;
-       /**
-        * Maximum size of the buckets
-        */
-       public final static int BUCKET_SIZE = 20;
-       /**
-        * Maximum number of trial for the "JOIN" request
-        */
-       public final static int MAX_JOIN_TRIALS = 4;
-       /**
-        * Timeout for a "FIND_NODE" request to a node
-        */
-       public final static int FIND_NODE_TIMEOUT = 10;
-       /**
-        * Global timeout for a FIND_NODE.
-        */
-       public final static int FIND_NODE_GLOBAL_TIMEOUT = 50;
-       /**
-        * Timeout for a "PING" request
-        */
-       public final static int PING_TIMEOUT = 35;
-       
-       public final static int MAX_STEPS = 10;
+  /* Common constants used all over the simulation */
+  public final static int COMM_SIZE = 1;
+  public final static int COMP_SIZE = 0;
+
+  public final static int RANDOM_LOOKUP_INTERVAL = 100;
+
+  public final static int alpha = 3;
+
+  public final static int IDENTIFIER_SIZE = 32;
+  /* Maximum size of the buckets */
+  public final static int BUCKET_SIZE = 20;
+  /* Maximum number of trials for the "JOIN" request */
+  public final static int MAX_JOIN_TRIALS = 4;
+  /* Timeout for a "FIND_NODE" request to a node */
+  public final static int FIND_NODE_TIMEOUT = 10;
+  /* Global timeout for a FIND_NODE request */
+  public final static int FIND_NODE_GLOBAL_TIMEOUT = 50;
+  /* Timeout for a "PING" request */
+  public final static int PING_TIMEOUT = 35;
 
-       public final static int JOIN_BUCKETS_QUERIES = 1;
+  public final static int MAX_STEPS = 10;
+  public final static int JOIN_BUCKETS_QUERIES = 1;
 }
index 16d3906..76e155b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -6,47 +6,43 @@
 
 package kademlia;
 
-/**
- * Contains the information about a foreign node according to
- * a node we are trying to find.
- */
 public class Contact implements Comparable<Object> {
-       private int id;
-       private int distance;
-       
-       public Contact(int id, int distance) {
-               this.id = id;
-               this.distance = distance;
-       }
-
-       public int getId() {
-               return id;
-       }
-
-       public int getDistance() {
-               return distance;
-       }
-       
-       public boolean equals(Object x) {
-               return x.equals(id) ;
-       }
-
-       public int compareTo(Object o) {
-               Contact c = (Contact)o;
-               if (distance < c.distance) {
-                       return -1;
-               }
-               else if (distance == c.distance) {
-                       return 0;
-               }
-               else {
-                       return 1;
-               }
-       }
-
-       @Override
-       public String toString() {
-               return "Contact [id=" + id + ", distance=" + distance + "]";
-       }
-       
+  private int id;
+  private int distance;
+
+  public Contact(int id, int distance) {
+    this.id = id;
+    this.distance = distance;
+  }
+
+  public int getId() {
+    return id;
+  }
+
+  public int getDistance() {
+    return distance;
+  }
+
+  public boolean equals(Object x) {
+    return x.equals(id) ;
+  }
+
+  public int compareTo(Object o) {
+    Contact c = (Contact)o;
+    if (distance < c.distance) {
+      return -1;
+    }
+    else if (distance == c.distance) {
+      return 0;
+    }
+    else {
+      return 1;
+    }
+  }
+
+  @Override
+  public String toString() {
+    return "Contact [id=" + id + ", distance=" + distance + "]";
+  }
+
 }
\ No newline at end of file
index cb036da..b4cad24 100644 (file)
@@ -1,35 +1,25 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package kademlia;
-
 import kademlia.Answer;
 
 public class FindNodeAnswerTask extends KademliaTask {
-       /**
-        * Destination id
-        */
-       protected int destinationId;
-       /**
-        * Answer to the FIND_NODE query.
-        */
-       protected Answer answer;
-       /**
-        * Constructor
-        */
-       public FindNodeAnswerTask(int senderId, int destinationId, Answer answer) {
-               super(senderId);
-               this.destinationId = destinationId;
-               this.answer = answer;
-       }
-       public int getDestinationId() {
-               return destinationId;
-       }
-       public Answer getAnswer() {
-               return answer;
-       }
-       
+  protected int destinationId;
+  protected Answer answer;
+
+  public FindNodeAnswerTask(int senderId, int destinationId, Answer answer) {
+    super(senderId);
+    this.destinationId = destinationId;
+    this.answer = answer;
+  }
+  public int getDestinationId() {
+    return destinationId;
+  }
+  public Answer getAnswer() {
+    return answer;
+  }
 }
index 9ee53a9..f2020aa 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,27 +7,19 @@
 package kademlia;
 
 /**
- * @brief Find node tasks sent by a node to another
- * "Find Node" task sent by a node to another. Ask him for
- * its closest nodes from a destination.
+ * @brief Find node tasks sent by a node to another "Find Node" task sent by a node to another. Ask him for its closest
+ * nodes from a destination.
  */
 public class FindNodeTask extends KademliaTask {
-       /**
-        * Id of the node we are trying to find: the destination
-        */
-       private int destination;
-       /**
-        * Constructor
-        */
-       public FindNodeTask(int senderId, int destination) {
-               super(senderId);        
-               this.destination = destination;
-       }
+  /* Id of the node we are trying to find: the destination */
+  private int destination;
 
+  public FindNodeTask(int senderId, int destination) {
+    super(senderId);  
+    this.destination = destination;
+  }
 
-
-       public int getDestination() {
-               return destination;
-       }
-       
+  public int getDestination() {
+    return destination;
+  }
 }
index a9c05c4..01fcef2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,24 +7,21 @@
 package kademlia;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.MsgException;
-/**
- * Main class of the simulation. Launch the simulation.
- */
+
 public class Kademlia {
-       public static void main(String[] args) throws MsgException {
-               /* initialize the MSG simulation. Must be done before anything else (even logging). */
-               Msg.init(args);
-               if(args.length < 2) {
-                       Msg.info("Usage   : Kademlia platform_file deployment_file");
-                       Msg.info("example : Kademlia platform.xml deployment.xml");
-                       System.exit(1);
-               }
-               
-               /* construct the platform and deploy the application */
-               Msg.createEnvironment(args[0]);
-               Msg.deployApplication(args[1]);
-                       
-               /*  execute the simulation. */
-        Msg.run();             
-       }
+  public static void main(String[] args) throws MsgException {
+    Msg.init(args);
+    if(args.length < 2) {
+      Msg.info("Usage   : Kademlia platform_file deployment_file");
+      Msg.info("example : Kademlia ../platforms/platform.xml kademlia.xml");
+      System.exit(1);
+    }
+
+    /* construct the platform and deploy the application */
+    Msg.createEnvironment(args[0]);
+    Msg.deployApplication(args[1]);
+
+    /*  execute the simulation. */
+    Msg.run();
+  }
 }
index 9ca0c5f..0a549b4 100644 (file)
@@ -1,32 +1,23 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package kademlia;
-
 import kademlia.Common;
 
 import org.simgrid.msg.Task;
 
-/**
- * @brief Base class for all the tasks related to Kademlia.
- */
 public class KademliaTask extends Task {
-       /**
-        * Sender id
-        */
-       protected int senderId;
-       
-       /**
-        * Constructor
-        */
-       public KademliaTask(int senderId) {
-               super("kademliatask",Common.COMP_SIZE,Common.COMM_SIZE);
-               this.senderId = senderId;
-       }
-       public int getSenderId() {
-               return senderId;
-       }
+  protected int senderId;
+
+  public KademliaTask(int senderId) {
+    super("kademliatask",Common.COMP_SIZE,Common.COMM_SIZE);
+    this.senderId = senderId;
+  }
+
+  public int getSenderId() {
+    return senderId;
+  }
 }
index 0a94781..5dd2ae2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -8,345 +8,312 @@ package kademlia;
 
 import org.simgrid.msg.Host;
 
-import org.simgrid.msg.Comm;
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.MsgException;
-import org.simgrid.msg.Process;
+import org.simgrid.msg.Comm;
 import org.simgrid.msg.Task;
-/**
- * Main class of the simulation, contains the logic of a node.
- */
+import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
+
 public class Node extends Process {
-       /**
-         * Id in the network.
-        */
-       protected int id;
-       /**
-        * Routing table
-        */
-       protected RoutingTable table;
-       /**
-        * Deadline
-        */
-       protected int deadline;
-       /**
-        * FIND_NODE which have succeeded.
-        */
-       protected int findNodeSuccedded = 0;
-       /**
-        * FIND_NODE which have failed
-        */
-       protected int findNodeFailed = 0;
-       
-       protected Comm comm;
+  protected int id;
+  protected RoutingTable table;
+  protected int deadline;
+  protected int findNodeSuccedded = 0;
+  protected int findNodeFailed = 0;
+  protected Comm comm;
+
+  public Node(Host host, String name, String[]args) {
+    super(host,name,args);
+  }
+
+  @Override
+  public void main(String[] args) throws MsgException {
+    //Check the number of arguments.
+    if (args.length != 2 && args.length != 3) {
+      Msg.info("Wrong argument count.");
+      return;
+    }
+    this.id = Integer.valueOf(args[0]);
+    this.table = new RoutingTable(this.id);
+
+    if (args.length == 3) {
+      this.deadline = Integer.valueOf(args[2]).intValue();
+      Msg.info("Hi, I'm going to join the network with the id " + id + "!");
+      if (joinNetwork(Integer.valueOf(args[1]))) {
+        this.mainLoop();
+      }
+      else {
+        Msg.info("I couldn't join the network :(");
+      }
+    }
+    else {
+      this.deadline = Integer.valueOf(args[1]).intValue();
+      Msg.info("Hi, I'm going to create the network with the id " + id + "!");
+      table.update(this.id);
+      this.mainLoop();
+    }
+    Msg.debug("I'm leaving the network");
+    Msg.debug("Here is my routing table:" + table);
+  }
+
+  public void mainLoop() {
+    double next_lookup_time = 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) {
+            randomLookup();
+            next_lookup_time += Common.RANDOM_LOOKUP_INTERVAL;
+          } else {
+            waitFor(1);
+          }
+        } else {
+          Task task = comm.getTask();
+          handleTask(task);
+          comm = null;
+        }
+      }
+      catch (Exception e) {
+      }
+    }
+    Msg.info(findNodeSuccedded + "/"  + (findNodeSuccedded + findNodeFailed) + " FIND_NODE have succedded.");
+  }
+
+  /**
+   * @brief Try to make the node join the network
+   * @param idKnown Id of someone we know in the system
+   */
+  public boolean joinNetwork(int idKnown) {
+    boolean answerGot = false;
+    double timeBegin = Msg.getClock();
+    Msg.debug("Joining the network knowing " + idKnown);
+    //Add ourselves and the node we know to our routing table
+    table.update(this.id);
+    table.update(idKnown);
+    //Send a "FIND_NODE" to the node we know.
+    sendFindNode(idKnown,this.id);
+    //Wait for the answer.
+    int trials = 0;
+
+    do {
+      try {
+        if (comm == null) {
+          comm = Task.irecv(Integer.toString(id));
+        }
+        if (comm != null) {
+          if (!comm.test()) {
+            waitFor(1);
+          } 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()) {
+                  table.update(c.getId());
+                }
+              }
+            } else {
+              handleTask(task);
+            }
+            comm = null;
+          }
+        }
+      }
+      catch (Exception ex) {
+        trials++;
+        Msg.info("FIND_NODE failed");
+      }
+    } while (!answerGot && trials < Common.MAX_JOIN_TRIALS);
+    /* Second step: Send a FIND_NODE in a node in each bucket */
+    int bucketId = table.findBucket(idKnown).getId();
+    for (int i = 0; ((bucketId - i) > 0 || 
+       (bucketId + i) <= Common.IDENTIFIER_SIZE) && 
+       i < Common.JOIN_BUCKETS_QUERIES; i++) {
+      if (bucketId - i > 0) {
+        int idInBucket = table.getIdInPrefix(this.id,bucketId - i);
+        this.findNode(idInBucket,false);
+      }
+      if (bucketId + i <= Common.IDENTIFIER_SIZE) {
+        int idInBucket = table.getIdInPrefix(this.id,bucketId + i);
+        findNode(idInBucket,false);
+      }
+    }
+    Msg.debug("Time spent:" + (Msg.getClock() - timeBegin));
+    return answerGot;
+  }
+
+  /* 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 steps = 0;
+    double timeBeginReceive;
+    double timeout, 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);
+    do {
+      timeBeginReceive = Msg.getClock();
+      answers = 0;
+      queries = this.sendFindNodeToBest(nodeList);
+      nodesAdded = 0;
+      timeout = Msg.getClock() + Common.FIND_NODE_TIMEOUT;
+      steps++;
+      do {
+        try {
+          if (comm == null) {
+            comm = Task.irecv(Integer.toString(id));
+          }
+          if (!comm.test()) {
+            waitFor(1);
+          } else {
+            Task task = comm.getTask();  
+            if (task instanceof FindNodeAnswerTask) {
+              FindNodeAnswerTask answerTask = (FindNodeAnswerTask)task;
+              //Check if we received what we are looking for.
+              if (answerTask.getDestinationId() == destination) {
+                table.update(answerTask.getSenderId());
+                //Add the answer to our routing table
+                for (Contact c: answerTask.getAnswer().getNodes()) {
+                  table.update(c.getId());
+                }
+                answers++;
+                
+                nodesAdded = nodeList.merge(answerTask.getAnswer());
+              } else {
+              /* If it's not our answer, we answer to the node that has queried us anyway */
+                handleTask(task);
+                //Update the timeout if it's not our answer.
+                timeout += Msg.getClock() - timeBeginReceive;
+                timeBeginReceive = Msg.getClock();
+              }
+            } else {
+              handleTask(task);
+              timeout += Msg.getClock() - timeBeginReceive;
+              timeBeginReceive = Msg.getClock();
+            }
+            comm = null;
+          }
+        }
+        catch (Exception e) {
+          comm = null;
+        }
+      } while (answers < queries && Msg.getClock() < timeout);
+      destinationFound = nodeList.destinationFound();
+    } while (!destinationFound && (nodesAdded > 0 || answers == 0) && Msg.getClock() < globalTimeout 
+             && steps < Common.MAX_STEPS);
+
+    if (destinationFound) {
+      if (counts) {
+        findNodeSuccedded++;
+      }
+      Msg.debug("Find node on " + destination + " succedded");
+    } else {
+      Msg.debug("Find node on " + destination + " failed");
+      Msg.debug("Queried " + queries + " nodes to find "  + destination);
+      Msg.debug(nodeList.toString());
+      if (counts) {
+        findNodeFailed++;
+      }
+    }
+    return destinationFound;
+  }
+
+  /**
+   * @brief Sends a "PING" request to a node
+   * @param destination Ping destination id.
+   */
+  public void ping(int destination) {
+    boolean destinationFound = false;
+    double timeout = Msg.getClock() + Common.PING_TIMEOUT;
+    PingTask pingTask = new PingTask(this.id);
+    /* Sending the ping task */
+    pingTask.dsend(Integer.toString(destination));
+    do {
+      try {
+        Task task = Task.receive(Integer.toString(this.id),Common.PING_TIMEOUT);
+        if (task instanceof PingAnswerTask) {
+          PingAnswerTask answerTask = (PingAnswerTask)task;
+          if (answerTask.getSenderId() == destination) {
+            this.table.update(destination);
+            destinationFound = true;
+          } else {
+            handleTask(task);
+          }
+        } else {
+          handleTask(task);
+        }
+        waitFor(1);
+      }
+      catch (Exception ex) {
+      }
+    } while (Msg.getClock() < timeout && !destinationFound);
+  }
+
+  /**
+   * @brief Sends a "FIND_NODE" request (task) to a node we know.
+   * @param id Id of the node we are querying
+   * @param destination id of the node we are trying to find.
+   */
+  public void sendFindNode(int id, int destination) {
+    Msg.debug("Sending a FIND_NODE to " + Integer.toString(id) + " to find " + destination  );
+    FindNodeTask task = new FindNodeTask(this.id,destination);
+    task.dsend(Integer.toString(id));
+  }
+
+  /** Sends a "FIND_NODE" request to the best "alpha" nodes in a node list */
+  public int sendFindNodeToBest(Answer nodeList) {
+    int destination = nodeList.getDestinationId();
+    int 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);
+      }
+    }
+    return i;
+  }
+
+  public void randomLookup() {
+    findNode(0,true);
+  }
 
-       public Node(Host host, String name, String[]args) {
-               super(host,name,args);
-       }
-       
-       @Override
-       public void main(String[] args) throws MsgException {
-               //Check the number of arguments.
-               if (args.length != 2 && args.length != 3) {
-                       Msg.info("Wrong argument count.");
-                       return;
-               }
-               this.id = Integer.valueOf(args[0]);
-               this.table = new RoutingTable(this.id);
-               
-               if (args.length == 3) {
-                       this.deadline = Integer.valueOf(args[2]).intValue();
-                       Msg.info("Hi, I'm going to join the network with the id " + id + "!");
-                       if (joinNetwork(Integer.valueOf(args[1]))) {
-                               this.mainLoop();
-                       } 
-                       else {
-                               Msg.info("I couldn't join the network :(");
-                       }
-               }
-               else {
-                       this.deadline = Integer.valueOf(args[1]).intValue();
-                       Msg.info("Hi, I'm going to create the network with the id " + id + "!");
-                       table.update(this.id);
-                       this.mainLoop();
-               }               
-               Msg.debug("I'm leaving the network");
-               Msg.debug("Here is my routing table:" + table);
-       }
-       /**
-        * Node main loop
-        */
-       public void mainLoop() {
-               double next_lookup_time = 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) {
-                                               randomLookup();
-                                               next_lookup_time += Common.RANDOM_LOOKUP_INTERVAL;
-                                       }
-                                       else {
-                                               waitFor(1);
-                                       }                                               
-                               }
-                               else {
-                                       Task task = comm.getTask();
-                                       handleTask(task);
-                                       comm = null;
-                               }
-                       }
-                       catch (Exception e) {
-                               
-                       }
-               }
-               Msg.info(findNodeSuccedded + "/"  + (findNodeSuccedded + findNodeFailed) + " FIND_NODE have succedded.");
-       }
-       /**
-        * @brief Try to make the node join the network
-        * @param idKnown Id of someone we know in the system
-        */
-       public boolean joinNetwork(int idKnown) {
-               boolean answerGot = false;
-               double timeBegin = Msg.getClock();
-               Msg.debug("Joining the network knowing " + idKnown);
-               //Add ourselves and the node we know to our routing table
-               table.update(this.id);
-               table.update(idKnown);
-               //Send a "FIND_NODE" to the node we know.
-               sendFindNode(idKnown,this.id);
-               //Wait for the answer.
-               int trials = 0;
+  /**
+   * @brief Handles an incomming task
+   * @param task The task we need to handle
+   */
+  public void handleTask(Task task) {
+    if (task instanceof KademliaTask) {
+      table.update(((KademliaTask) task).getSenderId());
+      if (task instanceof FindNodeTask) {
+        handleFindNode((FindNodeTask)task);
+      }
+      else if (task instanceof PingTask) {
+        handlePing((PingTask)task);
+      }
+    }
+  }
 
-               do {
-                       try {
-                               if (comm == null) {
-                                       comm = Task.irecv(Integer.toString(id));
-                               }
-                               if (comm != null) {
-                                       if (!comm.test()) {
-                                               waitFor(1);
-                                       }
-                                       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()) {
-                                                                       table.update(c.getId());
-                                                               }                                               
-                                                       }
-                                               }
-                                               else {
-                                                       handleTask(task);
-                                               }
-                                               comm = null;
-                                       }
-                               }
+  public void handleFindNode(FindNodeTask task) {
+    Msg.debug("Received a FIND_NODE from " + task.getSenderId());
+    Answer answer = table.findClosest(task.getDestination());
+    FindNodeAnswerTask taskToSend = new FindNodeAnswerTask(this.id,task.getDestination(),answer);
+    taskToSend.dsend(Integer.toString(task.getSenderId()));
+  }
 
-                       }
-                       catch (Exception ex) {
-                               trials++;
-                               Msg.info("FIND_NODE failed");
-                       }
-               } while (!answerGot && trials < Common.MAX_JOIN_TRIALS);
-               /* Second step: Send a FIND_NODE in a node in each bucket */
-               int bucketId = table.findBucket(idKnown).getId();
-               for (int i = 0; ((bucketId - i) > 0 || 
-                        (bucketId + i) <= Common.IDENTIFIER_SIZE) && 
-                        i < Common.JOIN_BUCKETS_QUERIES; i++) {
-                       if (bucketId - i > 0) {
-                               int idInBucket = table.getIdInPrefix(this.id,bucketId - i);
-                               this.findNode(idInBucket,false);
-                       }
-                       if (bucketId + i <= Common.IDENTIFIER_SIZE) {
-                               int idInBucket = table.getIdInPrefix(this.id,bucketId + i);                             
-                               findNode(idInBucket,false);
-                       }
-               }
-               Msg.debug("Time spent:" + (Msg.getClock() - timeBegin));
-               return answerGot;
-       }
-       /**
-        * 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 steps = 0;
-               double timeBeginReceive;
-               double timeout, 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);
-               do {
-                       timeBeginReceive = Msg.getClock();
-                       answers = 0;
-                       queries = this.sendFindNodeToBest(nodeList);
-                       nodesAdded = 0;
-                       timeout = Msg.getClock() + Common.FIND_NODE_TIMEOUT;
-                       steps++;
-                       do {
-                               try {
-                                       if (comm == null) {
-                                               comm = Task.irecv(Integer.toString(id));
-                                       }
-                                       if (!comm.test()) {
-                                               waitFor(1);
-                                       }
-                                       else {
-                                               Task task = comm.getTask();     
-                                               if (task instanceof FindNodeAnswerTask) {
-                                                       FindNodeAnswerTask answerTask = (FindNodeAnswerTask)task;
-                                                       //Check if we received what we are looking for.
-                                                       if (answerTask.getDestinationId() == destination) {
-                                                               table.update(answerTask.getSenderId());
-                                                               //Add the answer to our routing table
-                                                               for (Contact c: answerTask.getAnswer().getNodes()) {
-                                                                       table.update(c.getId());
-                                                               }
-                                                               answers++;
-                                                               
-                                                               nodesAdded = nodeList.merge(answerTask.getAnswer());                                                    
-                                                       }
-                                                       /* If it's not our answer, we answer to the node that
-                                                        * has queried us anyway
-                                                        */
-                                                       else {
-                                                               handleTask(task);
-                                                               //Update the timeout if it's not our answer.
-                                                               timeout += Msg.getClock() - timeBeginReceive;
-                                                               timeBeginReceive = Msg.getClock();
-                                                       }
-                                               }
-                                               else {
-                                                       handleTask(task);
-                                                       timeout += Msg.getClock() - timeBeginReceive;
-                                                       timeBeginReceive = Msg.getClock();
-                                               }
-                                               comm = null;
-                                       }
-                               }
-                               catch (Exception e) {
-                                       comm = null;
-                               }
-                       } while (answers < queries && Msg.getClock() < timeout);
-                       destinationFound = nodeList.destinationFound();
-               } while (!destinationFound && (nodesAdded > 0 || answers == 0) && Msg.getClock() < globalTimeout && steps < Common.MAX_STEPS);
-               
-               if (destinationFound) {
-                       if (counts) {
-                               findNodeSuccedded++;
-                       }
-                       Msg.debug("Find node on " + destination + " succedded");
-               }
-               else {
-                       Msg.debug("Find node on " + destination + " failed");
-                       Msg.debug("Queried " + queries + " nodes to find "  + destination);
-                       Msg.debug(nodeList.toString());
-                       if (counts) {
-                               findNodeFailed++;
-                       }
-               }
-               return destinationFound;
-       }
-       /**
-        * Sends a "PING" request to a node
-        * @param destination Ping destination id.
-        */
-       public void ping(int destination) {
-               boolean destinationFound = false;
-               double timeout = Msg.getClock() + Common.PING_TIMEOUT;
-               PingTask pingTask = new PingTask(this.id);
-               /* Sending the ping task */
-               pingTask.dsend(Integer.toString(destination));
-               do
-               {
-                       try {
-                               Task task = Task.receive(Integer.toString(this.id),Common.PING_TIMEOUT);
-                               if (task instanceof PingAnswerTask) {
-                                       PingAnswerTask answerTask = (PingAnswerTask)task;
-                                       if (answerTask.getSenderId() == destination) {
-                                               this.table.update(destination);
-                                               destinationFound = true;
-                                       }
-                                       else {
-                                               handleTask(task);
-                                       }
-                               }
-                               else {
-                                       handleTask(task);
-                               }
-                               waitFor(1);
-                       }
-                       catch (Exception ex) {
-                       }
-               } while (Msg.getClock() < timeout && !destinationFound);
-       }
-       /**
-        * Sends a "FIND_NODE" request (task) to a node we know.
-        * @brief id Id of the node we are querying
-        * @brief destination id of the node we are trying to find.
-        */
-       public void sendFindNode(int id, int destination) {
-               Msg.debug("Sending a FIND_NODE to " + Integer.toString(id) + " to find " + destination  );
-               FindNodeTask task = new FindNodeTask(this.id,destination);
-               task.dsend(Integer.toString(id));
-       }
-       /**
-        * Sends a "FIND_NODE" request to the best "alpha" nodes in a node
-        * list
-        */
-       public int sendFindNodeToBest(Answer nodeList) {
-               int destination = nodeList.getDestinationId();
-               int 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);
-                       }
-               }
-               return i;
-       }
-       /**
-        * Does a random lookup
-        */
-       public void randomLookup() {
-               findNode(0,true);
-       }
-       /**
-        * Handles an incomming task
-        * @param task The task we need to handle
-        */
-       public void handleTask(Task task) {
-               if (task instanceof KademliaTask) {
-                       table.update(((KademliaTask) task).getSenderId());
-                       if (task instanceof FindNodeTask) {
-                               handleFindNode((FindNodeTask)task);
-                       }
-                       else if (task instanceof PingTask) {
-                               handlePing((PingTask)task);
-                       }
-               }
-       }
-       public void handleFindNode(FindNodeTask task) {
-               Msg.debug("Received a FIND_NODE from " + task.getSenderId());
-               Answer answer = table.findClosest(task.getDestination());
-               FindNodeAnswerTask taskToSend = new FindNodeAnswerTask(this.id,task.getDestination(),answer);
-               taskToSend.dsend(Integer.toString(task.getSenderId()));
-       }
-       public void handlePing(PingTask task) {
-               Msg.debug("Received a PING from " + task.getSenderId());
-               PingAnswerTask taskToSend = new PingAnswerTask(this.id);
-               taskToSend.dsend(Integer.toString(task.getSenderId()));
-       }
+  public void handlePing(PingTask task) {
+    Msg.debug("Received a PING from " + task.getSenderId());
+    PingAnswerTask taskToSend = new PingAnswerTask(this.id);
+    taskToSend.dsend(Integer.toString(task.getSenderId()));
+  }
 }
index 46f2fd8..d6dd4a0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,10 +7,7 @@
 package kademlia;
 
 public class PingAnswerTask extends KademliaTask {
-       /**
-        * Constructor
-        */
-       public PingAnswerTask(int senderId) {
-               super(senderId);
-       }
+  public PingAnswerTask(int senderId) {
+    super(senderId);
+  }
 }
index 3b08c93..eacfb1d 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -6,14 +6,8 @@
 
 package kademlia;
 
-/**
- * @brief "PING" task sent by a node to another to see if it is still alive
- */
 public class PingTask extends KademliaTask {
-       /**
-        * Constructor
-        */
-       public PingTask(int senderId) {
-               super(senderId);
-       }
+  public PingTask(int senderId) {
+    super(senderId);
+  }
 }
index ca136a0..961d38f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -9,125 +9,105 @@ import java.util.Collections;
 import java.util.Vector;
 
 import org.simgrid.msg.Msg;
-/**
- * @brief Contains the various data of a routing table.
- */
+
 public class RoutingTable {
-       /**
-        * Bucket list
-        */
-       private Vector<Bucket> buckets;
-       /**
-        * Id of the routing table owner
-        */
-       private int id;
-       /**
-        * Constructor
-        */
-       public RoutingTable(int id) {
-               this.id = id;
-               buckets = new Vector<Bucket>();
-               for (int i = 0; i < Common.IDENTIFIER_SIZE + 1; i++) {
-                       buckets.add(new Bucket(i));
-               }               
-       }
-       /**
-        * Returns an identifier which is in a specific bucket of a routing table
-        * @brief id id of the routing table owner
-        * @brief prefix id of the bucket where we want that identifier to be
-        */
-       public int getIdInPrefix(int id, int prefix) {
-               if (prefix == 0) {
-                       return 0;
-               }
-               int identifier = 1;
-               identifier = identifier << (prefix - 1);
-               identifier = identifier ^ id;
-               return identifier;
-       }
-       /**
-        * Returns the corresponding node prefix for a given id
-        */
-       public int getNodePrefix(int id) {
-               for (int j = 0; j < 32; j++) {
-                       if ((id >> (32 - 1 - j) & 0x1) != 0) {
-                               return 32 - j;
-                       }
-               }
-               return 0;
-       }
-       /**
-         * Fins the corresponding bucket in a routing table for a given identifier
-         */
-       public Bucket findBucket(int id) {
-               int xorNumber = id ^ this.id;
-//             Msg.info("Number:" + xorNumber.toString(16));
-               int prefix = this.getNodePrefix(xorNumber);                             
-               
-               return buckets.get(prefix);
-       }
-       /**
-        * Updates the routing table with a new value.
-        */
-       public void update(int id) {
+  /* Bucket list */
+  private Vector<Bucket> buckets;
+  /* Id of the routing table owner */
+  private int id;
+
+  public RoutingTable(int id) {
+    this.id = id;
+    buckets = new Vector<Bucket>();
+    for (int i = 0; i < Common.IDENTIFIER_SIZE + 1; i++) {
+      buckets.add(new Bucket(i));
+    }
+  }
+
+  /**
+   * @brief Returns an identifier which is in a specific bucket of a routing table
+   * @param id id of the routing table owner
+   * @param prefix id of the bucket where we want that identifier to be
+   */
+  public int getIdInPrefix(int id, int prefix) {
+    if (prefix == 0) {
+      return 0;
+    }
+    int identifier = 1;
+    identifier = identifier << (prefix - 1);
+    identifier = identifier ^ id;
+    return identifier;
+  }
+
+  /* Returns the corresponding node prefix for a given id */
+  public int getNodePrefix(int id) {
+    for (int j = 0; j < 32; j++) {
+      if ((id >> (32 - 1 - j) & 0x1) != 0) {
+        return 32 - j;
+      }
+    }
+    return 0;
+  }
+
+  /* Finds the corresponding bucket in a routing table for a given identifier */
+  public Bucket findBucket(int id) {
+    int xorNumber = id ^ this.id;
+    int prefix = this.getNodePrefix(xorNumber);
+    return buckets.get(prefix);
+  }
+
+  /* Updates the routing table with a new value. */
+  public void update(int id) {
+    Bucket bucket = this.findBucket(id);
+    if (bucket.contains(id)) {
+      Msg.debug("Updating " + Integer.toString(id) + " in my routing table");
+      //If the element is already in the bucket, we update it.
+      bucket.pushToFront(id);
+    } else {
+      Msg.debug("Adding " + id + " to my routing table");
+      bucket.add(id);
+      if (bucket.size() > Common.BUCKET_SIZE)  {
+        //TODO: Ping the least seen guy and remove him if he is offline.
+      }
+    }
+  }
 
-               Bucket bucket = this.findBucket(id);
-               if (bucket.contains(id)) {
-                       Msg.debug("Updating " + Integer.toString(id) + " in my routing table");
-                       //If the element is already in the bucket, we update it.
-                       bucket.pushToFront(id);
-               }
-               else {
-                       Msg.debug("Adding " + id + " to my routing table");
-                       bucket.add(id);
-                       if (bucket.size() > Common.BUCKET_SIZE)  {
-                               //TODO: Ping the least seen guy and remove him if he is offline.
-                       }
-               }
-       }
-       /**
-        * Returns the closest notes we know to a given id 
-        */
-       public Answer findClosest(int destinationId) {
-               Answer answer = new Answer(destinationId);
+  /* Returns the closest notes we know to a given id */
+  public Answer findClosest(int destinationId) {
+    Answer answer = new Answer(destinationId);
+    Bucket bucket = this.findBucket(destinationId);
+    bucket.addToAnswer(answer,destinationId);
 
-               
-               Bucket bucket = this.findBucket(destinationId);
-               bucket.addToAnswer(answer,destinationId);
-               
-               for (int i = 1; answer.size() < Common.BUCKET_SIZE && 
-               ((bucket.getId() - i) >= 0 ||
-               (bucket.getId() + i) <= Common.IDENTIFIER_SIZE); i++) {
-                       //Check the previous buckets
-                       if (bucket.getId() - i >= 0) {
-                               Bucket bucketP = this.buckets.get(bucket.getId() - i);
-                               bucketP.addToAnswer(answer,destinationId);
-                       }
-                       //Check the next buckets
-                       if (bucket.getId() + i <= Common.IDENTIFIER_SIZE) {
-                               Bucket bucketN = this.buckets.get(bucket.getId() + i);
-                               bucketN.addToAnswer(answer, destinationId);
-                       }
-               }
-               //We sort the list
-               Collections.sort(answer.getNodes());
-               //We trim the list
-               while (answer.size() > Common.BUCKET_SIZE) {
-                       answer.remove(answer.size() - 1); //TODO: Not the best thing.
-               }
-               
-               return answer;
-       }
-       
-       @Override
-       public String toString() {
-               String string = "RoutingTable [ id=" + id + " " ;
-               for (int i = 0; i < buckets.size(); i++) {
-                       if (buckets.get(i).size() > 0) {
-                               string += buckets.get(i) + " ";
-                       }
-               }
-               return string;
-       }
+    for (int i = 1; answer.size() < Common.BUCKET_SIZE && ((bucket.getId() - i) >= 0 ||
+                                    (bucket.getId() + i) <= Common.IDENTIFIER_SIZE); i++) {
+      //Check the previous buckets
+      if (bucket.getId() - i >= 0) {
+        Bucket bucketP = this.buckets.get(bucket.getId() - i);
+        bucketP.addToAnswer(answer,destinationId);
+      }
+      //Check the next buckets
+      if (bucket.getId() + i <= Common.IDENTIFIER_SIZE) {
+        Bucket bucketN = this.buckets.get(bucket.getId() + i);
+        bucketN.addToAnswer(answer, destinationId);
+      }
+    }
+    //We sort the list
+    Collections.sort(answer.getNodes());
+    //We trim the list
+    while (answer.size() > Common.BUCKET_SIZE) {
+      answer.remove(answer.size() - 1); //TODO: Not the best thing.
+    }
+    return answer;
+  }
 
+  @Override
+  public String toString() {
+    String string = "RoutingTable [ id=" + id + " " ;
+    for (int i = 0; i < buckets.size(); i++) {
+      if (buckets.get(i).size() > 0) {
+        string += buckets.get(i) + " ";
+      }
+    }
+    return string;
+  }
 }
index 7315a7e..4ea6551 100644 (file)
@@ -1,28 +1,23 @@
 <?xml version='1.0'?>
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
 <platform version="4">
-
   <process host="Jacquelin" function="kademlia.Node">
     <argument value="0"/>        <!-- my id -->
-    <argument value ="900"/>           <!-- deadline -->
+    <argument value ="900"/>     <!-- deadline -->
   </process>
-
   <process host="Boivin" function="kademlia.Node">
     <argument value="1"/>        <!-- my id -->
-    <argument value="0"/>         <!-- known id -->
-    <argument value ="900"/>           <!-- deadline -->
+    <argument value="0"/>        <!-- known id -->
+    <argument value ="900"/>     <!-- deadline -->
   </process>
-
   <process host="Jean_Yves" function="kademlia.Node">
     <argument value="2"/>        <!-- my id -->
-    <argument value="0"/>         <!-- known id -->
-    <argument value ="900"/>           <!-- deadline -->
+    <argument value="0"/>        <!-- known id -->
+    <argument value ="900"/>     <!-- deadline -->
   </process>
-
   <process host="TeX" function="kademlia.Node">
     <argument value="4"/>        <!-- my id -->
-    <argument value="0"/>         <!-- known id -->
-    <argument value ="900"/>           <!-- deadline -->  
+    <argument value="0"/>        <!-- known id -->
+    <argument value ="900"/>     <!-- deadline -->  
   </process>
-
 </platform>
index 349c954..27a2553 100644 (file)
@@ -30,9 +30,3 @@ set(examples_src
   ${examples_src}
   ${sources}
   PARENT_SCOPE)
-set(bin_files
-  ${bin_files}
-  PARENT_SCOPE)
-set(txt_files
-  ${txt_files}
-  PARENT_SCOPE)
index 5fda9f5..1946306 100644 (file)
@@ -1,42 +1,42 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package migration;
-
-import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.Task;
 import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
 
 public class Emigrant extends Process {
-       public Emigrant(Host host, String name, String[]args) {
-               super(host,name,args);
-       }
-       public void main(String[] args) throws MsgException {           
-               Migration.mutex.acquire();
-               
-               Msg.info("I'll look for a new job on another machine where the grass is greener.");
-               migrate(Host.getByName("Boivin"));
-               
-               Msg.info("Yeah, found something to do");
-               Task task = new Task("job", 98095000, 0);
-               task.execute();
-               waitFor(2);
-               
-               Msg.info("Moving back to home after work");
-               migrate(Host.getByName("Jacquelin"));
-               migrate(Host.getByName("Boivin"));
-               waitFor(4);
-               
-               Migration.processToMigrate = this;
-               Migration.mutex.release();              
-               suspend();
-                       
-               Msg.info("I've been moved on this new host:" + getHost().getName());
-               Msg.info("Uh, nothing to do here. Stopping now");
-       }
+  public Emigrant(Host host, String name, String[]args) {
+    super(host,name,args);
+  }
+
+  public void main(String[] args) throws MsgException {    
+    Migration.mutex.acquire();
+    
+    Msg.info("I'll look for a new job on another machine where the grass is greener.");
+    migrate(Host.getByName("Boivin"));
+
+    Msg.info("Yeah, found something to do");
+    Task task = new Task("job", 98095000, 0);
+    task.execute();
+    waitFor(2);
+
+    Msg.info("Moving back to home after work");
+    migrate(Host.getByName("Jacquelin"));
+    migrate(Host.getByName("Boivin"));
+    waitFor(4);
+
+    Migration.processToMigrate = this;
+    Migration.mutex.release();
+    suspend();
+
+    Msg.info("I've been moved on this new host:" + getHost().getName());
+    Msg.info("Uh, nothing to do here. Stopping now");
+  }
 }
\ No newline at end of file
index 97aa53b..37509a0 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,37 +7,28 @@
 package migration;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Mutex;
-import org.simgrid.msg.NativeException;
 import org.simgrid.msg.Process;
-/**
- * Demonstrates the use of Task.setPriority to change
- * the computation priority of a task
- */ 
-public class Migration  {
-       public static Mutex mutex;
-       public static Process processToMigrate = null;
-       
-   /* This only contains the launcher. If you do nothing more than than you can run 
-    *   java simgrid.msg.Msg
-    * which also contains such a launcher
-    */
-    
-    public static void main(String[] args) throws NativeException {            
-               /* initialize the MSG simulation. Must be done before anything else (even logging). */
-               Msg.init(args);
-               if(args.length < 2) {
-                       Msg.info("Usage   : Priority platform_file deployment_file");
-               Msg.info("example : Priority ping_pong_platform.xml ping_pong_deployment.xml");
-               System.exit(1);
-               }
-               /* Create the mutex */
-               mutex = new Mutex();            
-               
-               /* construct the platform and deploy the application */
-               Msg.createEnvironment(args[0]);
-               Msg.deployApplication(args[1]);
-               
-               /*  execute the simulation. */
-           Msg.run();
+import org.simgrid.msg.NativeException;
+
+public class Migration {
+  public static Mutex mutex;
+  public static Process processToMigrate = null;
+
+  public static void main(String[] args) throws NativeException {      
+    Msg.init(args);
+    if(args.length < 2) {
+      Msg.info("Usage   : Migration platform_file deployment_file");
+      Msg.info("example : Migration ../platforms/platform.xml migrationDeployment.xml");
+      System.exit(1);
     }
+    /* Create the mutex */
+    mutex = new Mutex();
+
+    /* construct the platform and deploy the application */
+    Msg.createEnvironment(args[0]);
+    Msg.deployApplication(args[1]);
+
+    /*  execute the simulation. */
+    Msg.run();
+  }
 }
index 664dd33..3d4cfb4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -6,26 +6,26 @@
 
 package migration;
 
-import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
 
 public class Policeman extends Process {
-       public Policeman(Host host, String name, String[]args) {
-               super(host,name,args);
-       }
+  public Policeman(Host host, String name, String[]args) {
+    super(host,name,args);
+  }
 
-       @Override
-       public void main(String[] args) throws MsgException {
-               waitFor(1);
-               
-               Msg.info("Wait a bit before migrating the emigrant.");
-               
-               Migration.mutex.acquire();
-               
-               Migration.processToMigrate.migrate(Host.getByName("Jacquelin"));
-               Msg.info("I moved the emigrant");
-               Migration.processToMigrate.resume();
-       }
+  @Override
+  public void main(String[] args) throws MsgException {
+    waitFor(1);
+    
+    Msg.info("Wait a bit before migrating the emigrant.");
+    
+    Migration.mutex.acquire();
+    
+    Migration.processToMigrate.migrate(Host.getByName("Jacquelin"));
+    Msg.info("I moved the emigrant");
+    Migration.processToMigrate.resume();
+  }
 }
\ No newline at end of file
index 2c8c3d6..02048a8 100644 (file)
@@ -33,9 +33,3 @@ set(examples_src
   ${examples_src}
   ${sources}
   PARENT_SCOPE)
-set(bin_files
-  ${bin_files}
-  PARENT_SCOPE)
-set(txt_files
-  ${txt_files}
-  PARENT_SCOPE)
index 7a0e0a6..f605279 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,45 +7,44 @@
 package mutualExclusion;
 import java.util.LinkedList;
 
-import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.Task;
 import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
 
+public class Coordinator extends Process {
+  public Coordinator(Host host, String name, String[]args) {
+    super(host,name,args);
+  }
+  LinkedList<RequestTask> waitingQueue=new LinkedList<RequestTask>();
+  int CsToServe;
 
-public class Coordinator extends Process  {
-    public Coordinator(Host host, String name, String[]args) {
-               super(host,name,args);
-    } 
-       LinkedList<RequestTask> waitingQueue=new LinkedList<RequestTask>();
-       int CsToServe;
-               
-       public void main(String[] args) throws MsgException {
-               CsToServe = Integer.parseInt(args[0]);
-               Task task;
-               while (CsToServe >0) {
-                       task = Task.receive("coordinator");
-                       if (task instanceof RequestTask) {
-                               RequestTask t = (RequestTask) task;
-                               if (waitingQueue.isEmpty()) {
-                                  Msg.info("Got a request from "+t.from+". Queue empty: grant it");
-                                       GrantTask tosend =  new GrantTask();
-                                       tosend.send(t.from);
-                               } else {
-                                       waitingQueue.addFirst(t);
-                               }
-                       } else if (task instanceof ReleaseTask) {
-                               if (!waitingQueue.isEmpty()) {
-                                       RequestTask req = waitingQueue.removeLast();
-                                       GrantTask tosend = new GrantTask();
-                                       tosend.send(req.from);
-                               }
-                               CsToServe--;
-                               if (waitingQueue.isEmpty() && CsToServe==0) {
-                                       Msg.info("we should shutdown the simulation now");
-                               }
-                       }
-               }
-       }
+  public void main(String[] args) throws MsgException {
+    CsToServe = Integer.parseInt(args[0]);
+    Task task;
+    while (CsToServe >0) {
+      task = Task.receive("coordinator");
+      if (task instanceof RequestTask) {
+        RequestTask t = (RequestTask) task;
+        if (waitingQueue.isEmpty()) {
+          Msg.info("Got a request from "+t.from+". Queue empty: grant it");
+          GrantTask tosend =  new GrantTask();
+          tosend.send(t.from);
+        } else {
+          waitingQueue.addFirst(t);
+        }
+      } else if (task instanceof ReleaseTask) {
+        if (!waitingQueue.isEmpty()) {
+          RequestTask req = waitingQueue.removeLast();
+          GrantTask tosend = new GrantTask();
+          tosend.send(req.from);
+        }
+        CsToServe--;
+        if (waitingQueue.isEmpty() && CsToServe==0) {
+          Msg.info("we should shutdown the simulation now");
+        }
+      }
+    }
+  }
 }
index 79e19d0..fb405a9 100644 (file)
@@ -1,12 +1,8 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package mutualExclusion;
-import org.simgrid.msg.Task;
-
-
-public class GrantTask extends Task {
-}
+public class GrantTask extends org.simgrid.msg.Task {}
index d5da381..ef1fc02 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -10,29 +10,21 @@ import org.simgrid.msg.Msg;
 import org.simgrid.msg.NativeException;
 
 public class MutexCentral {
-
-       /* This only contains the launcher. If you do nothing more than than you can run 
-        *   java simgrid.msg.Msg
-        * which also contains such a launcher
-        */
-
-       public static void main(String[] args) throws NativeException {
-
-               /* initialize the MSG simulation. Must be done before anything else (even logging). */
-               Msg.init(args);
-
-               if(args.length < 2) {
-                       Msg.info("Usage: Basic platform_file deployment_file");
-                       Msg.info("Fallback to default values");
-                       Msg.createEnvironment("../ring3.xml");
-                       Msg.deployApplication("mutex_centralized_deployment.xml");
-               } else {
-                       /* construct the platform and deploy the application */
-                       Msg.createEnvironment(args[0]);
-                       Msg.deployApplication(args[1]);
-               }
-               
-               /*  execute the simulation. */
-               Msg.run();
-       }
+  public static void main(String[] args) throws NativeException {
+    Msg.init(args);
+
+    if(args.length < 2) {
+      Msg.info("Usage: MutexCentral platform_file deployment_file");
+      Msg.info("Fallback to default values");
+      Msg.createEnvironment("../platform/small_platform.xml");
+      Msg.deployApplication("mutex_centralized_deployment.xml");
+    } else {
+      /* construct the platform and deploy the application */
+      Msg.createEnvironment(args[0]);
+      Msg.deployApplication(args[1]);
+    }
+
+    /*  execute the simulation. */
+    Msg.run();
+  }
 }
index 55d91e3..353dfd7 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -6,29 +6,29 @@
 
 package mutualExclusion;
 
-import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.Task;
 import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
 
 public class Node extends Process {
-    public Node(Host host, String name, String[]args) {
-               super(host,name,args);
-    } 
-       public void request(double CStime) throws MsgException {
-               RequestTask req = new RequestTask(getName());
-          Msg.info("Send a request to the coordinator");
-               req.send("coordinator");
-          Msg.info("Wait for a grant from the coordinator");
-               Task.receive(getName()); // FIXME: ensure that this is a grant
-               Task compute = new Task("CS", CStime, 0);
-               compute.execute();
-               ReleaseTask release = new ReleaseTask();
-               release.send("coordinator");
-       }
-       
-       public void main(String[] args) throws MsgException {
-               request(Double.parseDouble(args[1]));
-       }
+  public Node(Host host, String name, String[]args) {
+   super(host,name,args);
+  }
+  public void request(double CStime) throws MsgException {
+    RequestTask req = new RequestTask(getName());
+    Msg.info("Send a request to the coordinator");
+    req.send("coordinator");
+    Msg.info("Wait for a grant from the coordinator");
+    Task.receive(getName()); // FIXME: ensure that this is a grant
+    Task compute = new Task("CS", CStime, 0);
+    compute.execute();
+    ReleaseTask release = new ReleaseTask();
+    release.send("coordinator");
+  }
+
+  public void main(String[] args) throws MsgException {
+    request(Double.parseDouble(args[1]));
+  }
 }
\ No newline at end of file
index 6348116..2a0e020 100644 (file)
@@ -1,9 +1,8 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package mutualExclusion;
-public class ReleaseTask extends org.simgrid.msg.Task {
-}
+public class ReleaseTask extends org.simgrid.msg.Task {}
index 225d16b..1b86e4b 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -8,9 +8,9 @@ package mutualExclusion;
 import org.simgrid.msg.Task;
 
 public class RequestTask extends Task {
-       String from;
-       public RequestTask(String name) {
-               super();
-               from=name;
-       }
+  String from;
+  public RequestTask(String name) {
+    super();
+    from=name;
+  }
 }
index 4abc36c..0f92c30 100644 (file)
@@ -2,14 +2,14 @@
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
 <platform version="4">
   <process host="Tremblay" function="mutualExclusion.Coordinator">
-      <argument value="2"/> <!-- Amount of CS to serve -->
+    <argument value="2"/> <!-- Amount of CS to serve -->
   </process>
   <process host="Jupiter" function="mutualExclusion.Node">
-      <argument value="2"/> <!-- initial sleep time -->
-      <argument value="5"/> <!-- CS time -->
+    <argument value="2"/> <!-- initial sleep time -->
+    <argument value="5"/> <!-- CS time -->
   </process>
   <process host="Fafard" function="mutualExclusion.Node">
-      <argument value="2"/> <!-- initial sleep time -->
-      <argument value="5"/> <!-- CS time -->
+    <argument value="2"/> <!-- initial sleep time -->
+    <argument value="5"/> <!-- CS time -->
   </process>
 </platform>
index 001a23b..1132494 100644 (file)
@@ -31,10 +31,3 @@ set(examples_src
   ${examples_src}
   ${sources}
   PARENT_SCOPE)
-set(bin_files
-  ${bin_files}
-  PARENT_SCOPE)
-set(txt_files
-  ${txt_files}
-  ${CMAKE_CURRENT_SOURCE_DIR}/README
-  PARENT_SCOPE)
index 76f7fff..17f2bed 100644 (file)
@@ -1,31 +1,29 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package pingPong;
-import org.simgrid.msg.NativeException;
 import org.simgrid.msg.Task;
+import org.simgrid.msg.NativeException;
 
 public class PingPongTask extends Task {
-   
-   private double timeVal;
-   
-   public PingPongTask() throws NativeException {
-      this.timeVal = 0;
-   }
-   
-   public PingPongTask(String name, double computeDuration, double messageSize) throws NativeException {      
-      super(name,computeDuration,messageSize);         
-   }
-   
-   public void setTime(double timeVal){
-      this.timeVal = timeVal;
-   }
-   
-   public double getTime() {
-      return this.timeVal;
-   }
+  private double timeVal;
+
+  public PingPongTask() throws NativeException {
+    this.timeVal = 0;
+  }
+
+  public PingPongTask(String name, double computeDuration, double messageSize) throws NativeException {
+    super(name,computeDuration,messageSize);
+  }
+
+  public void setTime(double timeVal) {
+    this.timeVal = timeVal;
+  }
+
+  public double getTime() {
+    return this.timeVal;
+  }
 }
-    
\ No newline at end of file
index 04f71d9..cb7ef02 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -8,27 +8,20 @@ package pingPong;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.NativeException;
  
-public class PingPongTest  {
+public class PingPongTest {
+  public static void main(String[] args) throws NativeException {
+    Msg.init(args);
+    if(args.length < 2) {
+      Msg.info("Usage   : PingPongTest platform_file deployment_file");
+      Msg.info("example : PingPongTest ../platforms/platform.xml pingPongDeployment.xml");
+      System.exit(1);
+    }
 
-   /* This only contains the launcher. If you do nothing more than than you can run 
-    *   java simgrid.msg.Msg
-    * which also contains such a launcher
-    */
+    /* construct the platform and deploy the application */
+    Msg.createEnvironment(args[0]);
+    Msg.deployApplication(args[1]);
     
-    public static void main(String[] args) throws NativeException {            
-               /* initialize the MSG simulation. Must be done before anything else (even logging). */
-               Msg.init(args);
-               if(args.length < 2) {
-                       Msg.info("Usage   : PingPong platform_file deployment_file");
-               Msg.info("example : PingPong ping_pong_platform.xml ping_pong_deployment.xml");
-               System.exit(1);
-               }
-       
-               /* construct the platform and deploy the application */
-               Msg.createEnvironment(args[0]);
-               Msg.deployApplication(args[1]);
-               
-               /*  execute the simulation. */
-           Msg.run();
-    }
+    /*  execute the simulation. */
+    Msg.run();
+  }
 }
diff --git a/examples/java/pingPong/README b/examples/java/pingPong/README
deleted file mode 100644 (file)
index aa16de9..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-This is a stupid ping/pong example. The processes exchange a simple
-task and time them.
\ No newline at end of file
index 57e69cf..0d6f1ce 100644 (file)
@@ -5,41 +5,38 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package pingPong;
-import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.Task;
 import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
 
 public class Receiver extends Process {
-   public Receiver(Host host, String name, String[]args) {
-               super(host,name,args);
-   } 
-   final double commSizeLat = 1;
-   final double commSizeBw = 100000000;
-    
-   public void main(String[] args) throws MsgException {
-        
-      Msg.info("hello!");
-      double communicationTime=0;
-
-      double time = Msg.getClock();
-    
-      Msg.info("try to get a task");
-        
-      PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
-      double timeGot = Msg.getClock();
-      double timeSent = task.getTime();
-            
-      Msg.info("Got at time "+ timeGot);
-      Msg.info("Was sent at time "+timeSent);
-      time=timeSent;
-            
-      communicationTime=timeGot - time;
-      Msg.info("Communication time : " + communicationTime);
-            
-      Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
-            
-      Msg.info("goodbye!");
-    }
+  final double commSizeLat = 1;
+  final double commSizeBw = 100000000;
+  public Receiver(Host host, String name, String[]args) {
+    super(host,name,args);
+  }
+
+  public void main(String[] args) throws MsgException {
+    Msg.info("hello!");
+    double communicationTime=0;
+
+    double time = Msg.getClock();
+
+    Msg.info("try to get a task");
+
+    PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
+    double timeGot = Msg.getClock();
+    double timeSent = task.getTime();
+
+    Msg.info("Got at time "+ timeGot);
+    Msg.info("Was sent at time "+timeSent);
+    time=timeSent;
+
+    communicationTime=timeGot - time;
+    Msg.info("Communication time : " + communicationTime);
+    Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
+    Msg.info("goodbye!");
+  }
 }
\ No newline at end of file
index 52fbab1..530b67a 100644 (file)
@@ -1,55 +1,55 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package pingPong;
-import org.simgrid.msg.Host;
-import org.simgrid.msg.HostNotFoundException;
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.HostNotFoundException;
 
 public class Sender extends Process {
-       public Sender(Host host, String name, String[] args) {
-               super(host,name,args);
-       }
-    private final double commSizeLat = 1;
-    final double commSizeBw = 100000000;
-   
-    public void main(String[] args) throws MsgException {
-       
-       Msg.info("hello!");
-        
-       int hostCount = args.length;
-        
-       Msg.info("host count: " + hostCount);
-       String mailboxes[] = new String[hostCount]; 
-       double time;
-       double computeDuration = 0;
-       PingPongTask task;
-        
-       for(int pos = 0; pos < args.length ; pos++) {
-         try {
-            mailboxes[pos] = Host.getByName(args[pos]).getName();
-         } catch (HostNotFoundException e) {
-            Msg.info("Invalid deployment file: " + e.toString());           
-            System.exit(1);
-         }
-        }
-        
-        for (int pos = 0; pos < hostCount; pos++) { 
-          time = Msg.getClock(); 
-            
-          Msg.info("sender time: " + time);
-          
-          task = new PingPongTask("no name",computeDuration,commSizeLat);
-          task.setTime(time);
-            
-          task.send(mailboxes[pos]);
-        } 
-        
-        Msg.info("goodbye!");
+  private final double commSizeLat = 1;
+  final double commSizeBw = 100000000;
+
+  public Sender(Host host, String name, String[] args) {
+    super(host,name,args);
+  }
+
+  public void main(String[] args) throws MsgException {
+    Msg.info("hello!");
+
+    int hostCount = args.length;
+
+    Msg.info("host count: " + hostCount);
+    String mailboxes[] = new String[hostCount]; 
+    double time;
+    double computeDuration = 0;
+    PingPongTask task;
+
+    for(int pos = 0; pos < args.length ; pos++) {
+      try {
+        mailboxes[pos] = Host.getByName(args[pos]).getName();
+      } catch (HostNotFoundException e) {
+        Msg.info("Invalid deployment file: " + e.toString());
+        System.exit(1);
+      }
+    }
+
+    for (int pos = 0; pos < hostCount; pos++) { 
+      time = Msg.getClock(); 
+
+      Msg.info("sender time: " + time);
+
+      task = new PingPongTask("no name",computeDuration,commSizeLat);
+      task.setTime(time);
+
+      task.send(mailboxes[pos]);
     }
+
+    Msg.info("goodbye!");
+  }
 }
\ No newline at end of file
index 16f5860..c7eec34 100644 (file)
@@ -2,7 +2,7 @@
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
 <platform version="4">
   <process host="Jacquelin" function="pingPong.Sender">
-      <argument value="Boivin"/>
+    <argument value="Boivin"/>
   </process>
-<process host="Boivin" function="pingPong.Receiver"/>
+  <process host="Boivin" function="pingPong.Receiver"/>
 </platform>
index b23c0c1..1eb9ee4 100644 (file)
@@ -29,9 +29,3 @@ set(examples_src
   ${examples_src}
   ${sources}
   PARENT_SCOPE)
-set(bin_files
-  ${bin_files}
-  PARENT_SCOPE)
-set(txt_files
-  ${txt_files}
-  PARENT_SCOPE)
index 2462ca0..10fa76a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,31 +7,22 @@
 package priority;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.NativeException;
-/**
- * Demonstrates the use of Task.setPriority to change
- * the computation priority of a task
- */ 
-public class Priority  {
 
-   /* This only contains the launcher. If you do nothing more than than you can run 
-    *   java simgrid.msg.Msg
-    * which also contains such a launcher
-    */
-    
-    public static void main(String[] args) throws NativeException {            
-               /* initialize the MSG simulation. Must be done before anything else (even logging). */
-               Msg.init(args);
-               if(args.length < 2) {
-                       Msg.info("Usage   : Priority platform_file deployment_file");
-               Msg.info("example : Priority ping_pong_platform.xml ping_pong_deployment.xml");
-               System.exit(1);
-               }
-       
-               /* construct the platform and deploy the application */
-               Msg.createEnvironment(args[0]);
-               Msg.deployApplication(args[1]);
-               
-               /*  execute the simulation. */
-           Msg.run();
+/* Demonstrates the use of Task.setPriority to change the computation priority of a task */ 
+public class Priority  {
+  public static void main(String[] args) throws NativeException {
+    Msg.init(args);
+    if(args.length < 2) {
+      Msg.info("Usage   : Priority platform_file deployment_file");
+      Msg.info("example : Priority ../platforms/platform.xml priorityDeployment.xml");
+      System.exit(1);
     }
+
+    /* construct the platform and deploy the application */
+    Msg.createEnvironment(args[0]);
+    Msg.deployApplication(args[1]);
+
+    /*  execute the simulation. */
+    Msg.run();
+  }
 }
index 14370f3..8fb44d3 100644 (file)
@@ -1,34 +1,35 @@
-/* Copyright (c) 2012-2014. The SimGrid Team.
+/* Copyright (c) 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package priority;
-import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.Task;
 import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
 
 public class Test extends Process {
-       public Test(Host host, String name, String[]args) {
-               super(host,name,args);
-       }
-       public void main(String[] args) throws MsgException {   
-               double computationAmount = 1.0;
-               double priority = 1.0;
-               
-               computationAmount = Double.valueOf(args[0]);
-               priority = Double.valueOf(args[1]);
-               
-               Msg.info("Hello! Running a task of size " + computationAmount + " with priority " + priority);
-               
-               Task task = new Task("Task", computationAmount, 0);
-               task.setPriority(priority);
-               
-               task.execute();
-               
-               Msg.info("Goodbye now!");
-       }
+  public Test(Host host, String name, String[]args) {
+    super(host,name,args);
+  }
+
+  public void main(String[] args) throws MsgException {  
+    double computationAmount = 1.0;
+    double priority = 1.0;
+
+    computationAmount = Double.valueOf(args[0]);
+    priority = Double.valueOf(args[1]);
+
+    Msg.info("Hello! Running a task of size " + computationAmount + " with priority " + priority);
+
+    Task task = new Task("Task", computationAmount, 0);
+    task.setPriority(priority);
+
+    task.execute();
+
+    Msg.info("Goodbye now!");
+  }
 }
index acfe44b..1a1bdc5 100644 (file)
@@ -24,18 +24,9 @@ set(tesh_files
   PARENT_SCOPE)
 set(xml_files
   ${xml_files}
-  ${CMAKE_CURRENT_SOURCE_DIR}/deployment.xml
-  ${CMAKE_CURRENT_SOURCE_DIR}/deployment_kill.xml
-  ${CMAKE_CURRENT_SOURCE_DIR}/deployment_start.xml
   ${CMAKE_CURRENT_SOURCE_DIR}/deployment_start_kill.xml
   PARENT_SCOPE)
 set(examples_src
   ${examples_src}
   ${sources}
   PARENT_SCOPE)
-set(bin_files
-  ${bin_files}
-  PARENT_SCOPE)
-set(txt_files
-  ${txt_files}
-  PARENT_SCOPE)
index 270c4a6..593e39a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -14,13 +14,13 @@ import org.simgrid.msg.TransferFailureException;
 
 
 public class Master extends Process {
-       public Master(Host host, String name, String[]args) {
-               super(host,name,args);
-       } 
-       public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
-               Msg.info("Hello!");
-               waitFor(10.0);
-               Msg.info("OK, goodbye now.");
-       
+  public Master(Host host, String name, String[]args) {
+    super(host,name,args);
+  }
+
+  public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
+    Msg.info("Hello!");
+    waitFor(10.0);
+    Msg.info("OK, goodbye now.");
   }
 }
index 0018b6e..d8feef4 100644 (file)
@@ -1,33 +1,28 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package startKillTime;
-import org.simgrid.msg.Host;
-import org.simgrid.msg.HostFailureException;
 import org.simgrid.msg.Msg;
-import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.Process;
-import org.simgrid.msg.TimeoutException;
-import org.simgrid.msg.TransferFailureException;
+import org.simgrid.msg.MsgException;
 
-/**
- * Lazy Guy Slave, suspends itself ASAP
- */
+/* Lazy Guy Slave, suspends itself ASAP */
 public class Slave extends Process {
-       public Slave(Host host, String name, String[]args) {
-               super(host,name,args);
-       } 
-       public void main(String[] args) throws TransferFailureException, HostFailureException, TimeoutException {
-               Msg.info("Hello!");
-                try {
-                        waitFor(10.0);
-                        Msg.info("OK, goodbye now.");
-                } catch (MsgException e) {
-                        Msg.debug("Wait cancelled.");
-                }
-       
+  public Slave(Host host, String name, String[]args) {
+    super(host,name,args);
+  }
+
+  public void main(String[] args) throws MsgException {
+    Msg.info("Hello!");
+    try {
+      waitFor(10.0);
+      Msg.info("OK, goodbye now.");
+    } catch (MsgException e) {
+      Msg.debug("Wait cancelled.");
+    }
   }
 }
index 8daffbe..b7240b3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -7,28 +7,20 @@
 package startKillTime;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.NativeException;
-public class StartKillTime  {
 
-   /* This only contains the launcher. If you do nothing more than than you can run 
-    *   java org.simgrid.msg.Msg
-    * which also contains such a launcher
-    */
-    
-    public static void main(String[] args) throws NativeException {            
-               /* initialize the MSG simulation. Must be done before anything else (even logging). */
-               Msg.init(args);
-               if(args.length < 2) {
-                       Msg.info("Usage   : StartKilltime platform_file deployment_file");
-               Msg.info("example : StartKilltime platform.xml startKilltime.xml");
-               System.exit(1);
-               }
-       
-               /* construct the platform and deploy the application */
-               Msg.createEnvironment(args[0]);
-               Msg.deployApplication(args[1]);
-               
-               /*  execute the simulation. */
-           Msg.run();
+public class StartKillTime {
+  public static void main(String[] args) throws NativeException {      
+    Msg.init(args);
+    if(args.length < 2) {
+      Msg.info("Usage   : StartKilltime platform_file deployment_file");
+      Msg.info("example : StartKilltime ../platforms/platform.xml deployment_start_kill.xml");
+      System.exit(1);
     }
+    /* construct the platform and deploy the application */
+    Msg.createEnvironment(args[0]);
+    Msg.deployApplication(args[1]);
+
+    /*  execute the simulation. */
+    Msg.run();
+  }
 }
diff --git a/examples/java/startKillTime/deployment.xml b/examples/java/startKillTime/deployment.xml
deleted file mode 100644 (file)
index 0bbd654..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
-   <process host="Jacquelin" function="startKillTime.Master"/>
-  <process host="Boivin" function="startKillTime.Slave"/>
-       <process host="Jean_Yves" function="startKillTime.Slave"/>
-       <process host="TeX" function="startKillTime.Slave"/>
-       <process host="Geoff" function="startKillTime.Slave"/>
-       <process host="Disney" function="startKillTime.Slave"/>
-</platform>
diff --git a/examples/java/startKillTime/deployment_kill.xml b/examples/java/startKillTime/deployment_kill.xml
deleted file mode 100644 (file)
index 4270dc0..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
-   <process host="Jacquelin" function="startKillTime.Master"/>
-  <process host="Boivin" function="startKillTime.Slave"  kill_time="5"/>
-       <process host="Jean_Yves" function="startKillTime.Slave" kill_time="6"/>
-       <process host="TeX" function="startKillTime.Slave"  kill_time="7"/>
-       <process host="Geoff" function="startKillTime.Slave" kill_time="8"/>
-       <process host="Disney" function="startKillTime.Slave" kill_time="9"/>
-</platform>
diff --git a/examples/java/startKillTime/deployment_start.xml b/examples/java/startKillTime/deployment_start.xml
deleted file mode 100644 (file)
index 7e33054..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
-  <process host="Jacquelin" function="startKillTime.Master"/>
-  <process host="Boivin" function="startKillTime.Slave" start_time="1" />
-       <process host="Jean_Yves" function="startKillTime.Slave" start_time="2"/>
-       <process host="TeX" function="startKillTime.Slave" start_time="3"/>
-       <process host="Geoff" function="startKillTime.Slave" start_time="4"/>
-       <process host="Disney" function="startKillTime.Slave" start_time="5"/>
-</platform>
index 5f083d8..d449286 100644 (file)
@@ -1,10 +1,10 @@
 <?xml version='1.0'?>
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
 <platform version="4">
-   <process host="Jacquelin" function="startKillTime.Master"/>
+  <process host="Jacquelin" function="startKillTime.Master"/>
   <process host="Boivin" function="startKillTime.Slave" start_time="1" kill_time="5"/>
-       <process host="Jean_Yves" function="startKillTime.Slave" start_time="2" kill_time="6"/>
-       <process host="TeX" function="startKillTime.Slave" start_time="3" kill_time="7"/>
-       <process host="Geoff" function="startKillTime.Slave" start_time="4" kill_time="8"/>
-       <process host="Disney" function="startKillTime.Slave" start_time="5" kill_time="9"/>
+  <process host="Jean_Yves" function="startKillTime.Slave" start_time="2" kill_time="6"/>
+  <process host="TeX" function="startKillTime.Slave" start_time="3" kill_time="7"/>
+  <process host="Geoff" function="startKillTime.Slave" start_time="4" kill_time="8"/>
+  <process host="Disney" function="startKillTime.Slave" start_time="5" kill_time="9"/>
 </platform>
index 07088a4..d978b49 100644 (file)
@@ -30,9 +30,3 @@ set(examples_src
   ${examples_src}
   ${sources}
   PARENT_SCOPE)
-set(bin_files
-  ${bin_files}
-  PARENT_SCOPE)
-set(txt_files
-  ${txt_files}
-  PARENT_SCOPE)
index 8dff985..6469b5a 100644 (file)
@@ -5,23 +5,24 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package suspend;
-
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Process;
 import org.simgrid.msg.MsgException;
+
 public class DreamMaster extends Process {
-       public DreamMaster(Host host, String name, String[]args) {
-               super(host,name,args);
-       } 
-       public void main(String[] args) throws MsgException {
-               Msg.info("Let's create a lazy guy.");
-               Process lazyGuy = new LazyGuy(getHost(),"Lazy",null);
-               lazyGuy.start();
-               Msg.info("Let's wait a little bit...");
-               waitFor(10);
-               Msg.info("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!");
-               lazyGuy.resume();
-               Msg.info("OK, goodbye now.");
-       }
+  public DreamMaster(Host host, String name, String[]args) {
+    super(host,name,args);
+  }
+
+  public void main(String[] args) throws MsgException {
+    Msg.info("Let's create a lazy guy.");
+    Process lazyGuy = new LazyGuy(getHost(),"Lazy",null);
+    lazyGuy.start();
+    Msg.info("Let's wait a little bit...");
+    waitFor(10);
+    Msg.info("Let's wake the lazy guy up! >:) BOOOOOUUUHHH!!!!");
+    lazyGuy.resume();
+    Msg.info("OK, goodbye now.");
+  }
 }
\ No newline at end of file
index ffad084..74231fe 100644 (file)
@@ -1,23 +1,24 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package suspend;
-
 import org.simgrid.msg.Host;
 import org.simgrid.msg.Msg;
 import org.simgrid.msg.Process;
 import org.simgrid.msg.MsgException;
+
 public class LazyGuy extends Process {
-       public LazyGuy(Host host, String name, String[]args) {
-               super(host,name,args);
-       } 
-       public void main(String[] args) throws MsgException {
-               Msg.info("Nobody's watching me ? Let's go to sleep.");
-               suspend();
-               Msg.info("Uuuh ? Did somebody call me ?");
-               Msg.info("Mmmh, goodbye now.");
-       }
+  public LazyGuy(Host host, String name, String[]args) {
+    super(host,name,args);
+  }
+
+  public void main(String[] args) throws MsgException {
+    Msg.info("Nobody's watching me ? Let's go to sleep.");
+    suspend();
+    Msg.info("Uuuh ? Did somebody call me ?");
+    Msg.info("Mmmh, goodbye now.");
+  }
 }
\ No newline at end of file
index 027ed8e..f6c19e0 100644 (file)
@@ -1,27 +1,25 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package suspend;
-
 import org.simgrid.msg.Msg;
 
 public class Suspend {
-       public static void main(String[] args) {
-               /* initialize the MSG simulation. Must be done before anything else (even logging). */
-               Msg.init(args);
-       if(args.length < 2) {
-               Msg.info("Usage   : Suspend platform_file deployment_file");
-               Msg.info("example : Suspend platform.xml deployment.xml");
-               System.exit(1);
-       }
-               /* construct the platform and deploy the application */
-               Msg.createEnvironment(args[0]);
-               Msg.deployApplication(args[1]);
-                       
-               /*  execute the simulation. */
-        Msg.run();             
-       }
+  public static void main(String[] args) {
+    Msg.init(args);
+    if(args.length < 2) {
+      Msg.info("Usage   : Suspend platform_file deployment_file");
+      Msg.info("example : Suspend ../platforms/platform.xml suspendDeployment.xml");
+      System.exit(1);
+    }
+    /* construct the platform and deploy the application */
+    Msg.createEnvironment(args[0]);
+    Msg.deployApplication(args[1]);
+
+    /*  execute the simulation. */
+    Msg.run();
+  }
 }
index 9dde98c..e21c754 100644 (file)
@@ -31,10 +31,3 @@ set(examples_src
   ${examples_src}
   ${sources}
   PARENT_SCOPE)
-set(bin_files
-  ${bin_files}
-  PARENT_SCOPE)
-set(txt_files
-  ${txt_files}
-  ${CMAKE_CURRENT_SOURCE_DIR}/README
-  PARENT_SCOPE)
index f43b69e..22ee817 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -9,23 +9,22 @@ import org.simgrid.msg.NativeException;
 import org.simgrid.msg.Task;
 
 public class PingPongTask extends Task {
-   
-   private double timeVal;
-   
-   public PingPongTask() throws NativeException {
-      this.timeVal = 0;
-   }
-   
-   public PingPongTask(String name, double computeDuration, double messageSize) throws NativeException {      
-      super(name,computeDuration,messageSize);         
-   }
-   
-   public void setTime(double timeVal){
-      this.timeVal = timeVal;
-   }
-   
-   public double getTime() {
-      return this.timeVal;
-   }
+  private double timeVal;
+
+  public PingPongTask() throws NativeException {
+    this.timeVal = 0;
+  }
+
+  public PingPongTask(String name, double computeDuration, double messageSize) throws NativeException {
+    super(name,computeDuration,messageSize);
+  }
+
+  public void setTime(double timeVal){
+    this.timeVal = timeVal;
+  }
+
+  public double getTime() {
+    return this.timeVal;
+  }
 }
-    
+
diff --git a/examples/java/tracing/README b/examples/java/tracing/README
deleted file mode 100644 (file)
index aa16de9..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-This is a stupid ping/pong example. The processes exchange a simple
-task and time them.
\ No newline at end of file
index 0cd91d4..d3d0a1a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2007, 2012-2014. The SimGrid Team.
+/* Copyright (c) 2006-2007, 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -13,49 +13,47 @@ import org.simgrid.msg.Process;
 import org.simgrid.trace.Trace;
 
 public class Receiver extends Process {
-  
-       private  final double commSizeLat = 1;
+  private  final double commSizeLat = 1;
   private final double commSizeBw = 100000000;
-                
-       public Receiver(Host host, String name, String[]args) {
-               super(host,name,args);
-   } 
-   
-   public void main(String[] args) throws MsgException {
-        
-      Msg.info("hello!");
-      Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPing");
-                       double communicationTime=0;
-
-      double time = Msg.getClock();
-    
-                       /* Wait for the ping */ 
-      Msg.info("try to get a task");
-        
-      PingPongTask ping = (PingPongTask)Task.receive(getHost().getName());
-      double timeGot = Msg.getClock();
-      double timeSent = ping.getTime();
-            
-      Msg.info("Got at time "+ timeGot);
-      Msg.info("Was sent at time "+timeSent);
-      time=timeSent;
-            
-      communicationTime=timeGot - time;
-      Msg.info("Communication time : " + communicationTime);
-            
-      Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
-      
-                       /* Send the pong */
-               Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPong");
-                       double computeDuration = 0;
-                       PingPongTask pong = new PingPongTask("no name",computeDuration,commSizeLat);
-                       pong.setTime(time);
-                       pong.send(ping.getSource().getName());
-
-               /* Pop the two states */
-      Trace.hostPopState (getHost().getName(), "PM_STATE");
-      Trace.hostPopState (getHost().getName(), "PM_STATE");
-  
-               Msg.info("goodbye!");
-    }
+
+  public Receiver(Host host, String name, String[]args) {
+    super(host,name,args);
+  } 
+
+  public void main(String[] args) throws MsgException {
+    Msg.info("hello!");
+    Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPing");
+    double communicationTime=0;
+
+    double time = Msg.getClock();
+
+    /* Wait for the ping */ 
+    Msg.info("try to get a task");
+
+    PingPongTask ping = (PingPongTask)Task.receive(getHost().getName());
+    double timeGot = Msg.getClock();
+    double timeSent = ping.getTime();
+
+    Msg.info("Got at time "+ timeGot);
+    Msg.info("Was sent at time "+timeSent);
+    time=timeSent;
+
+    communicationTime=timeGot - time;
+    Msg.info("Communication time : " + communicationTime);
+
+    Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
+
+    /* Send the pong */
+    Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPong");
+    double computeDuration = 0;
+    PingPongTask pong = new PingPongTask("no name",computeDuration,commSizeLat);
+    pong.setTime(time);
+    pong.send(ping.getSource().getName());
+
+    /* Pop the two states */
+    Trace.hostPopState (getHost().getName(), "PM_STATE");
+    Trace.hostPopState (getHost().getName(), "PM_STATE");
+
+    Msg.info("goodbye!");
+  }
 }
index 82930bd..8d9206b 100644 (file)
@@ -1,77 +1,74 @@
-/* Sender of basic ping/pong example */
-
-/* Copyright (c) 2006-2014. The SimGrid Team.
+/* Copyright (c) 2006-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 package tracing;
-import org.simgrid.msg.Host;
-import org.simgrid.msg.HostNotFoundException;
 import org.simgrid.msg.Msg;
+import org.simgrid.msg.Host;
 import org.simgrid.msg.Task;
-import org.simgrid.msg.MsgException;
 import org.simgrid.msg.Process;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.HostNotFoundException;
 import org.simgrid.trace.Trace;
 
 public class Sender extends Process {
-       
-                               private final double commSizeLat = 1;
-                               private final double commSizeBw = 100000000;
+  private final double commSizeLat = 1;
+  private final double commSizeBw = 100000000;
+
+  public Sender(Host host, String name, String[] args) {
+    super(host,name,args);
+  }
+
+  public void main(String[] args) throws MsgException {
+    Msg.info("hello !"); 
+    Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPing");
+
+    int hostCount = args.length;
+    Msg.info("host count: " + hostCount);
+    String mailboxes[] = new String[hostCount]; 
+    double time;
+    double computeDuration = 0;
+    PingPongTask ping, pong;
+
+    for(int pos = 0; pos < args.length ; pos++) {
+      try {
+        mailboxes[pos] = Host.getByName(args[pos]).getName();
+      } catch (HostNotFoundException e) {
+        Msg.info("Invalid deployment file: " + e.toString());
+        System.exit(1);
+      }
+    }
+
+    for (int pos = 0; pos < hostCount; pos++) { 
+      time = Msg.getClock(); 
+      Msg.info("sender time: " + time);
+      ping = new PingPongTask("no name",computeDuration,commSizeLat);
+      ping.setTime(time);
+      ping.send(mailboxes[pos]);
+
+      Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPong");
+      pong = (PingPongTask)Task.receive(getHost().getName());
+      double timeGot = Msg.getClock();
+      double timeSent = ping.getTime();
+      double communicationTime=0;
+
+      Msg.info("Got at time "+ timeGot);
+      Msg.info("Was sent at time "+timeSent);
+      time=timeSent;
+
+      communicationTime=timeGot - time;
+      Msg.info("Communication time : " + communicationTime);
+
+      Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
 
-                               public Sender(Host host, String name, String[] args) {
-                                                               super(host,name,args);
-                               }
-                               
-                               public void main(String[] args) throws MsgException {
-                                                               Msg.info("hello !"); 
-                                                               Trace.hostPushState (getHost().getName(), "PM_STATE", "sendingPing");
-                                                               
-                                                               int hostCount = args.length;
-                                                               Msg.info("host count: " + hostCount);
-                                                               String mailboxes[] = new String[hostCount]; 
-                                                               double time;
-                                                               double computeDuration = 0;
-                                                               PingPongTask ping, pong;
-                                                               
-                                                               for(int pos = 0; pos < args.length ; pos++) {
-                                                                                               try {
-                                                                                                                               mailboxes[pos] = Host.getByName(args[pos]).getName();
-                                                                                               } catch (HostNotFoundException e) {
-                                                                                                                               Msg.info("Invalid deployment file: " + e.toString());
-                                                                                                                               System.exit(1);
-                                                                                               }
-                                                               }
-                                                               
-                                                               for (int pos = 0; pos < hostCount; pos++) { 
-                                                                                               time = Msg.getClock(); 
-                                                                                               Msg.info("sender time: " + time);
-                                                                                               ping = new PingPongTask("no name",computeDuration,commSizeLat);
-                                                                                               ping.setTime(time);
-                                                                                               ping.send(mailboxes[pos]);
-                                                               
-                                                                                               Trace.hostPushState (getHost().getName(), "PM_STATE", "waitingPong");
-                                                                                               pong = (PingPongTask)Task.receive(getHost().getName());
-                                                                       double timeGot = Msg.getClock();
-                                                                       double timeSent = ping.getTime();
-                                                       double communicationTime=0;
-                                                                       
-                                                                                               Msg.info("Got at time "+ timeGot);
-                                                                       Msg.info("Was sent at time "+timeSent);
-                                                                       time=timeSent;
-            
-                                                                       communicationTime=timeGot - time;
-                                                                       Msg.info("Communication time : " + communicationTime);
-            
-                                                                       Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
-      
-                                                                                               /* Pop the last state (going back to sending ping) */   
-                                                                                               Trace.hostPopState (getHost().getName(), "PM_STATE");
+      /* Pop the last state (going back to sending ping) */  
+      Trace.hostPopState (getHost().getName(), "PM_STATE");
+    }
 
-                                                               }
-                                                          /* Pop the sendingPong state */      
-                                                               Trace.hostPopState (getHost().getName(), "PM_STATE");
-                                                               Msg.info("goodbye!");
-                               }
+    /* Pop the sendingPong state */  
+    Trace.hostPopState (getHost().getName(), "PM_STATE");
+    Msg.info("goodbye!");
+  }
 }
index b8453bd..5a033e3 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006-2007, 2012-2014. The SimGrid Team.
+/* Copyright (c) 2006-2007, 2012-2014, 2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -8,35 +8,28 @@ package tracing;
 import org.simgrid.msg.Msg;
 import org.simgrid.trace.Trace;
 import org.simgrid.msg.NativeException;
+
 public class TracingTest  {
+  public static void main(String[] args) throws NativeException {      
+    Msg.init(args);
+    if(args.length < 2) {
+      Msg.info("Usage   : TracingTest platform_file deployment_file");
+      Msg.info("example : TracingTest ../platforms/platform.xml tracingPingPongDeployment.xml");
+      System.exit(1);
+    }
 
-   /* This only contains the launcher. If you do nothing more than than you can run 
-    *   java simgrid.msg.Msg
-    * which also contains such a launcher
-    */
-    
-    public static void main(String[] args) throws NativeException {            
-               /* initialize the MSG simulation. Must be done before anything else (even logging). */
-               Msg.init(args);
-               if(args.length < 2) {
-                       Msg.info("Usage   : PingPong platform_file deployment_file");
-               Msg.info("example : PingPong ping_pong_platform.xml ping_pong_deployment.xml");
-               System.exit(1);
-               }
-       
-               /* construct the platform and deploy the application */
-               Msg.createEnvironment(args[0]);
-               Msg.deployApplication(args[1]);
+    /* construct the platform and deploy the application */
+    Msg.createEnvironment(args[0]);
+    Msg.deployApplication(args[1]);
 
-               /* Initialize some state for the hosts */
-               Trace.hostStateDeclare ("PM_STATE"); 
-               Trace.hostStateDeclareValue ("PM_STATE", "waitingPing", "0 0 1");
-               Trace.hostStateDeclareValue ("PM_STATE", "sendingPong", "0 1 0");
-               Trace.hostStateDeclareValue ("PM_STATE", "sendingPing", "0 1 1");
-               Trace.hostStateDeclareValue ("PM_STATE", "waitingPong", "1 0 0");
+    /* Initialize some state for the hosts */
+    Trace.hostStateDeclare ("PM_STATE"); 
+    Trace.hostStateDeclareValue ("PM_STATE", "waitingPing", "0 0 1");
+    Trace.hostStateDeclareValue ("PM_STATE", "sendingPong", "0 1 0");
+    Trace.hostStateDeclareValue ("PM_STATE", "sendingPing", "0 1 1");
+    Trace.hostStateDeclareValue ("PM_STATE", "waitingPong", "1 0 0");
 
-               /*  execute the simulation. */
-           Msg.run();
-    }
+    /*  execute the simulation. */
+    Msg.run();
+  }
 }
index fa2c473..ed7db68 100644 (file)
@@ -2,9 +2,9 @@
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
 <platform version="4">
   <process host="Jacquelin" function="tracing.Sender">
-      <argument value="Boivin"/>
-      <argument value="Marcel"/>
+    <argument value="Boivin"/>
+    <argument value="Marcel"/>
   </process>
-<process host="Boivin" function="tracing.Receiver"/>
-<process host="Marcel" function="tracing.Receiver"/>
+  <process host="Boivin" function="tracing.Receiver"/>
+  <process host="Marcel" function="tracing.Receiver"/>
 </platform>