set(example java_migration)
-set(sources ${CMAKE_CURRENT_SOURCE_DIR}/Migration.java ${CMAKE_CURRENT_SOURCE_DIR}/Emigrant.java ${CMAKE_CURRENT_SOURCE_DIR}/Policeman.java)
+set(sources ${CMAKE_CURRENT_SOURCE_DIR}/Main.java ${CMAKE_CURRENT_SOURCE_DIR}/Emigrant.java ${CMAKE_CURRENT_SOURCE_DIR}/Policeman.java)
if(enable_java)
add_custom_command(
endif()
set(tesh_files ${tesh_files} ${CMAKE_CURRENT_SOURCE_DIR}/migration.tesh PARENT_SCOPE)
-set(xml_files ${xml_files} ${CMAKE_CURRENT_SOURCE_DIR}/migrationDeployment.xml PARENT_SCOPE)
set(examples_src ${examples_src} ${sources} PARENT_SCOPE)
import org.simgrid.msg.Task;
import org.simgrid.msg.Process;
import org.simgrid.msg.MsgException;
+import org.simgrid.msg.HostNotFoundException;
public class Emigrant extends Process {
- public Emigrant(Host host, String name, String[]args) {
- super(host,name,args);
+ public Emigrant(String hostname, String name) throws HostNotFoundException {
+ super(hostname, name);
}
- public void main(String[] args) throws MsgException {
- Migration.mutex.acquire();
-
+ public void main(String[] args) throws MsgException {
+ Main.mutex.acquire();
+
Msg.info("I'll look for a new job on another machine where the grass is greener.");
migrate(Host.getByName("Boivin"));
migrate(Host.getByName("Boivin"));
waitFor(4);
- Migration.processToMigrate = this;
- Migration.mutex.release();
+ Main.processToMigrate = this;
+ Main.mutex.release();
suspend();
Msg.info("I've been moved on this new host:" + getHost().getName());
import org.simgrid.msg.Mutex;
import org.simgrid.msg.Process;
import org.simgrid.msg.NativeException;
+import org.simgrid.msg.HostNotFoundException;
-public class Migration {
+public class Main {
public static Mutex mutex;
public static Process processToMigrate = null;
- public static void main(String[] args) throws NativeException {
+ public static void main(String[] args) throws NativeException {
Msg.init(args);
- if(args.length < 2) {
- Msg.info("Usage : Migration platform_file deployment_file");
- Msg.info("example : Migration ../platforms/platform.xml migrationDeployment.xml");
+ if(args.length < 1) {
+ Msg.info("Usage : Migration platform_file");
+ Msg.info("example : Migration ../platforms/platform.xml");
System.exit(1);
}
/* Create the mutex */
mutex = new Mutex();
- /* construct the platform and deploy the application */
+ /* construct the platform*/
Msg.createEnvironment(args[0]);
- Msg.deployApplication(args[1]);
+ /* bypass deploymemt */
+ try {
+ Policeman policeman = new Policeman("Boivin","policeman");
+ policeman.start();
+ Emigrant emigrant = new Emigrant("Jacquelin","emigrant");
+ emigrant.start();
+ } catch (HostNotFoundException e){
+ System.out.println("Create processes failed!");
+ }
/* execute the simulation. */
Msg.run();
import org.simgrid.msg.Host;
import org.simgrid.msg.Process;
import org.simgrid.msg.MsgException;
+import org.simgrid.msg.HostNotFoundException;
public class Policeman extends Process {
- public Policeman(Host host, String name, String[]args) {
- super(host,name,args);
+ public Policeman(String hostname, String name) throws HostNotFoundException {
+ super(hostname, name);
}
- @Override
public void main(String[] args) throws MsgException {
waitFor(1);
-
+
Msg.info("Wait a bit before migrating the emigrant.");
-
- Migration.mutex.acquire();
-
- Migration.processToMigrate.migrate(Host.getByName("Jacquelin"));
+
+ Main.mutex.acquire();
+
+ Main.processToMigrate.migrate(Host.getByName("Jacquelin"));
Msg.info("I moved the emigrant");
- Migration.processToMigrate.resume();
+ Main.processToMigrate.resume();
}
}
\ No newline at end of file
! output sort 19
-$ java -classpath ${classpath:=.} migration/Migration ${srcdir:=.}/../platforms/platform.xml ${srcdir:=.}/migration/migrationDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+$ java -classpath ${classpath:=.} migration/Main ${srcdir:=.}/../platforms/platform.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
> [ 0.000000] (0:maestro@) Using regular java threads.
-> [ 0.000000] (1:migration.Emigrant@Jacquelin) I'll look for a new job on another machine where the grass is greener.
-> [ 0.000000] (1:migration.Emigrant@Boivin) Yeah, found something to do
-> [ 1.000000] (2:migration.Policeman@Boivin) Wait a bit before migrating the emigrant.
-> [ 3.000000] (1:migration.Emigrant@Boivin) Moving back to home after work
+> [ 0.000000] (2:emigrant@Jacquelin) I'll look for a new job on another machine where the grass is greener.
+> [ 0.000000] (2:emigrant@Boivin) Yeah, found something to do
+> [ 1.000000] (1:policeman@Boivin) Wait a bit before migrating the emigrant.
+> [ 3.000000] (2:emigrant@Boivin) Moving back to home after work
> [ 7.000000] (0:maestro@) MSG_main finished; Cleaning up the simulation...
-> [ 7.000000] (1:migration.Emigrant@Jacquelin) I've been moved on this new host:Jacquelin
-> [ 7.000000] (1:migration.Emigrant@Jacquelin) Uh, nothing to do here. Stopping now
-> [ 7.000000] (2:migration.Policeman@Boivin) I moved the emigrant
+> [ 7.000000] (2:emigrant@Jacquelin) I've been moved on this new host:Jacquelin
+> [ 7.000000] (2:emigrant@Jacquelin) Uh, nothing to do here. Stopping now
+> [ 7.000000] (1:policeman@Boivin) I moved the emigrant
+++ /dev/null
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd">
-<platform version="4">
- <process host="Jacquelin" function="migration.Emigrant"/>
- <process host="Boivin" function="migration.Policeman"/>
-</platform>