public interface RayRuntime
| 限定符和类型 | 方法和说明 |
|---|---|
ObjectRef |
call(PyFunction pyFunction,
Object[] args,
CallOptions options)
Invoke a remote Python function.
|
ObjectRef |
call(RayFunc func,
Object[] args,
CallOptions options)
Invoke a remote function.
|
ObjectRef |
callActor(ActorHandle<?> actor,
RayFunc func,
Object[] args,
CallOptions options)
Invoke a remote function on an actor.
|
ObjectRef |
callActor(PyActorHandle pyActor,
PyActorMethod pyActorMethod,
Object[] args)
Invoke a remote Python function on an actor.
|
PyActorHandle |
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.
|
ConcurrencyGroup |
createConcurrencyGroup(String name,
int maxConcurrency,
List<RayFunc> funcs)
Create concurrency group instance at runtime.
|
PlacementGroup |
createPlacementGroup(PlacementGroupCreationOptions creationOptions)
Create a placement group on remote nodes.
|
void |
exitActor()
Intentionally exit the current actor.
|
void |
free(List<ObjectRef<?>> objectRefs,
boolean localOnly)
Free a list of objects from Plasma Store.
|
<T> List<T> |
get(List<ObjectRef<T>> objectRefs)
Get a list of objects from the object store.
|
<T> T |
get(ObjectRef<T> objectRef)
Get an object from the object store.
|
<T extends BaseActorHandle> |
getActor(String name,
boolean global)
Get a handle to a named actor.
|
<T extends BaseActorHandle> |
getActorHandle(ActorId actorId) |
List<PlacementGroup> |
getAllPlacementGroups()
Get all placement groups in this cluster.
|
Object |
getAsyncContext() |
PlacementGroup |
getPlacementGroup(PlacementGroupId id)
Get a placement group by id.
|
PlacementGroup |
getPlacementGroup(String name,
boolean global)
Get a placement group by name.
|
RuntimeContext |
getRuntimeContext() |
void |
killActor(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.
|
void |
removePlacementGroup(PlacementGroupId id)
Remove a placement group by id.
|
void |
setAsyncContext(Object asyncContext) |
void |
shutdown()
Shutdown the runtime.
|
<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.
|
boolean |
waitPlacementGroupReady(PlacementGroupId id,
int timeoutSeconds)
Wait for the placement group to be ready within the specified time.
|
<T> Callable<T> |
wrapCallable(Callable<T> callable)
Wrap a
Callable with necessary context capture. |
Runnable |
wrapRunnable(Runnable runnable)
Wrap a
Runnable with necessary context capture. |
void shutdown()
<T> ObjectRef<T> put(T obj)
obj - The Java object to be stored.<T> ObjectRef<T> put(T obj, BaseActorHandle owner)
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.<T> T get(ObjectRef<T> objectRef)
objectRef - The reference of the object to get.<T> List<T> get(List<ObjectRef<T>> objectRefs)
objectRefs - The list of object references.<T> WaitResult<T> wait(List<ObjectRef<T>> waitList, int numReturns, int timeoutMs, boolean fetchLocal)
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.void free(List<ObjectRef<?>> objectRefs, boolean localOnly)
objectRefs - The object references to free.localOnly - Whether only free objects for local object store or not.<T extends BaseActorHandle> T getActorHandle(ActorId actorId)
<T extends BaseActorHandle> Optional<T> getActor(String name, boolean global)
Gets a handle to a named actor with the given name. The actor must have been created with name specified.
name - The name of the named actor.global - Whether the named actor is global.void killActor(BaseActorHandle actor, boolean noRestart)
actor - The actor to be killed.noRestart - If set to true, the killed actor will not be restarted anymore.ObjectRef call(RayFunc func, Object[] args, CallOptions options)
func - The remote function to run.args - The arguments of the remote function.options - The options for this call.ObjectRef call(PyFunction pyFunction, Object[] args, CallOptions options)
pyFunction - The Python function.args - Arguments of the function.options - The options for this call.ObjectRef callActor(ActorHandle<?> actor, RayFunc func, Object[] args, CallOptions options)
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.ObjectRef callActor(PyActorHandle pyActor, PyActorMethod pyActorMethod, Object[] args)
pyActor - A handle to the actor.pyActorMethod - The actor method.args - Arguments of the function.<T> ActorHandle<T> createActor(RayFunc actorFactoryFunc, Object[] args, ActorCreationOptions options)
T - The type of the actor object.actorFactoryFunc - A remote function whose return value is the actor object.args - The arguments for the remote function.options - The options for creating actor.PyActorHandle createActor(PyActorClass pyActorClass, Object[] args, ActorCreationOptions options)
pyActorClass - The Python actor class.args - Arguments of the actor constructor.options - The options for creating actor.PlacementGroup createPlacementGroup(PlacementGroupCreationOptions creationOptions)
creationOptions - Creation options of the placement group.RuntimeContext getRuntimeContext()
Object getAsyncContext()
void setAsyncContext(Object asyncContext)
Runnable wrapRunnable(Runnable runnable)
Runnable with necessary context capture.runnable - The runnable to wrap.<T> Callable<T> wrapCallable(Callable<T> callable)
Callable with necessary context capture.callable - The callable to wrap.void exitActor()
PlacementGroup getPlacementGroup(PlacementGroupId id)
id - placement group id.PlacementGroup getPlacementGroup(String name, boolean global)
name - The name of the placement group.global - Whether the named placement group is global.List<PlacementGroup> getAllPlacementGroups()
void removePlacementGroup(PlacementGroupId id)
id - Id of the placement group.boolean waitPlacementGroupReady(PlacementGroupId id, int timeoutSeconds)
id - Id of placement group.timeoutSeconds - Timeout in seconds.ConcurrencyGroup createConcurrencyGroup(String name, int maxConcurrency, List<RayFunc> funcs)
Copyright © 2021. All rights reserved.