Smelly code, smelly code it's not your fault...
13 files changed:
package app.bittorrent;
/* Common constants for use in the simulation */
package app.bittorrent;
/* Common constants for use in the simulation */
public static final String TRACKER_MAILBOX = "tracker_mailbox";
public static final int FILE_SIZE = 5120;
public static final int FILE_PIECE_SIZE = 512;
public static final String TRACKER_MAILBOX = "tracker_mailbox";
public static final int FILE_SIZE = 5120;
public static final int FILE_PIECE_SIZE = 512;
import org.simgrid.msg.MsgException;
public class Coordinator extends Process {
import org.simgrid.msg.MsgException;
public class Coordinator extends Process {
+ LinkedList<RequestTask> waitingQueue=new LinkedList<>();
+ int csToServe;
+
public Coordinator(Host host, String name, String[]args) {
super(host,name,args);
}
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 {
public void main(String[] args) throws MsgException {
- CsToServe = Integer.parseInt(args[0]);
+ csToServe = Integer.parseInt(args[0]);
task = Task.receive("coordinator");
if (task instanceof RequestTask) {
RequestTask t = (RequestTask) task;
task = Task.receive("coordinator");
if (task instanceof RequestTask) {
RequestTask t = (RequestTask) task;
GrantTask tosend = new GrantTask();
tosend.send(req.from);
}
GrantTask tosend = new GrantTask();
tosend.send(req.from);
}
- CsToServe--;
- if (waitingQueue.isEmpty() && CsToServe==0) {
+ csToServe--;
+ if (waitingQueue.isEmpty() && csToServe==0) {
Msg.info("we should shutdown the simulation now");
}
}
Msg.info("we should shutdown the simulation now");
}
}
import org.simgrid.msg.Msg;
import org.simgrid.msg.NativeException;
import org.simgrid.msg.Msg;
import org.simgrid.msg.NativeException;
public static void main(String[] args) throws NativeException {
Msg.init(args);
public static void main(String[] args) throws NativeException {
Msg.init(args);
}
public void request(double CStime) throws MsgException {
RequestTask req = new RequestTask(getName());
}
public void request(double CStime) throws MsgException {
RequestTask req = new RequestTask(getName());
+ GrantTask grant= new GrantTask();;
Msg.info("Send a request to the coordinator");
req.send("coordinator");
Msg.info("Wait for a grant from the coordinator");
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
+ grant.receive(getName());
Task compute = new Task("CS", CStime, 0);
compute.execute();
ReleaseTask release = new ReleaseTask();
Task compute = new Task("CS", CStime, 0);
compute.execute();
ReleaseTask release = new ReleaseTask();
import org.simgrid.msg.Msg;
import org.simgrid.msg.NativeException;
import org.simgrid.msg.Msg;
import org.simgrid.msg.NativeException;
public static final int TASK_COMP_SIZE = 10000000;
public static final int TASK_COMM_SIZE = 10000000;
/* This only contains the launcher. If you do nothing more than than you can run java simgrid.msg.Msg
public static final int TASK_COMP_SIZE = 10000000;
public static final int TASK_COMM_SIZE = 10000000;
/* This only contains the launcher. If you do nothing more than than you can run java simgrid.msg.Msg
- int tasksCount = Integer.valueOf(args[0]).intValue();
- double taskComputeSize = Double.valueOf(args[1]).doubleValue();
- double taskCommunicateSize = Double.valueOf(args[2]).doubleValue();
+ int tasksCount = Integer.parseInt(args[0]);
+ double taskComputeSize = Double.parseDouble(args[1]);
+ double taskCommunicateSize = Double.parseDouble(args[2]);
- int workersCount = Integer.valueOf(args[3]).intValue();
+ int workersCount = Integer.parseInt(args[3]);
Msg.info("Hello! Got "+ workersCount + " workers and "+tasksCount+" tasks to process");
for (int i = 0; i < tasksCount; i++) {
Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize);
Msg.info("Hello! Got "+ workersCount + " workers and "+tasksCount+" tasks to process");
for (int i = 0; i < tasksCount; i++) {
Task task = new Task("Task_" + i, taskComputeSize, taskCommunicateSize);
- //Msg.info("Sending \"" + task.getName()+ "\" to \"worker_" + i % workersCount + "\"");
+ Msg.debug("Sending \"" + task.getName()+ "\" to \"worker_" + i % workersCount + "\"");
task.send("worker_"+(i%workersCount));
}
task.send("worker_"+(i%workersCount));
}
- int num = Integer.valueOf(args[0]).intValue();
- //Msg.info("Receiving on 'worker_"+num+"'");
+ int num = Integer.parseInt(args[0]);
+ Msg.debug("Receiving on 'worker_"+num+"'");
while(true) {
Task task = Task.receive("worker_"+num);
while(true) {
Task task = Task.receive("worker_"+num);
Msg.info("Received \"" + task.getName() + "\". Processing it.");
try {
task.execute();
Msg.info("Received \"" + task.getName() + "\". Processing it.");
try {
task.execute();
- } catch (TaskCancelledException e) {}
+ } catch (TaskCancelledException e) {
+ e.printStackTrace();
+ }
}
Msg.info("Received Finalize. I'm done. See you!");
}
Msg.info("Received Finalize. I'm done. See you!");
package app.pingpong;
import org.simgrid.msg.Msg;
package app.pingpong;
import org.simgrid.msg.Msg;
-import org.simgrid.msg.MsgException;
+import org.simgrid.msg.HostNotFoundException;
import org.simgrid.msg.NativeException;
import org.simgrid.msg.NativeException;
-public class Main {
- public static void main(String[] args) throws MsgException, NativeException{
+class Main {
+ public static void main(String[] args) throws HostNotFoundException,NativeException{
Msg.init(args);
if(args.length < 1) {
Msg.info("Usage : Main platform_file");
Msg.init(args);
if(args.length < 1) {
Msg.info("Usage : Main platform_file");
package app.pingpong;
import org.simgrid.msg.Msg;
package app.pingpong;
import org.simgrid.msg.Msg;
-import org.simgrid.msg.Host;
import org.simgrid.msg.Task;
import org.simgrid.msg.Process;
import org.simgrid.msg.MsgException;
import org.simgrid.msg.Task;
import org.simgrid.msg.Process;
import org.simgrid.msg.MsgException;
import org.simgrid.msg.HostNotFoundException;
public class Receiver extends Process {
import org.simgrid.msg.HostNotFoundException;
public class Receiver extends Process {
- final double commSizeLat = 1;
- final double commSizeBw = 100000000;
+ static final double commSizeLat = 1;
+ static final double commSizeBw = 100000000;
public Receiver(String hostname, String name, String[]args) throws HostNotFoundException, NativeException{
super(hostname,name,args);
}
public void main(String[] args) throws MsgException {
Msg.info("hello!");
public Receiver(String hostname, String name, String[]args) throws HostNotFoundException, NativeException{
super(hostname,name,args);
}
public void main(String[] args) throws MsgException {
Msg.info("hello!");
- double communicationTime=0;
double time = Msg.getClock();
double time = Msg.getClock();
Msg.info("Was sent at time "+timeSent);
time=timeSent;
Msg.info("Was sent at time "+timeSent);
time=timeSent;
- communicationTime=timeGot - time;
+ double communicationTime = timeGot - time;
Msg.info("Communication time : " + communicationTime);
Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
Msg.info("goodbye!");
Msg.info("Communication time : " + communicationTime);
Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
Msg.info("goodbye!");
-/* Copyright (c) 2006-2014, 2016. 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
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
try {
mailboxes[pos] = Host.getByName(args[pos]).getName();
} catch (HostNotFoundException e) {
try {
mailboxes[pos] = Host.getByName(args[pos]).getName();
} catch (HostNotFoundException e) {
Msg.info("Invalid deployment file: " + e.toString());
Msg.info("Invalid deployment file: " + e.toString());
import org.simgrid.msg.NativeException;
import org.simgrid.msg.HostNotFoundException;
import org.simgrid.msg.NativeException;
import org.simgrid.msg.HostNotFoundException;
public static void main(String[] args) throws NativeException, HostNotFoundException {
Msg.init(args);
public static void main(String[] args) throws NativeException, HostNotFoundException {
Msg.init(args);
import org.simgrid.msg.Host;
import org.simgrid.msg.MsgException;
import org.simgrid.msg.Host;
import org.simgrid.msg.MsgException;
public static final double task_comp_size = 10;
public static final double task_comm_size = 10;
public static final int hostNB = 2 ;
public static final double task_comp_size = 10;
public static final double task_comm_size = 10;
public static final int hostNB = 2 ;
*/
public abstract void main(String[]args) throws MsgException;
*/
public abstract void main(String[]args) throws MsgException;
- public native void exit();
+ public native void exit();
/**
* Class initializer, to initialize various JNI stuff
*/
/**
* Class initializer, to initialize various JNI stuff
*/