${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
)
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!");
}
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());
}
}
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!");
}
}
* 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). */
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. */
<?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>
<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"/>
$ 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...
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 {
}
};
+%nodefaultctor RoutingEdge;
+class RoutingEdge {
+public:
+ virtual char *getName()=0;
+};
+
%rename lmm_constraint LmmConstraint;
struct lmm_constraint {
%extend {
}
};
+%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 {
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;
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));
+}
+
+
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) {}
};
-
-