Use send/receive instead.
* Cleanup the examples and add a README per directory
* Remove example autoDestination (that's the only way to go now)
- * Remove example explicitDestination (was a plain copy of basic)
+ * Remove example explicitDestination (was a plain copy of basic)
+ * Make JniException a runtime exception, so that there is no need to
+ declare the fact that you may encounter such a beast. I guess that
+ nobody will ever want to survive such error.
-- Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
return jprocess;
}
-
-JNIEXPORT jint JNICALL
-Java_simgrid_msg_MsgNative_processSelfPID(JNIEnv * env, jclass cls)
-{
- return (jint) MSG_process_self_PID();
-}
-
-
-JNIEXPORT jint JNICALL
-Java_simgrid_msg_MsgNative_processSelfPPID(JNIEnv * env, jclass cls)
-{
- return (jint) MSG_process_self_PPID();
-}
-
JNIEXPORT void JNICALL
Java_simgrid_msg_MsgNative_processChangeHost(JNIEnv * env, jclass cls,
jobject jhost)
process.properties = this.properties;
this.properties = new Hashtable();
- } catch(JniException e) {
- System.out.println(e.toString());
- e.printStackTrace();
-
} catch(NativeException e) {
System.out.println(e.toString());
e.printStackTrace();
e.printStackTrace();
} catch(InstantiationException e) {
- System.out.println("instantiation exception");
+ System.out.println("Unable to create the process. I got an instantiation exception");
e.printStackTrace();
} catch(IllegalAccessException e) {
- System.out.println("illegal access exception");
- e.printStackTrace();
- } catch(IllegalArgumentException e) {
- System.out.println("illegal argument exception");
+ System.out.println("Unable to create the process. I got an illegal access exception");
e.printStackTrace();
- }
+ }
}
}
* @param name The name of the host to get.
*
* @exception HostNotFoundException if the name of the host is not valid.
- * MsgException if the native version of this method failed.
+ * NativeException if the native version of this method failed.
*/
public static Host getByName(String name)
- throws HostNotFoundException, NativeException, JniException {
+ throws HostNotFoundException, NativeException {
+ if (name==null)
+ throw new NullPointerException("No host can have a null name");
return MsgNative.hostGetByName(name);
}
* @return The count of the installed hosts.
*
*/
- public static int getCount() throws NativeException, JniException {
+ public static int getCount() throws NativeException {
return MsgNative.hostGetCount();
}
* This static method return an instance to the host of the current process.
*
* @return The host on which the current process is executed.
- *
- * @exception MsgException if the native version of this method failed.
*/
- public static Host currentHost() throws JniException {
+ public static Host currentHost() {
return MsgNative.hostSelf();
}
*
* @return An array containing all the hosts installed.
*
- * @exception MsgException if the native version of this method failed.
+ * @exception NativeException if the native version of this method failed.
*/
- public static Host[] all() throws JniException, NativeException {
+ public static Host[] all() throws NativeException {
return MsgNative.allHosts();
}
*
* @return The name of the host.
*
- * @exception InvalidHostException if the host is not valid.
+ * @exception NativeException FIXME: check when
*/
- public String getName() throws NativeException, JniException {
+ public String getName() throws NativeException {
return MsgNative.hostGetName(this);
}
/**
- * This method sets the data of the host.
+ * Sets the data of the host.
*
*/
public void setData(Object data) {
this.data = data;
}
/**
- * This method gets the data of the host.
+ * Gets the data of the host.
*/
public Object getData() {
return this.data;
}
/**
- * This function tests if a host has data.
+ * Checks whether a host has data.
*/
public boolean hasData() {
return null != this.data;
* The external load is not taken in account.
*
* @return The number of tasks currently running on a host.
- *
- * @exception InvalidHostException if the host is invalid.
- *
*/
- public int getLoad() throws JniException {
+ public int getLoad() {
return MsgNative.hostGetLoad(this);
}
*
* @return The speed of the processor of the host in flops.
*
- * @exception InvalidHostException if the host is not valid.
- *
*/
- public double getSpeed() throws JniException {
+ public double getSpeed() {
return MsgNative.hostGetSpeed(this);
}
- /**
- * This method tests if a host is avail.
- *
- * @exception JniException if the host is not valid.
- */
- public boolean isAvail() throws JniException {
+ /** This method tests if a host is avail. */
+ public boolean isAvail() {
return MsgNative.hostIsAvail(this);
}
-
- /** Send the given task to mailbox identified by the default alias */
- public void send(Task task) throws JniException, NativeException {
- String alias = this.getName() + ":" + Process.currentProcess().msgName();
- MsgNative.taskSend(alias, task, -1);
- }
-
- /** Send the given task to the mailbox associated with the specified alias */
-
- public void send(String alias, Task task) throws JniException, NativeException {
- MsgNative.taskSend(alias, task, -1);
- }
-
- /** Send the given task in the mailbox associated with the alias of the current host (waiting at most \a timeout seconds) */
- public void send(Task task, double timeout) throws JniException, NativeException {
- String alias = this.getName() + ":" + Process.currentProcess().msgName();
- MsgNative.taskSend(alias, task, timeout);
- }
-
- /** Send the given task to mailbox associated with the specified alias (waiting at most \a timeout seconds) */
- public void send(String alias, Task task, double timeout) throws JniException, NativeException {
- MsgNative.taskSend(alias, task, timeout);
- }
-
- /** Send the given task to the mailbox associated with the default alias (capping the emision rate to \a maxrate) */
- public void sendBounded(Task task, double maxrate) throws JniException, NativeException {
- String alias = this.getName() + ":" + Process.currentProcess().msgName();
-
- MsgNative.taskSendBounded(alias, task, maxrate);
- }
-
- /** Send the given task to the mailbox associated with the specified alias (capping the emision rate to \a maxrate) */
- public void sendBounded(String alias, Task task, double maxrate) throws JniException, NativeException {
- MsgNative.taskSendBounded(alias, task, maxrate);
- }
}
/**
* This exception is raised when there is a problem within the bindings (in JNI).
+ * That's a RuntimeException: I guess nobody wants to survive a JNI error in SimGrid
*/
public class JniException extends RuntimeException {
private static final long serialVersionUID = 1L;
* @param platformFile The XML file which contains the description of the environment of the simulation
*
*/
- public final static native void createEnvironment(String platformFile)
- throws NativeException;
+ public final static native void createEnvironment(String platformFile) throws NativeException;
/**
* The method to deploy the simulation.
*
* @param platformFile The XML file which contains the description of the application to deploy.
*/
- public final static native void deployApplication(String deploymentFile)
- throws NativeException;
+ public final static native void deployApplication(String deploymentFile) throws NativeException;
/** Example launcher. You can use it or provide your own launcher, as you wish */
static public void main(String[]args) throws MsgException {
* @param process The java process object to bind with the MSG native process.
* @param host A valid (binded) host where create the process.
*
- * @exception simgrid.msg.JniException if JNI stuff goes wrong.
- *
* @see Process constructors.
*/
final static native
- void processCreate(Process process, Host host) throws JniException;
+ void processCreate(Process process, Host host);
/**
* The natively implemented method to kill all the process of the simulation.
*
* @param process The valid (binded with a native process) java process to suspend.
*
- * @exception JniException if something goes wrong with JNI
- * NativeException if the SimGrid native code failed.
+ * @exception NativeException if the SimGrid native code failed.
*
* @see Process.pause()
*/
- final static native void processSuspend(Process process) throws JniException, NativeException;
+ final static native void processSuspend(Process process) throws NativeException;
/**
* The natively implemented method to kill a MSG process.
*
* @see Process.kill()
*/
- final static native void processKill(Process process)
- throws JniException;
+ final static native void processKill(Process process);
/**
* The natively implemented method to resume a suspended MSG process.
*
* @param process The valid (binded with a native process) java process to resume.
*
- * @exception JniException if something goes wrong with JNI
- * NativeException if the SimGrid native code failed.
+ * @exception NativeException if the SimGrid native code failed.
*
* @see Process.restart()
*/
- final static native void processResume(Process process)
- throws JniException, NativeException;
+ final static native void processResume(Process process) throws NativeException;
/**
* The natively implemented method to test if MSG process is suspended.
* @return If the process is suspended the method retuns true. Otherwise the
* method returns false.
*
- * @exception JniException if something goes wrong with JNI
- *
* @see Process.isSuspended()
*/
- final static native boolean processIsSuspended(Process process) throws
- JniException;
+ final static native boolean processIsSuspended(Process process);
/**
* The natively implemented method to get the host of a MSG process.
*
* @return The method returns the host where the process is running.
*
- * @exception JniException if something goes wrong with JNI
- * NativeException if the SimGrid native code failed.
+ * @exception NativeException if the SimGrid native code failed.
*
* @see Process.getHost()
*/
- final static native Host processGetHost(Process process)
- throws JniException, NativeException;
+ final static native Host processGetHost(Process process) throws NativeException;
/**
* The natively implemented method to get a MSG process from his PID.
*
* @see Process.getPID()
*/
- final static native int processGetPID(Process process) throws
- NativeException;
+ final static native int processGetPID(Process process) throws NativeException;
/**
* The natively implemented method to get the PPID of a MSG process.
*
* @see Process.getPPID()
*/
- final static native int processGetPPID(Process process) throws
- NativeException;
+ final static native int processGetPPID(Process process) throws NativeException;
/**
* The natively implemented method to get the current running process.
*/
final static native Process processSelf() throws NativeException;
- /**
- * The natively implemented method to get the current running process PID.
- *
- * @return The PID of the current process.
- *
- * @see Process.currentProcessPID()
- */
- final static native int processSelfPID();
-
- /**
- * The natively implemented method to get the current running process PPID.
- *
- * @return The PPID of the current process.
- *
- * @see Process.currentProcessPPID()
- */
- final static native int processSelfPPID();
-
/**
* The natively implemented method to migrate a process from his currnet host to a new host.
*
* @param process The (valid) process to migrate.
* @param host A (valid) host where move the process.
*
- * @exception JniException if something goes wrong with JNI
- * NativeException if the SimGrid native code failed.
+ * @exception NativeException if the SimGrid native code failed.
*
* @see Process.migrate()
* @see Host.getByName()
*/
- final static native void processChangeHost(Process process, Host host)
- throws JniException, NativeException;
+ final static native void processChangeHost(Process process, Host host) throws NativeException;
/**
* The natively implemented native to request the current process to sleep
*
* @see Process.waitFor()
*/
- final static native void processWaitFor(double seconds) throws
- NativeException;
+ final static native void processWaitFor(double seconds) throws NativeException;
/**
* The natively implemented native method to exit a process.
*
- * @exception JniException if something goes wrong with JNI
- *
* @see Process.exit()
*/
- final static native void processExit(Process process) throws JniException;
+ final static native void processExit(Process process);
/******************************************************************
*
* @return The host having the specified name.
*
- * @exception JniException if something goes wrong with JNI
- * HostNotFoundException if there is no such host
+ * @exception HostNotFoundException if there is no such host
* NativeException if the SimGrid native code failed.
*
* @see Host.getByName()
*/
- final static native Host hostGetByName(String name)
- throws JniException, HostNotFoundException, NativeException;
+ final static native Host hostGetByName(String name) throws HostNotFoundException, NativeException;
/**
* The natively implemented method to get the name of an MSG host.
*
* @return The name of the specified host.
*
- * @exception JniException if something goes wrong with JNI
- *
* @see Host.getName()
*/
- final static native String hostGetName(Host host) throws JniException;
+ final static native String hostGetName(Host host);
/**
* The natively implemented method to get the number of hosts of the simulation.
*
* @return The host of the current running process.
*
- * @exception JniException if something goes wrong with JNI
- *
* @see Host.currentHost()
*/
- final static native Host hostSelf() throws JniException;
+ final static native Host hostSelf();
/**
* The natively implemented method to get the speed of a MSG host.
*
* @return The speed of the specified host.
*
- * @exception JniException if something goes wrong with JNI
- *
* @see Host.getSpeed()
*/
- final static native double hostGetSpeed(Host host) throws JniException;
+ final static native double hostGetSpeed(Host host);
/**
* The natively implemented native method to test if an host is avail.
* @return If the host is avail the method returns true.
* Otherwise the method returns false.
*
- * @exception JniException if something goes wrong with JNI
- *
* @see Host.isAvail()
*/
- final static native boolean hostIsAvail(Host host) throws JniException;
+ final static native boolean hostIsAvail(Host host);
/**
* The natively implemented native method to get all the hosts of the simulation.
*
- * @exception JniException if something goes wrong with JNI
- *
* @return A array which contains all the hosts of simulation.
*/
- final static native Host[] allHosts() throws JniException;
+ final static native Host[] allHosts();
/**
* The natively implemented native method to get the number of running tasks on a host.
* @param The host concerned by the operation.
*
* @return The number of running tasks.
- *
- * @exception JniException if something goes wrong with JNI
- *
*/
- final static native int hostGetLoad(Host host) throws JniException;
+ final static native int hostGetLoad(Host host);
/******************************************************************
* The natively implemented methods connected to the MSG task *
* methods. This value has to be >= 0.
* @param task The java task object to bind with the native task to create.
*
- * @exception JniException if something goes wrong with JNI
- * IllegalArgumentException if compute duration <0 or message size <0
+ * @exception IllegalArgumentException if compute duration <0 or message size <0
*
* @see Task.create()
*/
final static native void taskCreate(Task task, String name,
double computeDuration,
double messageSize)
- throws JniException, IllegalArgumentException;
+ throws IllegalArgumentException;
/**
* The natively implemented method to get the sender of a task.
*
* @return The sender of the task.
*
- * @exception InvalidTaskException is the specified task is not valid. A task
- * is invalid if it is not binded with a native task.
- *
* @see Task.getSender()
*/
- final static native Process taskGetSender(Task task) throws JniException;
+ final static native Process taskGetSender(Task task);
/**
* The natively implementd method to get the source of a task.
*
* @return The source of the task.
*
- * @exception InvalidTaskException is the specified task is not valid. A task
- * is invalid if it is not binded with a native task.
+ * @exception NativeException if the SimGrid native code failed.
*
* @see Task.getSource()
*/
- final static native Host taskGetSource(Task task) throws JniException,
- NativeException;
+ final static native Host taskGetSource(Task task) throws NativeException;
/**
* The natively implemented method to get the name of the task.
*
* @return The name of the specified task.
*
- * @exception InvalidTaskException is the specified task is not valid. A task
- * is invalid if it is not binded with a native task.
- *
* @see Task.getName()
*/
- final static native String taskGetName(Task task) throws JniException;
+ final static native String taskGetName(Task task);
/**
* The natively implemented method to cancel a task.
*
* @param task The task to cancel.
*
- * @exception InvalidTaskException if the specified task is not valid. A task
- * is invalid if it is not binded with a native task.
- * MsgException if the cancelation failed.
+ * @exception NativeException if the cancellation failed.
*
* @see Task.cancel().
*/
- final static native void taskCancel(Task task) throws JniException,
- NativeException;
+ final static native void taskCancel(Task task) throws NativeException;
/**
* The natively implemented method to create a MSG parallel task.
Host[]hosts,
double[]computeDurations,
double[]messageSizes)
- throws JniException, NullPointerException, IllegalArgumentException;
+ throws NullPointerException, IllegalArgumentException;
/**
* The natively implemented method to get the computing amount of the task.
*
* @return The computing amount of the specified task.
*
- * @exception InvalidTaskException if the specified task is not valid. A task
- * is invalid if it is not binded with a native task.
- * MsgException if the cancelation failed.
- *
* @see Task.getComputeDuration()
*/
- final static native double taskGetComputeDuration(Task task) throws
- JniException;
+ final static native double taskGetComputeDuration(Task task);
/**
* The natively implemented method to get the remaining computation
*
* @return The remaining computation of the specified task.
*
- * @exception InvalidTaskException if the specified task is not valid. A task
- * is invalid if it is not binded with a native task.
- * MsgException if the cancelation failed.
- *
* @see Task.getRemainingDuration()
*/
- final static native double taskGetRemainingDuration(Task task) throws
- JniException;
+ final static native double taskGetRemainingDuration(Task task);
/**
* The natively implemented method to set the priority of a task.
*
* @param priority The new priority of the specified task.
*
- * @exception InvalidTaskException if the specified task is not valid. A task
- * is invalid if it is not binded with a native task.
- * MsgException if the cancelation failed.
- *
* @see Task.setPriority()
*/
- final static native void taskSetPriority(Task task,
- double priority) throws
- JniException;
+ final static native void taskSetPriority(Task task, double priority);
/**
* The natively implemented method to destroy a MSG task.
*
* @param The task to destroy.
*
- * @exception InvalidTaskException is the specified task is not valid. A task
- * is invalid if it is not binded with a native task.
- * MsgException if the destruction failed.
+ * @exception NativeException on error in the C world
*
* @see Task.destroy()
*/
- final static native void taskDestroy(Task task) throws JniException,
- NativeException;
+ final static native void taskDestroy(Task task) throws NativeException;
/**
* The natively implemented method to execute a MSG task.
*
* @param task The task to execute.
*
- * @exception InvalidTaskException is the specified task is not valid. A task
- * is invalid if it is not binded with a native task.
- * MsgException if the destruction failed.
+ * @exception NativeException on error in the C world
*
* @see Task.execute()
*/
- final static native void taskExecute(Task task) throws JniException,
- NativeException;
+ final static native void taskExecute(Task task) throws NativeException;
**************************************************************** */
- final static native void taskSend(String alias, Task task, double timeout)
- throws JniException, NativeException;
-
-
- final static native Task taskReceive(String alias, double timeout, Host host)
- throws JniException, NativeException;
-
- final static native int taskListenFrom(String alias)
- throws JniException, NativeException;
-
-
- final static native boolean taskListen(String alias)
- throws JniException;
-
- final static native int taskListenFromHost(String alias, Host host)
- throws JniException;
+ final static native void taskSend(String alias, Task task, double timeout) throws NativeException;
+ final static native Task taskReceive(String alias, double timeout, Host host) throws NativeException;
+ final static native int taskListenFrom(String alias) throws NativeException;
+ final static native boolean taskListen(String alias);
+ final static native int taskListenFromHost(String alias, Host host);
/* ***************************************************************
* Task sending methods *
* @param task The task to put.
* @param max_rate The bounded transmition rate.
*
- * @exception InvalidTaskException if the task is not valid.
- * InvalidHostException if the host is not valid.
- * MsgException if the operation failed.
+ * @exception NativeException on error in the C world
*/
- final static native void taskSendBounded(String alias, Task task, double maxrate)
- throws JniException, NativeException;
+ final static native void taskSendBounded(String alias, Task task, double maxrate) throws NativeException;
}
public class NativeException extends MsgException {
private static final long serialVersionUID = 1L;
- /*
- * Constructs an <code>NativeException</code> without a
- * detail message.
- *
- public NativeException() {
- super();
- }*/
/**
* Constructs an <code>NativeException</code> with a detail message.
*
*/
protected Process() {
super();
- this.id = 0;
+ this.id = nextProcessId++;
this.name = null;
this.bind = 0;
this.args = new Vector<String>();
* @param name The name of the process.
*
* @exception HostNotFoundException if no host with this name exists.
- * NullPointerException if the provided name is null
- * JniException on JNI madness
* NativeException
*
*/
- public Process(String hostname, String name)
- throws NullPointerException, HostNotFoundException, JniException,
- NativeException {
+ public Process(String hostname, String name) throws HostNotFoundException, NativeException {
this(Host.getByName(hostname), name, null);
}
/**
* @param args The arguments of the main function of the process.
*
* @exception HostNotFoundException if no host with this name exists.
- * NullPointerException if the provided name is null
- * JniException on JNI madness
+ * NativeException
*
*/
- public Process(String hostname, String name, String args[])
- throws NullPointerException, HostNotFoundException, JniException,
- NativeException {
+ public Process(String hostname, String name, String args[]) throws HostNotFoundException, NativeException {
this(Host.getByName(hostname), name, args);
}
/**
* @param host The host of the process to create.
* @param name The name of the process.
*
- * @exception NullPointerException if the provided name is null
- * JniException on JNI madness
- *
*/
- public Process(Host host, String name) throws NullPointerException,
- JniException {
+ public Process(Host host, String name) {
this(host, name, null);
}
/**
* @param name The name of the process.
* @param args The arguments of main method of the process.
*
- * @exception NullPointerException if the provided name is null
- * JniException on JNI madness
- *
*/
- public Process(Host host, String name,
- String[]args) throws NullPointerException, JniException {
+ public Process(Host host, String name, String[]args) {
/* This is the constructor called by all others */
-
+ this();
+
if (name == null)
throw new NullPointerException("Process name cannot be NULL");
-
- this.properties = null;
+ this.name = name;
this.args = new Vector<String>();
-
if (null != args)
this.args.addAll(Arrays.asList(args));
- this.name = name;
- this.id = nextProcessId++;
-
- schedBegin = new Sem(0);
- schedEnd = new Sem(0);
-
MsgNative.processCreate(this, host);
}
*
* @param arg The argument to add.
*/
+ @Deprecated
protected void addArg(String arg) {
args.add(arg);
}
/**
- * This method suspends the process by suspending the task on which it was
+ * Suspends the process by suspending the task on which it was
* waiting for the completion.
*
- * @exception JniException on JNI madness
- * NativeException on error in the native SimGrid code
+ * @exception NativeException on error in the native SimGrid code
*/
- public void pause() throws JniException, NativeException {
+ public void pause() throws NativeException {
MsgNative.processSuspend(this);
}
/**
- * This method resumes a suspended process by resuming the task on which it was
+ * Resumes a suspended process by resuming the task on which it was
* waiting for the completion.
*
- * @exception JniException on JNI madness
- * NativeException on error in the native SimGrid code
+ * @exception NativeException on error in the native SimGrid code
*
*/
- public void restart() throws JniException, NativeException {
+ public void restart() throws NativeException {
MsgNative.processResume(this);
}
/**
- * This method tests if a process is suspended.
+ * Tests if a process is suspended.
*
* @return The method returns true if the process is suspended.
* Otherwise the method returns false.
- *
- * @exception JniException on JNI madness
*/
- public boolean isSuspended() throws JniException {
+ public boolean isSuspended() {
return MsgNative.processIsSuspended(this);
}
/**
- * This method returns the host of a process.
+ * Returns the host of a process.
*
* @return The host instance of the process.
*
- * @exception JniException on JNI madness
- * NativeException on error in the native SimGrid code
+ * @exception NativeException on error in the native SimGrid code
*
*/
- public Host getHost() throws JniException, NativeException {
+ public Host getHost() throws NativeException {
return MsgNative.processGetHost(this);
}
/**
- * This static method get a process from a PID.
+ * This static method gets a process from a PID.
*
* @param PID The process identifier of the process to get.
*
*
* @return The PID of the process.
*
- * @exception JniException on JNI madness
- * NativeException on error in the native SimGrid code
+ * @exception NativeException on error in the native SimGrid code
*/
- public int getPID() throws JniException, NativeException {
+ public int getPID() throws NativeException {
return MsgNative.processGetPID(this);
}
/**
* @return The current process.
*
* @exception NativeException on error in the native SimGrid code
- *
- *
*/
public static Process currentProcess() throws NativeException {
return MsgNative.processSelf();
}
/**
- * This static method returns the PID of the currently running process.
- *
- * @return The PID of the current process.
- */
- public static int currentProcessPID() {
- return MsgNative.processSelfPID();
- }
-
- /**
- * This static method returns the PID of the parent of the currently running process.
- *
- * @return The PID of the parent of current process.
- */
- public static int currentProcessPPID() {
- return MsgNative.processSelfPPID();
- }
-
- /**
- * This function migrates a process to another host.
+ * Migrates a process to another host.
*
* @param host The host where to migrate the process.
*
- * @exception JniException on JNI madness
- * NativeException on error in the native SimGrid code
+ * @exception NativeException on error in the native SimGrid code
*/
- public void migrate(Host host) throws JniException, NativeException {
+ public void migrate(Host host) throws NativeException {
MsgNative.processChangeHost(this, host);
}
/**
- * This method makes the current process sleep until time seconds have elapsed.
+ * Makes the current process sleep until time seconds have elapsed.
*
* @param seconds The time the current process must sleep.
*
/**
* The main function of the process (to implement).
*/
- public abstract void main(String[]args) throws JniException, NativeException;
+ public abstract void main(String[]args) throws NativeException;
public void unschedule() {
}
/** Send the given task in the mailbox associated with the specified alias (waiting at most given time) */
- public void taskSend(String mailbox, Task task, double timeout) throws NativeException, JniException {
+ public void taskSend(String mailbox, Task task, double timeout) throws NativeException {
MsgNative.taskSend(mailbox, task, timeout);
}
/** Send the given task in the mailbox associated with the specified alias*/
- public void taskSend(String mailbox, Task task) throws NativeException, JniException {
+ public void taskSend(String mailbox, Task task) throws NativeException {
MsgNative.taskSend(mailbox, task, -1);
}
/** Receive a task on mailbox associated with the specified mailbox */
- public Task taskReceive(String mailbox) throws NativeException, JniException {
+ public Task taskReceive(String mailbox) throws NativeException {
return MsgNative.taskReceive(mailbox, -1.0, null);
}
/** Receive a task on mailbox associated with the specified alias (waiting at most given time) */
- public Task taskReceive(String mailbox, double timeout) throws NativeException, JniException {
+ public Task taskReceive(String mailbox, double timeout) throws NativeException {
return MsgNative.taskReceive(mailbox, timeout, null);
}
/** Receive a task on mailbox associated with the specified alias from given sender */
- public Task taskReceive(String mailbox, double timeout, Host host) throws NativeException, JniException {
+ public Task taskReceive(String mailbox, double timeout, Host host) throws NativeException {
return MsgNative.taskReceive(mailbox, timeout, host);
}
/** Receive a task on mailbox associated with the specified alias from given sender*/
- public Task taskReceive(String mailbox, Host host) throws NativeException, JniException {
+ public Task taskReceive(String mailbox, Host host) throws NativeException {
return MsgNative.taskReceive(mailbox, -1.0, host);
}
}
public long bind = 0;
- /* Default constructor (disabled) */
- public Task() throws JniException {
+ /** Default constructor (all fields to 0 or null) */
+ public Task() {
MsgNative.taskCreate(this, null, 0, 0);
}
/* * * *
* @param messageSize A value of amount of data (in bytes) needed to transfert this task.
* If 0, then it cannot be transfered with the get() and put() methods.
* This value has to be >= 0.
- *
- * @exception JniException if the binding mechanism fails.
*/
- public Task(String name, double computeDuration, double messageSize) throws JniException {
+ public Task(String name, double computeDuration, double messageSize) {
MsgNative.taskCreate(this, name, computeDuration, messageSize);
}
/**
* @param hosts The list of hosts implied by the parallel task.
* @param computeDurations The amount of operations to be performed by each host of \a hosts.
* @param messageSizes A matrix describing the amount of data to exchange between hosts.
- *
- * @exception JniException if the binding mecanism fails.
*/
- public Task(String name, Host[]hosts, double[]computeDurations, double[]messageSizes) throws JniException {
+ public Task(String name, Host[]hosts, double[]computeDurations, double[]messageSizes) {
MsgNative.parallelTaskCreate(this, name, hosts, computeDurations, messageSizes);
}
/* * * *
* * Getters / Setters * *
* * * */
- /** gets the name of a task.
- * @exception JniException if the binding mechanism fails.
- */
- public String getName() throws JniException {
+ /** Gets the name of a task */
+ public String getName() {
return MsgNative.taskGetName(this);
}
- /** gets the sender of the task.
- * @exception JniException if the binding mechanism fails.
- *
- */
- Process getSender() throws JniException {
+ /** Gets the sender of the task */
+ Process getSender() {
return MsgNative.taskGetSender(this);
}
- /** Gets the source of the task.
- * @exception JniException if the binding mechanism fails.
- */
- public Host getSource() throws JniException, NativeException {
+ /** Gets the source of the task */
+ public Host getSource() throws NativeException {
return MsgNative.taskGetSource(this);
}
- /** gets the computing amount of the task.
- * @exception JniException if the binding mechanism fails.
- */
- public double getComputeDuration() throws JniException {
+ /** Gets the computing amount of the task */
+ public double getComputeDuration() {
return MsgNative.taskGetComputeDuration(this);
}
- /** gets the remaining computation of the task.
- * @exception JniException if the binding mechanism fails.
- */
- public double getRemainingDuration() throws JniException {
+ /** Gets the remaining computation of the task */
+ public double getRemainingDuration() {
return MsgNative.taskGetRemainingDuration(this);
}
/**
* the other ones.
*
* @param priority The new priority of the task.
- *
- * @exception JniException is the specified task is not valid (ie, not binded to a native task)
*/
- public void setPriority(double priority) throws JniException {
+ public void setPriority(double priority) {
MsgNative.taskSetPriority(this, priority);
}
/* * * *
* * Computation-related * *
* * * */
/**
- * This method execute a task on the location on which the
- * process is running.
+ * Executes a task on the location on which the process is running.
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the execution failed.
*/
- public void execute() throws JniException, NativeException {
+ public void execute() throws NativeException {
MsgNative.taskExecute(this);
}
/**
- * This method cancels a task.
+ * Cancels a task.
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the cancellation failed.
*/
- public void cancel() throws JniException, NativeException {
+ public void cancel() throws NativeException {
MsgNative.taskCancel(this);
}
/** Deletes a task.
*
- * @exception JniException if the binding mechanism fails
- * NativeException if the destruction failed.
+ * @exception NativeException if the destruction failed.
*/
- protected void finalize() throws JniException, NativeException {
+ protected void finalize() throws NativeException {
if (this.bind != 0)
MsgNative.taskDestroy(this);
}
/**
- * Send the task on the mailbox identified by the specified name
+ * Sends the task on the mailbox identified by the specified name
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the retrieval fails.
*/
- public void send(String mailbox) throws JniException,NativeException {
+ public void send(String mailbox) throws NativeException {
MsgNative.taskSend(mailbox, this, -1);
}
/**
- * Send the task on the mailbox identified by the specified name (wait at most \a timeout seconds)
+ * Sends the task on the mailbox identified by the specified name (wait at most \a timeout seconds)
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the retrieval fails.
*/
- public void send(String mailbox, double timeout) throws JniException,NativeException {
+ public void send(String mailbox, double timeout) throws NativeException {
MsgNative.taskSend(mailbox, this, timeout);
}
/**
- * Send the task on the mailbox identified by the specified alias (capping the sending rate to \a maxrate)
+ * Sends the task on the mailbox identified by the specified alias (capping the sending rate to \a maxrate)
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the retrieval fails.
*/
- public void sendBounded(String alias, double maxrate) throws JniException,NativeException {
+ public void sendBounded(String alias, double maxrate) throws NativeException {
MsgNative.taskSendBounded(alias, this, maxrate);
}
/**
* Retrieves next task from the mailbox identified by the specified name
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the retrieval fails.
*/
- public static Task receive(String mailbox) throws JniException, NativeException {
+ public static Task receive(String mailbox) throws NativeException {
return MsgNative.taskReceive(mailbox, -1.0, null);
}
/**
* Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds)
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the retrieval fails.
*/
- public static Task receive(String mailbox, double timeout) throws JniException, NativeException {
+ public static Task receive(String mailbox, double timeout) throws NativeException {
return MsgNative.taskReceive(mailbox, timeout, null);
}
/**
* Retrieves next task sent by a given host on the mailbox identified by the specified alias
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the retrieval fails.
*/
- public static Task receive(String mailbox, Host host) throws JniException, NativeException {
+ public static Task receive(String mailbox, Host host) throws NativeException {
return MsgNative.taskReceive(mailbox, -1.0, host);
}
/**
* Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds)
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the retrieval fails.
*/
- public static Task receive(String mailbox, double timeout, Host host) throws JniException, NativeException {
+ public static Task receive(String mailbox, double timeout, Host host) throws NativeException {
return MsgNative.taskReceive(mailbox, timeout, host);
}
/**
- * Test whether there is a pending communication on the mailbox identified by the specified alias, and who sent it
+ * Tests whether there is a pending communication on the mailbox identified by the specified alias, and who sent it
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the retrieval fails.
*/
- public static int listenFrom(String mailbox) throws JniException, NativeException {
+ public static int listenFrom(String mailbox) throws NativeException {
return MsgNative.taskListenFrom(mailbox);
}
/**
* Listen whether there is a waiting task on the mailbox identified by the specified alias
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the retrieval fails.
*/
- public static boolean listen(String mailbox) throws JniException, NativeException {
+ public static boolean listen(String mailbox) throws NativeException {
return MsgNative.taskListen(mailbox);
}
/**
* Counts the number of tasks waiting to be received on the \a mailbox identified by the specified alia and sended by the specified \a host.
*
- * @exception JniException if the binding mechanism fails.
* @exception NativeException if the retrieval fails.
*/
- public static int listenFromHost(String alias, Host host) throws JniException, NativeException {
+ public static int listenFromHost(String alias, Host host) throws NativeException {
return MsgNative.taskListenFromHost(alias, host);
}
}