1 /* Copyright (c) 2014. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 package sleep_host_off;
9 import org.simgrid.msg.*;
10 import org.simgrid.msg.Process;
11 import org.simgrid.trace.Trace;
13 import java.util.ArrayList;
14 import java.util.List;
15 import java.util.Random;
17 class Sleeper extends Process {
18 public Sleeper(Host host, String name, String[] args) {
19 super(host,name,args);
21 public void main(String[] args) {
23 Msg.info("I'm not dead");
26 } catch (HostFailureException e) {
27 Msg.info("catch HostException: "+e.getLocalizedMessage());
28 break; //Break is needed to finalize the endless loop
34 class TestRunner extends Process {
36 public TestRunner(Host host, String name, String[] args) {
37 super(host,name,args);
40 public void main(String[] strings) throws MsgException {
41 Host host = Host.all()[1];
44 Msg.info("**** **** **** ***** ***** Test Sleep ***** ***** **** **** ****");
45 Msg.info("Test sleep: Create a process on "+host.getName()+" that simply make periodic sleep, turn off "+host.getName());
46 new Sleeper(host, "Sleeper", null).start();
49 Msg.info("Stop "+host.getName());
51 Msg.info(host.getName()+" has been stopped");
53 Msg.info("Test sleep seems ok, cool! (number of Process : " + Process.getCount() + ", it should be 1 (i.e. the Test one))");
57 public class SleepHostOff {
59 public static void main(String[] args) throws Exception {
60 /* Init. internal values */
63 if (args.length < 1) {
64 Msg.info("Usage: java -cp simgrid.jar:. sleep_host_off.SleepHostOff <platform.xml>");
68 /* construct the platform and deploy the application */
69 Msg.createEnvironment(args[0]);
71 Host[] hosts = Host.all();
72 new TestRunner(hosts[0], "TestRunner", null).start();