ADD_TEST(chord ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/chord/chord.tesh)
ADD_TEST(kill ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/kill.tesh)
ADD_TEST(masterslave ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/masterslave/masterslave.tesh)
+ADD_TEST(migration ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/migration/migration.tesh)
ADD_TEST(mutualExclusion ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/mutualexclusion.tesh)
ADD_TEST(pingPong ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/pingPong/pingpong.tesh)
ADD_TEST(priority ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/priority/priority.tesh)
ADD_TEST(startKillTime ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/startKillTime/startKillTime.tesh)
ADD_TEST(suspend ${TESH_BIN_PATH} ${TESH_OPTION} --setenv srcdir=${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/examples/suspend/suspend.tesh)
#Don't forget to put new test in this list!!!
-set(test_list async bittorrent bypass chord commTime kill masterslave mutualExclusion pingPong priority startKillTime)
+set(test_list async bittorrent bypass chord commTime kill masterslave migration mutualExclusion pingPong priority startKillTime)
##########################################
# Set the DYLD_LIBRARY_PATH for mac #
--- /dev/null
+/*
+ * 2012. The SimGrid Team. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package.
+ */
+package migration;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+
+public class Emigrant extends Process {
+ public Emigrant(Host host, String name, String[]args) {
+ super(host,name,args);
+ }
+ public void main(String[] args) throws MsgException {
+ Migration.mutex.acquire();
+
+ Msg.info("I'll look for a new job on another machine where the grass is greener.");
+ migrate(Host.getByName("Boivin"));
+
+ Msg.info("Yeah, found something to do");
+ Task task = new Task("job", 98095000, 0);
+ task.execute();
+ waitFor(2);
+
+ Msg.info("Moving back to home after work");
+ migrate(Host.getByName("Jacquelin"));
+ migrate(Host.getByName("Boivin"));
+ waitFor(4);
+
+ Migration.processToMigrate = this;
+ Migration.mutex.release();
+ suspend();
+
+ Msg.info("I've been moved on this new host:" + getHost().getName());
+ Msg.info("Uh, nothing to do here. Stopping now");
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * $Id$
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package.
+ */
+package migration;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.Mutex;
+import org.simgrid.msg.NativeException;
+import org.simgrid.msg.Process;
+/**
+ * Demonstrates the use of Task.setPriority to change
+ * the computation priority of a task
+ */
+public class Migration {
+ public static Mutex mutex;
+ public static Process processToMigrate = null;
+
+ /* 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
+ */
+
+ public static void main(String[] args) throws NativeException {
+ /* initialize the MSG simulation. Must be done before anything else (even logging). */
+ Msg.init(args);
+ if(args.length < 2) {
+ Msg.info("Usage : Priority platform_file deployment_file");
+ Msg.info("example : Priority ping_pong_platform.xml ping_pong_deployment.xml");
+ System.exit(1);
+ }
+ /* Create the mutex */
+ mutex = new Mutex();
+
+ /* construct the platform and deploy the application */
+ Msg.createEnvironment(args[0]);
+ Msg.deployApplication(args[1]);
+
+ /* execute the simulation. */
+ Msg.run();
+ }
+}
--- /dev/null
+/*
+ * 2012. The SimGrid Team. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package.
+ */
+package migration;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.Process;
+
+public class Policeman extends Process {
+ public Policeman(Host host, String name, String[]args) {
+ super(host,name,args);
+ }
+
+ @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"));
+ Msg.info("I moved the emigrant");
+ Migration.processToMigrate.resume();
+ }
+}
\ No newline at end of file
--- /dev/null
+#! ./tesh
+
+! output sort
+
+$ java -cp .:${srcdir:=.}/examples:${srcdir:=.}/simgrid.jar migration/Migration ${srcdir:=.}/examples/platform.xml ${srcdir:=.}/examples/migration/migrationDeployment.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n"
+> [ 0.000000] (0:@) Ready to run MSG_MAIN
+> [ 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
+> [ 7.000000] (0:@) Done running MSG_MAIN
+> [ 7.000000] (0:@) MSG_main finished
+> [ 7.000000] (0:@) Clean java world
+> [ 7.000000] (0:@) Clean native world
+> [ 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
+
--- /dev/null
+<?xml version='1.0'?>
+<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
+<platform version="3">
+ <process host="Jacquelin" function="migration.Emigrant"/>
+ <process host="Boivin" function="migration.Policeman"/>
+</platform>