examples/java/bittorrent/java_bittorrent_compiled
examples/java/chord/java_chord_compiled
examples/java/cloud/java_cloud_compiled
+examples/java/cloud/energy/java_cloud_energy_compiled
examples/java/cloud/migration/java_cloud_migration_compiled
examples/java/commTime/java_commTime_compiled
examples/java/energy/java_energy_compiled
--- /dev/null
+set(example java_cloud_energy)
+set(sources
+ ${CMAKE_CURRENT_SOURCE_DIR}/Main.java
+ ${CMAKE_CURRENT_SOURCE_DIR}/EnergyVMRunner.java
+ )
+
+if(enable_java)
+ add_custom_command(
+ COMMENT "Building ${example}..."
+ OUTPUT ${example}_compiled
+ DEPENDS ${sources} simgrid-java_jar ${SIMGRID_JAR}
+ COMMAND ${JAVA_COMPILE} -classpath ${SIMGRID_JAR}
+ -d ${CMAKE_CURRENT_BINARY_DIR}/../.. ${sources}
+ COMMAND ${CMAKE_COMMAND} -E remove ${example}_compiled
+ COMMAND ${CMAKE_COMMAND} -E touch ${example}_compiled
+ )
+ add_custom_target(${example} ALL DEPENDS ${example}_compiled)
+endif()
+
+set(tesh_files
+ ${tesh_files}
+ ${CMAKE_CURRENT_SOURCE_DIR}/energyVM.tesh
+ PARENT_SCOPE
+ )
+set(xml_files
+ ${xml_files}
+ PARENT_SCOPE
+ )
+set(examples_src
+ ${examples_src}
+ ${sources}
+ PARENT_SCOPE
+ )
+set(bin_files
+ ${bin_files}
+ PARENT_SCOPE
+ )
+set(txt_files
+ ${CMAKE_CURRENT_SOURCE_DIR}/README
+ ${txt_files}
+ PARENT_SCOPE
+ )
--- /dev/null
+/* Copyright (c) 2016. 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.energy;
+
+import org.simgrid.msg.*;
+import org.simgrid.msg.Process;
+
+/* This class is a process in charge of running the test. It creates and starts the VMs, and fork processes within the VMs */
+public class EnergyVMRunner extends Process {
+
+ public class DummyProcess extends Process {
+ public DummyProcess (Host host, String name) {
+ super(host, name);
+ }
+
+ public void main(String[] args) {
+ Task task = new Task(this.getHost().getName()+"-task", 300E6 , 0);
+ try {
+ task.execute();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ Msg.info("This worker is done.");
+ }
+ }
+
+ EnergyVMRunner(Host host, String name, String[] args) throws HostNotFoundException, NativeException {
+ super(host, name, args);
+ }
+
+ public void main(String[] strings) throws MsgException, HostNotFoundException {
+ double startTime = 0;
+ double endTime = 0;
+
+ /* get hosts */
+ Host host1 = Host.getByName("MyHost1");
+ Host host2 = Host.getByName("MyHost2");
+ Host host3 = Host.getByName("MyHost3");
+
+ Msg.info("Creating and starting two VMs");
+ VM vmHost1 = new VM(host1, "vmHost1", 4, 2048, 100, null, 1024 * 20, 10,50);
+ vmHost1.start();
+
+ VM vmHost3 = new VM(host3, "vmHost3", 4, 2048, 100, null, 1024 * 20, 10,50);
+ vmHost3.start();
+
+ Msg.info("Create two tasks on Host1: one inside a VM, the other directly on the host");
+ new DummyProcess (vmHost1, "p11");
+ new DummyProcess (host1, "p12");
+
+ Msg.info("Create two tasks on Host2: both directly on the host");
+ new DummyProcess (host2, "p21");
+ new DummyProcess (host2, "p22");
+
+ Msg.info("Create two tasks on Host3: both inside a VM");
+ new DummyProcess (vmHost3, "p31");
+ new DummyProcess (vmHost3, "p312");
+
+ Msg.info("Wait 5 seconds. The tasks are still running (they run for 3 seconds, but 2 tasks are co-located, so they run for 6 seconds)");
+ waitFor(5);
+ Msg.info("Wait another 5 seconds. The tasks stop at some point in between");
+ waitFor(5);
+
+ vmHost1.shutdown();
+ vmHost3.shutdown();
+ }
+}
-/* Copyright (c) 2014. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2016. 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.energy;
+package cloud.energy;
import org.simgrid.msg.Host;
import org.simgrid.msg.HostNotFoundException;
import org.simgrid.msg.NativeException;
public class Main {
- private static boolean endOfTest = false;
- public static void setEndOfTest(){
- endOfTest=true;
- }
+ public static void main(String[] args) throws NativeException, HostNotFoundException {
+ /* Init. internal values */
+ Msg.energyInit();
+ Msg.init(args);
- public static boolean isEndOfTest(){
- return endOfTest;
- }
+ if (args.length < 1) {
+ Msg.info("Usage: Main platform_file.xml");
+ System.exit(1);
+ }
- public static void main(String[] args) throws NativeException {
- /* Init. internal values */
- Msg.energyInit();
- Msg.init(args);
+ /* construct the platform */
+ Msg.createEnvironment(args[0]);
+
+ /* Create and start a runner for the experiment */
+ new EnergyVMRunner(Host.all()[0],"energy VM runner",null).start();
- if (args.length < 1) {
- Msg.info("Usage : Main platform_file.xml deployment_file.xml");
- System.exit(1);
- }
-
- /* construct the platform and deploy the application */
- Msg.createEnvironment(args[0]);
- Msg.deployApplication(args[1]);
-
- Msg.run();
-
- }
+ Msg.run();
+ }
}
+++ /dev/null
-/* Copyright (c) 2014. 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.energy;
-
-import org.simgrid.msg.*;
-import org.simgrid.msg.Process;
-
-public class Test extends Process{
-
-
- public class DummyProcess extends Process {
- public DummyProcess (Host host, String name) {
- super(host, name);
- }
-
- public void main(String[] args) {
- Task task = new Task(this.getHost().getName()+"-task", 30E6 , 0);
- try {
- task.execute();
- } catch (Exception e) {
- e.printStackTrace();
- }
- //task.finalize();
- Msg.info("This worker is done.");
- }
- }
-
- Test(Host host, String name, String[] args) throws HostNotFoundException, NativeException {
- super(host, name, args);
- }
-
- public void main(String[] strings) throws MsgException {
-
- double startTime = 0;
- double endTime = 0;
-
- /* get hosts */
- Host host1 = null;
- Host host2 = null;
- Host host3 = null;
-
- try {
- host1 = Host.getByName("MyHost1");
- host2 = Host.getByName("MyHost2");
- host3 = Host.getByName("MyHost3");
- } catch (HostNotFoundException e) {
- e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
- }
-
-
- /* Host 1*/
- Msg.info("Creating and starting two VMs");
- VM vmHost1 = null;
- vmHost1 = new VM(
- host1,
- "vmHost1",
- 4, // Nb of vcpu
- 2048, // Ramsize,
- 100, // Net Bandwidth
- null, //VM disk image
- 1024 * 20, //size of disk image,
- 10, // Net bandwidth,
- 50 // Memory intensity
- );
- vmHost1.start();
-
- VM vmHost3 = null;
- vmHost3 = new VM(
- host3,
- "vmHost3",
- 4, // Nb of vcpu
- 2048, // Ramsize,
- 100, // Net Bandwidth
- null, //VM disk image
- 1024 * 20, //size of disk image,
- 10, // Net bandwidth,
- 50 // Memory intensity
- );
- vmHost3.start();
-
- Msg.info("Create two tasks on Host1: one inside a VM, the other directly on the host");
- DummyProcess p11 = new DummyProcess (vmHost1, "p11");
- p11.run();
- DummyProcess p12 = new DummyProcess (host1, "p12");
- p12.run();
-
- Msg.info("Create two tasks on Host2: both directly on the host");
- DummyProcess p21 = new DummyProcess (host2, "p21");
- p21.run();
- DummyProcess p22 = new DummyProcess (host2, "p22");
- p22.run();
-
- Msg.info("Create two tasks on Host3: both inside a VM");
- DummyProcess p31 = new DummyProcess (vmHost3, "p31");
- p31.run();
- DummyProcess p32 = new DummyProcess (vmHost3, "p312");
- p32.run();
-
- Msg.info("Wait 5 seconde. The tasks are still runing (they run for 3 secondes, but 2 tasks are co-located, so they run for 6 seconds)");
- Process.sleep(5);
- Msg.info("Wait another 5 seconds. The tasks stop at some point in between");
- Process.sleep(5);
-
- vmHost1.shutdown();
- vmHost3.shutdown();
- }
-}
+++ /dev/null
-<?xml version='1.0'?>
-<!DOCTYPE platform SYSTEM "http://simgrid.gforge.inria.fr/simgrid.dtd">
-<platform version="3">
-
- <process host="MyHost1" function="Test" />
-
-</platform>
--- /dev/null
+#! tesh
+
+$ java -classpath ${classpath:=.} cloud/energy/Main ${srcdir:=.}/../platforms/energy_platform.xml
+> [0.000000] [jmsg/INFO] Using regular java threads.
+> [MyHost1:energy VM runner:(1) 0.000000] [jmsg/INFO] Creating and starting two VMs
+> [0.000000] [surf_vm/INFO] Create VM(vmHost1)@PM(MyHost1) with 0 mounted disks
+> [0.000000] [surf_vm/INFO] Create VM(vmHost3)@PM(MyHost3) with 0 mounted disks
+> [MyHost1:energy VM runner:(1) 0.000000] [jmsg/INFO] Create two tasks on Host1: one inside a VM, the other directly on the host
+> [MyHost1:energy VM runner:(1) 0.000000] [jmsg/INFO] Create two tasks on Host2: both directly on the host
+> [MyHost1:energy VM runner:(1) 0.000000] [jmsg/INFO] Create two tasks on Host3: both inside a VM
+> [MyHost1:energy VM runner:(1) 0.000000] [jmsg/INFO] Wait 5 seconds. The tasks are still running (they run for 3 seconds, but 2 tasks are co-located, so they run for 6 seconds)
+> [MyHost1:energy VM runner:(1) 5.000000] [jmsg/INFO] Wait another 5 seconds. The tasks stop at some point in between
+> [10.000000] [jmsg/INFO] MSG_main finished; Cleaning up the simulation...
+> [10.000000] [surf_energy/INFO] Total energy of host MyHost1: 1000.000000 Joules
+> [10.000000] [surf_energy/INFO] Total energy of host MyHost2: 1000.000000 Joules
+> [10.000000] [surf_energy/INFO] Total energy of host MyHost3: 1000.000000 Joules
msg_host_t host = MSG_vm_get_pm(vm);
if (!host->extension(JAVA_HOST_LEVEL)) {
+ THROW_DEADCODE;
/* the native host not yet associated with the java host instance */
/* instanciate a new java host instance */
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/bittorrent)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/chord)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/cloud)
+add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/cloud/energy)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/cloud/migration)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/commTime)
add_subdirectory(${CMAKE_HOME_DIRECTORY}/examples/java/energy)
ADD_TESH(java-bypass --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/master_slave_bypass/bypass.tesh)
ADD_TESH(java-chord --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/chord/chord.tesh)
ADD_TESH(java-cloud --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/cloud/cloud.tesh)
+ ADD_TESH(java-cloud-energy --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/cloud/energy/energy.tesh)
ADD_TESH(java-cloud-migration --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/cloud/migration/migration.tesh)
ADD_TESH(java-commTime --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/commTime/commtime.tesh)
ADD_TESH(java-energy --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/java --setenv classpath=${TESH_CLASSPATH} --cd ${CMAKE_BINARY_DIR}/examples/java ${CMAKE_HOME_DIRECTORY}/examples/java/energy/energy.tesh)