${CMAKE_HOME_DIRECTORY}/examples/chord/FindSuccessorTask.java
${CMAKE_HOME_DIRECTORY}/examples/chord/GetPredecessorAnswerTask.java
${CMAKE_HOME_DIRECTORY}/examples/chord/NotifyTask.java
+ ${CMAKE_HOME_DIRECTORY}/examples/cloud/Cloud.java
+ ${CMAKE_HOME_DIRECTORY}/examples/cloud/FinalizeTask.java
+ ${CMAKE_HOME_DIRECTORY}/examples/cloud/Master.java
+ ${CMAKE_HOME_DIRECTORY}/examples/cloud/Slave.java
${CMAKE_HOME_DIRECTORY}/examples/commTime/FinalizeTask.java
${CMAKE_HOME_DIRECTORY}/examples/commTime/Master.java
${CMAKE_HOME_DIRECTORY}/examples/commTime/Slave.java
COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/async/*.java
COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/bittorrent/*.java
COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/chord/*.java
+ COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/cloud/*.java
COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/commTime/*.java
COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/io/*.java
COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/masterslave/*.java
--- /dev/null
+/*
+ * Copyright 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 cloud;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+
+/**
+ * Example showing the use of the new experimental Cloud API.
+ */
+public class Cloud {
+ public static final double task_comp_size = 10000000;
+ public static final double task_comm_size = 10000000;
+
+ public static void main(String[] args) throws MsgException {
+ Msg.init(args);
+
+ if (args.length < 1) {
+ Msg.info("Usage : Cloud platform_file");
+ Msg.info("Usage : Cloud platform.xml");
+ System.exit(1);
+ }
+ /* Construct the platform */
+ Msg.createEnvironment(args[0]);
+ /* Retrieve the 10 first hosts of the platform file */
+ Host[] hosts = Host.all();
+ if (hosts.length < 10) {
+ Msg.info("I need at least 10 hosts in the platform file, but " + args[0] + " contains only " + hosts.length + " hosts");
+ System.exit(42);
+ }
+ new Master(hosts[0],"Master",hosts).start();
+ /* Execute the simulation */
+ Msg.run();
+
+ Msg.clean();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 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 cloud;
+
+import org.simgrid.msg.Task;
+
+public class FinalizeTask extends Task {
+ public FinalizeTask(double compSize, double commSize) {
+ super("Finalize",compSize,commSize);
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 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 cloud;
+
+import java.util.ArrayList;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.VM;
+
+public class Master extends Process {
+ private Host[] hosts;
+
+ public Master(Host host, String name, Host[] hosts) {
+ super(host,name,null);
+ this.hosts = hosts;
+ }
+ public void main(String[] args) throws MsgException {
+ int slavesCount = 10;
+
+ ArrayList<VM> vms = new ArrayList<VM>();
+
+ for (int i = 0; i < slavesCount; i++) {
+ Slave slave = new Slave(hosts[i],i);
+ slave.start();
+ VM vm = new VM(hosts[i],1);
+ vm.bind(slave);
+ vms.add(vm);
+ }
+ Msg.info("Launched " + vms.size() + " VMs");
+
+ Msg.info("Send a first batch of work to everyone");
+ workBatch(slavesCount);
+
+ Msg.info("Now suspend all VMs, just for fun");
+ for (int i = 0; i < vms.size(); i++) {
+ vms.get(i).suspend();
+ }
+
+ Msg.info("Wait a while");
+ waitFor(2);
+
+ Msg.info("Enough. Let's resume everybody.");
+ for (int i = 0; i < vms.size(); i++) {
+ vms.get(i).resume();
+ }
+
+ Msg.info("Sleep long enough for everyone to be done with previous batch of work");
+ waitFor(1000 - Msg.getClock());
+
+ Msg.info("Add one more process per VM, and dispatch a batch of work to everyone");
+ for (int i = 0; i < vms.size(); i++) {
+ VM vm = vms.get(i);
+ Slave slave = new Slave(hosts[i],i + slavesCount);
+ slave.start();
+ vm.bind(slave);
+ }
+
+ Msg.info("Migrate everyone to the second host.");
+ for (int i = 0; i < vms.size(); i++) {
+ vms.get(i).migrate(hosts[1]);
+ }
+
+ Msg.info("Suspend everyone, move them to the third host, and resume them.");
+ for (int i = 0; i < vms.size(); i++) {
+ VM vm = vms.get(i);
+ vm.suspend();
+ vm.migrate(hosts[2]);
+ }
+
+ workBatch(slavesCount * 2);
+
+ Msg.info("Let's shut down the simulation. 10 first processes will be shut down cleanly while the second half will forcefully get killed");
+
+ for (int i = 0; i < 10; i++) {
+ FinalizeTask task = new FinalizeTask(0,0);
+ task.send("slave_" + i);
+ }
+
+ for (int i = 0; i < vms.size(); i++) {
+ vms.get(i).shutdown();
+ }
+ }
+
+ public void workBatch(int slavesCount) throws MsgException {
+ for (int i = 0; i < slavesCount; i++) {
+ Task task = new Task("Task_" + i, Cloud.task_comp_size, Cloud.task_comm_size);
+ task.send("slave_" + i);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 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 cloud;
+
+import org.simgrid.msg.Host;
+import org.simgrid.msg.Msg;
+import org.simgrid.msg.MsgException;
+import org.simgrid.msg.Process;
+import org.simgrid.msg.Task;
+import org.simgrid.msg.TaskCancelledException;
+
+public class Slave extends Process {
+ private int number;
+ public Slave(Host host, int number) {
+ super(host,"Slave " + number,null);
+ this.number = number;
+ }
+ public void main(String[] args) throws MsgException {
+ while(true) {
+ Task task = Task.receive("slave_"+number);
+
+ if (task instanceof FinalizeTask) {
+ break;
+ }
+ Msg.info("Received \"" + task.getName() + "\". Processing it.");
+ try {
+ task.execute();
+ } catch (TaskCancelledException e) {
+
+ }
+ // Msg.info("\"" + task.getName() + "\" done ");
+ }
+
+ Msg.info("Received Finalize. I'm done. See you!");
+
+ }
+}
\ No newline at end of file
*/
public VM(Host host, int coreAmount) {
this.coreAmount = coreAmount;
+ start(host,coreAmount);
}
/**
* Natively implemented method starting the VM.
* of VM resume to you.
*/
public native void resume();
+
+ public native void shutdown();
}
\ No newline at end of file
/*argc, argv, properties*/
0,NULL,NULL);
MSG_process_set_kill_time(process, (double)jkill);
- MSG_process_set_data(process,&process);
/* bind the java process instance to the native process */
jprocess_bind(jprocess, process, env);
jvm_bind(env,jvm,vm);
}
+
JNIEXPORT jboolean JNICALL
Java_org_simgrid_msg_VM_isSuspended(JNIEnv *env, jobject jvm) {
msg_vm_t vm = jvm_get_native(env,jvm);
msg_vm_t vm = jvm_get_native(env,jvm);
m_process_t process = jprocess_to_native_process(jprocess,env);
+ xbt_assert((vm != NULL), "VM object is not binded");
+ xbt_assert((process != NULL), "Process object is not binded.");
+
MSG_vm_bind(vm,process);
}
JNIEXPORT void JNICALL