Package io.ray.api.runtime
Interface RayRuntime
public interface RayRuntime
Base interface of a Ray runtime.
-
Method Summary
Modifier and TypeMethodDescriptioncall(PyFunction pyFunction, Object[] args, CallOptions options)Invoke a remote Python function.call(RayFunc func, Object[] args, CallOptions options)Invoke a remote function.callActor(ActorHandle<?> actor, RayFunc func, Object[] args, CallOptions options)Invoke a remote function on an actor.callActor(PyActorHandle pyActor, PyActorMethod pyActorMethod, Object[] args)Invoke a remote Python function on an actor.createActor(PyActorClass pyActorClass, Object[] args, ActorCreationOptions options)Create a Python actor on a remote node.<T> ActorHandle<T>createActor(RayFunc actorFactoryFunc, Object[] args, ActorCreationOptions options)Create an actor on a remote node.createConcurrencyGroup(String name, int maxConcurrency, List<RayFunc> funcs)Create concurrency group instance at runtime.createPlacementGroup(PlacementGroupCreationOptions creationOptions)Create a placement group on remote nodes.createRuntimeEnv(Map<String,String> envVars)Create runtime env instance at runtime.voidIntentionally exit the current actor.extractConcurrencyGroups(RayFuncR<?> actorConstructorLambda)voidFree a list of objects from Plasma Store.<T> TGet an object from the object store.<T> TGet an object from the object store.<T> List<T>Get a list of objects from the object store.<T> List<T>Get a list of objects from the object store.<T extends BaseActorHandle>
Optional<T>Get a handle to a named actor.<T extends BaseActorHandle>
TgetActorHandle(ActorId actorId)Get all placement groups in this cluster.Get the resources available on this worker.Get the namespace of this job.Get a placement group by id.getPlacementGroup(String name, String namespace)Get a placement group by name.voidkillActor(BaseActorHandle actor, boolean noRestart)Kill the actor immediately.<T> ObjectRef<T>put(T obj)Store an object in the object store.<T> ObjectRef<T>put(T obj, BaseActorHandle owner)Store an object in the object store, and assign its ownership to owner.voidRemove a placement group by id.voidsetAsyncContext(Object asyncContext)voidshutdown()Shutdown the runtime.<T> WaitResult<T>Wait for a list of RayObjects to be available, until specified number of objects are ready, or specified timeout has passed.booleanwaitPlacementGroupReady(PlacementGroupId id, int timeoutSeconds)Wait for the placement group to be ready within the specified time.<T> Callable<T>wrapCallable(Callable<T> callable)Wrap aCallablewith necessary context capture.wrapRunnable(Runnable runnable)Wrap aRunnablewith necessary context capture.
-
Method Details
-
shutdown
void shutdown()Shutdown the runtime. -
put
Store an object in the object store.- Parameters:
obj- The Java object to be stored.- Returns:
- A ObjectRef instance that represents the in-store object.
-
put
Store an object in the object store, and assign its ownership to owner. This function is experimental.- Parameters:
obj- The Java object to be stored.owner- The actor that should own this object. This allows creating objects with lifetimes decoupled from that of the creating process. Note that the owner actor must be passed a reference to the object prior to the object creator exiting, otherwise the reference will still be lost.- Returns:
- A ObjectRef instance that represents the in-store object.
-
get
Get an object from the object store.- Parameters:
objectRef- The reference of the object to get.- Returns:
- The Java object.
-
get
Get a list of objects from the object store.- Parameters:
objectRefs- The list of object references.- Returns:
- A list of Java objects.
-
get
Get an object from the object store.- Parameters:
objectRef- The reference of the object to get.timeoutMs- The maximum amount of time in millseconds to wait before returning.- Returns:
- The Java object.
- Throws:
RayTimeoutException- If it's timeout to get the object.
-
get
Get a list of objects from the object store.- Parameters:
objectRefs- The list of object references.timeoutMs- The maximum amount of time in millseconds to wait before returning.- Returns:
- A list of Java objects.
- Throws:
RayTimeoutException- If it's timeout to get the object.
-
wait
<T> WaitResult<T> wait(List<ObjectRef<T>> waitList, int numReturns, int timeoutMs, boolean fetchLocal)Wait for a list of RayObjects to be available, until specified number of objects are ready, or specified timeout has passed.- Parameters:
waitList- A list of ObjectRef to wait for.numReturns- The number of objects that should be returned.timeoutMs- The maximum time in milliseconds to wait before returning.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.- Returns:
- Two lists, one containing locally available objects, one containing the rest.
-
free
Free a list of objects from Plasma Store.- Parameters:
objectRefs- The object references to free.localOnly- Whether only free objects for local object store or not.
-
getActorHandle
-
getActor
Get a handle to a named actor.Gets a handle to a named actor with the given name. The actor must have been created with name specified.
- Parameters:
name- The name of the named actor.namespace- The namespace of the actor.- Returns:
- ActorHandle to the actor.
-
killActor
Kill the actor immediately.- Parameters:
actor- The actor to be killed.noRestart- If set to true, the killed actor will not be restarted anymore.
-
call
Invoke a remote function.- Parameters:
func- The remote function to run.args- The arguments of the remote function.options- The options for this call.- Returns:
- The result object.
-
call
Invoke a remote Python function.- Parameters:
pyFunction- The Python function.args- Arguments of the function.options- The options for this call.- Returns:
- The result object.
-
callActor
Invoke a remote function on an actor.- Parameters:
actor- A handle to the actor.func- The remote function to run, it must be a method of the given actor.args- The arguments of the remote function.- Returns:
- The result object.
-
callActor
Invoke a remote Python function on an actor.- Parameters:
pyActor- A handle to the actor.pyActorMethod- The actor method.args- Arguments of the function.- Returns:
- The result object.
-
createActor
<T> ActorHandle<T> createActor(RayFunc actorFactoryFunc, Object[] args, ActorCreationOptions options)Create an actor on a remote node.- Type Parameters:
T- The type of the actor object.- Parameters:
actorFactoryFunc- A remote function whose return value is the actor object.args- The arguments for the remote function.options- The options for creating actor.- Returns:
- A handle to the actor.
-
createActor
Create a Python actor on a remote node.- Parameters:
pyActorClass- The Python actor class.args- Arguments of the actor constructor.options- The options for creating actor.- Returns:
- A handle to the actor.
-
createPlacementGroup
Create a placement group on remote nodes.- Parameters:
creationOptions- Creation options of the placement group.- Returns:
- A handle to the created placement group.
-
getRuntimeContext
RuntimeContext getRuntimeContext() -
getAsyncContext
Object getAsyncContext() -
setAsyncContext
-
wrapRunnable
Wrap aRunnablewith necessary context capture.- Parameters:
runnable- The runnable to wrap.- Returns:
- The wrapped runnable.
-
wrapCallable
Wrap aCallablewith necessary context capture.- Parameters:
callable- The callable to wrap.- Returns:
- The wrapped callable.
-
exitActor
void exitActor()Intentionally exit the current actor. -
getAvailableResourceIds
Map<String,List<ResourceValue>> getAvailableResourceIds()Get the resources available on this worker. Note that this API doesn't work on driver.- Returns:
- The resource info of one node.
-
getNamespace
String getNamespace()Get the namespace of this job. -
getPlacementGroup
Get a placement group by id.- Parameters:
id- placement group id.- Returns:
- The placement group.
-
getPlacementGroup
Get a placement group by name.- Parameters:
name- The name of the placement group.namespace- The namespace of the placement group.- Returns:
- The placement group.
-
getAllPlacementGroups
List<PlacementGroup> getAllPlacementGroups()Get all placement groups in this cluster.- Returns:
- All placement groups.
-
removePlacementGroup
Remove a placement group by id.- Parameters:
id- Id of the placement group.
-
waitPlacementGroupReady
Wait for the placement group to be ready within the specified time.- Parameters:
id- Id of placement group.timeoutSeconds- Timeout in seconds.- Returns:
- True if the placement group is created. False otherwise.
-
createConcurrencyGroup
Create concurrency group instance at runtime. -
extractConcurrencyGroups
-
createRuntimeEnv
Create runtime env instance at runtime. -
getParallelActorContext
ParallelActorContext getParallelActorContext()
-