X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/0424e24e1f270b3c65b20e994079679b18be3eb8..68422deb1639b1ce574393779ae259579be53fb5:/src/bindings/java/org/simgrid/msg/Task.java?ds=sidebyside diff --git a/src/bindings/java/org/simgrid/msg/Task.java b/src/bindings/java/org/simgrid/msg/Task.java index e371caee7e..0dec155c5b 100644 --- a/src/bindings/java/org/simgrid/msg/Task.java +++ b/src/bindings/java/org/simgrid/msg/Task.java @@ -48,7 +48,14 @@ public class Task { * This value has to be ≥ 0. */ public Task(String name, double flopsAmount, double bytesAmount) { + if (flopsAmount<0) + throw new IllegalArgumentException("Task flopsAmount (" + flopsAmount + ") cannot be negative"); + if (bytesAmount<0) + throw new IllegalArgumentException("Task bytesAmount (" + bytesAmount + ") cannot be negative"); + create(name, flopsAmount, bytesAmount); + + this.name = name; this.messageSize = bytesAmount; } /** @@ -66,7 +73,17 @@ public class Task { * the destination of the communications. */ public Task(String name, Host[]hosts, double[]flopsAmount, double[]bytesAmount) { + if (flopsAmount == null) + throw new NullPointerException("Parallel task flops amounts is null"); + if (bytesAmount == null) + throw new NullPointerException("Parallel task bytes amounts is null"); + if (hosts == null) + throw new NullPointerException("Host list is null"); + if (name == null) + throw new NullPointerException("Parallel task name is null"); + parallelCreate(name, hosts, flopsAmount, bytesAmount); + this.name = name; } /** @@ -84,8 +101,7 @@ public class Task { */ private final native void create(String name, double flopsAmount, - double bytesAmount) - throws IllegalArgumentException; + double bytesAmount); /** * The natively implemented method to create a MSG parallel task. * @@ -99,8 +115,7 @@ public class Task { private final native void parallelCreate(String name, Host[]hosts, double[]flopsAmount, - double[]bytesAmount) - throws NullPointerException, IllegalArgumentException; + double[]bytesAmount); /* * * * * * Getters / Setters * * * * * */ @@ -166,6 +181,7 @@ public class Task { public native void cancel(); /** Deletes a task once the garbage collector reclaims it */ + @Override protected void finalize() throws Throwable{ nativeFinalize(); bind=0; // to avoid segfaults if the impossible happens yet again making this task surviving its finalize() @@ -209,7 +225,9 @@ public class Task { * @throws HostFailureException * @throws TransferFailureException */ - public native void send(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException; + public void send(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException { + sendBounded(mailbox, timeout, -1); + } /** Sends the task on the specified mailbox (capping the sending rate to \a maxrate) * @@ -220,7 +238,7 @@ public class Task { * @throws TimeoutException */ public void sendBounded(String mailbox, double maxrate) throws TransferFailureException, HostFailureException, TimeoutException { - sendBounded(mailbox,-1,maxrate); + sendBounded(mailbox, -1, maxrate); } @@ -253,49 +271,26 @@ public class Task { * @return a Comm handler */ public static native Comm irecv(String mailbox); - /** - * Retrieves next task from the mailbox identified by the specified name - * - * @param mailbox - * @return a Task - */ - - public static Task receive(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException { - return receive(mailbox, -1.0, null); - } - - /** - * Retrieves next task on the mailbox identified by the specified name (wait at most \a timeout seconds) - * - * @param mailbox - * @param timeout - * @return a Task - */ - public static Task receive(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException { - return receive(mailbox, timeout, null); - } /** - * Retrieves next task sent by a given host on the mailbox identified by the specified alias + * Retrieves next task on the mailbox identified by the specified alias * * @param mailbox - * @param host * @return a Task */ - public static Task receive(String mailbox, Host host) throws TransferFailureException, HostFailureException, TimeoutException { - return receive(mailbox, -1.0, host); + public static Task receive(String mailbox) throws TransferFailureException, HostFailureException, TimeoutException { + return receive(mailbox, -1.0); } /** - * Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds) + * Retrieves next task on the mailbox identified by the specified alias (wait at most \a timeout seconds) * * @param mailbox * @param timeout - * @param host * @return a Task */ - public static native Task receive(String mailbox, double timeout, Host host) throws TransferFailureException, HostFailureException, TimeoutException; + public static native Task receive(String mailbox, double timeout) throws TransferFailureException, HostFailureException, TimeoutException; /** * Starts listening for receiving a task from an asynchronous communication with a capped rate @@ -311,7 +306,7 @@ public class Task { */ public static Task receiveBounded(String mailbox, double rate) throws TransferFailureException, HostFailureException, TimeoutException { - return receiveBounded(mailbox, -1.0, null, rate); + return receiveBounded(mailbox, -1.0, rate); } /** @@ -321,32 +316,7 @@ public class Task { * @param timeout * @return a Task */ - public static Task receiveBounded(String mailbox, double timeout, double rate) throws TransferFailureException, HostFailureException, TimeoutException { - return receiveBounded(mailbox, timeout, null, rate); - } - - /** - * Retrieves next task sent by a given host on the mailbox identified by the specified alias with a capped rate - * - * @param mailbox - * @param host - * @return a Task - */ - - public static Task receiveBounded(String mailbox, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException { - return receiveBounded(mailbox, -1.0, host, rate); - } - - /** - * Retrieves next task sent by a given host on the mailbox identified by the specified alias (wait at most \a timeout seconds) - * with a capped rate - * - * @param mailbox - * @param timeout - * @param host - * @return a Task - */ - public static native Task receiveBounded(String mailbox, double timeout, Host host, double rate) throws TransferFailureException, HostFailureException, TimeoutException; + public static native Task receiveBounded(String mailbox, double timeout, double rate) throws TransferFailureException, HostFailureException, TimeoutException;