1 /* Copyright (c) 2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 package reservationSurfPlugin;
9 import org.simgrid.surf.*;
10 import org.simgrid.msg.Msg;
11 import java.util.HashMap;
13 public class ReservationPlugin extends Plugin {
15 public ReservationPlugin() {
16 activateNetworkCommunicateCallback();
19 //HashMap<String,Reservation> reservations;
24 public void limitBandwidthActions(String src, String dst, double bandwidth){
25 this.bandwidth = bandwidth;
30 public void updateBandwidthRoute(String src, String dst, double bandwidth){
31 NetworkLink[] route = Surf.getRoute(src, dst);
32 for (int i =0; i<route.length; i++){
33 Msg.info("Trace: bandwidth of "+route[i].getName()+" before "+route[i].getBandwidth());
34 route[i].updateBandwidth(bandwidth);//getName();
35 Msg.info("Trace: bandwidth of "+route[i].getName()+" after "+route[i].getBandwidth());
39 public void networkCommunicateCallback(NetworkAction action, RoutingEdge src, RoutingEdge dst, double size, double rate){
40 if (src.getName().equals(this.src) && dst.getName().equals(this.dst)) {
41 action.setBound(this.bandwidth);
43 Msg.info("Trace: Communicate message of size "+size+" with rate "+rate+" and bound "+action.getBound()+" from "+src.getName()+" to "+dst.getName());