1 /* Copyright (c) 2006-2015. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #ifndef SIMGRID_S4U_HOST_HPP
7 #define SIMGRID_S4U_HOST_HPP
9 #include <boost/unordered_map.hpp>
12 #include "simgrid/simix.h"
21 /** @brief Simulated machine that can host some actors
23 * It represents some physical resource with computing and networking capabilities.
25 * All hosts are automatically created during the call of the method
26 * @link{simgrid::s4u::Engine::loadPlatform()}.
27 * You cannot create a host yourself.
29 * You can retrieve a particular host using @link{simgrid::s4u::Host.byName()},
30 * and actors can retrieve the host on which they run using @link{simgrid::s4u::Host.current()}.
36 Host(const char *name);
40 /** Retrieves an host from its name. */
41 static s4u::Host *byName(std::string name);
42 /** Retrieves the host on which the current actor is running */
43 static s4u::Host *current();
47 /** Turns that host on if it was previously off
49 * All actors on that host which were marked autorestart will be restarted automatically.
50 * This call does nothing if the host is already on.
53 /** Turns that host off. All actors are forcefully stopped. */
55 /** Returns if that host is currently up and running */
59 /** Allows to store user data on that host */
60 void set_userdata(void *data) {p_userdata = data;}
61 /** Retrieves the previously stored data */
62 void* userdata() {return p_userdata;}
64 /** Get an associative list [mount point]->[Storage] off all local mount points.
66 * This is defined in the platform file, and cannot be modified programatically (yet).
68 * Do not change the returned value in any way.
70 boost::unordered_map<std::string, Storage&> &mountedStorages();
72 boost::unordered_map<std::string, Storage&> *mounts = NULL; // caching
75 sg_host_t inferior() {return p_inferior;}
79 static boost::unordered_map<std::string, s4u::Host *> *hosts;
82 }} // namespace simgrid::s4u
84 #endif /* SIMGRID_S4U_HOST_HPP */
87 /* Bindings to the MSG hosts */
89 /* Copyright (c) 2006-2014. The SimGrid Team.
90 * All rights reserved. */
92 /* This program is free software; you can redistribute it and/or modify it
93 * under the terms of the license (GNU LGPL) which comes with this package. */
95 package org.simgrid.msg;
97 import org.simgrid.msg.Storage;
103 jacquelin = Host.getByName("Jacquelin");
104 } catch(HostNotFoundException e) {
105 System.err.println(e.toString());
113 * This static method returns all of the hosts of the installed platform.
115 * @return An array containing all the hosts installed.
118 public native static Host[] all();
121 * This static method sets a mailbox to receive in asynchronous mode.
123 * All messages sent to this mailbox will be transferred to
124 * the receiver without waiting for the receive call.
125 * The receive call will still be necessary to use the received data.
126 * If there is a need to receive some messages asynchronously, and some not,
127 * two different mailboxes should be used.
129 * @param mailboxName The name of the mailbox
131 public static native void setAsyncMailbox(String mailboxName);
134 * This method returns the number of tasks currently running on a host.
135 * The external load (comming from an availability trace) is not taken in account.
137 * @return The number of tasks currently running on a host.
139 public native int getLoad();
142 * This method returns the speed of the processor of a host,
143 * regardless of the current load of the machine.
145 * @return The speed of the processor of the host in flops.
148 public native double getSpeed();
151 * This method returns the number of core of a host.
153 * @return The speed of the processor of the host in flops.
156 public native double getCoreNumber();
159 * Returns the value of a given host property (set from the platform file).
161 public native String getProperty(String name);
164 * Change the value of a given host property.
166 public native void setProperty(String name, String value);
168 /** This methods returns the list of storages attached to an host
169 * @return An array containing all storages (name) attached to the host
171 public native String[] getAttachedStorage();