Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove unecessary imports to please sonar
[simgrid.git] / src / bindings / java / org / simgrid / msg / Host.java
index c00dd54..0b52540 100644 (file)
@@ -1,27 +1,23 @@
-/*
- * Bindings to the MSG hosts
- *
- * Copyright 2006-2012 The SimGrid Team           
- * All right reserved. 
- *
- * This program is free software; you can redistribute 
- * it and/or modify it under the terms of the license 
- *(GNU LGPL) which comes with this package. 
- *
- */  
+/* Bindings to the MSG hosts */
+
+/* Copyright (c) 2006-2018. The SimGrid Team. All rights reserved.          */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
 package org.simgrid.msg;
 
 /**
- * A host object represents a location (any possible place) where a process may run. 
- * Thus it is represented as a physical resource with computing capabilities, some 
- * mailboxes to enable running process to communicate with remote ones, and some private 
- * data that can be only accessed by local process. An instance of this class is always 
+ * A host object represents a location (any possible place) where a process may run.
+ * Thus it is represented as a physical resource with computing capabilities, some
+ * mailboxes to enable running process to communicate with remote ones, and some private
+ * data that can be only accessed by local process. An instance of this class is always
  * bound with the corresponding native host. All the native hosts are automatically created
  * during the call of the method Msg.createEnvironment(). This method take as parameter a
  * platform file which describes all elements of the platform (host, link, root..).
  * You cannot create a host yourself.
  *
- * The best way to get an host instance is to call the static method 
+ * The best way to get an host instance is to call the static method
  * Host.getByName().
  *
  * For example to get the instance of the host. If your platform
@@ -30,7 +26,7 @@ package org.simgrid.msg;
  * \verbatim
 Host jacquelin;
 
-try { 
+try {
        jacquelin = Host.getByName("Jacquelin");
 } catch(HostNotFoundException e) {
        System.err.println(e.toString());
@@ -38,34 +34,31 @@ try {
 ...
 \endverbatim
  *
- */ 
+ */
 public class Host {
 
        /**
         * This attribute represents a bind between a java host object and
         * a native host. Even if this attribute is public you must never
-        * access to it. It is set automatically during the call of the 
+        * access to it. It is set automatically during the call of the
         * static method Host.getByName().
         *
         * @see                         Host.getByName().
-        */ 
-       private long bind;
-       /**
-        * Host name
         */
-       private String name;
+       private long bind;
+       protected String name;
 
-       /**
-        * User data.
-        */ 
+       /** User data. */
        private Object data;
-    /**
-     *
-     */
-    protected Host() {
+       protected Host() {
                this.bind = 0;
                this.data = null;
-       };
+       }
+
+       @Override
+       public String toString (){
+               return this.name;
+       }
 
        /**
         * This static method gets an host instance associated with a native
@@ -74,100 +67,107 @@ public class Host {
         * @param name          The name of the host to get.
         *
         * @return              The host object with the given name.
-     * @exception              HostNotFoundException if the name of the host is not valid.
-        *                                      NativeException if the native version of this method failed.
-        */ 
-       public native static Host getByName(String name) 
-       throws HostNotFoundException, NullPointerException;
-       /**
-        * This static method returns the count of the installed hosts.
-        *
-        * @return                      The count of the installed hosts.
-        */ 
-       public native static int getCount();
+        * @exception           HostNotFoundException if the name of the host is not valid.
+        */
+       public static native Host getByName(String name) throws HostNotFoundException;
+       /** Counts the installed hosts. */
+       public static native int getCount();
 
-       /**
-        * This static method return an instance to the host of the current process.
-        *
-        * @return                      The host on which the current process is executed.
-        */ 
-       public native static Host currentHost();
+       /** Returns the host of the current process. */
+       public static native Host currentHost();
+
+       /** Returns all hosts of the installed platform. */
+       public static native Host[] all();
 
        /**
-        * This static method returns all of the hosts of the installed platform.
+        * This static method sets a mailbox to receive in asynchronous mode.
         *
-        * @return                      An array containing all the hosts installed.
+        * All messages sent to this mailbox will be transferred to
+        * the receiver without waiting for the receive call.
+        * The receive call will still be necessary to use the received data.
+        * If there is a need to receive some messages asynchronously, and some not,
+        * two different mailboxes should be used.
         *
-        */ 
-       public native static Host[] all();
+        * @param mailboxName The name of the mailbox
+        */
+       public static native void setAsyncMailbox(String mailboxName);
 
-       /**
-        * This method returns the name of a host.
-        * @return                      The name of the host.
-        *
-        */ 
        public String getName() {
                return name;
        }
-       /**
-        * Sets the data of the host.
-     * @param data
-     */
+
        public void setData(Object data) {
                this.data = data;
-       } 
-       /**
-        * Gets the data of the host.
-     *
-     * @return The data object associated with the host.
-     */
+       }
+
        public Object getData() {
                return this.data;
        }
-
-       /**
-        * Checks whether a host has data.
-     *
-     * @return True if the host has an associated data object.
-     */
+       /** Returns true if the host has an associated data object. */
        public boolean hasData() {
                return null != this.data;
        }
 
-       /**
-        * This method returns the number of tasks currently running on a host.
-        * The external load is not taken in account.
-        *
-        * @return                      The number of tasks currently running on a host.
-        */ 
-       public native int getLoad();
+       /** Starts the host if it is off */
+       public native void on();
+       /** Stops the host if it is on */
+       public native void off();
 
        /**
-        * This method returns the speed of the processor of a host,
+        * This method returns the speed of the processor of a host (in flops),
         * regardless of the current load of the machine.
-        *
-        * @return                      The speed of the processor of the host in flops.
-        *
-        */ 
-       public native double getSpeed();
-       /**
-        * Returns the value of a given host property. 
         */
+       public native double getSpeed();
+       public native double getCoreNumber();
+
        public native String getProperty(String name);
-       /**
-        * Change the value of a given host property. 
-        */
        public native void setProperty(String name, String value);
-    /** This method tests if a host is available.
-     * @return True if the host is available.
-     */
-       public native boolean isAvail();
-       
-       /**
-        * Class initializer, to initialize various JNI stuff
+       /** Tests if an host is up and running. */
+       public native boolean isOn();
+
+       /** Returns the list of mount point names on an host */
+       public native Storage[] getMountedStorage();
+       /** This methods returns the list of storages (names) attached to an host */
+       public native String[] getAttachedStorage();
+
+       /** After this call, sg_host_get_consumed_energy() will not interrupt your process
+        * (until after the next clock update).
+        */
+       public static native void updateAllEnergyConsumptions();
+       /** Returns the amount of Joules consumed by that host so far
+        *
+        * Please note that since the consumption is lazily updated, it may require a simcall to update it.
+        * The result is that the actor requesting this value will be interrupted,
+        * the value will be updated in kernel mode before returning the control to the requesting actor.
+        */
+       public native double getConsumedEnergy();
+
+       /** Returns the current load of the host, as a ratio = achieved_flops / (core_current_speed * core_amount)
+        *      
+        * See simgrid::plugin::HostLoad::get_current_load() for the full documentation.
         */
-       public static native void nativeInit();
+       public native double getCurrentLoad();
+       /** Returns the number of flops computed of the host since the beginning of the simulation */
+       public native double getComputedFlops();
+       /** Returns the average load of the host as a ratio since the beginning of the simulation*/
+       public native double getAvgLoad();
+   
+       /** Returns the current pstate */
+       public native int getPstate();
+       /** Changes the current pstate */
+       public native void setPstate(int pstate);
+       public native int getPstatesCount();
+       /** Returns the speed of the processor (in flop/s) at the current pstate. See also @ref plugin_energy. */
+       public native double getCurrentPowerPeak();
+       /** Returns the speed of the processor (in flop/s) at a given pstate. See also @ref plugin_energy. */
+       public native double getPowerPeakAt(int pstate);
+
+       /** Returns the current computation load (in flops per second) */
+       public native double getLoad();
+
+       /** Class initializer, to initialize various JNI stuff */
+       private static native void nativeInit();
        static {
                nativeInit();
        }       
-} 
+}