[Java] Rename java ObjectRef/ActorHandle (#8799)

This commit is contained in:
chaokunyang
2020-06-09 11:40:43 +08:00
committed by GitHub
parent c1e6813cea
commit 31a4d07bc4
88 changed files with 1551 additions and 1544 deletions
@@ -3,10 +3,10 @@ package io.ray.runtime;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
import io.ray.api.BaseActor;
import io.ray.api.RayActor;
import io.ray.api.RayObject;
import io.ray.api.RayPyActor;
import io.ray.api.ActorHandle;
import io.ray.api.BaseActorHandle;
import io.ray.api.ObjectRef;
import io.ray.api.PyActorHandle;
import io.ray.api.WaitResult;
import io.ray.api.exception.RayException;
import io.ray.api.function.PyActorClass;
@@ -27,8 +27,8 @@ import io.ray.runtime.functionmanager.RayFunction;
import io.ray.runtime.gcs.GcsClient;
import io.ray.runtime.generated.Common;
import io.ray.runtime.generated.Common.Language;
import io.ray.runtime.object.ObjectRefImpl;
import io.ray.runtime.object.ObjectStore;
import io.ray.runtime.object.RayObjectImpl;
import io.ray.runtime.task.ArgumentsBuilder;
import io.ray.runtime.task.FunctionArg;
import io.ray.runtime.task.TaskExecutor;
@@ -72,9 +72,9 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
public abstract void shutdown();
@Override
public <T> RayObject<T> put(T obj) {
public <T> ObjectRef<T> put(T obj) {
ObjectId objectId = objectStore.put(obj);
return new RayObjectImpl<T>(objectId, (Class<T>)(obj == null ? Object.class : obj.getClass()));
return new ObjectRefImpl<T>(objectId, (Class<T>)(obj == null ? Object.class : obj.getClass()));
}
@Override
@@ -94,12 +94,12 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
}
@Override
public <T> WaitResult<T> wait(List<RayObject<T>> waitList, int numReturns, int timeoutMs) {
public <T> WaitResult<T> wait(List<ObjectRef<T>> waitList, int numReturns, int timeoutMs) {
return objectStore.wait(waitList, numReturns, timeoutMs);
}
@Override
public RayObject call(RayFunc func, Object[] args, CallOptions options) {
public ObjectRef call(RayFunc func, Object[] args, CallOptions options) {
RayFunction rayFunction = functionManager.getFunction(workerContext.getCurrentJobId(), func);
FunctionDescriptor functionDescriptor = rayFunction.functionDescriptor;
Optional<Class<?>> returnType = rayFunction.getReturnType();
@@ -107,8 +107,8 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
}
@Override
public RayObject call(PyRemoteFunction pyRemoteFunction, Object[] args,
CallOptions options) {
public ObjectRef call(PyRemoteFunction pyRemoteFunction, Object[] args,
CallOptions options) {
PyFunctionDescriptor functionDescriptor = new PyFunctionDescriptor(
pyRemoteFunction.moduleName,
"",
@@ -119,7 +119,7 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
}
@Override
public RayObject callActor(RayActor<?> actor, RayFunc func, Object[] args) {
public ObjectRef callActor(ActorHandle<?> actor, RayFunc func, Object[] args) {
RayFunction rayFunction = functionManager.getFunction(workerContext.getCurrentJobId(), func);
FunctionDescriptor functionDescriptor = rayFunction.functionDescriptor;
Optional<Class<?>> returnType = rayFunction.getReturnType();
@@ -127,7 +127,7 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
}
@Override
public RayObject callActor(RayPyActor pyActor, PyActorMethod pyActorMethod, Object... args) {
public ObjectRef callActor(PyActorHandle pyActor, PyActorMethod pyActorMethod, Object... args) {
PyFunctionDescriptor functionDescriptor = new PyFunctionDescriptor(pyActor.getModuleName(),
pyActor.getClassName(), pyActorMethod.methodName);
// Python functions always have a return value, even if it's `None`.
@@ -137,22 +137,22 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
@Override
@SuppressWarnings("unchecked")
public <T> RayActor<T> createActor(RayFunc actorFactoryFunc,
Object[] args, ActorCreationOptions options) {
public <T> ActorHandle<T> createActor(RayFunc actorFactoryFunc,
Object[] args, ActorCreationOptions options) {
FunctionDescriptor functionDescriptor =
functionManager.getFunction(workerContext.getCurrentJobId(), actorFactoryFunc)
.functionDescriptor;
return (RayActor<T>) createActorImpl(functionDescriptor, args, options);
return (ActorHandle<T>) createActorImpl(functionDescriptor, args, options);
}
@Override
public RayPyActor createActor(PyActorClass pyActorClass, Object[] args,
ActorCreationOptions options) {
public PyActorHandle createActor(PyActorClass pyActorClass, Object[] args,
ActorCreationOptions options) {
PyFunctionDescriptor functionDescriptor = new PyFunctionDescriptor(
pyActorClass.moduleName,
pyActorClass.className,
PYTHON_INIT_METHOD_NAME);
return (RayPyActor) createActorImpl(functionDescriptor, args, options);
return (PyActorHandle) createActorImpl(functionDescriptor, args, options);
}
@@ -207,7 +207,8 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
};
}
private RayObject callNormalFunction(FunctionDescriptor functionDescriptor,
private ObjectRef callNormalFunction(
FunctionDescriptor functionDescriptor,
Object[] args, Optional<Class<?>> returnType, CallOptions options) {
int numReturns = returnType.isPresent() ? 1 : 0;
List<FunctionArg> functionArgs = ArgumentsBuilder
@@ -218,12 +219,15 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
if (returnIds.isEmpty()) {
return null;
} else {
return new RayObjectImpl(returnIds.get(0), returnType.get());
return new ObjectRefImpl(returnIds.get(0), returnType.get());
}
}
private RayObject callActorFunction(BaseActor rayActor,
FunctionDescriptor functionDescriptor, Object[] args, Optional<Class<?>> returnType) {
private ObjectRef callActorFunction(
BaseActorHandle rayActor,
FunctionDescriptor functionDescriptor,
Object[] args,
Optional<Class<?>> returnType) {
int numReturns = returnType.isPresent() ? 1 : 0;
List<FunctionArg> functionArgs = ArgumentsBuilder
.wrap(args, functionDescriptor.getLanguage());
@@ -233,18 +237,18 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
if (returnIds.isEmpty()) {
return null;
} else {
return new RayObjectImpl(returnIds.get(0), returnType.get());
return new ObjectRefImpl(returnIds.get(0), returnType.get());
}
}
private BaseActor createActorImpl(FunctionDescriptor functionDescriptor,
Object[] args, ActorCreationOptions options) {
private BaseActorHandle createActorImpl(FunctionDescriptor functionDescriptor,
Object[] args, ActorCreationOptions options) {
List<FunctionArg> functionArgs = ArgumentsBuilder
.wrap(args, functionDescriptor.getLanguage());
if (functionDescriptor.getLanguage() != Language.JAVA && options != null) {
Preconditions.checkState(Strings.isNullOrEmpty(options.jvmOptions));
}
BaseActor actor = taskSubmitter.createActor(functionDescriptor, functionArgs, options);
BaseActorHandle actor = taskSubmitter.createActor(functionDescriptor, functionArgs, options);
return actor;
}
@@ -1,7 +1,7 @@
package io.ray.runtime;
import com.google.common.base.Preconditions;
import io.ray.api.BaseActor;
import io.ray.api.BaseActorHandle;
import io.ray.api.id.JobId;
import io.ray.api.id.UniqueId;
import io.ray.runtime.config.RayConfig;
@@ -62,7 +62,7 @@ public class RayDevRuntime extends AbstractRayRuntime {
}
@Override
public void killActor(BaseActor actor, boolean noRestart) {
public void killActor(BaseActorHandle actor, boolean noRestart) {
throw new UnsupportedOperationException();
}
@@ -1,7 +1,7 @@
package io.ray.runtime;
import com.google.common.base.Preconditions;
import io.ray.api.BaseActor;
import io.ray.api.BaseActorHandle;
import io.ray.api.id.JobId;
import io.ray.api.id.UniqueId;
import io.ray.runtime.config.RayConfig;
@@ -132,7 +132,7 @@ public final class RayNativeRuntime extends AbstractRayRuntime {
}
@Override
public void killActor(BaseActor actor, boolean noRestart) {
public void killActor(BaseActorHandle actor, boolean noRestart) {
nativeKillActor(actor.getId().getBytes(), noRestart);
}
@@ -1,6 +1,6 @@
package io.ray.runtime.actor;
import io.ray.api.RayActor;
import io.ray.api.ActorHandle;
import io.ray.api.id.ActorId;
import io.ray.api.id.ObjectId;
import java.io.Externalizable;
@@ -12,13 +12,13 @@ import java.util.concurrent.atomic.AtomicReference;
/**
* Implementation of actor handle for local mode.
*/
public class LocalModeRayActor implements RayActor, Externalizable {
public class LocalModeActorHandle implements ActorHandle, Externalizable {
private ActorId actorId;
private AtomicReference<ObjectId> previousActorTaskDummyObjectId = new AtomicReference<>();
public LocalModeRayActor(ActorId actorId, ObjectId previousActorTaskDummyObjectId) {
public LocalModeActorHandle(ActorId actorId, ObjectId previousActorTaskDummyObjectId) {
this.actorId = actorId;
this.previousActorTaskDummyObjectId.set(previousActorTaskDummyObjectId);
}
@@ -26,7 +26,7 @@ public class LocalModeRayActor implements RayActor, Externalizable {
/**
* Required by FST
*/
public LocalModeRayActor() {
public LocalModeActorHandle() {
}
@Override
@@ -1,7 +1,7 @@
package io.ray.runtime.actor;
import com.google.common.base.Preconditions;
import io.ray.api.BaseActor;
import io.ray.api.BaseActorHandle;
import io.ray.api.id.ActorId;
import io.ray.runtime.generated.Common.Language;
import java.io.Externalizable;
@@ -14,7 +14,7 @@ import java.util.List;
* Abstract and language-independent implementation of actor handle for cluster mode. This is a
* wrapper class for C++ ActorHandle.
*/
public abstract class NativeRayActor implements BaseActor, Externalizable {
public abstract class NativeActorHandle implements BaseActorHandle, Externalizable {
/**
* ID of the actor.
@@ -23,7 +23,7 @@ public abstract class NativeRayActor implements BaseActor, Externalizable {
private Language language;
NativeRayActor(byte[] actorId, Language language) {
NativeActorHandle(byte[] actorId, Language language) {
Preconditions.checkState(!ActorId.fromBytes(actorId).isNil());
this.actorId = actorId;
this.language = language;
@@ -32,15 +32,15 @@ public abstract class NativeRayActor implements BaseActor, Externalizable {
/**
* Required by FST
*/
NativeRayActor() {
NativeActorHandle() {
}
public static NativeRayActor create(byte[] actorId, Language language) {
public static NativeActorHandle create(byte[] actorId, Language language) {
switch (language) {
case JAVA:
return new NativeRayJavaActor(actorId);
return new NativeJavaActorHandle(actorId);
case PYTHON:
return new NativeRayPyActor(actorId);
return new NativePyActorHandle(actorId);
default:
throw new IllegalStateException("Unknown actor handle language: " + language);
}
@@ -81,17 +81,14 @@ public abstract class NativeRayActor implements BaseActor, Externalizable {
*
* @return the bytes of an actor handle
*/
public static NativeRayActor fromBytes(byte[] bytes) {
public static NativeActorHandle fromBytes(byte[] bytes) {
byte[] actorId = nativeDeserialize(bytes);
Language language = Language.forNumber(nativeGetLanguage(actorId));
Preconditions.checkNotNull(language);
return create(actorId, language);
}
@Override
protected void finalize() {
// TODO(zhijunfu): do we need to free the ActorHandle in core worker?
}
// TODO(chaokunyang) do we need to free the ActorHandle in core worker by using phantom reference?
private static native int nativeGetLanguage(byte[] actorId);
@@ -8,20 +8,20 @@ import org.nustaq.serialization.FSTObjectInput;
import org.nustaq.serialization.FSTObjectOutput;
/**
* To deal with serialization about {@link NativeRayActor}.
* To deal with serialization about {@link NativeActorHandle}.
*/
public class NativeRayActorSerializer extends FSTBasicObjectSerializer {
public class NativeActorHandleSerializer extends FSTBasicObjectSerializer {
@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo,
FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
((NativeRayActor) toWrite).writeExternal(out);
((NativeActorHandle) toWrite).writeExternal(out);
}
@Override
public void readObject(FSTObjectInput in, Object toRead, FSTClazzInfo clzInfo,
FSTFieldInfo referencedBy) throws Exception {
super.readObject(in, toRead, clzInfo, referencedBy);
((NativeRayActor) toRead).readExternal(in);
((NativeActorHandle) toRead).readExternal(in);
}
}
@@ -1,7 +1,7 @@
package io.ray.runtime.actor;
import com.google.common.base.Preconditions;
import io.ray.api.RayActor;
import io.ray.api.ActorHandle;
import io.ray.runtime.generated.Common.Language;
import java.io.IOException;
import java.io.ObjectInput;
@@ -9,16 +9,16 @@ import java.io.ObjectInput;
/**
* Java implementation of actor handle for cluster mode.
*/
public class NativeRayJavaActor extends NativeRayActor implements RayActor {
public class NativeJavaActorHandle extends NativeActorHandle implements ActorHandle {
NativeRayJavaActor(byte[] actorId) {
NativeJavaActorHandle(byte[] actorId) {
super(actorId, Language.JAVA);
}
/**
* Required by FST
*/
public NativeRayJavaActor() {
public NativeJavaActorHandle() {
super();
}
@@ -1,7 +1,7 @@
package io.ray.runtime.actor;
import com.google.common.base.Preconditions;
import io.ray.api.RayPyActor;
import io.ray.api.PyActorHandle;
import io.ray.runtime.generated.Common.Language;
import java.io.IOException;
import java.io.ObjectInput;
@@ -9,16 +9,16 @@ import java.io.ObjectInput;
/**
* Python actor handle implementation for cluster mode.
*/
public class NativeRayPyActor extends NativeRayActor implements RayPyActor {
public class NativePyActorHandle extends NativeActorHandle implements PyActorHandle {
NativeRayPyActor(byte[] actorId) {
NativePyActorHandle(byte[] actorId) {
super(actorId, Language.PYTHON);
}
/**
* Required by FST
*/
public NativeRayPyActor() {
public NativePyActorHandle() {
super();
}
@@ -1,14 +1,14 @@
package io.ray.runtime.object;
import io.ray.api.ObjectRef;
import io.ray.api.Ray;
import io.ray.api.RayObject;
import io.ray.api.id.ObjectId;
import java.io.Serializable;
/**
* Implementation of {@link RayObject}.
* Implementation of {@link ObjectRef}.
*/
public final class RayObjectImpl<T> implements RayObject<T>, Serializable {
public final class ObjectRefImpl<T> implements ObjectRef<T>, Serializable {
private final ObjectId id;
@@ -27,7 +27,7 @@ public final class RayObjectImpl<T> implements RayObject<T>, Serializable {
*/
private transient boolean objectGotten;
public RayObjectImpl(ObjectId id, Class<T> type) {
public ObjectRefImpl(ObjectId id, Class<T> type) {
this.id = id;
this.type = type;
object = null;
@@ -1,7 +1,7 @@
package io.ray.runtime.object;
import com.google.common.base.Preconditions;
import io.ray.api.RayObject;
import io.ray.api.ObjectRef;
import io.ray.api.WaitResult;
import io.ray.api.exception.RayException;
import io.ray.api.id.ObjectId;
@@ -126,22 +126,22 @@ public abstract class ObjectStore {
* Wait for a list of RayObjects to be locally available, until specified number of objects are
* ready, or specified timeout has passed.
*
* @param waitList A list of RayObject to wait for.
* @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.
* @return Two lists, one containing locally available objects, one containing the rest.
*/
public <T> WaitResult<T> wait(List<RayObject<T>> waitList, int numReturns, int timeoutMs) {
public <T> WaitResult<T> wait(List<ObjectRef<T>> waitList, int numReturns, int timeoutMs) {
Preconditions.checkNotNull(waitList);
if (waitList.isEmpty()) {
return new WaitResult<>(Collections.emptyList(), Collections.emptyList());
}
List<ObjectId> ids = waitList.stream().map(RayObject::getId).collect(Collectors.toList());
List<ObjectId> ids = waitList.stream().map(ObjectRef::getId).collect(Collectors.toList());
List<Boolean> ready = wait(ids, numReturns, timeoutMs);
List<RayObject<T>> readyList = new ArrayList<>();
List<RayObject<T>> unreadyList = new ArrayList<>();
List<ObjectRef<T>> readyList = new ArrayList<>();
List<ObjectRef<T>> unreadyList = new ArrayList<>();
for (int i = 0; i < ready.size(); i++) {
if (ready.get(i)) {
@@ -1,7 +1,7 @@
package io.ray.runtime.serializer;
import io.ray.runtime.actor.NativeRayActor;
import io.ray.runtime.actor.NativeRayActorSerializer;
import io.ray.runtime.actor.NativeActorHandle;
import io.ray.runtime.actor.NativeActorHandleSerializer;
import org.nustaq.serialization.FSTConfiguration;
/**
@@ -11,7 +11,7 @@ public class FstSerializer {
private static final ThreadLocal<FSTConfiguration> conf = ThreadLocal.withInitial(() -> {
FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
conf.registerSerializer(NativeRayActor.class, new NativeRayActorSerializer(), true);
conf.registerSerializer(NativeActorHandle.class, new NativeActorHandleSerializer(), true);
return conf;
});
@@ -1,7 +1,7 @@
package io.ray.runtime.task;
import io.ray.api.ObjectRef;
import io.ray.api.Ray;
import io.ray.api.RayObject;
import io.ray.api.id.ObjectId;
import io.ray.runtime.RayRuntimeInternal;
import io.ray.runtime.generated.Common.Language;
@@ -36,8 +36,8 @@ public class ArgumentsBuilder {
for (Object arg : args) {
ObjectId id = null;
NativeRayObject value = null;
if (arg instanceof RayObject) {
id = ((RayObject) arg).getId();
if (arg instanceof ObjectRef) {
id = ((ObjectRef) arg).getId();
} else {
value = ObjectSerializer.serialize(arg);
if (language != Language.JAVA) {
@@ -3,7 +3,7 @@ package io.ray.runtime.task;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.protobuf.ByteString;
import io.ray.api.BaseActor;
import io.ray.api.BaseActorHandle;
import io.ray.api.id.ActorId;
import io.ray.api.id.ObjectId;
import io.ray.api.id.TaskId;
@@ -11,7 +11,7 @@ import io.ray.api.id.UniqueId;
import io.ray.api.options.ActorCreationOptions;
import io.ray.api.options.CallOptions;
import io.ray.runtime.RayRuntimeInternal;
import io.ray.runtime.actor.LocalModeRayActor;
import io.ray.runtime.actor.LocalModeActorHandle;
import io.ray.runtime.context.LocalModeWorkerContext;
import io.ray.runtime.functionmanager.FunctionDescriptor;
import io.ray.runtime.functionmanager.JavaFunctionDescriptor;
@@ -149,8 +149,8 @@ public class LocalModeTaskSubmitter implements TaskSubmitter {
}
@Override
public BaseActor createActor(FunctionDescriptor functionDescriptor, List<FunctionArg> args,
ActorCreationOptions options) {
public BaseActorHandle createActor(FunctionDescriptor functionDescriptor, List<FunctionArg> args,
ActorCreationOptions options) {
ActorId actorId = ActorId.fromRandom();
TaskSpec taskSpec = getTaskSpecBuilder(TaskType.ACTOR_CREATION_TASK, functionDescriptor, args)
.setNumReturns(1)
@@ -159,12 +159,12 @@ public class LocalModeTaskSubmitter implements TaskSubmitter {
.build())
.build();
submitTaskSpec(taskSpec);
return new LocalModeRayActor(actorId, getReturnIds(taskSpec).get(0));
return new LocalModeActorHandle(actorId, getReturnIds(taskSpec).get(0));
}
@Override
public List<ObjectId> submitActorTask(
BaseActor actor, FunctionDescriptor functionDescriptor,
BaseActorHandle actor, FunctionDescriptor functionDescriptor,
List<FunctionArg> args, int numReturns, CallOptions options) {
Preconditions.checkState(numReturns <= 1);
TaskSpec.Builder builder = getTaskSpecBuilder(TaskType.ACTOR_TASK, functionDescriptor, args);
@@ -175,7 +175,7 @@ public class LocalModeTaskSubmitter implements TaskSubmitter {
.setActorTaskSpec(
ActorTaskSpec.newBuilder().setActorId(ByteString.copyFrom(actor.getId().getBytes()))
.setPreviousActorTaskDummyObjectId(ByteString.copyFrom(
((LocalModeRayActor) actor)
((LocalModeActorHandle) actor)
.exchangePreviousActorTaskDummyObjectId(returnIds.get(returnIds.size() - 1))
.getBytes()))
.build())
@@ -1,11 +1,11 @@
package io.ray.runtime.task;
import com.google.common.base.Preconditions;
import io.ray.api.BaseActor;
import io.ray.api.BaseActorHandle;
import io.ray.api.id.ObjectId;
import io.ray.api.options.ActorCreationOptions;
import io.ray.api.options.CallOptions;
import io.ray.runtime.actor.NativeRayActor;
import io.ray.runtime.actor.NativeActorHandle;
import io.ray.runtime.functionmanager.FunctionDescriptor;
import java.util.List;
import java.util.stream.Collectors;
@@ -23,17 +23,17 @@ public class NativeTaskSubmitter implements TaskSubmitter {
}
@Override
public BaseActor createActor(FunctionDescriptor functionDescriptor, List<FunctionArg> args,
ActorCreationOptions options) {
public BaseActorHandle createActor(FunctionDescriptor functionDescriptor, List<FunctionArg> args,
ActorCreationOptions options) {
byte[] actorId = nativeCreateActor(functionDescriptor, args, options);
return NativeRayActor.create(actorId, functionDescriptor.getLanguage());
return NativeActorHandle.create(actorId, functionDescriptor.getLanguage());
}
@Override
public List<ObjectId> submitActorTask(
BaseActor actor, FunctionDescriptor functionDescriptor,
BaseActorHandle actor, FunctionDescriptor functionDescriptor,
List<FunctionArg> args, int numReturns, CallOptions options) {
Preconditions.checkState(actor instanceof NativeRayActor);
Preconditions.checkState(actor instanceof NativeActorHandle);
List<byte[]> returnIds = nativeSubmitActorTask(actor.getId().getBytes(),
functionDescriptor, args, numReturns, options);
return returnIds.stream().map(ObjectId::new).collect(Collectors.toList());
@@ -1,6 +1,6 @@
package io.ray.runtime.task;
import io.ray.api.BaseActor;
import io.ray.api.BaseActorHandle;
import io.ray.api.id.ObjectId;
import io.ray.api.options.ActorCreationOptions;
import io.ray.api.options.CallOptions;
@@ -30,8 +30,8 @@ public interface TaskSubmitter {
* @param options Options for this actor creation task.
* @return Handle to the actor.
*/
BaseActor createActor(FunctionDescriptor functionDescriptor, List<FunctionArg> args,
ActorCreationOptions options);
BaseActorHandle createActor(FunctionDescriptor functionDescriptor, List<FunctionArg> args,
ActorCreationOptions options);
/**
* Submit an actor task.
@@ -42,6 +42,6 @@ public interface TaskSubmitter {
* @param options Options for this task.
* @return Ids of the return objects.
*/
List<ObjectId> submitActorTask(BaseActor actor, FunctionDescriptor functionDescriptor,
List<FunctionArg> args, int numReturns, CallOptions options);
List<ObjectId> submitActorTask(BaseActorHandle actor, FunctionDescriptor functionDescriptor,
List<FunctionArg> args, int numReturns, CallOptions options);
}
@@ -170,9 +170,9 @@ public class RayCallGenerator extends BaseGenerator {
// 2) Construct the `returnType` part.
String returnType;
if (forActorCreation) {
returnType = "RayActor<A>";
returnType = "ActorHandle<A>";
} else {
returnType = hasReturn ? "RayObject<R>" : "void";
returnType = hasReturn ? "ObjectRef<R>" : "void";
}
// 3) Construct the `argsDeclaration` part.
@@ -222,7 +222,7 @@ public class RayCallGenerator extends BaseGenerator {
// 5) Construct the third line.
String callFuncArgs = "";
if (forActor) {
callFuncArgs += "(RayActor) this, ";
callFuncArgs += "(ActorHandle) this, ";
}
callFuncArgs += "f, args, ";
callFuncArgs += forActor ? "" : hasOptionsParam ? "options, " : "null, ";
@@ -297,7 +297,7 @@ public class RayCallGenerator extends BaseGenerator {
}
String genericType = forActorCreation ? "" : " <R>";
String returnType = !forActorCreation ? "RayObject<R>" : "RayPyActor";
String returnType = !forActorCreation ? "ObjectRef<R>" : "PyActorHandle";
String funcName = forActorCreation ? "createActor" : "call";
String internalCallFunc = forActorCreation ? "createActor" :
forActor ? "callActor" : "call";
@@ -310,7 +310,7 @@ public class RayCallGenerator extends BaseGenerator {
// Method body.
newLine(2, String.format("Object[] args = new Object[]{%s};", argList));
if (forActor) {
newLine(2, String.format("return Ray.internal().%s((RayPyActor)this, %s%s);",
newLine(2, String.format("return Ray.internal().%s((PyActorHandle)this, %s%s);",
internalCallFunc, funcArgs, optionsArg));
} else {
newLine(2, String.format("return Ray.internal().%s(%s%s);",
@@ -333,7 +333,7 @@ public class RayCallGenerator extends BaseGenerator {
}
String nextParameter = String.format("T%d t%d, ", pos, pos);
dfs(pos + 1, numParams, cur + nextParameter, res);
nextParameter = String.format("RayObject<T%d> t%d, ", pos, pos);
nextParameter = String.format("ObjectRef<T%d> t%d, ", pos, pos);
dfs(pos + 1, numParams, cur + nextParameter, res);
}