Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Finalize reservation surf plugin
authorPaul Bédaride <paul.bedaride@gmail.com>
Wed, 26 Mar 2014 16:03:08 +0000 (17:03 +0100)
committerPaul Bédaride <paul.bedaride@gmail.com>
Wed, 26 Mar 2014 16:03:48 +0000 (17:03 +0100)
buildtools/Cmake/DefinePackages.cmake
examples/java/reservationSurfPlugin/Receiver.java
examples/java/reservationSurfPlugin/ReservationPlugin.java
examples/java/reservationSurfPlugin/Sender.java
examples/java/reservationSurfPlugin/TestPlugin.java
examples/java/reservationSurfPlugin/reservationSurfPluginDeployment.xml
examples/java/reservationSurfPlugin/reservationSurfPluginPlatform.xml
examples/java/reservationSurfPlugin/reservation_surf_plugin.tesh
src/bindings/java/surf.i
src/bindings/java/surf_swig.cpp
src/bindings/java/surf_swig.hpp

index d7b0a5a..478b767 100644 (file)
@@ -505,10 +505,13 @@ set(JSURF_JAVA_GENERATED_SRC
   ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/NetworkLink.java
   ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/NetworkAction.java
 
+  ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/RoutingEdge.java
+
   ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/ActionState.java
   ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/ResourceState.java
 
   ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/LmmConstraint.java
+  ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/LmmVariable.java
   ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/XbtDict.java
 )
 
index cd66bb4..7097e5b 100644 (file)
@@ -21,15 +21,11 @@ public class Receiver extends Process {
    public void main(String[] args) throws MsgException {
 
       Msg.info("helloo!");
-      double communicationTime=0;
 
-      Msg.info("try to get a task");
-
-      Task task = Task.receive(getHost().getName());
-      double timeGot = Msg.getClock();
-
-      Msg.info("Got at time "+ timeGot);
-      task.execute();
+      Task task;
+      task = Task.receive(getHost().getName());
+      task = Task.receive(getHost().getName());
+      task = Task.receive(getHost().getName());
 
       Msg.info("goodbye!");
     }
index 8a637a8..8f3b6b7 100644 (file)
@@ -7,55 +7,34 @@ import java.util.HashMap;
 public class ReservationPlugin extends Plugin {
 
   public ReservationPlugin() {
-    activateCpuCreatedCallback();
-    activateCpuDestructedCallback();
-    activateCpuStateChangedCallback();
-    activateCpuActionStateChangedCallback();
-
-    activateNetworkLinkCreatedCallback();
-    activateNetworkLinkDestructedCallback();
-    activateNetworkLinkStateChangedCallback();
-    activateNetworkActionStateChangedCallback();
-
-  }
-
-  public void init() {
-    NetworkLink[] route = Surf.getRoute("Jacquelin", "Boivin");
-    Msg.info("RouteLength:"+route.length);
-    Msg.info("RouteName0:"+route[0].getName());
-    Msg.info("RouteName1:"+route[1].getName());
+    activateNetworkCommunicateCallback();
   }
 
-  public void cpuCreatedCallback(Cpu cpu) {
-    Msg.info("Trace: Cpu created "+cpu.getName());
-  }
-
-  public void cpuDestructedCallback(Cpu cpu) {
-    Msg.info("Trace: Cpu destructed "+cpu.getName());
-  }
-
-  public void cpuStateChangedCallback(Cpu cpu, ResourceState old, ResourceState cur){
-    Msg.info("Trace: Cpu state changed "+cpu.getName());
-  }
-
-  public void cpuActionStateChangedCallback(CpuAction action, ActionState old, ActionState cur){
-    Msg.info("Trace: CpuAction state changed "+action.getModel().getName());
-  }
-
-  public void networkLinkCreatedCallback(NetworkLink link) {
-    Msg.info("Trace: NetworkLink created "+link.getName());
-  }
+  //HashMap<String,Reservation> reservations;
+  double bandwidth = 0;
+  String src = "";
+  String dst = "";
 
-  public void networkLinkDestructedCallback(NetworkLink link) {
-    Msg.info("Trace: NetworkLink destructed "+link.getName());
+  public void limitBandwidthActions(String src, String dst, double bandwidth){
+    this.bandwidth = bandwidth;
+    this.src = src;
+    this.dst = dst;
   }
 
-  public void networkLinkStateChangedCallback(NetworkLink link, ResourceState old, ResourceState cur){
-    Msg.info("Trace: NetworkLink state changed "+link.getName());
+  public void updateBandwidthRoute(String src, String dst, double bandwidth){
+    NetworkLink[] route = Surf.getRoute(src, dst);
+    for (int i =0; i<route.length; i++){
+      Msg.info("Trace: bandwidth of "+route[i].getName()+" before "+route[i].getBandwidth());
+      route[i].updateBandwidth(bandwidth);//getName();
+      Msg.info("Trace: bandwidth of "+route[i].getName()+" after "+route[i].getBandwidth());
+    }
   }
 
-  public void networkActionStateChangedCallback(NetworkAction action, ActionState old, ActionState cur){
-    Msg.info("Trace: NetworkAction state changed "+action.getModel().getName());
+  public void networkCommunicateCallback(NetworkAction action, RoutingEdge src, RoutingEdge dst, double size, double rate){
+    if (src.getName().equals(this.src) && dst.getName().equals(this.dst)) {
+      action.setBound(this.bandwidth);
+    }
+    Msg.info("Trace: Communicate message of size "+size+" with rate "+rate+" and bound "+action.getBound()+" from "+src.getName()+" to "+dst.getName());
   }
 
 }
index 6f5ccf4..5f6ca38 100644 (file)
@@ -23,33 +23,31 @@ public class Sender extends Process {
 
        Msg.info("helloo!");
 
-       int hostCount = args.length;
-
-       Msg.info("host count: " + hostCount);
-       String mailboxes[] = new String[hostCount];
-       double time;
+       String receiverName = args[0];
+       double oldTime, curTime;
        double computeDuration = 10000;
        Task 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 Task("no name",computeDuration,commSizeLat);
-
-          task.send(mailboxes[pos]);
-        }
-
-        Msg.info("goodbye!");
+       oldTime = Msg.getClock();
+            task = new Task("no name",computeDuration,commSizeLat);
+            task.send(receiverName);
+       curTime = Msg.getClock();
+       Msg.info("Send duration: " + (curTime - oldTime));
+
+       TestPlugin.tp.updateBandwidthRoute("Jacquelin", "Boivin", 10E2);
+       oldTime = curTime;
+       task = new Task("no name",computeDuration,commSizeLat);
+       task.send(receiverName);
+       curTime = Msg.getClock();
+       Msg.info("Send duration with update bandwidth: " + (curTime - oldTime));
+
+       TestPlugin.tp.limitBandwidthActions("Jacquelin", "Boivin", 10E1);
+       oldTime = curTime;
+       task = new Task("no name",computeDuration,commSizeLat);
+       task.send(receiverName);
+       curTime = Msg.getClock();
+       Msg.info("Send normal duration with limited bandwidth: " + (curTime - oldTime));
+
+       Msg.info("goodbye!");
     }
 }
index cedbb04..64e0a6c 100644 (file)
@@ -16,7 +16,7 @@ public class TestPlugin {
   *   java simgrid.msg.Msg
   * which also contains such a launcher
   */
-  static ReservationPlugin tp = new ReservationPlugin();
+  public static ReservationPlugin tp = new ReservationPlugin();
 
   public static void main(String[] args) throws NativeException {
     /* initialize the MSG simulation. Must be done before anything else (even logging). */
@@ -26,10 +26,12 @@ public class TestPlugin {
       Msg.info("example : TestPlugin 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]);
-    tp.init();
+
+
 
     // getName());
     /*  execute the simulation. */
index 9101480..c238e1e 100644 (file)
@@ -1,8 +1,8 @@
 <?xml version='1.0'?>
 <!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
 <platform version="3">
-  <process host="Jacquelin" function="surfPlugin.Sender">
+  <process host="Jacquelin" function="reservationSurfPlugin.Sender">
       <argument value="Boivin"/>
   </process>
-<process host="Boivin" function="surfPlugin.Receiver"/>
+<process host="Boivin" function="reservationSurfPlugin.Receiver"/>
 </platform>
index 2712607..155dd2d 100644 (file)
@@ -5,9 +5,9 @@
    <host id="Jacquelin" power="137.333Mf"/>
    <host id="Boivin" power="98.095Mf"/>
    <host id="TeX" power="68.667Mf"/>
-   <link id="link0" bandwidth="1MBps" latency="100ms"/>
-   <link id="link1" bandwidth="1MBps" latency="100ms"/>
-   <link id="link2" bandwidth="1MBps" latency="100ms"/>
+   <link id="link0" bandwidth="1MBps" latency="1ms"/>
+   <link id="link1" bandwidth="1MBps" latency="1ms"/>
+   <link id="link2" bandwidth="1MBps" latency="1ms"/>
    <route src="Jacquelin" dst="Boivin">
      <link_ctn id="link0"/>
      <link_ctn id="link1"/>
index 012094f..3d2e4b2 100644 (file)
@@ -2,26 +2,18 @@
 
 $ java -classpath ${classpath:=.} reservationSurfPlugin/TestPlugin ${srcdir:=.}/reservationSurfPlugin/reservationSurfPluginPlatform.xml ${srcdir:=.}/reservationSurfPlugin/reservationSurfPluginDeployment.xml
 > [0.000000] [jmsg/INFO] Using regular java threads. Coroutines could speed your simulation up.
-> [0.000000] [jmsg/INFO] Trace: NetworkLink created __loopback__
-> [0.000000] [jmsg/INFO] Trace: NetworkLink state changed __loopback__
-> [0.000000] [jmsg/INFO] Trace: Cpu created Jacquelin
-> [0.000000] [jmsg/INFO] Trace: Cpu state changed Jacquelin
-> [0.000000] [jmsg/INFO] Trace: Cpu created Boivin
-> [0.000000] [jmsg/INFO] Trace: Cpu state changed Boivin
-> [0.000000] [jmsg/INFO] Trace: NetworkLink created link
-> [0.000000] [jmsg/INFO] Trace: NetworkLink state changed link
-> [Jacquelin:surfPlugin.Sender:(1) 0.000000] [jmsg/INFO] helloo!
-> [Jacquelin:surfPlugin.Sender:(1) 0.000000] [jmsg/INFO] host count: 1
-> [Jacquelin:surfPlugin.Sender:(1) 0.000000] [jmsg/INFO] sender time: 0.0
-> [Boivin:surfPlugin.Receiver:(2) 0.000000] [jmsg/INFO] helloo!
-> [Boivin:surfPlugin.Receiver:(2) 0.000000] [jmsg/INFO] try to get a task
-> [1.301001] [jmsg/INFO] Trace: NetworkAction state changed network
-> [Boivin:surfPlugin.Receiver:(2) 1.301001] [jmsg/INFO] Got at time 1.3010010824742269
-> [Jacquelin:surfPlugin.Sender:(1) 1.301001] [jmsg/INFO] goodbye!
-> [1.301103] [jmsg/INFO] Trace: CpuAction state changed cpu
-> [Boivin:surfPlugin.Receiver:(2) 1.301103] [jmsg/INFO] goodbye!
-> [1.301103] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
-> [1.301103] [jmsg/INFO] Trace: Cpu destructed Jacquelin
-> [1.301103] [jmsg/INFO] Trace: Cpu destructed Boivin
-> [1.301103] [jmsg/INFO] Trace: NetworkLink destructed link
-> [1.301103] [jmsg/INFO] Trace: NetworkLink destructed __loopback__
+> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.000000] [jmsg/INFO] helloo!
+> [Boivin:reservationSurfPlugin.Receiver:(2) 0.000000] [jmsg/INFO] helloo!
+> [0.000000] [jmsg/INFO] Trace: Communicate message of size 1.0 with rate -1.0 and bound 1.048576E9 from Jacquelin to Boivin
+> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.026021] [jmsg/INFO] Send duration: 0.026021082474226805
+> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.026021] [jmsg/INFO] Trace: bandwidth of link0 before 1000000.0
+> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.026021] [jmsg/INFO] Trace: bandwidth of link0 after 1000.0
+> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.026021] [jmsg/INFO] Trace: bandwidth of link1 before 1000000.0
+> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.026021] [jmsg/INFO] Trace: bandwidth of link1 after 1000.0
+> [0.026021] [jmsg/INFO] Trace: Communicate message of size 1.0 with rate -1.0 and bound 1.048576E9 from Jacquelin to Boivin
+> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.053124] [jmsg/INFO] Send duration with update bandwidth: 0.027102474226804125
+> [0.053124] [jmsg/INFO] Trace: Communicate message of size 1.0 with rate -1.0 and bound 100.0 from Jacquelin to Boivin
+> [Boivin:reservationSurfPlugin.Receiver:(2) 0.089144] [jmsg/INFO] goodbye!
+> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.089144] [jmsg/INFO] Send normal duration with limited bandwidth: 0.036019999999999996
+> [Jacquelin:reservationSurfPlugin.Sender:(1) 0.089144] [jmsg/INFO] goodbye!
+> [0.089144] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
index 4f247b1..28b4f6e 100644 (file)
@@ -76,11 +76,18 @@ class NetworkLink : public Resource {
 public:
   NetworkLink();
   ~NetworkLink();
+  double getBandwidth();
+  void updateBandwidth(double value, double date=surf_get_clock());
+  double getLatency();
+  void updateLatency(double value, double date=surf_get_clock());
 };
 
 class Action {
 public:
   Model *getModel();
+  lmm_variable *getVariable();
+  double getBound();
+  void setBound(double bound);
 };
 
 class CpuAction : public Action {
@@ -98,6 +105,12 @@ public:
 }
 };
 
+%nodefaultctor RoutingEdge;
+class RoutingEdge {
+public:
+  virtual char *getName()=0;
+};
+
 %rename lmm_constraint LmmConstraint;
 struct lmm_constraint {
 %extend {
@@ -105,6 +118,13 @@ struct lmm_constraint {
 }
 };
 
+%rename lmm_variable LmmVariable;
+struct lmm_variable {
+%extend {
+  double getValue() {return lmm_variable_getvalue($self);}
+}
+};
+
 %rename s_xbt_dict XbtDict;
 struct s_xbt_dict {
 %extend {
index 5432d48..88f0ee6 100644 (file)
@@ -24,7 +24,6 @@ NetworkLinkDynar getRoute(char *srcName, char *dstName) {
     xbt_die("TOTO");
   if (dst==NULL)
     xbt_die("TOTO");
-  printf("src: %s\ndst: %s\n", src->getName(), dst->getName());
   xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdgePtr), NULL);
   routing_platf->getRouteAndLatency(src, dst, &route, NULL);
   return route;
@@ -63,4 +62,9 @@ void Plugin::activateNetworkActionStateChangedCallback(){
   surf_callback_connect(networkActionStateChangedCallbacks, boost::bind(&Plugin::networkActionStateChangedCallback, this, _1, _2, _3));
 }
 
+void Plugin::activateNetworkCommunicateCallback(){
+  surf_callback_connect(networkCommunicateCallbacks, boost::bind(&Plugin::networkCommunicateCallback, this, _1, _2, _3, _4, _5));
+}
+
+
 
index 2fad2c3..a7e7024 100644 (file)
@@ -43,6 +43,6 @@ public:
  void activateNetworkActionStateChangedCallback();
  virtual void networkActionStateChangedCallback(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t cur) {}
 
+ void activateNetworkCommunicateCallback();
+ virtual void networkCommunicateCallback(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate) {}
 };
-
-