2 * Bindings to the MSG hosts
4 * Copyright 2006-2012 The SimGrid Team
7 * This program is free software; you can redistribute
8 * it and/or modify it under the terms of the license
9 *(GNU LGPL) which comes with this package.
12 package org.simgrid.msg;
15 * A host object represents a location (any possible place) where a process may run.
16 * Thus it is represented as a physical resource with computing capabilities, some
17 * mailboxes to enable running process to communicate with remote ones, and some private
18 * data that can be only accessed by local process. An instance of this class is always
19 * bound with the corresponding native host. All the native hosts are automatically created
20 * during the call of the method Msg.createEnvironment(). This method take as parameter a
21 * platform file which describes all elements of the platform (host, link, root..).
22 * You cannot create a host yourself.
24 * The best way to get an host instance is to call the static method
27 * For example to get the instance of the host. If your platform
28 * file description contains an host named "Jacquelin" :
34 jacquelin = Host.getByName("Jacquelin");
35 } catch(HostNotFoundException e) {
36 System.err.println(e.toString());
45 * This attribute represents a bind between a java host object and
46 * a native host. Even if this attribute is public you must never
47 * access to it. It is set automatically during the call of the
48 * static method Host.getByName().
50 * @see Host.getByName().
56 protected String name;
70 public String toString (){
76 * This static method gets an host instance associated with a native
77 * host of your platform. This is the best way to get a java host object.
79 * @param name The name of the host to get.
81 * @return The host object with the given name.
82 * @exception HostNotFoundException if the name of the host is not valid.
83 * NativeException if the native version of this method failed.
85 public native static Host getByName(String name)
86 throws HostNotFoundException, NullPointerException;
88 * This static method returns the count of the installed hosts.
90 * @return The count of the installed hosts.
92 public native static int getCount();
95 * This static method return an instance to the host of the current process.
97 * @return The host on which the current process is executed.
99 public native static Host currentHost();
102 * This static method returns all of the hosts of the installed platform.
104 * @return An array containing all the hosts installed.
107 public native static Host[] all();
110 * This method returns the name of a host.
111 * @return The name of the host.
114 public String getName() {
118 * Sets the data of the host.
121 public void setData(Object data) {
125 * Gets the data of the host.
127 * @return The data object associated with the host.
129 public Object getData() {
134 * Checks whether a host has data.
136 * @return True if the host has an associated data object.
138 public boolean hasData() {
139 return null != this.data;
143 * This method returns the number of tasks currently running on a host.
144 * The external load is not taken in account.
146 * @return The number of tasks currently running on a host.
148 public native int getLoad();
151 * This method returns the speed of the processor of a host,
152 * regardless of the current load of the machine.
154 * @return The speed of the processor of the host in flops.
157 public native double getSpeed();
160 * Returns the value of a given host property.
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 method tests if a host is available.
170 * @return True if the host is available.
172 public native boolean isAvail();
175 * Class initializer, to initialize various JNI stuff
177 public static native void nativeInit();