mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 21:38:18 +08:00
[Java] Make both RayActor and RayPyActor inheriting from BaseActor (#7462)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package org.ray.api;
|
||||
|
||||
import org.ray.api.id.ActorId;
|
||||
|
||||
/**
|
||||
* A handle to an actor. <p>
|
||||
*
|
||||
* A handle can be used to invoke a remote actor method.
|
||||
*/
|
||||
public interface BaseActor {
|
||||
|
||||
/**
|
||||
* @return The id of this actor.
|
||||
*/
|
||||
ActorId getId();
|
||||
|
||||
/**
|
||||
* Kill the actor immediately. This will cause any outstanding tasks submitted to the actor to
|
||||
* fail and the actor to exit in the same way as if it crashed.
|
||||
*
|
||||
* @param noReconstruction If set to true, the killed actor will not be reconstructed anymore.
|
||||
*/
|
||||
default void kill(boolean noReconstruction) {
|
||||
Ray.internal().killActor(this, noReconstruction);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
package org.ray.api;
|
||||
|
||||
import org.ray.api.id.ActorId;
|
||||
|
||||
/**
|
||||
* A handle to an actor. <p>
|
||||
* A handle to a Java actor. <p>
|
||||
*
|
||||
* A handle can be used to invoke a remote actor method, with the {@code "call"} method. For
|
||||
* example:
|
||||
@@ -14,7 +12,7 @@ import org.ray.api.id.ActorId;
|
||||
* }
|
||||
* }
|
||||
* // Create an actor, and get a handle.
|
||||
* RayActor<MyActor> myActor = Ray.createActor(RayActor::new);
|
||||
* RayActor<MyActor> myActor = Ray.createActor(MyActor::new);
|
||||
* // Call the `echo` method remotely.
|
||||
* RayObject<Integer> result = myActor.call(MyActor::echo, 1);
|
||||
* // Get the result of the remote `echo` method.
|
||||
@@ -26,20 +24,6 @@ import org.ray.api.id.ActorId;
|
||||
*
|
||||
* @param <A> The type of the concrete actor class.
|
||||
*/
|
||||
public interface RayActor<A> extends ActorCall<A> {
|
||||
public interface RayActor<A> extends BaseActor, ActorCall<A> {
|
||||
|
||||
/**
|
||||
* @return The id of this actor.
|
||||
*/
|
||||
ActorId getId();
|
||||
|
||||
/**
|
||||
* Kill the actor immediately. This will cause any outstanding tasks submitted to the actor to
|
||||
* fail and the actor to exit in the same way as if it crashed.
|
||||
*
|
||||
* @param noReconstruction If set to true, the killed actor will not be reconstructed anymore.
|
||||
*/
|
||||
default void kill(boolean noReconstruction) {
|
||||
Ray.internal().killActor(this, noReconstruction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.ray.api;
|
||||
/**
|
||||
* Handle of a Python actor.
|
||||
*/
|
||||
public interface RayPyActor extends RayActor, PyActorCall {
|
||||
public interface RayPyActor extends BaseActor, PyActorCall {
|
||||
|
||||
/**
|
||||
* @return Module name of the Python actor class.
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.ray.api.runtime;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import org.ray.api.BaseActor;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.RayPyActor;
|
||||
@@ -82,7 +83,7 @@ public interface RayRuntime {
|
||||
* @param actor The actor to be killed.
|
||||
* @param noReconstruction If set to true, the killed actor will not be reconstructed anymore.
|
||||
*/
|
||||
void killActor(RayActor<?> actor, boolean noReconstruction);
|
||||
void killActor(BaseActor actor, boolean noReconstruction);
|
||||
|
||||
/**
|
||||
* Invoke a remote function.
|
||||
|
||||
Reference in New Issue
Block a user