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>
11 #include "simgrid/simix.h"
18 /** @brief Simulated machine that can host some processes
20 * It represents some physical resource with computing and networking capabilities.
22 * All hosts are automatically created during the call of the method
23 * @link{simgrid::s4u::Engine::loadPlatform()}.
24 * You cannot create a host yourself.
26 * You can retrieve a particular host using @link{simgrid::s4u::Host.byName()},
27 * and processes can retrieve the host on which they run using @link{simgrid::s4u::Host.current()}.
31 Host(const char *name);
33 /** Retrieves an host from its name. */
34 static s4u::Host *byName(std::string name);
35 /** Retrieves the host on which the current process is running */
36 static s4u::Host *current();
38 const char* getName();
40 /** Turn sthat host on if it was previously off
42 * All processes on that host which were marked autorestart will be restarted automatically.
43 * This call does nothing if the host is already on.
46 /** Turns that host off. All processes are forcefully stopped. */
48 /** Returns if that host is currently up and running */
52 /** Allows to store user data on that host */
53 void setData(void *data) {p_userdata = data;}
54 /** Retrieves the previously stored data */
55 void* getData() {return p_userdata;}
59 sg_host_t getInferior() {return p_sghost;}
63 static boost::unordered_map<std::string, s4u::Host *> *hosts;
66 }} // namespace simgrid::s4u
68 #endif /* SIMGRID_S4U_HOST_HPP */
71 /* Bindings to the MSG hosts */
73 /* Copyright (c) 2006-2014. The SimGrid Team.
74 * All rights reserved. */
76 /* This program is free software; you can redistribute it and/or modify it
77 * under the terms of the license (GNU LGPL) which comes with this package. */
79 package org.simgrid.msg;
81 import org.simgrid.msg.Storage;
87 jacquelin = Host.getByName("Jacquelin");
88 } catch(HostNotFoundException e) {
89 System.err.println(e.toString());
97 * This static method returns all of the hosts of the installed platform.
99 * @return An array containing all the hosts installed.
102 public native static Host[] all();
105 * This static method sets a mailbox to receive in asynchronous mode.
107 * All messages sent to this mailbox will be transferred to
108 * the receiver without waiting for the receive call.
109 * The receive call will still be necessary to use the received data.
110 * If there is a need to receive some messages asynchronously, and some not,
111 * two different mailboxes should be used.
113 * @param mailboxName The name of the mailbox
115 public static native void setAsyncMailbox(String mailboxName);
118 * This method returns the number of tasks currently running on a host.
119 * The external load (comming from an availability trace) is not taken in account.
121 * @return The number of tasks currently running on a host.
123 public native int getLoad();
126 * This method returns the speed of the processor of a host,
127 * regardless of the current load of the machine.
129 * @return The speed of the processor of the host in flops.
132 public native double getSpeed();
135 * This method returns the number of core of a host.
137 * @return The speed of the processor of the host in flops.
140 public native double getCoreNumber();
143 * Returns the value of a given host property (set from the platform file).
145 public native String getProperty(String name);
148 * Change the value of a given host property.
150 public native void setProperty(String name, String value);
152 /** This methods returns the list of mount point names on an host
153 * @return An array containing all mounted storages on the host
155 public native Storage[] getMountedStorage();
157 /** This methods returns the list of storages attached to an host
158 * @return An array containing all storages (name) attached to the host
160 public native String[] getAttachedStorage();