[Java] Add fetchLocal parameter in Ray.wait() (#13604)

This commit is contained in:
Kai Yang
2021-01-22 17:55:00 +08:00
committed by GitHub
parent 00c14ce4a4
commit 90f1e408de
14 changed files with 78 additions and 87 deletions
+24 -7
View File
@@ -87,6 +87,24 @@ public final class Ray extends RayCall {
return internal().get(objectList);
}
/**
* Wait for a list of RayObjects to be available, until specified number of objects are ready, or
* specified timeout has passed.
*
* @param waitList A list of object references to wait for.
* @param numReturns The number of objects that should be returned.
* @param timeoutMs The maximum time in milliseconds to wait before returning.
* @param fetchLocal If true, wait for the object to be downloaded onto the local node before
* returning it as ready. If false, ray.wait() will not trigger fetching of objects to the
* local node and will return immediately once the object is available anywhere in the
* cluster.
* @return Two lists, one containing locally available objects, one containing the rest.
*/
public static <T> WaitResult<T> wait(
List<ObjectRef<T>> waitList, int numReturns, int timeoutMs, boolean fetchLocal) {
return internal().wait(waitList, numReturns, timeoutMs, fetchLocal);
}
/**
* Wait for a list of RayObjects to be locally available, until specified number of objects are
* ready, or specified timeout has passed.
@@ -97,30 +115,29 @@ public final class Ray extends RayCall {
* @return Two lists, one containing locally available objects, one containing the rest.
*/
public static <T> WaitResult<T> wait(List<ObjectRef<T>> waitList, int numReturns, int timeoutMs) {
return internal().wait(waitList, numReturns, timeoutMs);
return wait(waitList, numReturns, timeoutMs, true);
}
/**
* A convenient helper method for Ray.wait. It will wait infinitely until specified number of
* objects are locally available.
* Wait for a list of RayObjects to be locally available, until specified number of objects are
* ready.
*
* @param waitList A list of object references to wait for.
* @param numReturns The number of objects that should be returned.
* @return Two lists, one containing locally available objects, one containing the rest.
*/
public static <T> WaitResult<T> wait(List<ObjectRef<T>> waitList, int numReturns) {
return internal().wait(waitList, numReturns, Integer.MAX_VALUE);
return wait(waitList, numReturns, Integer.MAX_VALUE);
}
/**
* A convenient helper method for Ray.wait. It will wait infinitely until all objects are locally
* available.
* Wait for a list of RayObjects to be locally available.
*
* @param waitList A list of object references to wait for.
* @return Two lists, one containing locally available objects, one containing the rest.
*/
public static <T> WaitResult<T> wait(List<ObjectRef<T>> waitList) {
return internal().wait(waitList, waitList.size(), Integer.MAX_VALUE);
return wait(waitList, waitList.size());
}
/**
@@ -53,15 +53,20 @@ public interface RayRuntime {
<T> List<T> get(List<ObjectRef<T>> objectRefs);
/**
* Wait for a list of RayObjects to be locally available, until specified number of objects are
* ready, or specified timeout has passed.
* Wait for a list of RayObjects to be available, until specified number of objects are ready, or
* specified timeout has passed.
*
* @param waitList A list of ObjectRef to wait for.
* @param numReturns The number of objects that should be returned.
* @param timeoutMs The maximum time in milliseconds to wait before returning.
* @param fetchLocal If true, wait for the object to be downloaded onto the local node before
* returning it as ready. If false, ray.wait() will not trigger fetching of objects to the
* local node and will return immediately once the object is available anywhere in the
* cluster.
* @return Two lists, one containing locally available objects, one containing the rest.
*/
<T> WaitResult<T> wait(List<ObjectRef<T>> waitList, int numReturns, int timeoutMs);
<T> WaitResult<T> wait(
List<ObjectRef<T>> waitList, int numReturns, int timeoutMs, boolean fetchLocal);
/**
* Free a list of objects from Plasma Store.