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>
13 #include "simgrid/simix.h"
22 /** @brief Simulated machine that can host some actors
24 * It represents some physical resource with computing and networking capabilities.
26 * All hosts are automatically created during the call of the method
27 * @link{simgrid::s4u::Engine::loadPlatform()}.
28 * You cannot create a host yourself.
30 * You can retrieve a particular host using @link{simgrid::s4u::Host.byName()},
31 * and actors can retrieve the host on which they run using @link{simgrid::s4u::Host.current()}.
33 XBT_PUBLIC_CLASS Host {
37 Host(const char *name);
41 /** Retrieves an host from its name. */
42 static s4u::Host *byName(std::string name);
43 /** Retrieves the host on which the current actor is running */
44 static s4u::Host *current();
48 /** Turns that host on if it was previously off
50 * All actors on that host which were marked autorestart will be restarted automatically.
51 * This call does nothing if the host is already on.
54 /** Turns that host off. All actors are forcefully stopped. */
56 /** Returns if that host is currently up and running */
60 /** Allows to store user data on that host */
61 void set_userdata(void *data) {p_userdata = data;}
62 /** Retrieves the previously stored data */
63 void* userdata() {return p_userdata;}
65 /** Get an associative list [mount point]->[Storage] off all local mount points.
67 * This is defined in the platform file, and cannot be modified programatically (yet).
69 * Do not change the returned value in any way.
71 boost::unordered_map<std::string, Storage&> &mountedStorages();
73 boost::unordered_map<std::string, Storage&> *mounts = NULL; // caching
76 sg_host_t inferior() {return p_inferior;}
80 static boost::unordered_map<std::string, s4u::Host *> *hosts;
83 }} // namespace simgrid::s4u
85 #endif /* SIMGRID_S4U_HOST_HPP */
88 /* Bindings to the MSG hosts */
90 /* Copyright (c) 2006-2014. The SimGrid Team.
91 * All rights reserved. */
93 /* This program is free software; you can redistribute it and/or modify it
94 * under the terms of the license (GNU LGPL) which comes with this package. */
96 package org.simgrid.msg;
98 import org.simgrid.msg.Storage;
104 jacquelin = Host.getByName("Jacquelin");
105 } catch(HostNotFoundException e) {
106 System.err.println(e.toString());
114 * This static method returns all of the hosts of the installed platform.
116 * @return An array containing all the hosts installed.
119 public native static Host[] all();
122 * This static method sets a mailbox to receive in asynchronous mode.
124 * All messages sent to this mailbox will be transferred to
125 * the receiver without waiting for the receive call.
126 * The receive call will still be necessary to use the received data.
127 * If there is a need to receive some messages asynchronously, and some not,
128 * two different mailboxes should be used.
130 * @param mailboxName The name of the mailbox
132 public static native void setAsyncMailbox(String mailboxName);
135 * This method returns the number of tasks currently running on a host.
136 * The external load (comming from an availability trace) is not taken in account.
138 * @return The number of tasks currently running on a host.
140 public native int getLoad();
143 * This method returns the speed of the processor of a host,
144 * regardless of the current load of the machine.
146 * @return The speed of the processor of the host in flops.
149 public native double getSpeed();
152 * This method returns the number of core of a host.
154 * @return The speed of the processor of the host in flops.
157 public native double getCoreNumber();
160 * Returns the value of a given host property (set from the platform file).
162 public native String getProperty(String name);
165 * Change the value of a given host property.
167 public native void setProperty(String name, String value);
169 /** This methods returns the list of storages attached to an host
170 * @return An array containing all storages (name) attached to the host
172 public native String[] getAttachedStorage();