import org.simgrid.msg.Msg;
import org.simgrid.msg.MsgException;
-public class Main{
+class Main{
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) throws MsgException {
Msg.init(args);
if(args.length < 2) {
import org.simgrid.msg.NativeException;
class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) throws NativeException {
Msg.init(args);
class Main {
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
- * which also contains such a launcher
- */
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
public static void main(String[] args) throws NativeException {
/* initialize the MSG simulation. Must be done before anything else (even logging). */
public void main(String[] args) throws MsgException {
Msg.info("hello!");
- double time = Msg.getClock();
-
Msg.info("try to get a task");
PingPongTask task = (PingPongTask)Task.receive(getHost().getName());
Msg.info("Got at time "+ timeGot);
Msg.info("Was sent at time "+timeSent);
- time = timeSent;
+ double time = timeSent;
double communicationTime = timeGot - time;
Msg.info("Communication time : " + communicationTime);
import org.simgrid.msg.Process;
public class Daemon extends Process {
- private Task currentTask;
- public Daemon(VM vm, int load) {
- super((Host)vm,"Daemon");
- currentTask = new Task(this.getHost().getName()+"-daemon-0", this.getHost().getSpeed()*100, 0);
- }
- public void main(String[] args) throws MsgException {
- int i = 1;
- while(!Main.isEndOfTest()) {
- // TODO the binding is not yet available
- try {
- currentTask.execute();
- } catch (HostFailureException e) {
- e.printStackTrace();
- } catch (TaskCancelledException e) {
- System.out.println("task cancelled");
- suspend(); // Suspend the process
- }
- currentTask = new Task(this.getHost().getName()+"-daemon-"+(i++), this.getHost().getSpeed()*100, 0);
-// Msg.info(currentTask.getName());
- }
+ private Task currentTask;
+ public Daemon(VM vm, int load) {
+ super((Host)vm,"Daemon");
+ currentTask = new Task(this.getHost().getName()+"-daemon-0", this.getHost().getSpeed()*100, 0);
+ }
+ public void main(String[] args) throws MsgException {
+ int i = 1;
+ while(!Main.isEndOfTest()) {
+ // TODO the binding is not yet available
+ try {
+ currentTask.execute();
+ } catch (HostFailureException e) {
+ e.printStackTrace();
+ } catch (TaskCancelledException e) {
+ System.out.println("task cancelled");
+ suspend(); // Suspend the process
}
+ currentTask = new Task(this.getHost().getName()+"-daemon-"+(i++), this.getHost().getSpeed()*100, 0);
+ }
+}
- public double getRemaining(){
- return this.currentTask.getFlopsAmount();
- }
+ public double getRemaining(){
+ return this.currentTask.getFlopsAmount();
+ }
}
public class Main {
private static boolean endOfTest = false;
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void setEndOfTest(){
endOfTest=true;
}
super(hostname, name);
}
- public void main(String[] strings) throws MsgException {
- double startTime = 0;
- double endTime = 0;
+ public void doMigration(VM vm, Host src, Host dst) throws HostFailureException{
+ Msg.info(" - Launch migration from "+ src.getName() +" to " + dst.getName());
+ double startTime = Msg.getClock();
+ vm.migrate(dst);
+ double endTime = Msg.getClock();
+ Msg.info(" - End of Migration from "+ src.getName() +" to " + dst.getName()+ " (duration:" +
+ (endTime-startTime)+")");
+ }
- /* get hosts 1 and 2*/
+ public void main(String[] strings) throws MsgException {
Host host0 = null;
Host host1 = null;
-
try {
+ /* get hosts 1 and 2*/
host0 = Host.getByName("PM0");
host1 = Host.getByName("PM1");
}catch (HostNotFoundException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ e.printStackTrace();
}
- List<VM> vms = new ArrayList<VM>();
+ List<VM> vms = new ArrayList<>();
/* Create VM1 */
int dpRate = 70;
Msg.info("Load of collocated VMs fluctuate between 0 and 90% in order to create a starvation issue and see "
+ "whether it impacts or not the migration time");
- XVM vm1 = null;
- vm1 = new XVM(host0, "vm0",
+ XVM vm1 = new XVM(host0, "vm0",
1, // Nb of vcpu
2048, // Ramsize,
125, // Net Bandwidth
/* Collocated VMs */
int collocatedSrc = 6;
- int vmSrcLoad[] = {
+ int[] vmSrcLoad = {
80,
0,
90,
90,
};
- XVM tmp = null;
+ XVM tmp;
for (int i=1 ; i<= collocatedSrc ; i++){
tmp = new XVM(host0, "vm"+i,
1, // Nb of vcpu
}
int collocatedDst = 6;
- int vmDstLoad[] = {
+ int[] vmDstLoad = {
0,
40,
90,
Msg.info("Round trip of VM1 (load "+load1+"%)");
vm1.setLoad(load1);
- Msg.info(" - Launch migration from PM0 to PM1");
- startTime = Msg.getClock();
- vm1.migrate(host1);
- endTime = Msg.getClock();
- Msg.info(" - End of Migration from PM0 to PM1 (duration:"+(endTime-startTime)+")");
- Msg.info(" - Launch migration from PM1 to PM0");
- startTime = Msg.getClock();
- vm1.migrate(host0);
- endTime = Msg.getClock();
- Msg.info(" - End of Migration from PM1 to PM0 (duration:"+(endTime-startTime)+")");
-
+ doMigration(vm1, host0, host1);
+ doMigration(vm1, host1, host0);
Msg.info("");
Msg.info("");
Msg.info("Round trip of VM1 (load "+load2+"%)");
vm1.setLoad(load2);
- Msg.info(" - Launch migration from PM0 to PM1");
- startTime = Msg.getClock();
- vm1.migrate(host1);
- endTime = Msg.getClock();
- Msg.info(" - End of Migration from PM0 to PM1 (duration:"+(endTime-startTime)+")");
- Msg.info(" - Launch migration from PM1 to PM0");
- startTime = Msg.getClock();
- vm1.migrate(host0);
- endTime = Msg.getClock();
- Msg.info(" - End of Migration from PM1 to PM0 (duration:"+(endTime-startTime)+")");
+ doMigration(vm1, host0, host1);
+ doMigration(vm1, host1, host0);
Main.setEndOfTest();
Msg.info("Forcefully destroy VMs");
import org.simgrid.msg.Msg;
-public class Main {
+class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) {
Msg.init(args);
if(args.length < 2) {
public final static int MAX_STEPS = 10;
public final static int JOIN_BUCKETS_QUERIES = 1;
+ private Common() {
+ throw new IllegalAccessError("Utility class");
+ }
}
import org.simgrid.msg.Msg;
import org.simgrid.msg.MsgException;
-public class Main {
+class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) throws MsgException {
Msg.init(args);
if(args.length < 2) {
public static final double task_comp_size = 10;
public static final double task_comm_size = 10;
public static final int hostNB = 2 ;
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
public static void main(String[] args) throws MsgException {
Msg.energyInit();
import org.simgrid.msg.MsgException;
public class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) throws MsgException {
Msg.init(args);
if(args.length < 1) {
import org.simgrid.msg.MsgException;
public class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) throws MsgException {
Msg.init(args);
if(args.length < 1) {
import org.simgrid.msg.NativeException;
public class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) throws NativeException {
/* initialize the MSG simulation. Must be done before anything else (even logging). */
Msg.init(args);
protected static Mutex mutex;
protected static Process processToMigrate = null;
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) throws NativeException {
Msg.init(args);
if(args.length < 1) {
import org.simgrid.msg.NativeException;
public class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) throws NativeException {
Msg.init(args);
if(args.length < 2) {
import org.simgrid.msg.MsgException;
public class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) {
Msg.init(args);
if(args.length < 1) {
/* Demonstrates the use of Task.setPriority to change the computation priority of a task */
public class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) throws NativeException {
Msg.init(args);
if(args.length < 2) {
import org.simgrid.msg.NativeException;
public class Main {
+ private Main() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void main(String[] args) throws MsgException, NativeException {
Msg.init(args);
if(args.length < 1) {
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");
Msg.info("Got at time "+ timeGot);
Msg.info("Was sent at time "+timeSent);
- time=timeSent;
+ double time=timeSent;
- communicationTime=timeGot - time;
+ double communicationTime=timeGot - time;
Msg.info("Communication time : " + communicationTime);
Msg.info(" --- bw "+ commSizeBw/communicationTime + " ----");
public final class NativeLib {
/* Statically load the library which contains all native functions used in here */
- static private boolean isNativeInited = false;
+ private static boolean isNativeInited = false;
+ static Path tempDir = null;
+
+ private NativeLib() {
+ throw new IllegalAccessError("Utility class");
+ }
+
public static void nativeInit() {
if (isNativeInited)
return;
NativeLib.nativeInit("winpthread-1");
NativeLib.nativeInit("simgrid");
- NativeLib.nativeInit("simgrid-java");
+ NativeLib.nativeInit("simgrid-java");
isNativeInited = true;
}
try {
System.loadLibrary(name);
} catch (UnsatisfiedLinkError systemException) {
- if (! name.equals("boost_context")) { // Ignore when we cannot load boost_context
+ if (! "boost_context".equals(name)) { // Ignore when we cannot load boost_context
System.err.println("\nCannot load the bindings to the "+name+" library in path "+getPath());
Throwable cause = embeededException.getCause();
else if (cause.getMessage().matches(".*libboost_context.so.*"))
System.err.println("HINT: Try to install the boost-context package (sudo apt-get install libboost-context-dev).");
else
- System.err.println("Try to install the missing dependencies, which name should appear above.");
+ System.err.println("Try to install the missing dependencies, which name should appear above.");
} else {
System.err.println("This jar file does not seem to fit your system, and no usable SimGrid installation found on disk.");
}
if (arch.matches("^i[3-6]86$"))
arch = "x86";
- else if (arch.equalsIgnoreCase("x86_64"))
+ else if ("x86_64".equalsIgnoreCase(arch))
arch = "amd64";
- else if (arch.equalsIgnoreCase("AMD64"))
+ else if ("AMD64".equalsIgnoreCase(arch))
arch = "amd64";
if (os.toLowerCase().startsWith("win")){
return prefix + "/" + os + "/" + arch + "/";
}
- static Path tempDir = null;
+
private static void loadLib (String name) throws LinkageException {
- String Path = NativeLib.getPath();
+ String path = NativeLib.getPath();
String filename=name;
- InputStream in = NativeLib.class.getClassLoader().getResourceAsStream(Path+filename);
+ InputStream in = NativeLib.class.getClassLoader().getResourceAsStream(path+filename);
if (in == null) {
filename = "lib"+name+".so";
- in = NativeLib.class.getClassLoader().getResourceAsStream(Path+filename);
+ in = NativeLib.class.getClassLoader().getResourceAsStream(path+filename);
}
if (in == null) {
filename = name+".dll";
- in = NativeLib.class.getClassLoader().getResourceAsStream(Path+filename);
+ in = NativeLib.class.getClassLoader().getResourceAsStream(path+filename);
}
if (in == null) {
filename = "lib"+name+".dll";
- in = NativeLib.class.getClassLoader().getResourceAsStream(Path+filename);
+ in = NativeLib.class.getClassLoader().getResourceAsStream(path+filename);
}
if (in == null) {
filename = "lib"+name+".dylib";
- in = NativeLib.class.getClassLoader().getResourceAsStream(Path+filename);
+ in = NativeLib.class.getClassLoader().getResourceAsStream(path+filename);
}
if (in == null) {
- throw new LinkageException("Cannot find library "+name+" in path "+Path+". Sorry, but this jar does not seem to be usable on your machine.");
+ throw new LinkageException("Cannot find library "+name+" in path "+path+". Sorry, but this jar does not seem to be usable on your machine.");
}
try {
// We must write the lib onto the disk before loading it -- stupid operating systems
/* copy the library in position */
OutputStream out = new FileOutputStream(fileOut);
byte[] buffer = new byte[4096];
- int bytes_read;
- while ((bytes_read = in.read(buffer)) != -1) // Read until EOF
- out.write(buffer, 0, bytes_read);
+ int bytesRead;
+ while ((bytesRead = in.read(buffer)) != -1) // Read until EOF
+ out.write(buffer, 0, bytesRead);
/* close all file descriptors, and load that shit */
in.close();
for (File f : dir.listFiles())
if (! f.delete() )
System.err.println("Unable to clean temporary file "+f.getAbsolutePath()+" during shutdown.");
- if (! dir.delete() )
+ if (! dir.delete() )
System.err.println("Unable to clean temporary file "+dir.getAbsolutePath()+" during shutdown.");
} catch(Exception e) {
System.err.println("Unable to clean temporary file "+dir.getAbsolutePath()+" during shutdown: "+e.getCause());
e.printStackTrace();
}
- }
+ }
}
public final class Msg {
/** Retrieves the simulation time */
- public final static native double getClock();
+ public static final native double getClock();
/** Issue a debug logging message. */
- public final static native void debug(String msg);
+ public static final native void debug(String msg);
/** Issue a verbose logging message. */
- public final static native void verb(String msg);
+ public static final native void verb(String msg);
/** Issue an information logging message */
- public final static native void info(String msg);
+ public static final native void info(String msg);
/** Issue a warning logging message. */
- public final static native void warn(String msg);
+ public static final native void warn(String msg);
/** Issue an error logging message. */
- public final static native void error(String msg);
+ public static final native void error(String msg);
/** Issue a critical logging message. */
- public final static native void critical(String s);
+ public static final native void critical(String s);
+
+ private Msg() {
+ throw new IllegalAccessError("Utility class");
+ }
/*********************************************************************************
* Deployment and initialization related functions *
*
* @param args The arguments of the command line of the simulation.
*/
- public final static native void init(String[]args);
+ public static final native void init(String[]args);
/** Tell the kernel that you want to use the energy plugin */
- public final static native void energyInit();
+ public static final native void energyInit();
/** Run the MSG simulation.
*
* retrieve the information that you want from the simulation. In particular, retrieving the status
* of a process or the current date is perfectly ok.
*/
- public final static native void run() ;
-
- /** This function is useless nowadays, just stop calling it. */
- @Deprecated
- public final static void clean(){}
+ public static final native void run() ;
/** Create the simulation environment by parsing a platform file. */
- public final static native void createEnvironment(String platformFile);
+ public static final native void createEnvironment(String platformFile);
- public final static native As environmentGetRoutingRoot();
+ public static final native As environmentGetRoutingRoot();
/** Starts your processes by parsing a deployment file. */
- public final static native void deployApplication(String deploymentFile);
+ public static final native void deployApplication(String deploymentFile);
/** Example launcher. You can use it or provide your own launcher, as you wish
* @param args
package org.simgrid.msg;
import java.util.Arrays;
-import java.util.Vector;
+import java.util.ArrayList;
/**
* A process may be defined as a code, with some private data, executing
* Even if this attribute is public you must never access to it.
* It is used to compute the id of an MSG process.
*/
- public static long nextProcessId = 0;
+ private static long nextProcessId = 0;
/**
* Even if this attribute is public you must never access to it.
private Host host = null;
/** The arguments of the method function of the process. */
- public Vector<String> args;
+ public ArrayList<String> args;
/** Default constructor */
this.id = nextProcessId++;
this.name = null;
this.bind = 0;
- this.args = new Vector<String>();
+ this.args = new ArrayList<>();
}
* @throws NativeException
*
*/
- public Process(String hostname, String name, String args[]) throws HostNotFoundException, NativeException {
+ public Process(String hostname, String name, String[] args) throws HostNotFoundException, NativeException {
this(Host.getByName(hostname), name, args);
}
/**
this();
this.host = host;
if (host == null)
- throw new NullPointerException("Process name cannot be NULL");
+ throw new NullPointerException("Host cannot be NULL");
if (name == null)
throw new NullPointerException("Process name cannot be NULL");
this.name = name;
- this.args = new Vector<String>();
+ this.args = new ArrayList<>();
if (null != args)
this.args.addAll(Arrays.asList(args));
- }
+ }
/**
* Constructs a new process from a host and his name, the arguments of here method function are
* specified by the parameter args.
throw new NullPointerException("Process name cannot be NULL");
this.name = name;
- this.args = new Vector<String>();
+ this.args = new ArrayList<>();
if (null != args)
this.args.addAll(Arrays.asList(args));
this.startTime = startTime;
- this.killTime = killTime;
+ this.killTime = killTime;
}
/**
* The natively implemented method to create an MSG process.
* @param millis the length of time to sleep in milliseconds.
* @param nanos additionnal nanoseconds to sleep.
*/
- public native static void sleep(long millis, int nanos) throws HostFailureException;
+ public static native void sleep(long millis, int nanos) throws HostFailureException;
/**
* Makes the current process sleep until time seconds have elapsed.
* @param seconds The time the current process must sleep.
try {
args = new String[this.args.size()];
- if (this.args.size() > 0) {
+ if (!this.args.isEmpty()) {
this.args.toArray(args);
}