mirror of
https://github.com/wassname/ray.git
synced 2026-06-29 04:44:28 +08:00
[Java] Add killActor API in Java (#6728)
* Add killActor API in Java * fix javadoc * update test case * Address comments
This commit is contained in:
@@ -2,6 +2,7 @@ package org.ray.runtime;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.id.JobId;
|
||||
import org.ray.api.id.UniqueId;
|
||||
import org.ray.runtime.config.RayConfig;
|
||||
@@ -47,6 +48,11 @@ public class RayDevRuntime extends AbstractRayRuntime {
|
||||
LOGGER.error("Not implemented under SINGLE_PROCESS mode.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killActor(RayActor<?> actor) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAsyncContext() {
|
||||
return null;
|
||||
|
||||
@@ -140,6 +140,11 @@ public class RayMultiWorkerNativeRuntime implements RayRuntime {
|
||||
getCurrentRuntime().setResource(resourceName, capacity, nodeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killActor(RayActor<?> actor) {
|
||||
getCurrentRuntime().killActor(actor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RayObject call(RayFunc func, Object[] args, CallOptions options) {
|
||||
return getCurrentRuntime().call(func, args, options);
|
||||
|
||||
@@ -6,8 +6,10 @@ import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.id.JobId;
|
||||
import org.ray.api.id.UniqueId;
|
||||
import org.ray.runtime.actor.NativeRayActor;
|
||||
import org.ray.runtime.config.RayConfig;
|
||||
import org.ray.runtime.context.NativeWorkerContext;
|
||||
import org.ray.runtime.functionmanager.FunctionManager;
|
||||
@@ -127,6 +129,14 @@ public final class RayNativeRuntime extends AbstractRayRuntime {
|
||||
nativeSetResource(nativeCoreWorkerPointer, resourceName, capacity, nodeId.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void killActor(RayActor<?> actor) {
|
||||
if (!((NativeRayActor) actor).isDirectCallActor()) {
|
||||
throw new UnsupportedOperationException("Only direct call actors can be killed.");
|
||||
}
|
||||
nativeKillActor(nativeCoreWorkerPointer, actor.getId().getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getAsyncContext() {
|
||||
return null;
|
||||
@@ -184,4 +194,6 @@ public final class RayNativeRuntime extends AbstractRayRuntime {
|
||||
|
||||
private static native void nativeSetResource(long conn, String resourceName, double capacity,
|
||||
byte[] nodeId);
|
||||
|
||||
private static native void nativeKillActor(long nativeCoreWorkerPointer, byte[] actorId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user