[Java] improve Java API module (#2783)

API module (`ray/java/api` dir) includes all public APIs provided by Ray, it should be the only module that normal Ray users need to face.

The purpose of this PR to first improve the code quality of the API module. Subsequent PRs will improve other modules later. The changes of this PR include the following aspects: 
1) Only keep interfaces in api module, to hide implementation details from users and fix circular dependencies among modules.
2) Document everything in the api module. 
3) Improve naming.
4) Add more tests for API. 
5) Also fix/improve related code in other modules.
6) Remove some unused code.

(Apologize for posting such a large PR. Java worker code has been lack of maintenance for a while. There're a lot of code quality issues that need to be fixed. We plan to use a couple of large PRs to address them. After that, future changes will come in small PRs.)
This commit is contained in:
Hao Chen
2018-09-03 02:51:16 +08:00
committed by Robert Nishihara
parent 2691b3a11a
commit 3b0a2c4197
98 changed files with 2232 additions and 2158 deletions
-8
View File
@@ -20,19 +20,11 @@
<dependencies>
<dependency>
<groupId>org.ray</groupId>
<artifactId>ray-common</artifactId>
<version>${project.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
+92 -67
View File
@@ -1,99 +1,124 @@
package org.ray.api;
import com.google.common.collect.ImmutableList;
import java.util.List;
import org.ray.api.internal.RayConnector;
import org.ray.util.exception.TaskExecutionException;
import org.ray.util.logger.RayLog;
import org.ray.api.id.UniqueId;
import org.ray.api.runtime.DefaultRayRuntimeFactory;
import org.ray.api.runtime.RayRuntime;
import org.ray.api.runtime.RayRuntimeFactory;
/**
* Ray API.
* This class contains all public APIs of Ray.
*/
public final class Ray extends Rpc {
public final class Ray extends RayCall {
private static RayApi impl = null;
private static RayRuntime runtime = null;
/**
* initialize the current worker or the single-box cluster.
* Initialize Ray runtime with the default runtime implementation.
*/
public static void init() {
if (impl == null) {
impl = RayConnector.run();
init(new DefaultRayRuntimeFactory());
}
/**
* Initialize Ray runtime with a custom runtime implementation.
*
* @param factory A factory that produces the runtime instance.
*/
public static synchronized void init(RayRuntimeFactory factory) {
if (runtime == null) {
runtime = factory.createRayRuntime();
}
}
/**
* Put obj into object store.
* Shutdown Ray runtime.
*/
public static void shutdown() {
runtime.shutdown();
}
/**
* Store an object in the object store.
*
* @param obj The Java object to be stored.
* @return A RayObject instance that represents the in-store object.
*/
public static <T> RayObject<T> put(T obj) {
return impl.put(obj);
}
public static <T, TMT> RayObject<T> put(T obj, TMT metadata) {
return impl.put(obj, metadata);
return runtime.put(obj);
}
/**
* Get obj(s) from object store.
*/
static <T> T get(UniqueID objectId) throws TaskExecutionException {
return impl.get(objectId);
}
static <T> List<T> get(List<UniqueID> objectIds) throws TaskExecutionException {
return impl.get(objectIds);
}
static <T> T getMeta(UniqueID objectId) throws TaskExecutionException {
return impl.getMeta(objectId);
}
static <T> List<T> getMeta(List<UniqueID> objectIds) throws TaskExecutionException {
return impl.getMeta(objectIds);
}
/**
* wait until timeout or enough RayObject are ready.
* Get an object from the object store.
*
* @param waitfor wait for who
* @param numReturns how many of ready is enough
* @param timeoutMilliseconds in millisecond
* @param objectId The ID of the object to get.
* @return The Java object.
*/
public static <T> WaitResult<T> wait(List<RayObject<T>> waitfor, int numReturns,
int timeoutMilliseconds) {
return impl.wait(waitfor, numReturns, timeoutMilliseconds);
}
public static <T> WaitResult<T> wait(List<RayObject<T>> waitfor, int numReturns) {
return impl.wait(waitfor, numReturns, Integer.MAX_VALUE);
}
public static <T> WaitResult<T> wait(List<RayObject<T>> waitfor) {
return impl.wait(waitfor, waitfor.size(), Integer.MAX_VALUE);
public static <T> T get(UniqueId objectId) {
return runtime.get(objectId);
}
/**
* create actor object.
* Get a list of objects from the object store.
*
* @param objectIds The list of object IDs.
* @return A list of Java objects.
*/
public static <T> RayActor<T> create(Class<T> cls) {
try {
if (cls.getConstructor() == null) {
System.err.println("class " + cls.getName()
+ " does not (actors must) have a constructor with no arguments");
RayLog.core.error("class {} does not (actors must) have a constructor with no arguments",
cls.getName());
}
} catch (Exception e) {
System.exit(1);
return null;
}
return impl.create(cls);
public static <T> List<T> get(List<UniqueId> objectIds) {
return runtime.get(objectIds);
}
/**
* get underlying runtime.
* 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 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.
*/
static RayApi internal() {
return impl;
public static <T> WaitResult<T> wait(List<RayObject<T>> waitList, int numReturns,
int timeoutMs) {
return runtime.wait(waitList, numReturns, timeoutMs);
}
/**
* A convenient helper method for Ray.wait. It will wait infinitely until
* specified number of objects are locally available.
*
* @param waitList A list of RayObject to wait for.
* @param numReturns The number of objects that should be returned.
* @return Two lists, one containing locally available objects, one containing the rest.
*/
public static <T> WaitResult<T> wait(List<RayObject<T>> waitList, int numReturns) {
return runtime.wait(waitList, numReturns, Integer.MAX_VALUE);
}
/**
* A convenient helper method for Ray.wait. It will wait infinitely until
* all objects are locally available.
*
* @param waitList A list of RayObject to wait for.
* @return Two lists, one containing locally available objects, one containing the rest.
*/
public static <T> WaitResult<T> wait(List<RayObject<T>> waitList) {
return runtime.wait(waitList, waitList.size(), Integer.MAX_VALUE);
}
/**
* Create an actor on a remote node.
*
* @param actorClass the class of the actor to be created.
* @return A handle to the newly created actor.
*/
public static <T> RayActor<T> createActor(Class<T> actorClass) {
return runtime.createActor(actorClass);
}
/**
* Get the underlying runtime instance.
*/
static RayRuntime internal() {
return runtime;
}
}
@@ -1,87 +1,20 @@
package org.ray.api;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.ray.util.Sha1Digestor;
import org.ray.api.id.UniqueId;
/**
* Ray actor abstraction.
* A handle to an actor.
* @param <T> The type of the concrete actor class.
*/
public class RayActor<T> extends RayObject<T> implements Externalizable {
public static final RayActor<?> NIL = new RayActor<>(UniqueID.NIL, UniqueID.NIL);
private static final long serialVersionUID = 1877485807405645036L;
private int taskCounter = 0;
private UniqueID taskCursor = null;
private UniqueID actorHandleId = UniqueID.NIL;
private int forksNum = 0;
public RayActor() {
}
public RayActor(UniqueID id) {
super(id);
this.taskCounter = 1;
}
public RayActor(UniqueID id, UniqueID actorHandleId) {
super(id);
this.actorHandleId = actorHandleId;
this.taskCounter = 0;
}
public int increaseTaskCounter() {
return taskCounter++;
}
public interface RayActor<T> {
/**
* Getter method for property <tt>taskCursor</tt>.
*
* @return property value of taskCursor
* @return The id of this actor.
*/
public UniqueID getTaskCursor() {
return taskCursor;
}
UniqueId getId();
/**
* Setter method for property <tt>taskCursor</tt>.
*
* @param taskCursor value to be assigned to property taskCursor
* @return The id of this actor handle.
*/
public void setTaskCursor(UniqueID taskCursor) {
this.taskCursor = taskCursor;
}
public UniqueID getActorHandleId() {
return actorHandleId;
}
public void setActorHandleId(UniqueID actorHandleId) {
this.actorHandleId = actorHandleId;
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(this.id);
out.writeObject(this.computeNextActorHandleId());
out.writeObject(this.taskCursor);
}
public UniqueID computeNextActorHandleId() {
byte[] bytes = Sha1Digestor.digest(actorHandleId.getBytes(), ++forksNum);
return new UniqueID(bytes);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
this.id = (UniqueID) in.readObject();
this.actorHandleId = (UniqueID) in.readObject();
this.taskCursor = (UniqueID) in.readObject();
}
}
UniqueId getHandleId();
}
@@ -1,60 +0,0 @@
package org.ray.api;
import java.util.List;
import org.ray.api.funcs.RayFunc;
import org.ray.util.exception.TaskExecutionException;
/**
* Ray runtime abstraction.
*/
public interface RayApi {
/**
* Put obj into object store.
*
* @return RayObject
*/
<T> RayObject<T> put(T obj);
<T, TMT> RayObject<T> put(T obj, TMT metadata);
/**
* Get real obj from object store.
*/
<T> T get(UniqueID objectId) throws TaskExecutionException;
/**
* Get real objects from object store.
*
* @param objectIds list of ids of objects to get
*/
<T> List<T> get(List<UniqueID> objectIds) throws TaskExecutionException;
<T> T getMeta(UniqueID objectId) throws TaskExecutionException;
<T> List<T> getMeta(List<UniqueID> objectIds) throws TaskExecutionException;
/**
* wait until timeout or enough RayObjects are ready.
*
* @param waitfor wait for who
* @param numReturns how many of ready is enough
* @param timeout in millisecond
*/
<T> WaitResult<T> wait(List<RayObject<T>> waitfor, int numReturns, int timeout);
/**
* create remote actor.
*/
<T> RayActor<T> create(Class<T> cls);
/**
* Invoke a remote function.
*
* @param func the target running function
* @param args arguments to this funcRun, can be its original form or RayObject
* @return a set of ray objects with their return ids
*/
RayObject call(RayFunc func, Object... args);
}
@@ -0,0 +1,772 @@
// generated automatically, do not modify.
package org.ray.api;
import org.ray.api.function.*;
/**
* This class provides type-safe interfaces for Ray.call.
**/
@SuppressWarnings({"rawtypes", "unchecked"})
class RayCall {
public static <R> RayObject<R> call(RayFunc0<R> f) {
Object[] args = new Object[]{};
return Ray.internal().call(f, args);
}
public static <T0, R> RayObject<R> call(RayFunc1<T0, R> f, RayActor<T0> actor) {
Object[] args = new Object[]{};
return Ray.internal().call(f, actor, args);
}
public static <T0, R> RayObject<R> call(RayFunc1<T0, R> f, T0 t0) {
Object[] args = new Object[]{t0};
return Ray.internal().call(f, args);
}
public static <T0, R> RayObject<R> call(RayFunc1<T0, R> f, RayObject<T0> t0) {
Object[] args = new Object[]{t0};
return Ray.internal().call(f, args);
}
public static <T0, T1, R> RayObject<R> call(RayFunc2<T0, T1, R> f, RayActor<T0> actor, T1 t1) {
Object[] args = new Object[]{t1};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, R> RayObject<R> call(RayFunc2<T0, T1, R> f, RayActor<T0> actor, RayObject<T1> t1) {
Object[] args = new Object[]{t1};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, R> RayObject<R> call(RayFunc2<T0, T1, R> f, T0 t0, T1 t1) {
Object[] args = new Object[]{t0, t1};
return Ray.internal().call(f, args);
}
public static <T0, T1, R> RayObject<R> call(RayFunc2<T0, T1, R> f, T0 t0, RayObject<T1> t1) {
Object[] args = new Object[]{t0, t1};
return Ray.internal().call(f, args);
}
public static <T0, T1, R> RayObject<R> call(RayFunc2<T0, T1, R> f, RayObject<T0> t0, T1 t1) {
Object[] args = new Object[]{t0, t1};
return Ray.internal().call(f, args);
}
public static <T0, T1, R> RayObject<R> call(RayFunc2<T0, T1, R> f, RayObject<T0> t0, RayObject<T1> t1) {
Object[] args = new Object[]{t0, t1};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, RayActor<T0> actor, T1 t1, T2 t2) {
Object[] args = new Object[]{t1, t2};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2) {
Object[] args = new Object[]{t1, t2};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2) {
Object[] args = new Object[]{t1, t2};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2) {
Object[] args = new Object[]{t1, t2};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, T0 t0, T1 t1, T2 t2) {
Object[] args = new Object[]{t0, t1, t2};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, T0 t0, T1 t1, RayObject<T2> t2) {
Object[] args = new Object[]{t0, t1, t2};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, T0 t0, RayObject<T1> t1, T2 t2) {
Object[] args = new Object[]{t0, t1, t2};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2) {
Object[] args = new Object[]{t0, t1, t2};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, RayObject<T0> t0, T1 t1, T2 t2) {
Object[] args = new Object[]{t0, t1, t2};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2) {
Object[] args = new Object[]{t0, t1, t2};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2) {
Object[] args = new Object[]{t0, t1, t2};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, R> RayObject<R> call(RayFunc3<T0, T1, T2, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2) {
Object[] args = new Object[]{t0, t1, t2};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayActor<T0> actor, T1 t1, T2 t2, T3 t3) {
Object[] args = new Object[]{t1, t2, t3};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayActor<T0> actor, T1 t1, T2 t2, RayObject<T3> t3) {
Object[] args = new Object[]{t1, t2, t3};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, T3 t3) {
Object[] args = new Object[]{t1, t2, t3};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, RayObject<T3> t3) {
Object[] args = new Object[]{t1, t2, t3};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, T3 t3) {
Object[] args = new Object[]{t1, t2, t3};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, RayObject<T3> t3) {
Object[] args = new Object[]{t1, t2, t3};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, T3 t3) {
Object[] args = new Object[]{t1, t2, t3};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3) {
Object[] args = new Object[]{t1, t2, t3};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, T0 t0, T1 t1, T2 t2, T3 t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, T0 t0, T1 t1, T2 t2, RayObject<T3> t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, T0 t0, T1 t1, RayObject<T2> t2, T3 t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, T0 t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, T0 t0, RayObject<T1> t1, T2 t2, T3 t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, T0 t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayObject<T0> t0, T1 t1, T2 t2, T3 t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayObject<T0> t0, T1 t1, T2 t2, RayObject<T3> t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, T3 t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, T3 t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, R> RayObject<R> call(RayFunc4<T0, T1, T2, T3, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3) {
Object[] args = new Object[]{t0, t1, t2, t3};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, T1 t1, T2 t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, T1 t1, T2 t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, T1 t1, T2 t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t1, t2, t3, t4};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, T1 t1, T2 t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, T1 t1, T2 t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, T1 t1, RayObject<T2> t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, RayObject<T1> t1, T2 t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, T1 t1, T2 t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, T1 t1, T2 t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, T1 t1, T2 t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, R> RayObject<R> call(RayFunc5<T0, T1, T2, T3, T4, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4) {
Object[] args = new Object[]{t0, t1, t2, t3, t4};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayActor<T0> actor, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t1, t2, t3, t4, t5};
return Ray.internal().call(f, actor, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, T0 t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
public static <T0, T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc6<T0, T1, T2, T3, T4, T5, R> f, RayObject<T0> t0, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
Object[] args = new Object[]{t0, t1, t2, t3, t4, t5};
return Ray.internal().call(f, args);
}
}
@@ -1,5 +0,0 @@
package org.ray.api;
public @interface RayDisabled {
}
@@ -1,35 +1,23 @@
package org.ray.api;
import java.io.Serializable;
import org.ray.util.exception.TaskExecutionException;
import org.ray.api.id.UniqueId;
/**
* RayObject&lt;T&gt; is a handle for T object, which may or may not be available now.
* That said, RayObject can be viewed as a Future object with metadata.
* Represents an object in the object store.
* @param <T> The object type.
*/
public class RayObject<T> implements Serializable {
public interface RayObject<T> {
private static final long serialVersionUID = 3250003902037418062L;
/**
* Fetch the object from the object store, this method will block
* until the object is locally available.
*/
T get();
UniqueID id;
public RayObject() {
}
public RayObject(UniqueID id) {
this.id = id;
}
public T get() throws TaskExecutionException {
return Ray.get(id);
}
public <TMT> TMT getMeta() throws TaskExecutionException {
return Ray.getMeta(id);
}
public UniqueID getId() {
return id;
}
/**
* Get the object id.
*/
UniqueId getId();
}
@@ -1,20 +0,0 @@
package org.ray.api;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.ray.util.ResourceItem;
/**
* a ray remote function or class (as an actor).
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface RayRemote {
/**
* This is used for default resources.
* @return The resources of the method or actor need.
*/
ResourceItem[] resources() default {@ResourceItem()};
}
@@ -1,9 +0,0 @@
package org.ray.api;
/**
* a RPC service that represent the data processing services implemented in Ray.
* it is programmed in other services but will be shipped and executed on ray machines at runtime
*/
public @interface RayService {
}
-390
View File
@@ -1,390 +0,0 @@
// generated automatically, do not modify.
package org.ray.api;
import org.ray.api.funcs.*;
@SuppressWarnings({"rawtypes", "unchecked"})
class Rpc {
public static <R> RayObject<R> call(RayFunc0<R> f) {
return Ray.internal().call(f);
}
public static <T1, R> RayObject<R> call(RayFunc1<T1, R> f, T1 t1) {
return Ray.internal().call(f, t1);
}
public static <T1, R> RayObject<R> call(RayFunc1<T1, R> f, RayObject<T1> t1) {
return Ray.internal().call(f, t1);
}
public static <T1, T2, R> RayObject<R> call(RayFunc2<T1, T2, R> f, T1 t1, T2 t2) {
return Ray.internal().call(f, t1, t2);
}
public static <T1, T2, R> RayObject<R> call(RayFunc2<T1, T2, R> f, T1 t1, RayObject<T2> t2) {
return Ray.internal().call(f, t1, t2);
}
public static <T1, T2, R> RayObject<R> call(RayFunc2<T1, T2, R> f, RayObject<T1> t1, T2 t2) {
return Ray.internal().call(f, t1, t2);
}
public static <T1, T2, R> RayObject<R> call(RayFunc2<T1, T2, R> f, RayObject<T1> t1, RayObject<T2> t2) {
return Ray.internal().call(f, t1, t2);
}
public static <T1, T2, T3, R> RayObject<R> call(RayFunc3<T1, T2, T3, R> f, T1 t1, T2 t2, T3 t3) {
return Ray.internal().call(f, t1, t2, t3);
}
public static <T1, T2, T3, R> RayObject<R> call(RayFunc3<T1, T2, T3, R> f, T1 t1, T2 t2, RayObject<T3> t3) {
return Ray.internal().call(f, t1, t2, t3);
}
public static <T1, T2, T3, R> RayObject<R> call(RayFunc3<T1, T2, T3, R> f, T1 t1, RayObject<T2> t2, T3 t3) {
return Ray.internal().call(f, t1, t2, t3);
}
public static <T1, T2, T3, R> RayObject<R> call(RayFunc3<T1, T2, T3, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3) {
return Ray.internal().call(f, t1, t2, t3);
}
public static <T1, T2, T3, R> RayObject<R> call(RayFunc3<T1, T2, T3, R> f, RayObject<T1> t1, T2 t2, T3 t3) {
return Ray.internal().call(f, t1, t2, t3);
}
public static <T1, T2, T3, R> RayObject<R> call(RayFunc3<T1, T2, T3, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3) {
return Ray.internal().call(f, t1, t2, t3);
}
public static <T1, T2, T3, R> RayObject<R> call(RayFunc3<T1, T2, T3, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3) {
return Ray.internal().call(f, t1, t2, t3);
}
public static <T1, T2, T3, R> RayObject<R> call(RayFunc3<T1, T2, T3, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3) {
return Ray.internal().call(f, t1, t2, t3);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, T1 t1, T2 t2, T3 t3, T4 t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, T1 t1, T2 t2, T3 t3, RayObject<T4> t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, T1 t1, T2 t2, RayObject<T3> t3, T4 t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, T1 t1, RayObject<T2> t2, T3 t3, T4 t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, RayObject<T1> t1, T2 t2, T3 t3, T4 t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, R> RayObject<R> call(RayFunc4<T1, T2, T3, T4, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4) {
return Ray.internal().call(f, t1, t2, t3, t4);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, R> RayObject<R> call(RayFunc5<T1, T2, T3, T4, T5, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5) {
return Ray.internal().call(f, t1, t2, t3, t4, t5);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, T1 t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, T3 t3, T4 t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, T2 t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, T4 t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, T3 t3, RayObject<T4> t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, T4 t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, T5 t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5, T6 t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
public static <T1, T2, T3, T4, T5, T6, R> RayObject<R> call(RayFunc6<T1, T2, T3, T4, T5, T6, R> f, RayObject<T1> t1, RayObject<T2> t2, RayObject<T3> t3, RayObject<T4> t4, RayObject<T5> t5, RayObject<T6> t6) {
return Ray.internal().call(f, t1, t2, t3, t4, t5, t6);
}
}
@@ -1,13 +0,0 @@
package org.ray.api;
import java.io.Serializable;
/**
* Represents a status of type T of a task.
*/
public class TaskStatus<T> implements Serializable {
private static final long serialVersionUID = -3382082416577683751L;
public T status;
}
@@ -4,24 +4,31 @@ package org.ray.api;
import java.util.List;
/**
* The result of Ray.wait() distinguish the ready ones and the remain ones
* Represents the result of a Ray.wait call. It contains 2 lists,
* one containing the locally available objects, one containing the rest.
*/
public class WaitResult<T> {
public final class WaitResult<T> {
private final List<RayObject<T>> readyOnes;
private final List<RayObject<T>> remainOnes;
private final List<RayObject<T>> ready;
private final List<RayObject<T>> unready;
public WaitResult(List<RayObject<T>> readyOnes, List<RayObject<T>> remainOnes) {
this.readyOnes = readyOnes;
this.remainOnes = remainOnes;
public WaitResult(List<RayObject<T>> ready, List<RayObject<T>> unready) {
this.ready = ready;
this.unready = unready;
}
public List<RayObject<T>> getReadyOnes() {
return readyOnes;
/**
* Get the list of ready objects.
*/
public List<RayObject<T>> getReady() {
return ready;
}
public List<RayObject<T>> getRemainOnes() {
return remainOnes;
/**
* Get the list of unready objects.
*/
public List<RayObject<T>> getUnready() {
return unready;
}
}
@@ -0,0 +1,24 @@
package org.ray.api.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Defines a remote function (when used on a method),
* or an actor (when used on a class).
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface RayRemote {
/**
* Defines the quantity of various custom resources to reserve
* for this task or for the lifetime of the actor.
* @return an array of custom resource items.
*/
ResourceItem[] resources() default {};
}
@@ -0,0 +1,28 @@
package org.ray.api.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Represents a custom resource, including its name and quantity.
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.ANNOTATION_TYPE)
public @interface ResourceItem {
/**
* Name of this resource, must not be null or empty.
*/
String name();
/**
* Quantity of this resource.
*/
double value() default 0;
}
@@ -0,0 +1,15 @@
package org.ray.api.exception;
/**
* Base class of all ray exceptions.
*/
public class RayException extends RuntimeException {
public RayException(String message) {
super(message);
}
public RayException(String message, Throwable cause) {
super(message, cause);
}
}
@@ -1,4 +1,4 @@
package org.ray.api.funcs;
package org.ray.api.function;
import java.io.Serializable;
@@ -1,7 +1,10 @@
// generated automatically, do not modify.
package org.ray.api.funcs;
package org.ray.api.function;
/**
* Functional interface for a remote function that has 0 parameter.
*/
@FunctionalInterface
public interface RayFunc0<R> extends RayFunc {
R apply();
@@ -1,7 +1,10 @@
// generated automatically, do not modify.
package org.ray.api.funcs;
package org.ray.api.function;
/**
* Functional interface for a remote function that has 1 parameter.
*/
@FunctionalInterface
public interface RayFunc1<T0, R> extends RayFunc {
R apply(T0 t0);
@@ -1,7 +1,10 @@
// generated automatically, do not modify.
package org.ray.api.funcs;
package org.ray.api.function;
/**
* Functional interface for a remote function that has 2 parameters.
*/
@FunctionalInterface
public interface RayFunc2<T0, T1, R> extends RayFunc {
R apply(T0 t0, T1 t1);
@@ -1,7 +1,10 @@
// generated automatically, do not modify.
package org.ray.api.funcs;
package org.ray.api.function;
/**
* Functional interface for a remote function that has 3 parameters.
*/
@FunctionalInterface
public interface RayFunc3<T0, T1, T2, R> extends RayFunc {
R apply(T0 t0, T1 t1, T2 t2);
@@ -1,7 +1,10 @@
// generated automatically, do not modify.
package org.ray.api.funcs;
package org.ray.api.function;
/**
* Functional interface for a remote function that has 4 parameters.
*/
@FunctionalInterface
public interface RayFunc4<T0, T1, T2, T3, R> extends RayFunc {
R apply(T0 t0, T1 t1, T2 t2, T3 t3);
@@ -1,7 +1,10 @@
// generated automatically, do not modify.
package org.ray.api.funcs;
package org.ray.api.function;
/**
* Functional interface for a remote function that has 5 parameters.
*/
@FunctionalInterface
public interface RayFunc5<T0, T1, T2, T3, T4, R> extends RayFunc {
R apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4);
@@ -1,7 +1,10 @@
// generated automatically, do not modify.
package org.ray.api.funcs;
package org.ray.api.function;
/**
* Functional interface for a remote function that has 6 parameters.
*/
@FunctionalInterface
public interface RayFunc6<T0, T1, T2, T3, T4, T5, R> extends RayFunc {
R apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5);
@@ -1,4 +1,4 @@
package org.ray.api;
package org.ray.api.id;
import java.io.Serializable;
import java.nio.ByteBuffer;
@@ -7,59 +7,88 @@ import java.util.Random;
import javax.xml.bind.DatatypeConverter;
/**
* Unique ID for task, worker, function.
* Represents a unique id of all Ray concepts, including
* objects, tasks, workers, actors, etc.
*/
public class UniqueID implements Serializable {
public class UniqueId implements Serializable {
public static final int LENGTH = 20;
public static final UniqueID NIL = genNil();
public static final UniqueId NIL = genNil();
private static final long serialVersionUID = 8588849129675565761L;
private final byte[] id;
public static UniqueID fromHexString(String hex) {
/**
* Create a UniqueId from a hex string.
*/
public static UniqueId fromHexString(String hex) {
byte[] bytes = DatatypeConverter.parseHexBinary(hex);
return new UniqueID(bytes);
return new UniqueId(bytes);
}
public static UniqueID fromByteBuffer(ByteBuffer bb) {
/**
* Creates a UniqueId from a ByteBuffer.
*/
public static UniqueId fromByteBuffer(ByteBuffer bb) {
byte[] id = new byte[bb.remaining()];
bb.get(id);
return new UniqueID(id);
return new UniqueId(id);
}
public static UniqueID genNil() {
/**
* Generate a nil UniqueId.
*/
public static UniqueId genNil() {
byte[] b = new byte[LENGTH];
Arrays.fill(b, (byte) 0xFF);
return new UniqueID(b);
return new UniqueId(b);
}
public static UniqueID randomId() {
/**
* Generate an UniqueId with random value.
*/
public static UniqueId randomId() {
byte[] b = new byte[LENGTH];
new Random().nextBytes(b);
return new UniqueID(b);
return new UniqueId(b);
}
public UniqueID(byte[] id) {
public UniqueId(byte[] id) {
if (id.length != LENGTH) {
throw new IllegalArgumentException("Illegal argument for UniqueID, expect " + LENGTH
throw new IllegalArgumentException("Illegal argument for UniqueId, expect " + LENGTH
+ " bytes, but got " + id.length + " bytes.");
}
this.id = id;
}
/**
* Get the byte data of this UniqueId.
*/
public byte[] getBytes() {
return id;
}
/**
* Convert the byte data to a ByteBuffer.
*/
public ByteBuffer toByteBuffer() {
return ByteBuffer.wrap(id);
}
public UniqueID copy() {
/**
* Create a copy of this UniqueId.
*/
public UniqueId copy() {
byte[] nid = Arrays.copyOf(id, id.length);
return new UniqueID(nid);
return new UniqueId(nid);
}
/**
* Returns true if this id is nil.
*/
public boolean isNil() {
return this.equals(NIL);
}
@Override
@@ -73,11 +102,11 @@ public class UniqueID implements Serializable {
return false;
}
if (!(obj instanceof UniqueID)) {
if (!(obj instanceof UniqueId)) {
return false;
}
UniqueID r = (UniqueID) obj;
UniqueId r = (UniqueId) obj;
return Arrays.equals(id, r.id);
}
@@ -85,8 +114,4 @@ public class UniqueID implements Serializable {
public String toString() {
return DatatypeConverter.printHexBinary(id);
}
public boolean isNil() {
return this.equals(NIL);
}
}
@@ -1,26 +0,0 @@
package org.ray.api.internal;
import java.lang.reflect.Method;
import org.ray.api.RayApi;
import org.ray.util.logger.RayLog;
/**
* Mediator, which pulls the {@code org.ray.api.RayApi} up to run.
*/
public class RayConnector {
private static final String className = "org.ray.core.RayRuntime";
public static RayApi run() {
try {
Method m = Class.forName(className).getDeclaredMethod("init");
m.setAccessible(true);
RayApi api = (RayApi) m.invoke(null);
m.setAccessible(false);
return api;
} catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) {
RayLog.core.error("Load {} class failed.", className, e);
throw new Error("RayApi is not successfully initiated.");
}
}
}
@@ -0,0 +1,22 @@
package org.ray.api.runtime;
import java.lang.reflect.Method;
/**
* The default Ray runtime factory. It produces an instance of AbstractRayRuntime.
*/
public class DefaultRayRuntimeFactory implements RayRuntimeFactory {
@Override
public RayRuntime createRayRuntime() {
try {
Method m = Class.forName("org.ray.core.AbstractRayRuntime").getDeclaredMethod("init");
m.setAccessible(true);
RayRuntime runtime = (RayRuntime) m.invoke(null);
m.setAccessible(false);
return runtime;
} catch (Exception e) {
throw new RuntimeException("Failed to initialize ray runtime", e);
}
}
}
@@ -0,0 +1,81 @@
package org.ray.api.runtime;
import java.util.List;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.WaitResult;
import org.ray.api.function.RayFunc;
import org.ray.api.id.UniqueId;
/**
* Base interface of a Ray runtime.
*/
public interface RayRuntime {
/**
* Shutdown the runtime.
*/
void shutdown();
/**
* Store an object in the object store.
*
* @param obj The Java object to be stored.
* @return A RayObject instance that represents the in-store object.
*/
<T> RayObject<T> put(T obj);
/**
* Get an object from the object store.
*
* @param objectId The ID of the object to get.
* @return The Java object.
*/
<T> T get(UniqueId objectId);
/**
* Get a list of objects from the object store.
*
* @param objectIds The list of object IDs.
* @return A list of Java objects.
*/
<T> List<T> get(List<UniqueId> objectIds);
/**
* 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 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.
*/
<T> WaitResult<T> wait(List<RayObject<T>> waitList, int numReturns, int timeoutMs);
/**
* Create an actor on a remote node.
*
* @param actorClass the class of the actor to be created.
* @return A handle to the newly created actor.
*/
<T> RayActor<T> createActor(Class<T> actorClass);
/**
* Invoke a remote function.
*
* @param func The remote function to run.
* @param args The arguments of the remote function.
* @return The result object.
*/
RayObject call(RayFunc func, Object[] args);
/**
* Invoke a remote function on an actor.
*
* @param func The remote function to run, it must be a method of the given actor.
* @param actor A handle to the actor.
* @param args The arguments of the remote function.
* @return The result object.
*/
RayObject call(RayFunc func, RayActor actor, Object[] args);
}
@@ -0,0 +1,9 @@
package org.ray.api.runtime;
/**
* A factory that produces a RayRuntime instance.
*/
public interface RayRuntimeFactory {
RayRuntime createRayRuntime();
}
+1 -6
View File
@@ -3,15 +3,10 @@
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress checks="MethodNameCheck" files="DefaultLocalSchedulerClient.java"/>
<suppress checks="MemberNameCheck" files="PathConfig.java"/>
<suppress checks="MemberNameCheck" files="RayParameters.java"/>
<suppress checks="AbbreviationAsWordInNameCheck" files="RayParameters.java"/>
<suppress checks="MethodNameCheck" files="ResourcePair.java"/>
<suppress checks="ParameterNameCheck" files="ResourcePair.java"/>
<suppress checks="MethodTypeParameterNameCheck" files="Rpc.java"/>
<suppress checks="AbbreviationAsWordInNameCheck" files="UniqueID.java"/>
<suppress checks=".*" files="Rpc.java"/>
<suppress checks=".*" files="RayCall.java"/>
<!-- suppress check for flatbuffer-generated files. -->
<!-- TODO(raulchen): move these files to a directory, so this rule can be simplier. -->
<suppress checks=".*" files="(Arg|ResourcePair|TaskLanguage|TaskInfo|ClientTableData).java" />
@@ -6,7 +6,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.lingala.zip4j.core.ZipFile;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.core.model.RayParameters;
import org.ray.core.model.RunMode;
import org.ray.runner.RunManager;
@@ -162,10 +162,7 @@ public class RayCli {
cmdSubmit.packageZip.lastIndexOf('/') + 1,
cmdSubmit.packageZip.lastIndexOf('.'));
//final RemoteFunctionManager functionManager = RayRuntime
// .getInstance().getRemoteFunctionManager();
UniqueID resourceId = functionManager.registerResource(zip);
UniqueId resourceId = functionManager.registerResource(zip);
// Init RayLog before using it.
RayLog.init(params.log_dir);
@@ -173,7 +170,7 @@ public class RayCli {
RayLog.rapp.debug(
"registerResource " + resourceId + " for package " + packageName + " done");
UniqueID appId = params.driver_id;
UniqueId appId = params.driver_id;
functionManager.registerApp(appId, resourceId);
RayLog.rapp.debug("registerApp " + appId + " for resouorce " + resourceId + " done");
@@ -206,8 +203,6 @@ public class RayCli {
RayLog.rapp.debug("Find app class path " + additionalClassPath);
// Start driver process.
//RunManager runManager = new RunManager(params, RayRuntime.getInstance().getPaths(),
// RayRuntime.configReader);
RunManager runManager = new RunManager(params, paths, config);
Process proc = runManager.startDriver(
DefaultDriver.class.getName(),
+41 -39
View File
@@ -1,46 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.ray.parent</groupId>
<artifactId>ray-superpom</artifactId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.ray.parent</groupId>
<artifactId>ray-superpom</artifactId>
<version>1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.ray</groupId>
<artifactId>ray-common</artifactId>
<name>java common and util for ray</name>
<description>java common and util for ray</description>
<url></url>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>quartz</groupId>
<artifactId>quartz</artifactId>
</dependency>
<dependency>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
<groupId>org.ray</groupId>
<artifactId>ray-common</artifactId>
<name>java common and util for ray</name>
<description>java common and util for ray</description>
<url></url>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.ray</groupId>
<artifactId>ray-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
<groupId>quartz</groupId>
<artifactId>quartz</artifactId>
</dependency>
<dependency>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
</project>
@@ -1,10 +0,0 @@
package org.ray.util;
import java.io.Serializable;
import java.util.function.BiFunction;
@FunctionalInterface
public interface RemoteBiFunction<T1, T2, O> extends BiFunction<T1, T2, O>, Serializable {
}
@@ -1,9 +0,0 @@
package org.ray.util;
import java.io.Serializable;
import java.util.function.Function;
@FunctionalInterface
public interface RemoteFunction<I, O> extends Function<I, O>, Serializable {
}
@@ -1,7 +0,0 @@
package org.ray.util;
public @interface ResourceItem {
public String name() default "";
public double value() default 0;
}
@@ -2,6 +2,7 @@ package org.ray.util;
import java.util.HashMap;
import java.util.Map;
import org.ray.api.annotation.ResourceItem;
public class ResourceUtil {
public static final String CPU_LITERAL = "CPU";
@@ -12,6 +12,7 @@ import java.util.Vector;
import org.ini4j.Config;
import org.ini4j.Ini;
import org.ini4j.Profile;
import org.ray.api.id.UniqueId;
import org.ray.util.ObjectUtil;
import org.ray.util.StringUtil;
@@ -319,7 +320,7 @@ public class ConfigReader {
Object v = Enum.valueOf((Class<Enum>) fld.getType(), sv);
fld.set(obj, v);
// TODO: this is a hack and needs to be resolved later
} else if (fld.getType().getName().equals("org.ray.api.UniqueID")) {
} else if (fld.getType().equals(UniqueId.class)) {
String sv = getStringValue(section, fld.getName(), defaultFldValue.toString(), comment);
Object v;
try {
@@ -0,0 +1,113 @@
package org.ray.util.generator;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.ray.util.FileUtil;
/**
* A util class that generates `RayCall.java`
*/
public class RayCallGenerator extends BaseGenerator {
/**
* @return Whole file content of `RayCall.java`.
*/
private String build() {
sb = new StringBuilder();
newLine("// generated automatically, do not modify.");
newLine("");
newLine("package org.ray.api;");
newLine("");
newLine("import org.ray.api.function.*;");
newLine("");
newLine("/**");
newLine(" * This class provides type-safe interfaces for Ray.call.");
newLine(" **/");
newLine("@SuppressWarnings({\"rawtypes\", \"unchecked\"})");
newLine("class RayCall {");
for (int i = 0; i <= 6; i++) {
if (i > 0) {
buildCalls(i, true);
}
buildCalls(i, false);
}
newLine("}");
return sb.toString();
}
/**
* Build the `Ray.call` methods for given number of parameters.
* @param numParameters the number of parameters, including the actor parameter.
* @param forActor build actor api when true, otherwise build task api.
*/
private void buildCalls(int numParameters, boolean forActor) {
String genericTypes = "";
String argList = "";
for (int i = 0; i < numParameters; i++) {
genericTypes += "T" + i + ", ";
if (!forActor || i > 0) {
argList += "t" + i + ", ";
}
}
if (argList.endsWith(", ")) {
argList = argList.substring(0, argList.length() - 2);
}
String funcParam = String.format("RayFunc%d<%sR> f%s",
numParameters,
genericTypes,
numParameters > 0 ? ", " : "");
String actorParam = "";
if (forActor) {
actorParam = "RayActor<T0> actor";
if (numParameters > 1) {
actorParam += ", ";
}
}
for (String param : generateParameters(forActor ? 1 : 0, numParameters)) {
// method signature
indents(1);
newLine(String.format(
"public static <%sR> RayObject<R> call(%s%s%s) {",
genericTypes, funcParam, actorParam, param
));
// method body
indents(2);
newLine(String.format("Object[] args = new Object[]{%s};", argList));
indents(2);
newLine(String.format("return Ray.internal().call(f%s, args);", forActor ? ", actor" : ""));
indents(1);
newLine("}");
}
}
private List<String> generateParameters(int from, int to) {
List<String> res = new ArrayList<>();
dfs(from, from, to, "", res);
return res;
}
private void dfs(int pos, int from, int to, String cur, List<String> res) {
if (pos >= to) {
res.add(cur);
return;
}
if (pos > from) {
cur += ", ";
}
String nextParameter = String.format("T%d t%d", pos, pos);
dfs(pos + 1, from, to, cur + nextParameter, res);
nextParameter = String.format("RayObject<T%d> t%d", pos, pos);
dfs(pos + 1, from, to, cur + nextParameter, res);
}
public static void main(String[] args) throws IOException {
String path = System.getProperty("user.dir")
+ "/api/src/main/java/org/ray/api/RayCall.java";
FileUtil.overrideFile(path, new RayCallGenerator().build());
}
}
@@ -4,9 +4,9 @@ import java.io.IOException;
import org.ray.util.FileUtil;
/**
* A util class that generates all the classes under org.ray.api.funcs package.
* A util class that generates all the RayFuncX classes under org.ray.api.function package.
*/
public class FuncsGenerator extends BaseGenerator {
public class RayFuncGenerator extends BaseGenerator {
private String generate(int numParameters) {
sb = new StringBuilder();
@@ -23,8 +23,14 @@ public class FuncsGenerator extends BaseGenerator {
newLine("// generated automatically, do not modify.");
newLine("");
newLine("package org.ray.api.funcs;");
newLine("package org.ray.api.function;");
newLine("");
newLine("/**");
String comment = String.format(
" * Functional interface for a remote function that has %d parameter%s.",
numParameters, numParameters > 1 ? "s" : "");
newLine(comment);
newLine(" */");
newLine("@FunctionalInterface");
newLine(String.format("public interface RayFunc%d<%sR> extends RayFunc {",
numParameters, genericTypes));
@@ -37,8 +43,8 @@ public class FuncsGenerator extends BaseGenerator {
public static void main(String[] args) throws IOException {
String root = System.getProperty("user.dir")
+ "/api/src/main/java/org/ray/api/funcs/";
FuncsGenerator generator = new FuncsGenerator();
+ "/api/src/main/java/org/ray/api/function/";
RayFuncGenerator generator = new RayFuncGenerator();
for (int i = 0; i <= MAX_PARAMETERS; i++) {
String content = generator.generate(i);
FileUtil.overrideFile(root + "RayFunc" + i + ".java", content);
@@ -1,77 +0,0 @@
package org.ray.util.generator;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.ray.util.FileUtil;
/**
* A util class that generates Rpc.java
*/
public class RpcGenerator extends BaseGenerator {
private String build() {
sb = new StringBuilder();
newLine("// generated automatically, do not modify.");
newLine("");
newLine("package org.ray.api;");
newLine("");
newLine("import org.ray.api.funcs.*;");
newLine("");
newLine("@SuppressWarnings({\"rawtypes\", \"unchecked\"})");
newLine("class Rpc {");
for (int i = 0; i <= 6; i++) {
buildCalls(i);
}
newLine("}");
return sb.toString();
}
private void buildCalls(int numParameters) {
String funcClass = "RayFunc" + numParameters;
String genericTypes = "";
String callList = "";
for (int i = 1; i <= numParameters; i++) {
genericTypes += "T" + i + ", ";
callList += ", t" + i;
}
String body = String.format("return Ray.internal().call(f%s);", callList);
for (String param : generateParameters(numParameters)) {
indents(1);
newLine(String.format(
"public static <%sR> RayObject<R> call(%s<%sR> f%s) {",
genericTypes, funcClass, genericTypes, param
));
indents(2);
newLine(body);
indents(1);
newLine("}");
}
}
private List<String> generateParameters(int numParameters) {
List<String> res = new ArrayList<>();
dfs(1, numParameters, "", res);
return res;
}
private void dfs(int pos, int max, String cur, List<String> res) {
if (pos > max) {
res.add(cur);
return;
}
cur += ", ";
String nextParameter = String.format("T%d t%d", pos, pos);
dfs(pos + 1, max, cur + nextParameter, res);
nextParameter = String.format("RayObject<T%d> t%d", pos, pos);
dfs(pos + 1, max, cur + nextParameter, res);
}
public static void main(String[] args) throws IOException {
String path = System.getProperty("user.dir") + "/api/src/main/java";
path += "/org/ray/api/Rpc.java";
FileUtil.overrideFile(path, new RpcGenerator().build());
}
}
+5
View File
@@ -23,6 +23,11 @@
<artifactId>ray-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.ray</groupId>
<artifactId>ray-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>de.ruedigermoeller</groupId>
<artifactId>fst</artifactId>
@@ -11,18 +11,24 @@ import java.util.Map;
import org.apache.arrow.plasma.ObjectStoreLink;
import org.apache.commons.lang3.tuple.Pair;
import org.ray.api.Ray;
import org.ray.api.RayApi;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.UniqueID;
import org.ray.api.WaitResult;
import org.ray.api.funcs.RayFunc;
import org.ray.api.annotation.RayRemote;
import org.ray.api.function.RayFunc;
import org.ray.api.function.RayFunc2;
import org.ray.api.id.UniqueId;
import org.ray.api.runtime.RayRuntime;
import org.ray.core.model.RayParameters;
import org.ray.spi.LocalSchedulerLink;
import org.ray.spi.LocalSchedulerProxy;
import org.ray.spi.ObjectStoreProxy;
import org.ray.spi.ObjectStoreProxy.GetStatus;
import org.ray.spi.PathConfig;
import org.ray.spi.RemoteFunctionManager;
import org.ray.spi.model.RayMethod;
import org.ray.spi.model.TaskSpec;
import org.ray.util.MethodId;
import org.ray.util.ResourceUtil;
import org.ray.util.config.ConfigReader;
import org.ray.util.exception.TaskExecutionException;
import org.ray.util.logger.RayLog;
@@ -30,26 +36,31 @@ import org.ray.util.logger.RayLog;
/**
* Core functionality to implement Ray APIs.
*/
public abstract class RayRuntime implements RayApi {
public abstract class AbstractRayRuntime implements RayRuntime {
public static ConfigReader configReader;
protected static RayRuntime ins = null;
protected static AbstractRayRuntime ins = null;
protected static RayParameters params = null;
private static boolean fromRayInit = false;
protected Worker worker;
protected LocalSchedulerProxy localSchedulerProxy;
protected LocalSchedulerLink localSchedulerClient;
protected ObjectStoreProxy objectStoreProxy;
protected LocalFunctionManager functions;
protected RemoteFunctionManager remoteFunctionManager;
protected PathConfig pathConfig;
/**
* Actor ID -> actor instance.
*/
private Map<UniqueId, Object> actors = new HashMap<>();
// app level Ray.init()
// make it private so there is no direct usage but only from Ray.init
private static RayRuntime init() {
private static AbstractRayRuntime init() {
if (ins == null) {
try {
fromRayInit = true;
RayRuntime.init(null, null);
AbstractRayRuntime.init(null, null);
fromRayInit = false;
} catch (Exception e) {
e.printStackTrace();
@@ -59,9 +70,10 @@ public abstract class RayRuntime implements RayApi {
return ins;
}
// engine level RayRuntime.init(xx, xx)
// engine level AbstractRayRuntime.init(xx, xx)
// updateConfigStr is sth like section1.k1=v1;section2.k2=v2
public static RayRuntime init(String configPath, String updateConfigStr) throws Exception {
public static AbstractRayRuntime init(String configPath, String updateConfigStr)
throws Exception {
if (ins == null) {
if (configPath == null) {
configPath = System.getenv("RAY_CONFIG");
@@ -74,7 +86,7 @@ public abstract class RayRuntime implements RayApi {
}
}
configReader = new ConfigReader(configPath, updateConfigStr);
RayRuntime.params = new RayParameters(configReader);
AbstractRayRuntime.params = new RayParameters(configReader);
RayLog.init(params.log_dir);
assert RayLog.core != null;
@@ -91,7 +103,7 @@ public abstract class RayRuntime implements RayApi {
// init with command line args
// --config=ray.config.ini --overwrite=updateConfigStr
public static RayRuntime init(String[] args) throws Exception {
public static AbstractRayRuntime init(String[] args) throws Exception {
String config = null;
String updateConfig = null;
for (String arg : args) {
@@ -117,7 +129,7 @@ public abstract class RayRuntime implements RayApi {
pathConfig = pathManager;
functions = new LocalFunctionManager(remoteLoader);
localSchedulerProxy = new LocalSchedulerProxy(slink);
localSchedulerClient = slink;
if (!params.use_raylet) {
objectStoreProxy = new ObjectStoreProxy(plink);
@@ -125,22 +137,23 @@ public abstract class RayRuntime implements RayApi {
objectStoreProxy = new ObjectStoreProxy(plink, slink);
}
worker = new Worker(localSchedulerProxy, functions);
worker = new Worker(localSchedulerClient, functions);
}
private static RayRuntime instantiate(RayParameters params) {
private static AbstractRayRuntime instantiate(RayParameters params) {
String className = params.run_mode.isNativeRuntime()
? "org.ray.core.impl.RayNativeRuntime" : "org.ray.core.impl.RayDevRuntime";
RayRuntime runtime;
AbstractRayRuntime runtime;
try {
Class<?> cls = Class.forName(className);
if (cls.getConstructors().length > 0) {
throw new Error("The RayRuntime final class should not have any public constructor.");
throw new Error(
"The AbstractRayRuntime final class should not have any public constructor.");
}
Constructor<?> cons = cls.getDeclaredConstructor();
cons.setAccessible(true);
runtime = (RayRuntime) cons.newInstance();
runtime = (AbstractRayRuntime) cons.newInstance();
cons.setAccessible(false);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | SecurityException | ClassNotFoundException
@@ -148,7 +161,8 @@ public abstract class RayRuntime implements RayApi {
RayLog.core
.error("Load class " + className + " failed for run-mode " + params.run_mode.toString(),
e);
throw new Error("RayRuntime not registered for run-mode " + params.run_mode.toString());
throw new Error("AbstractRayRuntime not registered for run-mode "
+ params.run_mode.toString());
}
RayLog.core
@@ -156,9 +170,7 @@ public abstract class RayRuntime implements RayApi {
try {
runtime.start(params);
} catch (Exception e) {
System.err.println("RayRuntime start failed:" + e.getMessage()); //in case of logger not ready
e.printStackTrace(); //in case of logger not ready
RayLog.core.error("RayRuntime start failed", e);
RayLog.core.error("Failed to init RayRuntime", e);
System.exit(-1);
}
@@ -170,7 +182,7 @@ public abstract class RayRuntime implements RayApi {
*/
public abstract void start(RayParameters params) throws Exception;
public static RayRuntime getInstance() {
public static AbstractRayRuntime getInstance() {
return ins;
}
@@ -178,39 +190,29 @@ public abstract class RayRuntime implements RayApi {
return params;
}
public abstract void cleanUp();
@Override
public abstract void shutdown();
public <T> void putRaw(UniqueID taskId, UniqueID objectId, T obj) {
putRaw(taskId, objectId, obj, null);
@Override
public <T> RayObject<T> put(T obj) {
UniqueId objectId = getCurrentTaskNextPutId();
put(objectId, obj);
return new RayObjectImpl<>(objectId);
}
/***********
* RayApi methods.
***********/
public <T, TMT> void putRaw(UniqueID taskId, UniqueID objectId, T obj, TMT metadata) {
RayLog.core.info("Task " + taskId.toString() + " Object " + objectId.toString() + " put");
public <T> void put(UniqueId objectId, T obj) {
UniqueId taskId = getCurrentTaskId();
RayLog.core.info("Putting object {}, for task {} ", objectId, taskId);
if (!params.use_raylet) {
localSchedulerProxy.markTaskPutDependency(taskId, objectId);
localSchedulerClient.markTaskPutDependency(taskId, objectId);
}
objectStoreProxy.put(objectId, obj, metadata);
}
public <T> void putRaw(UniqueID objectId, T obj) {
UniqueID taskId = getCurrentTaskId();
putRaw(taskId, objectId, obj, null);
}
public <T> void putRaw(T obj) {
UniqueID taskId = getCurrentTaskId();
UniqueID objectId = getCurrentTaskNextPutId();
putRaw(taskId, objectId, obj, null);
objectStoreProxy.put(objectId, obj, null);
}
/**
* get the task identity of the currently running task, UniqueID.NIL if not inside any
* get the task identity of the currently running task, UniqueId.NIL if not inside any
*/
public UniqueID getCurrentTaskId() {
public UniqueId getCurrentTaskId() {
return worker.getCurrentTaskId();
}
@@ -218,79 +220,42 @@ public abstract class RayRuntime implements RayApi {
* get the to-be-returned objects identities of the currently running task, empty array if not
* inside any.
*/
public UniqueID getCurrentTaskNextPutId() {
public UniqueId getCurrentTaskNextPutId() {
return worker.getCurrentTaskNextPutId();
}
@Override
public <T> RayObject<T> put(T obj) {
return put(obj, null);
public <T> T get(UniqueId objectId) throws TaskExecutionException {
List<T> ret = get(ImmutableList.of(objectId));
return ret.get(0);
}
@Override
public <T, TMT> RayObject<T> put(T obj, TMT metadata) {
UniqueID taskId = getCurrentTaskId();
UniqueID objectId = getCurrentTaskNextPutId();
putRaw(taskId, objectId, obj, metadata);
return new RayObject<>(objectId);
}
@Override
public <T> T get(UniqueID objectId) throws TaskExecutionException {
return doGet(objectId, false);
}
@Override
public <T> List<T> get(List<UniqueID> objectIds) throws TaskExecutionException {
return doGet(objectIds, false);
}
@Override
public <T> T getMeta(UniqueID objectId) throws TaskExecutionException {
return doGet(objectId, true);
}
@Override
public <T> List<T> getMeta(List<UniqueID> objectIds) throws TaskExecutionException {
return doGet(objectIds, true);
}
@Override
public <T> WaitResult<T> wait(List<RayObject<T>> waitfor, int numReturns, int timeout) {
return objectStoreProxy.wait(waitfor, numReturns, timeout);
}
@Override
public RayObject call(RayFunc func, Object... args) {
return worker.submit(func, args);
}
private <T> List<T> doGet(List<UniqueID> objectIds, boolean isMetadata)
throws TaskExecutionException {
public <T> List<T> get(List<UniqueId> objectIds) {
boolean wasBlocked = false;
UniqueID taskId = getCurrentTaskId();
UniqueId taskId = getCurrentTaskId();
try {
int numObjectIds = objectIds.size();
// Do an initial fetch for remote objects.
List<List<UniqueID>> fetchBatches =
List<List<UniqueId>> fetchBatches =
splitIntoBatches(objectIds, params.worker_fetch_request_size);
for (List<UniqueID> batch : fetchBatches) {
for (List<UniqueId> batch : fetchBatches) {
if (!params.use_raylet) {
objectStoreProxy.fetch(batch);
} else {
localSchedulerProxy.reconstructObjects(batch, true);
localSchedulerClient.reconstructObjects(batch, true);
}
}
// Get the objects. We initially try to get the objects immediately.
List<Pair<T, GetStatus>> ret = objectStoreProxy
.get(objectIds, params.default_first_check_timeout_ms, isMetadata);
.get(objectIds, params.default_first_check_timeout_ms, false);
assert ret.size() == numObjectIds;
// Mapping the object IDs that we haven't gotten yet to their original index in objectIds.
Map<UniqueID, Integer> unreadys = new HashMap<>();
Map<UniqueId, Integer> unreadys = new HashMap<>();
for (int i = 0; i < numObjectIds; i++) {
if (ret.get(i).getRight() != GetStatus.SUCCESS) {
unreadys.put(objectIds.get(i), i);
@@ -301,32 +266,32 @@ public abstract class RayRuntime implements RayApi {
// Try reconstructing any objects we haven't gotten yet. Try to get them
// until at least PlasmaLink.GET_TIMEOUT_MS milliseconds passes, then repeat.
while (unreadys.size() > 0) {
List<UniqueID> unreadyList = new ArrayList<>(unreadys.keySet());
List<List<UniqueID>> reconstructBatches =
List<UniqueId> unreadyList = new ArrayList<>(unreadys.keySet());
List<List<UniqueId>> reconstructBatches =
splitIntoBatches(unreadyList, params.worker_fetch_request_size);
for (List<UniqueID> batch : reconstructBatches) {
for (List<UniqueId> batch : reconstructBatches) {
if (!params.use_raylet) {
for (UniqueID objectId : batch) {
localSchedulerProxy.reconstructObject(objectId, false);
for (UniqueId objectId : batch) {
localSchedulerClient.reconstructObject(objectId, false);
}
// Do another fetch for objects that aren't available locally yet, in case
// they were evicted since the last fetch.
objectStoreProxy.fetch(batch);
} else {
localSchedulerProxy.reconstructObjects(batch, false);
localSchedulerClient.reconstructObjects(batch, false);
}
}
List<Pair<T, GetStatus>> results = objectStoreProxy
.get(unreadyList, params.default_get_check_interval_ms, isMetadata);
.get(unreadyList, params.default_get_check_interval_ms, false);
// Remove any entries for objects we received during this iteration so we
// don't retrieve the same object twice.
for (int i = 0; i < results.size(); i++) {
Pair<T, GetStatus> value = results.get(i);
if (value.getRight() == GetStatus.SUCCESS) {
UniqueID id = unreadyList.get(i);
UniqueId id = unreadyList.get(i);
ret.set(unreadys.get(id), value);
unreadys.remove(id);
}
@@ -350,26 +315,18 @@ public abstract class RayRuntime implements RayApi {
// If there were objects that we weren't able to get locally, let the local
// scheduler know that we're now unblocked.
if (wasBlocked) {
localSchedulerProxy.notifyUnblocked();
localSchedulerClient.notifyUnblocked();
}
}
}
private <T> T doGet(UniqueID objectId, boolean isMetadata) throws TaskExecutionException {
ImmutableList<UniqueID> objectIds = ImmutableList.of(objectId);
List<T> results = doGet(objectIds, isMetadata);
assert results.size() == 1;
return results.get(0);
}
private List<List<UniqueID>> splitIntoBatches(List<UniqueID> objectIds, int batchSize) {
List<List<UniqueID>> batches = new ArrayList<>();
private List<List<UniqueId>> splitIntoBatches(List<UniqueId> objectIds, int batchSize) {
List<List<UniqueId>> batches = new ArrayList<>();
int objectsSize = objectIds.size();
for (int i = 0; i < objectsSize; i += batchSize) {
int endIndex = i + batchSize;
List<UniqueID> batchIds = (endIndex < objectsSize)
List<UniqueId> batchIds = (endIndex < objectsSize)
? objectIds.subList(i, endIndex)
: objectIds.subList(i, objectsSize);
@@ -379,11 +336,121 @@ public abstract class RayRuntime implements RayApi {
return batches;
}
@Override
public <T> WaitResult<T> wait(List<RayObject<T>> waitList, int numReturns, int timeoutMs) {
return objectStoreProxy.wait(waitList, numReturns, timeoutMs);
}
@Override
public RayObject call(RayFunc func, Object[] args) {
TaskSpec spec = createTaskSpec(func, RayActorImpl.NIL, args, null);
localSchedulerClient.submitTask(spec);
return new RayObjectImpl(spec.returnIds[0]);
}
@Override
public RayObject call(RayFunc func, RayActor actor, Object[] args) {
if (!(actor instanceof RayActorImpl)) {
throw new IllegalArgumentException("Unsupported actor type: " + actor.getClass().getName());
}
RayActorImpl actorImpl = (RayActorImpl)actor;
TaskSpec spec = createTaskSpec(func, actorImpl, args, null);
actorImpl.setTaskCursor(spec.returnIds[1]);
localSchedulerClient.submitTask(spec);
return new RayObjectImpl(spec.returnIds[0]);
}
@Override
@SuppressWarnings("unchecked")
public <T> RayActor<T> createActor(Class<T> actorClass) {
RayFunc2<UniqueId, String, Object> func = AbstractRayRuntime::createLocalActor;
TaskSpec spec = createTaskSpec(func, RayActorImpl.NIL, null, actorClass);
RayActorImpl actor = new RayActorImpl(spec.returnIds[0]);
actor.increaseTaskCounter();
actor.setTaskCursor(spec.returnIds[0]);
localSchedulerClient.submitTask(spec);
return actor;
}
@RayRemote
private static Object createLocalActor(UniqueId actorId, String className) {
try {
Class<?> cls = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
Object actor = cls.getConstructor().newInstance();
getInstance().actors.put(actorId, actor);
RayLog.core.info("Created actor: {}, actor id: {}", className, actorId);
return null;
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException | NoSuchMethodException
| SecurityException e) {
RayLog.core.error("Failed to create actor {}", className, e);
throw new TaskExecutionException(e);
}
}
/**
* get the object put identity of the currently running task, UniqueID.NIL if not inside any
* Generate the return ids of a task.
*/
public UniqueID[] getCurrentTaskReturnIDs() {
return worker.getCurrentTaskReturnIDs();
private UniqueId[] genReturnIds(UniqueId taskId, int numReturns) {
UniqueId[] ret = new UniqueId[numReturns];
for (int i = 0; i < numReturns; i++) {
ret[i] = UniqueIdHelper.computeReturnId(taskId, i + 1);
}
return ret;
}
/**
* Create the task specification.
* @param func The target remote function.
* @param actor The actor handle. If the task is not an actor task, actor id must be NIL.
* @param args The arguments for the remote function.
* @param actorClassForCreation If the task is a actor creation task, the argument should be
* the actor class. Otherwise, it should be null.
* @return A TaskSpec object.
*/
private TaskSpec createTaskSpec(RayFunc func, RayActorImpl actor, Object[] args,
Class actorClassForCreation) {
final TaskSpec current = WorkerContext.currentTask();
UniqueId taskId = localSchedulerClient.generateTaskId(current.driverId,
current.taskId,
WorkerContext.nextCallIndex());
int numReturns = actor.getId().isNil() ? 1 : 2;
UniqueId[] returnIds = genReturnIds(taskId, numReturns);
UniqueId actorCreationId = UniqueId.NIL;
if (actorClassForCreation != null) {
args = new Object[] {returnIds[0], actorClassForCreation.getName()};
actorCreationId = returnIds[0];
}
MethodId methodId = MethodId.fromSerializedLambda(func);
// NOTE: we append the class name at the end of arguments,
// so that we can look up the method based on the class name.
// TODO(hchen): move class name to task spec.
args = Arrays.copyOf(args, args.length + 1);
args[args.length - 1] = methodId.className;
RayMethod rayMethod = functions.getMethod(
current.driverId, actor.getId(), new UniqueId(methodId.getSha1Hash()), methodId.className
).getRight();
UniqueId funcId = rayMethod.getFuncId();
return new TaskSpec(
current.driverId,
taskId,
current.taskId,
-1,
actor.getId(),
actor.increaseTaskCounter(),
funcId,
ArgumentsBuilder.wrap(args),
returnIds,
actor.getHandleId(),
actorCreationId,
ResourceUtil.getResourcesMapFromArray(rayMethod.remoteAnnotation.resources()),
actor.getTaskCursor()
);
}
/***********
@@ -397,13 +464,8 @@ public abstract class RayRuntime implements RayApi {
/**
* get actor with given id.
*/
public abstract Object getLocalActor(UniqueID id);
public PathConfig getPaths() {
return pathConfig;
public Object getLocalActor(UniqueId id) {
return actors.get(id);
}
public RemoteFunctionManager getRemoteFunctionManager() {
return remoteFunctionManager;
}
}
@@ -1,22 +1,13 @@
package org.ray.core;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.commons.lang3.tuple.Pair;
import org.ray.api.Ray;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.spi.model.FunctionArg;
import org.ray.spi.model.RayInvocation;
import org.ray.spi.model.TaskSpec;
import org.ray.util.exception.TaskExecutionException;
/**
* arguments wrap and unwrap.
@@ -24,36 +15,27 @@ import org.ray.util.exception.TaskExecutionException;
public class ArgumentsBuilder {
@SuppressWarnings({"rawtypes", "unchecked"})
public static FunctionArg[] wrap(RayInvocation invocation) {
Object[] oargs = invocation.getArgs();
FunctionArg[] fargs = new FunctionArg[oargs.length];
int k = 0;
for (Object oarg : oargs) {
fargs[k] = new FunctionArg();
if (oarg == null) {
fargs[k].data = Serializer.encode(null);
} else if (oarg.getClass().equals(RayActor.class)) {
// serialize actor unique id
if (k == 0) {
RayActorId aid = new RayActorId();
aid.id = ((RayActor) oarg).getId();
fargs[k].data = Serializer.encode(aid);
} else { // serialize actor handle
fargs[k].data = Serializer.encode(oarg);
}
} else if (oarg.getClass().equals(RayObject.class)) {
fargs[k].ids = new ArrayList<>();
fargs[k].ids.add(((RayObject) oarg).getId());
} else if (checkSimpleValue(oarg)) {
fargs[k].data = Serializer.encode(oarg);
public static FunctionArg[] wrap(Object[] args) {
FunctionArg[] ret = new FunctionArg[args.length];
for (int i = 0; i < ret.length; i++) {
Object arg = args[i];
UniqueId id = null;
byte[] data = null;
if (arg == null) {
data = Serializer.encode(null);
} else if (arg instanceof RayActor) {
data = Serializer.encode(arg);
} else if (arg instanceof RayObject) {
id = ((RayObject) arg).getId();
} else if (checkSimpleValue(arg)) {
data = Serializer.encode(arg);
} else {
//big parameter, use object store and pass future
fargs[k].ids = new ArrayList<>();
fargs[k].ids.add(RayRuntime.getInstance().put(oarg).getId());
RayObject obj = Ray.put(arg);
id = obj.getId();
}
k++;
ret[i] = new FunctionArg(id, data);
}
return fargs;
return ret;
}
private static boolean checkSimpleValue(Object o) {
@@ -61,52 +43,22 @@ public class ArgumentsBuilder {
}
@SuppressWarnings({"rawtypes", "unchecked"})
public static Pair<Object, Object[]> unwrap(TaskSpec task, Method m, ClassLoader classLoader)
throws TaskExecutionException {
public static Pair<Object, Object[]> unwrap(TaskSpec task, Method m, ClassLoader classLoader) {
// the last arg is className
FunctionArg[] fargs = Arrays.copyOf(task.args, task.args.length - 1);
Object current = null;
Object[] realArgs;
int start = 0;
// check actor method
if (!Modifier.isStatic(m.getModifiers())) {
start = 1;
RayActorId actorId = Serializer.decode(fargs[0].data, classLoader);
current = RayRuntime.getInstance().getLocalActor(actorId.id);
realArgs = new Object[fargs.length - 1];
} else {
realArgs = new Object[fargs.length];
}
int raIndex = 0;
for (int k = start; k < fargs.length; k++, raIndex++) {
FunctionArg farg = fargs[k];
// pass by value
if (farg.ids == null) {
Object obj = Serializer.decode(farg.data, classLoader);
// due to remote lambda, method may be static
if (obj instanceof RayActorId) {
assert (k == 0);
realArgs[raIndex] = RayRuntime.getInstance().getLocalActor(((RayActorId) obj).id);
} else {
realArgs[raIndex] = obj;
}
} else if (farg.data == null) { // only ids, big data or single object id
assert (farg.ids.size() == 1);
realArgs[raIndex] = RayRuntime.getInstance().get(farg.ids.get(0));
Object[] realArgs = new Object[task.args.length - 1];
for (int i = 0; i < task.args.length - 1; i++) {
FunctionArg arg = task.args[i];
if (arg.id == null) {
// pass by value
Object obj = Serializer.decode(arg.data, classLoader);
realArgs[i] = obj;
} else if (arg.data == null) {
// pass by reference
realArgs[i] = Ray.get(arg.id);
}
}
return Pair.of(current, realArgs);
}
public static class RayActorId implements Serializable {
private static final long serialVersionUID = 3993646395842605166L;
public UniqueID id;
Object actor = task.actorId.isNil()
? null : AbstractRayRuntime.getInstance().getLocalActor(task.actorId);
return Pair.of(actor, realArgs);
}
}
@@ -2,9 +2,8 @@ package org.ray.core;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import org.apache.commons.lang3.tuple.Pair;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.spi.model.RayMethod;
import org.ray.spi.model.TaskSpec;
import org.ray.util.exception.TaskExecutionException;
@@ -33,7 +32,8 @@ public class InvocationExecutor {
try {
executeInternal(task, pr);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
if (!task.actorId.isNil() && RayRuntime.getInstance().getLocalActor(task.actorId) == null) {
if (!task.actorId.isNil()
&& AbstractRayRuntime.getInstance().getLocalActor(task.actorId) == null) {
ex = new TaskExecutionException("Task " + taskdesc + " execution on actor " + task.actorId
+ " failed as the actor is not present ", e);
RayLog.core.error("Task " + taskdesc + " execution on actor " + task.actorId
@@ -80,7 +80,7 @@ public class InvocationExecutor {
if (task.returnIds == null || task.returnIds.length == 0) {
return;
}
RayRuntime.getInstance().putRaw(task.returnIds[0], result);
AbstractRayRuntime.getInstance().put(task.returnIds[0], result);
}
private static String formatTaskExecutionExceptionMsg(TaskSpec task, String funcName) {
@@ -88,7 +88,7 @@ public class InvocationExecutor {
+ " failed with function name = " + funcName;
}
private static void safePut(UniqueID objectId, Object obj) {
RayRuntime.getInstance().putRaw(objectId, obj);
private static void safePut(UniqueId objectId, Object obj) {
AbstractRayRuntime.getInstance().put(objectId, obj);
}
}
@@ -3,7 +3,7 @@ package org.ray.core;
import com.google.common.base.Preconditions;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang3.tuple.Pair;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.spi.RemoteFunctionManager;
import org.ray.spi.model.FunctionArg;
import org.ray.spi.model.RayActorMethods;
@@ -18,7 +18,7 @@ public class LocalFunctionManager {
private final RemoteFunctionManager remoteLoader;
private final ConcurrentHashMap<UniqueID, FunctionTable> functionTables
private final ConcurrentHashMap<UniqueId, FunctionTable> functionTables
= new ConcurrentHashMap<>();
/**
@@ -29,7 +29,7 @@ public class LocalFunctionManager {
this.remoteLoader = remoteLoader;
}
private FunctionTable loadDriverFunctions(UniqueID driverId) {
private FunctionTable loadDriverFunctions(UniqueId driverId) {
FunctionTable functionTable = functionTables.get(driverId);
if (functionTable == null) {
RayLog.core.info("DriverId " + driverId + " Try to load functions");
@@ -44,8 +44,8 @@ public class LocalFunctionManager {
return functionTable;
}
Pair<ClassLoader, RayMethod> getMethod(UniqueID driverId, UniqueID actorId,
UniqueID methodId, String className) {
Pair<ClassLoader, RayMethod> getMethod(UniqueId driverId, UniqueId actorId,
UniqueId methodId, String className) {
// assert the driver's resource is load.
FunctionTable functionTable = loadDriverFunctions(driverId);
Preconditions.checkNotNull(functionTable, "driver's resource is not loaded:%s", driverId);
@@ -61,8 +61,8 @@ public class LocalFunctionManager {
* get local method for executing, which pulls information from remote repo on-demand, therefore
* it may block for a while if the related resources (e.g., jars) are not ready on local machine
*/
public Pair<ClassLoader, RayMethod> getMethod(UniqueID driverId, UniqueID actorId,
UniqueID methodId,
public Pair<ClassLoader, RayMethod> getMethod(UniqueId driverId, UniqueId actorId,
UniqueId methodId,
FunctionArg[] args) throws NoSuchMethodException, SecurityException, ClassNotFoundException {
Preconditions.checkArgument(args.length >= 1, "method's args len %s<=1", args.length);
String className = (String) Serializer.decode(args[args.length - 1].data);
@@ -72,7 +72,7 @@ public class LocalFunctionManager {
/**
* unload the functions when the driver is declared dead.
*/
public synchronized void removeApp(UniqueID driverId) {
public synchronized void removeApp(UniqueId driverId) {
FunctionTable funcs = functionTables.get(driverId);
if (funcs != null) {
functionTables.remove(driverId);
@@ -90,7 +90,7 @@ public class LocalFunctionManager {
this.classLoader = classLoader;
}
RayMethod getTaskMethod(UniqueID methodId, String className) {
RayMethod getTaskMethod(UniqueId methodId, String className) {
RayTaskMethods tasks = taskMethods.get(className);
if (tasks == null) {
tasks = RayTaskMethods.fromClass(className, classLoader);
@@ -105,11 +105,11 @@ public class LocalFunctionManager {
return getActorMethod(methodId, className, true);
}
RayMethod getActorMethod(UniqueID methodId, String className) {
RayMethod getActorMethod(UniqueId methodId, String className) {
return getActorMethod(methodId, className, false);
}
private RayMethod getActorMethod(UniqueID methodId, String className, boolean isStatic) {
private RayMethod getActorMethod(UniqueId methodId, String className, boolean isStatic) {
RayActorMethods actor = actors.get(className);
if (actor == null) {
actor = RayActorMethods.fromClass(className, classLoader);
@@ -0,0 +1,89 @@
package org.ray.core;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import org.ray.api.RayActor;
import org.ray.api.id.UniqueId;
import org.ray.util.Sha1Digestor;
public final class RayActorImpl<T> implements RayActor<T>, Externalizable {
public static final RayActorImpl NIL = new RayActorImpl();
private UniqueId id;
private UniqueId handleId;
/**
* The number of tasks that have been invoked on this actor.
*/
private int taskCounter;
/**
* The unique id of the last return of the last task.
* It's used as a dependency for the next task.
*/
private UniqueId taskCursor;
/**
* The number of times that this actor handle has been forked.
* It's used to make sure ids of actor handles are unique.
*/
private int numForks;
public RayActorImpl() {
this(UniqueId.NIL, UniqueId.NIL);
}
public RayActorImpl(UniqueId id) {
this(id, UniqueId.NIL);
}
public RayActorImpl(UniqueId id, UniqueId handleId) {
this.id = id;
this.handleId = handleId;
this.taskCounter = 0;
this.taskCursor = null;
numForks = 0;
}
@Override
public UniqueId getId() {
return id;
}
@Override
public UniqueId getHandleId() {
return handleId;
}
public void setTaskCursor(UniqueId taskCursor) {
this.taskCursor = taskCursor;
}
public UniqueId getTaskCursor() {
return taskCursor;
}
public int increaseTaskCounter() {
return taskCounter++;
}
private UniqueId computeNextActorHandleId() {
byte[] bytes = Sha1Digestor.digest(handleId.getBytes(), ++numForks);
return new UniqueId(bytes);
}
@Override
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(this.id);
out.writeObject(this.computeNextActorHandleId());
out.writeObject(this.taskCursor);
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
this.id = (UniqueId) in.readObject();
this.handleId = (UniqueId) in.readObject();
this.taskCursor = (UniqueId) in.readObject();
}
}
@@ -0,0 +1,26 @@
package org.ray.core;
import java.io.Serializable;
import org.ray.api.Ray;
import org.ray.api.RayObject;
import org.ray.api.id.UniqueId;
public final class RayObjectImpl<T> implements RayObject<T>, Serializable {
private final UniqueId id;
public RayObjectImpl(UniqueId id) {
this.id = id;
}
@Override
public T get() {
return Ray.get(id);
}
@Override
public UniqueId getId() {
return id;
}
}
@@ -3,12 +3,14 @@ package org.ray.core;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
//
// Helper methods for UniqueID. These are the same as the helper functions in src/ray/id.h.
//
/**
* Helper method for UniqueId.
* Note: any changes to these methods must be synced with C++ helper functions
* in src/ray/id.h
*/
public class UniqueIdHelper {
public static final int OBJECT_INDEX_POS = 0;
public static final int OBJECT_INDEX_LENGTH = 4;
@@ -20,7 +22,7 @@ public class UniqueIdHelper {
* @param returnIndex What number return value this object is in the task.
* @return The computed object ID.
*/
public static UniqueID computeReturnId(UniqueID taskId, int returnIndex) {
public static UniqueId computeReturnId(UniqueId taskId, int returnIndex) {
return computeObjectId(taskId, returnIndex);
}
@@ -30,14 +32,14 @@ public class UniqueIdHelper {
* @param index The index which can distinguish different objects in one task.
* @return The computed object ID.
*/
private static UniqueID computeObjectId(UniqueID taskId, int index) {
byte[] objId = new byte[UniqueID.LENGTH];
System.arraycopy(taskId.getBytes(),0, objId, 0, UniqueID.LENGTH);
private static UniqueId computeObjectId(UniqueId taskId, int index) {
byte[] objId = new byte[UniqueId.LENGTH];
System.arraycopy(taskId.getBytes(),0, objId, 0, UniqueId.LENGTH);
ByteBuffer wbb = ByteBuffer.wrap(objId);
wbb.order(ByteOrder.LITTLE_ENDIAN);
wbb.putInt(UniqueIdHelper.OBJECT_INDEX_POS, index);
return new UniqueID(objId);
return new UniqueId(objId);
}
/**
@@ -47,7 +49,7 @@ public class UniqueIdHelper {
* @param putIndex What number put this object was created by in the task.
* @return The computed object ID.
*/
public static UniqueID computePutId(UniqueID taskId, int putIndex) {
public static UniqueId computePutId(UniqueId taskId, int putIndex) {
// We multiply putIndex by -1 to distinguish from returnIndex.
return computeObjectId(taskId, -1 * putIndex);
}
@@ -58,13 +60,13 @@ public class UniqueIdHelper {
* @param objectId The object ID.
* @return The task ID of the task that created this object.
*/
public static UniqueID computeTaskId(UniqueID objectId) {
byte[] taskId = new byte[UniqueID.LENGTH];
System.arraycopy(objectId.getBytes(), 0, taskId, 0, UniqueID.LENGTH);
public static UniqueId computeTaskId(UniqueId objectId) {
byte[] taskId = new byte[UniqueId.LENGTH];
System.arraycopy(objectId.getBytes(), 0, taskId, 0, UniqueId.LENGTH);
Arrays.fill(taskId, UniqueIdHelper.OBJECT_INDEX_POS,
UniqueIdHelper.OBJECT_INDEX_POS + UniqueIdHelper.OBJECT_INDEX_LENGTH, (byte) 0);
return new UniqueID(taskId);
return new UniqueId(taskId);
}
}
@@ -1,19 +1,11 @@
package org.ray.core;
import com.google.common.base.Preconditions;
import java.util.Arrays;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.UniqueID;
import org.ray.api.funcs.RayFunc;
import org.ray.spi.LocalSchedulerProxy;
import org.ray.spi.model.RayInvocation;
import org.ray.api.id.UniqueId;
import org.ray.spi.LocalSchedulerLink;
import org.ray.spi.model.RayMethod;
import org.ray.spi.model.TaskSpec;
import org.ray.util.MethodId;
import org.ray.util.exception.TaskExecutionException;
import org.ray.util.logger.RayLog;
/**
@@ -22,10 +14,10 @@ import org.ray.util.logger.RayLog;
*/
public class Worker {
private final LocalSchedulerProxy scheduler;
private final LocalSchedulerLink scheduler;
private final LocalFunctionManager functions;
public Worker(LocalSchedulerProxy scheduler, LocalFunctionManager functions) {
public Worker(LocalSchedulerLink scheduler, LocalFunctionManager functions) {
this.scheduler = scheduler;
this.functions = functions;
}
@@ -39,8 +31,7 @@ public class Worker {
}
public static void execute(TaskSpec task, LocalFunctionManager funcs) {
RayLog.core.info("Task " + task.taskId + " start execute");
Throwable ex = null;
RayLog.core.info("Executing task {}", task.taskId);
if (!task.actorId.isNil() || (task.createActorId != null && !task.createActorId.isNil())) {
task.returnIds = ArrayUtils.subarray(task.returnIds, 0, task.returnIds.length - 1);
@@ -51,85 +42,23 @@ public class Worker {
.getMethod(task.driverId, task.actorId, task.functionId, task.args);
WorkerContext.prepare(task, pr.getLeft());
InvocationExecutor.execute(task, pr);
} catch (NoSuchMethodException | SecurityException | ClassNotFoundException e) {
RayLog.core.error("task execution failed for " + task.taskId, e);
ex = new TaskExecutionException("task execution failed for " + task.taskId, e);
} catch (Throwable e) {
RayLog.core.error("catch Throwable when execute for " + task.taskId, e);
ex = e;
}
if (ex != null) {
for (int k = 0; k < task.returnIds.length; k++) {
RayRuntime.getInstance().putRaw(task.returnIds[k], ex);
}
}
}
private RayObject taskSubmit(UniqueID taskId, MethodId methodId, Object[] args) {
RayInvocation ri = createRemoteInvocation(methodId, args, RayActor.NIL);
return scheduler.submit(taskId, ri);
}
private RayObject actorTaskSubmit(UniqueID taskId, MethodId methodId, Object[] args,
RayActor<?> actor) {
RayInvocation ri = createRemoteInvocation(methodId, args, actor);
RayObject ret = scheduler.submitActorTask(taskId, ri);
actor.setTaskCursor(ret.getId());
return ret;
}
public RayObject submit(RayFunc func, Object[] args) {
MethodId methodId = methodIdOf(func);
UniqueID taskId = scheduler.generateTaskId(WorkerContext.currentTask().driverId,
WorkerContext.currentTask().taskId,
WorkerContext.nextCallIndex());
if (args.length > 0 && args[0].getClass().equals(RayActor.class)) {
return actorTaskSubmit(taskId, methodId, args, (RayActor<?>) args[0]);
} else {
return taskSubmit(taskId, methodId, args);
RayLog.core.info("Finished executing task {}", task.taskId);
} catch (Exception e) {
RayLog.core.error("Failed to execute task " + task.taskId, e);
AbstractRayRuntime.getInstance().put(task.returnIds[0], e);
}
}
public RayObject createActor(UniqueID taskId, UniqueID createActorId,
RayFunc func, Object[] args) {
Preconditions.checkNotNull(taskId);
MethodId mid = methodIdOf(func);
RayInvocation ri = createRemoteInvocation(mid, args, RayActor.NIL);
return scheduler.submitActorCreationTask(taskId, createActorId, ri);
}
private RayInvocation createRemoteInvocation(MethodId methodId, Object[] args,
RayActor<?> actor) {
UniqueID driverId = WorkerContext.currentTask().driverId;
Object[] ls = Arrays.copyOf(args, args.length + 1);
ls[args.length] = methodId.className;
RayMethod method = functions
.getMethod(driverId, actor.getId(), new UniqueID(methodId.getSha1Hash()),
methodId.className).getRight();
RayInvocation ri = new RayInvocation(methodId.className, method.getFuncId(),
ls, method.remoteAnnotation, actor);
return ri;
}
private MethodId methodIdOf(RayFunc serialLambda) {
return MethodId.fromSerializedLambda(serialLambda);
}
public UniqueID getCurrentTaskId() {
public UniqueId getCurrentTaskId() {
return WorkerContext.currentTask().taskId;
}
public UniqueID getCurrentTaskNextPutId() {
public UniqueId getCurrentTaskNextPutId() {
return UniqueIdHelper.computePutId(
WorkerContext.currentTask().taskId, WorkerContext.nextPutIndex());
}
public UniqueID[] getCurrentTaskReturnIDs() {
public UniqueId[] getCurrentTaskReturnIDs() {
return WorkerContext.currentTask().returnIds;
}
}
}
@@ -1,6 +1,6 @@
package org.ray.core;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.core.model.RayParameters;
import org.ray.core.model.WorkerMode;
import org.ray.spi.model.TaskSpec;
@@ -8,11 +8,11 @@ import org.ray.spi.model.TaskSpec;
public class WorkerContext {
private static final ThreadLocal<WorkerContext> currentWorkerCtx =
ThreadLocal.withInitial(() -> init(RayRuntime.getParams()));
ThreadLocal.withInitial(() -> init(AbstractRayRuntime.getParams()));
/**
* id of worker.
*/
public static UniqueID workerID = UniqueID.randomId();
public static UniqueId workerID = UniqueId.randomId();
/**
* current doing task.
*/
@@ -35,13 +35,13 @@ public class WorkerContext {
currentWorkerCtx.set(ctx);
TaskSpec dummy = new TaskSpec();
dummy.parentTaskId = UniqueID.NIL;
dummy.parentTaskId = UniqueId.NIL;
if (params.worker_mode == WorkerMode.DRIVER) {
dummy.taskId = UniqueID.randomId();
dummy.taskId = UniqueId.randomId();
} else {
dummy.taskId = UniqueID.NIL;
dummy.taskId = UniqueId.NIL;
}
dummy.actorId = UniqueID.NIL;
dummy.actorId = UniqueId.NIL;
dummy.driverId = params.driver_id;
prepare(dummy, null);
@@ -72,7 +72,7 @@ public class WorkerContext {
return ++get().currentTaskCallCount;
}
public static UniqueID currentWorkerId() {
public static UniqueId currentWorkerId() {
return WorkerContext.workerID;
}
@@ -1,6 +1,6 @@
package org.ray.core.model;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.util.NetworkUtil;
import org.ray.util.config.AConfig;
import org.ray.util.config.ConfigReader;
@@ -44,7 +44,7 @@ public class RayParameters {
public int local_scheduler_rpc_port = 34567;
@AConfig(comment = "driver ID when the worker is served as a driver")
public UniqueID driver_id = UniqueID.NIL;
public UniqueId driver_id = UniqueId.NIL;
@AConfig(comment = "logging directory")
public String log_dir = "/tmp/raylogs";
@@ -1,7 +1,7 @@
package org.ray.spi;
import java.util.List;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.spi.model.TaskSpec;
/**
@@ -13,15 +13,15 @@ public interface LocalSchedulerLink {
TaskSpec getTask();
void markTaskPutDependency(UniqueID taskId, UniqueID objectId);
void markTaskPutDependency(UniqueId taskId, UniqueId objectId);
void reconstructObject(UniqueID objectId, boolean fetchOnly);
void reconstructObject(UniqueId objectId, boolean fetchOnly);
void reconstructObjects(List<UniqueID> objectIds, boolean fetchOnly);
void reconstructObjects(List<UniqueId> objectIds, boolean fetchOnly);
void notifyUnblocked();
UniqueID generateTaskId(UniqueID driverId, UniqueID parentTaskId, int taskIndex);
UniqueId generateTaskId(UniqueId driverId, UniqueId parentTaskId, int taskIndex);
List<byte[]> wait(byte[][] objectIds, int timeoutMs, int numReturns);
}
@@ -1,136 +0,0 @@
package org.ray.spi;
import java.util.ArrayList;
import java.util.List;
import org.ray.api.RayObject;
import org.ray.api.UniqueID;
import org.ray.api.WaitResult;
import org.ray.core.ArgumentsBuilder;
import org.ray.core.UniqueIdHelper;
import org.ray.core.WorkerContext;
import org.ray.spi.model.RayInvocation;
import org.ray.spi.model.TaskSpec;
import org.ray.util.ResourceUtil;
import org.ray.util.logger.RayLog;
/**
* Local scheduler proxy, which provides a user-friendly facet on top of {code
* org.ray.spi.LocalSchedulerLink}.
*/
@SuppressWarnings("rawtypes")
public class LocalSchedulerProxy {
private final LocalSchedulerLink scheduler;
public LocalSchedulerProxy(LocalSchedulerLink scheduler) {
this.scheduler = scheduler;
}
public RayObject submit(UniqueID taskId, RayInvocation invocation) {
UniqueID[] returnIds = genReturnIds(taskId, 1);
this.doSubmit(invocation, taskId, returnIds, UniqueID.NIL);
return new RayObject(returnIds[0]);
}
public RayObject submitActorTask(UniqueID taskId, RayInvocation invocation) {
// add one for the dummy return ID
UniqueID[] returnIds = genReturnIds(taskId, 2);
this.doSubmit(invocation, taskId, returnIds, UniqueID.NIL);
return new RayObject(returnIds[0]);
}
public RayObject submitActorCreationTask(UniqueID taskId, UniqueID createActorId,
RayInvocation invocation) {
UniqueID[] returnIds = genReturnIds(taskId, 1);
this.doSubmit(invocation, taskId, returnIds, createActorId);
return new RayObject(returnIds[0]);
}
// generate the return ids of a task.
private UniqueID[] genReturnIds(UniqueID taskId, int numReturns) {
UniqueID[] ret = new UniqueID[numReturns];
for (int i = 0; i < numReturns; i++) {
ret[i] = UniqueIdHelper.computeReturnId(taskId, i + 1);
}
return ret;
}
private void doSubmit(RayInvocation invocation, UniqueID taskId, UniqueID[] returnIds,
UniqueID createActorId) {
final TaskSpec current = WorkerContext.currentTask();
TaskSpec task = new TaskSpec();
task.actorCounter = invocation.getActor().increaseTaskCounter();
task.actorId = invocation.getActor().getId();
task.createActorId = createActorId;
task.args = ArgumentsBuilder.wrap(invocation);
task.driverId = current.driverId;
task.functionId = invocation.getId();
task.parentCounter = -1; // TODO: this field is not used in core or python logically yet
task.parentTaskId = current.taskId;
task.actorHandleId = invocation.getActor().getActorHandleId();
task.taskId = taskId;
task.returnIds = returnIds;
task.cursorId = invocation.getActor() != null ? invocation.getActor().getTaskCursor() : null;
task.resources = ResourceUtil.getResourcesMapFromArray(
invocation.getRemoteAnnotation().resources());
scheduler.submitTask(task);
}
public TaskSpec getTask() {
TaskSpec ts = scheduler.getTask();
RayLog.core.info("Task " + ts.taskId.toString() + " received");
return ts;
}
public void markTaskPutDependency(UniqueID taskId, UniqueID objectId) {
scheduler.markTaskPutDependency(taskId, objectId);
}
public void reconstructObject(UniqueID objectId, boolean fetchOnly) {
scheduler.reconstructObject(objectId, fetchOnly);
}
public void reconstructObjects(List<UniqueID> objectIds, boolean fetchOnly) {
scheduler.reconstructObjects(objectIds, fetchOnly);
}
public void notifyUnblocked() {
scheduler.notifyUnblocked();
}
private static byte[][] getIdBytes(List<UniqueID> objectIds) {
int size = objectIds.size();
byte[][] ids = new byte[size][];
for (int i = 0; i < size; i++) {
ids[i] = objectIds.get(i).getBytes();
}
return ids;
}
public <T> WaitResult<T> wait(List<RayObject<T>> waitfor, int numReturns, int timeout) {
List<UniqueID> ids = new ArrayList<>();
for (RayObject<T> obj : waitfor) {
ids.add(obj.getId());
}
List<byte[]> readys = scheduler.wait(getIdBytes(ids), timeout, numReturns);
List<RayObject<T>> readyObjs = new ArrayList<>();
List<RayObject<T>> remainObjs = new ArrayList<>();
for (RayObject<T> obj : waitfor) {
if (readys.contains(obj.getId().getBytes())) {
readyObjs.add(obj);
} else {
remainObjs.add(obj);
}
}
return new WaitResult<>(readyObjs, remainObjs);
}
public UniqueID generateTaskId(UniqueID driverId, UniqueID parentTaskId, int taskIndex) {
return scheduler.generateTaskId(driverId, parentTaskId, taskIndex);
}
}
@@ -1,57 +1,57 @@
package org.ray.spi;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
/**
* mock version of remote function manager using local loaded jars.
*/
public class NopRemoteFunctionManager implements RemoteFunctionManager {
public NopRemoteFunctionManager(UniqueID driverId) {
public NopRemoteFunctionManager(UniqueId driverId) {
//onLoad(driverId, Agent.hookedMethods);
//Agent.consumers.add(m -> { this.onLoad(m); });
}
@Override
public UniqueID registerResource(byte[] resourceZip) {
public UniqueId registerResource(byte[] resourceZip) {
return null;
// nothing to do
}
@Override
public byte[] getResource(UniqueID resourceId) {
public byte[] getResource(UniqueId resourceId) {
return null;
}
@Override
public void unregisterResource(UniqueID resourceId) {
public void unregisterResource(UniqueId resourceId) {
// nothing to do
}
@Override
public void registerApp(UniqueID driverId, UniqueID resourceId) {
public void registerApp(UniqueId driverId, UniqueId resourceId) {
// nothing to do
}
@Override
public UniqueID getAppResourceId(UniqueID driverId) {
public UniqueId getAppResourceId(UniqueId driverId) {
return null;
// nothing to do
}
@Override
public void unregisterApp(UniqueID driverId) {
public void unregisterApp(UniqueId driverId) {
// nothing to do
}
@Override
public ClassLoader loadResource(UniqueID driverId) {
public ClassLoader loadResource(UniqueId driverId) {
//assert (startupDriverId().equals(driverId));
return this.getClass().getClassLoader();
}
@Override
public void unloadFunctions(UniqueID driverId) {
public void unloadFunctions(UniqueId driverId) {
// never
//assert (startupDriverId().equals(driverId));
}
@@ -5,11 +5,10 @@ import java.util.List;
import org.apache.arrow.plasma.ObjectStoreLink;
import org.apache.commons.lang3.tuple.Pair;
import org.ray.api.RayObject;
import org.ray.api.UniqueID;
import org.ray.api.WaitResult;
import org.ray.api.id.UniqueId;
import org.ray.core.Serializer;
import org.ray.core.WorkerContext;
import org.ray.spi.LocalSchedulerLink;
import org.ray.util.exception.TaskExecutionException;
/**
@@ -32,12 +31,12 @@ public class ObjectStoreProxy {
this.localSchedulerLink = localSchedulerLink;
}
public <T> Pair<T, GetStatus> get(UniqueID objectId, boolean isMetadata)
public <T> Pair<T, GetStatus> get(UniqueId objectId, boolean isMetadata)
throws TaskExecutionException {
return get(objectId, getTimeoutMs, isMetadata);
}
public <T> Pair<T, GetStatus> get(UniqueID id, int timeoutMs, boolean isMetadata)
public <T> Pair<T, GetStatus> get(UniqueId id, int timeoutMs, boolean isMetadata)
throws TaskExecutionException {
byte[] obj = store.get(id.getBytes(), timeoutMs, isMetadata);
if (obj != null) {
@@ -52,12 +51,12 @@ public class ObjectStoreProxy {
}
}
public <T> List<Pair<T, GetStatus>> get(List<UniqueID> objectIds, boolean isMetadata)
public <T> List<Pair<T, GetStatus>> get(List<UniqueId> objectIds, boolean isMetadata)
throws TaskExecutionException {
return get(objectIds, getTimeoutMs, isMetadata);
}
public <T> List<Pair<T, GetStatus>> get(List<UniqueID> ids, int timeoutMs, boolean isMetadata)
public <T> List<Pair<T, GetStatus>> get(List<UniqueId> ids, int timeoutMs, boolean isMetadata)
throws TaskExecutionException {
List<byte[]> objs = store.get(getIdBytes(ids), timeoutMs, isMetadata);
List<Pair<T, GetStatus>> ret = new ArrayList<>();
@@ -77,7 +76,7 @@ public class ObjectStoreProxy {
return ret;
}
private static byte[][] getIdBytes(List<UniqueID> objectIds) {
private static byte[][] getIdBytes(List<UniqueId> objectIds) {
int size = objectIds.size();
byte[][] ids = new byte[size][];
for (int i = 0; i < size; i++) {
@@ -86,12 +85,12 @@ public class ObjectStoreProxy {
return ids;
}
public void put(UniqueID id, Object obj, Object metadata) {
public void put(UniqueId id, Object obj, Object metadata) {
store.put(id.getBytes(), Serializer.encode(obj), Serializer.encode(metadata));
}
public <T> WaitResult<T> wait(List<RayObject<T>> waitfor, int numReturns, int timeout) {
List<UniqueID> ids = new ArrayList<>();
List<UniqueId> ids = new ArrayList<>();
for (RayObject<T> obj : waitfor) {
ids.add(obj.getId());
}
@@ -102,20 +101,20 @@ public class ObjectStoreProxy {
readys = localSchedulerLink.wait(getIdBytes(ids), timeout, numReturns);
}
List<RayObject<T>> readyObjs = new ArrayList<>();
List<RayObject<T>> remainObjs = new ArrayList<>();
List<RayObject<T>> readyList = new ArrayList<>();
List<RayObject<T>> unreadyList = new ArrayList<>();
for (RayObject<T> obj : waitfor) {
if (readys.contains(obj.getId().getBytes())) {
readyObjs.add(obj);
readyList.add(obj);
} else {
remainObjs.add(obj);
unreadyList.add(obj);
}
}
return new WaitResult<>(readyObjs, remainObjs);
return new WaitResult<>(readyList, unreadyList);
}
public void fetch(List<UniqueID> objectIds) {
public void fetch(List<UniqueId> objectIds) {
if (localSchedulerLink == null) {
store.fetch(getIdBytes(objectIds));
} else {
@@ -1,6 +1,6 @@
package org.ray.spi;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
/**
* register and load functions from function table.
@@ -15,14 +15,14 @@ public interface RemoteFunctionManager {
* @param resourceZip a directory zip from @JarRewriter
* @return SHA-1 hash of the content
*/
UniqueID registerResource(byte[] resourceZip);
UniqueId registerResource(byte[] resourceZip);
/**
* download resource content.
*
* @return resource content
*/
byte[] getResource(UniqueID resourceId);
byte[] getResource(UniqueId resourceId);
/**
* remove resource by its hash id
@@ -30,35 +30,35 @@ public interface RemoteFunctionManager {
*
* @param resourceId SHA-1 hash of the resource zip bytes
*/
void unregisterResource(UniqueID resourceId);
void unregisterResource(UniqueId resourceId);
/*
* register the <driver, resource> mapping to repo,
* this function is invoked by whoever initiates the driver id
*/
void registerApp(UniqueID driverId, UniqueID resourceId);
void registerApp(UniqueId driverId, UniqueId resourceId);
/**
* get the resourceId of one app.
*
* @return resourceId of the app driver
*/
UniqueID getAppResourceId(UniqueID driverId);
UniqueId getAppResourceId(UniqueId driverId);
/*
* unregister <dirver, resource> mapping
* this function is called when the driver exits or detected dead
*/
void unregisterApp(UniqueID driverId);
void unregisterApp(UniqueId driverId);
/**
* load resource.
*/
ClassLoader loadResource(UniqueID driverId);
ClassLoader loadResource(UniqueId driverId);
/**
* unload functions for this driver
* this function is used by the workers on demand when a driver is dead.
*/
void unloadFunctions(UniqueID driverId);
void unloadFunctions(UniqueId driverId);
}
@@ -1,17 +1,21 @@
package org.ray.spi.model;
import java.util.ArrayList;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
/**
* Represents arguments for ray function calls.
*/
public class FunctionArg {
public ArrayList<UniqueID> ids;
public byte[] data;
public final UniqueId id;
public final byte[] data;
public FunctionArg(UniqueId id, byte[] data) {
this.id = id;
this.data = data;
}
public void toString(StringBuilder builder) {
builder.append("ids: ").append(ids).append(", ").append("<data>:").append(data);
builder.append("ids: ").append(id).append(", ").append("<data>:").append(data);
}
}
@@ -6,22 +6,22 @@ import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.ray.api.RayRemote;
import org.ray.api.UniqueID;
import org.ray.api.annotation.RayRemote;
import org.ray.api.id.UniqueId;
public final class RayActorMethods {
public final Class clazz;
public final RayRemote remoteAnnotation;
public final Map<UniqueID, RayMethod> functions;
public final Map<UniqueId, RayMethod> functions;
/**
* the static function in Actor, call as task.
*/
public final Map<UniqueID, RayMethod> staticFunctions;
public final Map<UniqueId, RayMethod> staticFunctions;
private RayActorMethods(Class clazz, RayRemote remoteAnnotation,
Map<UniqueID, RayMethod> functions, Map<UniqueID, RayMethod> staticFunctions) {
Map<UniqueId, RayMethod> functions, Map<UniqueId, RayMethod> staticFunctions) {
this.clazz = clazz;
this.remoteAnnotation = remoteAnnotation;
this.functions = Collections.unmodifiableMap(new HashMap<>(functions));
@@ -35,8 +35,8 @@ public final class RayActorMethods {
Preconditions
.checkNotNull(remoteAnnotation, "%s must declare @RayRemote", clazzName);
Method[] methods = clazz.getDeclaredMethods();
Map<UniqueID, RayMethod> functions = new HashMap<>(methods.length * 2);
Map<UniqueID, RayMethod> staticFunctions = new HashMap<>(methods.length * 2);
Map<UniqueId, RayMethod> functions = new HashMap<>(methods.length * 2);
Map<UniqueId, RayMethod> staticFunctions = new HashMap<>(methods.length * 2);
for (Method m : methods) {
if (!Modifier.isPublic(m.getModifiers())) {
@@ -1,56 +0,0 @@
package org.ray.spi.model;
import org.ray.api.RayActor;
import org.ray.api.RayRemote;
import org.ray.api.UniqueID;
/**
* Represents an invocation of ray remote function.
*/
public class RayInvocation {
private static final RayActor<?> nil = new RayActor<>(UniqueID.NIL, UniqueID.NIL);
public final String className;
/**
* unique id for a method.
*/
private final UniqueID id;
private final RayRemote remoteAnnotation;
/**
* function arguments.
*/
private Object[] args;
private RayActor<?> actor;
public RayInvocation(String className, UniqueID id, Object[] args, RayRemote remoteAnnotation,
RayActor<?> actor) {
this.className = className;
this.id = id;
this.args = args;
this.actor = actor;
this.remoteAnnotation = remoteAnnotation;
}
public UniqueID getId() {
return id;
}
public Object[] getArgs() {
return args;
}
public void setArgs(Object[] args) {
this.args = args;
}
public RayActor<?> getActor() {
return actor;
}
public RayRemote getRemoteAnnotation() {
return remoteAnnotation;
}
}
@@ -1,8 +1,8 @@
package org.ray.spi.model;
import java.lang.reflect.Method;
import org.ray.api.RayRemote;
import org.ray.api.UniqueID;
import org.ray.api.annotation.RayRemote;
import org.ray.api.id.UniqueId;
import org.ray.util.MethodId;
/**
@@ -13,9 +13,9 @@ public class RayMethod {
public final Method invokable;
public final String fullName;
public final RayRemote remoteAnnotation;
private final UniqueID funcId;
private final UniqueId funcId;
private RayMethod(Method m, RayRemote remoteAnnotation, UniqueID funcId) {
private RayMethod(Method m, RayRemote remoteAnnotation, UniqueId funcId) {
this.invokable = m;
this.remoteAnnotation = remoteAnnotation;
this.funcId = funcId;
@@ -26,7 +26,7 @@ public class RayMethod {
Class<?> clazz = m.getDeclaringClass();
RayRemote remoteAnnotation = m.getAnnotation(RayRemote.class);
MethodId mid = MethodId.fromMethod(m);
UniqueID funcId = new UniqueID(mid.getSha1Hash());
UniqueId funcId = new UniqueId(mid.getSha1Hash());
RayMethod method = new RayMethod(m,
remoteAnnotation != null ? remoteAnnotation : parentRemoteAnnotation,
funcId);
@@ -38,7 +38,7 @@ public class RayMethod {
return fullName;
}
public UniqueID getFuncId() {
public UniqueId getFuncId() {
return funcId;
}
}
@@ -5,17 +5,17 @@ import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.ray.api.RayRemote;
import org.ray.api.UniqueID;
import org.ray.api.annotation.RayRemote;
import org.ray.api.id.UniqueId;
public final class RayTaskMethods {
public final Class clazz;
public final Map<UniqueID, RayMethod> functions;
public final Map<UniqueId, RayMethod> functions;
public RayTaskMethods(Class clazz,
Map<UniqueID, RayMethod> functions) {
Map<UniqueId, RayMethod> functions) {
this.clazz = clazz;
this.functions = Collections.unmodifiableMap(new HashMap<>(functions));
}
@@ -24,7 +24,7 @@ public final class RayTaskMethods {
try {
Class clazz = Class.forName(clazzName, true, classLoader);
Method[] methods = clazz.getDeclaredMethods();
Map<UniqueID, RayMethod> functions = new HashMap<>(methods.length * 2);
Map<UniqueId, RayMethod> functions = new HashMap<>(methods.length * 2);
for (Method m : methods) {
if (!Modifier.isStatic(m.getModifiers())) {
@@ -2,7 +2,7 @@ package org.ray.spi.model;
import java.util.Arrays;
import java.util.Map;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.util.ResourceUtil;
/**
@@ -11,43 +11,64 @@ import org.ray.util.ResourceUtil;
public class TaskSpec {
// ID of the driver that created this task.
public UniqueID driverId;
public UniqueId driverId;
// Task ID of the task.
public UniqueID taskId;
public UniqueId taskId;
// Task ID of the parent task.
public UniqueID parentTaskId;
public UniqueId parentTaskId;
// A count of the number of tasks submitted by the parent task before this one.
public int parentCounter;
// Actor ID of the task. This is the actor that this task is executed on
// or NIL_ACTOR_ID if the task is just a normal task.
public UniqueID actorId;
public UniqueId actorId;
// Number of tasks that have been submitted to this actor so far.
public int actorCounter;
// Function ID of the task.
public UniqueID functionId;
public UniqueId functionId;
// Task arguments.
public FunctionArg[] args;
// return ids
public UniqueID[] returnIds;
public UniqueId[] returnIds;
// ID per actor client for session consistency
public UniqueID actorHandleId;
public UniqueId actorHandleId;
// Id for create a target actor
public UniqueID createActorId;
// Id for createActor a target actor
public UniqueId createActorId;
// The task's resource demands.
public Map<String, Double> resources;
public UniqueID cursorId;
public UniqueId cursorId;
public TaskSpec() {}
public TaskSpec(UniqueId driverId, UniqueId taskId, UniqueId parentTaskId, int parentCounter,
UniqueId actorId, int actorCounter, UniqueId functionId, FunctionArg[] args,
UniqueId[] returnIds, UniqueId actorHandleId, UniqueId createActorId,
Map<String, Double> resources, UniqueId cursorId) {
this.driverId = driverId;
this.taskId = taskId;
this.parentTaskId = parentTaskId;
this.parentCounter = parentCounter;
this.actorId = actorId;
this.actorCounter = actorCounter;
this.functionId = functionId;
this.args = args;
this.returnIds = returnIds;
this.actorHandleId = actorHandleId;
this.createActorId = createActorId;
this.resources = resources;
this.cursorId = cursorId;
}
@Override
public String toString() {
@@ -1,64 +1,14 @@
package org.ray.core.impl;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.ConcurrentHashMap;
import org.ray.api.Ray;
import org.ray.api.RayActor;
import org.ray.api.RayRemote;
import org.ray.api.UniqueID;
import org.ray.core.RayRuntime;
import org.ray.core.UniqueIdHelper;
import org.ray.core.WorkerContext;
import org.ray.core.AbstractRayRuntime;
import org.ray.core.model.RayParameters;
import org.ray.spi.NopRemoteFunctionManager;
import org.ray.spi.PathConfig;
import org.ray.spi.RemoteFunctionManager;
import org.ray.spi.impl.MockLocalScheduler;
import org.ray.spi.impl.MockObjectStore;
import org.ray.util.exception.TaskExecutionException;
import org.ray.util.logger.RayLog;
public class RayDevRuntime extends RayRuntime {
private final ConcurrentHashMap<UniqueID, Object> actors = new ConcurrentHashMap<>();
protected RayDevRuntime() {
}
@RayRemote
private static byte[] createActor(String className) {
return ((RayDevRuntime) RayRuntime.getInstance()).createLocalActor(className);
}
private byte[] createLocalActor(String className) {
UniqueID taskId = WorkerContext.currentTask().taskId;
UniqueID actorId = UniqueIdHelper.computeReturnId(taskId, 0);
try {
Class<?> cls = Class.forName(className);
Constructor<?>[] cts = cls.getConstructors();
for (Constructor<?> ct : cts) {
System.err.println(ct.getName() + ", param count = " + ct.getParameterCount());
}
Object r = cls.getConstructor().newInstance();
actors.put(actorId, r);
RayLog.core.info("TaskId " + taskId + ", create actor ok " + actorId);
return actorId.getBytes();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException | NoSuchMethodException
| SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
String logInfo =
"TaskId " + taskId + " error at RayDevRuntime createLocalActor, create actor " + actorId
+ " for " + className + " failed";
System.err.println(logInfo + ", ex = " + e.getMessage());
RayLog.core.error(logInfo, e);
throw new TaskExecutionException(logInfo, e);
}
}
public class RayDevRuntime extends AbstractRayRuntime {
@Override
public void start(RayParameters params) {
@@ -71,17 +21,7 @@ public class RayDevRuntime extends RayRuntime {
}
@Override
public void cleanUp() {
public void shutdown() {
// nothing to do
}
@Override
public Object getLocalActor(UniqueID id) {
return actors.get(id);
}
@Override
public <T> RayActor<T> create(Class<T> cls) {
return new RayActor<>(Ray.call(RayDevRuntime::createActor, cls.getName()).getId());
}
}
@@ -3,7 +3,7 @@ package org.ray.spi.impl;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.core.LocalFunctionManager;
import org.ray.core.Worker;
import org.ray.spi.LocalSchedulerLink;
@@ -16,7 +16,7 @@ import org.ray.spi.model.TaskSpec;
*/
public class MockLocalScheduler implements LocalSchedulerLink {
private final Map<UniqueID, Map<UniqueID, TaskSpec>> waitTasks = new ConcurrentHashMap<>();
private final Map<UniqueId, Map<UniqueId, TaskSpec>> waitTasks = new ConcurrentHashMap<>();
private final MockObjectStore store;
private LocalFunctionManager functions = null;
@@ -29,8 +29,8 @@ public class MockLocalScheduler implements LocalSchedulerLink {
functions = mgr;
}
public void onObjectPut(UniqueID id) {
Map<UniqueID, TaskSpec> bucket = waitTasks.get(id);
public void onObjectPut(UniqueId id) {
Map<UniqueId, TaskSpec> bucket = waitTasks.get(id);
if (bucket != null) {
waitTasks.remove(id);
for (TaskSpec ts : bucket.values()) {
@@ -41,23 +41,21 @@ public class MockLocalScheduler implements LocalSchedulerLink {
@Override
public void submitTask(TaskSpec task) {
UniqueID id = isTaskReady(task);
UniqueId id = isTaskReady(task);
if (id == null) {
Worker.execute(task, functions);
} else {
Map<UniqueID, TaskSpec> bucket = waitTasks
Map<UniqueId, TaskSpec> bucket = waitTasks
.computeIfAbsent(id, id_ -> new ConcurrentHashMap<>());
bucket.put(id, task);
}
}
private UniqueID isTaskReady(TaskSpec spec) {
private UniqueId isTaskReady(TaskSpec spec) {
for (FunctionArg arg : spec.args) {
if (arg.ids != null) {
for (UniqueID id : arg.ids) {
if (!store.isObjectReady(id)) {
return id;
}
if (arg.id != null) {
if (!store.isObjectReady(arg.id)) {
return arg.id;
}
}
}
@@ -70,17 +68,17 @@ public class MockLocalScheduler implements LocalSchedulerLink {
}
@Override
public void markTaskPutDependency(UniqueID taskId, UniqueID objectId) {
public void markTaskPutDependency(UniqueId taskId, UniqueId objectId) {
}
@Override
public void reconstructObject(UniqueID objectId, boolean fetchOnly) {
public void reconstructObject(UniqueId objectId, boolean fetchOnly) {
}
@Override
public void reconstructObjects(List<UniqueID> objectIds, boolean fetchOnly) {
public void reconstructObjects(List<UniqueId> objectIds, boolean fetchOnly) {
}
@@ -90,7 +88,7 @@ public class MockLocalScheduler implements LocalSchedulerLink {
}
@Override
public UniqueID generateTaskId(UniqueID driverId, UniqueID parentTaskId, int taskIndex) {
public UniqueId generateTaskId(UniqueId driverId, UniqueId parentTaskId, int taskIndex) {
throw new RuntimeException("Not implemented here.");
}
@@ -6,7 +6,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.arrow.plasma.ObjectStoreLink;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.core.WorkerContext;
import org.ray.util.logger.RayLog;
@@ -15,8 +15,8 @@ import org.ray.util.logger.RayLog;
*/
public class MockObjectStore implements ObjectStoreLink {
private final Map<UniqueID, byte[]> data = new ConcurrentHashMap<>();
private final Map<UniqueID, byte[]> metadata = new ConcurrentHashMap<>();
private final Map<UniqueId, byte[]> data = new ConcurrentHashMap<>();
private final Map<UniqueId, byte[]> metadata = new ConcurrentHashMap<>();
private MockLocalScheduler scheduler = null;
@Override
@@ -26,7 +26,7 @@ public class MockObjectStore implements ObjectStoreLink {
.error(logPrefix() + "cannot put null: " + objectId + "," + Arrays.toString(value));
System.exit(-1);
}
UniqueID uniqueId = new UniqueID(objectId);
UniqueId uniqueId = new UniqueId(objectId);
data.put(uniqueId, value);
metadata.put(uniqueId, metadataValue);
@@ -37,10 +37,10 @@ public class MockObjectStore implements ObjectStoreLink {
@Override
public List<byte[]> get(byte[][] objectIds, int timeoutMs, boolean isMetadata) {
final Map<UniqueID, byte[]> dataMap = isMetadata ? metadata : data;
final Map<UniqueId, byte[]> dataMap = isMetadata ? metadata : data;
ArrayList<byte[]> rets = new ArrayList<>(objectIds.length);
for (byte[] objId : objectIds) {
UniqueID uniqueId = new UniqueID(objId);
UniqueId uniqueId = new UniqueId(objId);
RayLog.core.info(logPrefix() + " is notified for objectid " + uniqueId);
rets.add(dataMap.get(uniqueId));
}
@@ -52,7 +52,7 @@ public class MockObjectStore implements ObjectStoreLink {
ArrayList<byte[]> rets = new ArrayList<>();
for (byte[] objId : objectIds) {
//tod test
if (data.containsKey(new UniqueID(objId))) {
if (data.containsKey(new UniqueId(objId))) {
rets.add(objId);
}
}
@@ -82,7 +82,7 @@ public class MockObjectStore implements ObjectStoreLink {
@Override
public boolean contains(byte[] objectId) {
return data.containsKey(new UniqueID(objectId));
return data.containsKey(new UniqueId(objectId));
}
private String logPrefix() {
@@ -99,7 +99,7 @@ public class MockObjectStore implements ObjectStoreLink {
return stes[k].getFileName() + ":" + stes[k].getLineNumber();
}
public boolean isObjectReady(UniqueID id) {
public boolean isObjectReady(UniqueId id) {
return data.containsKey(id);
}
@@ -1,18 +1,11 @@
package org.ray.core.impl;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.arrow.plasma.ObjectStoreLink;
import org.apache.arrow.plasma.PlasmaClient;
import org.ray.api.RayActor;
import org.ray.api.RayRemote;
import org.ray.api.UniqueID;
import org.ray.api.funcs.RayFunc2;
import org.ray.core.RayRuntime;
import org.ray.core.UniqueIdHelper;
import org.ray.core.AbstractRayRuntime;
import org.ray.core.WorkerContext;
import org.ray.core.model.RayParameters;
import org.ray.core.model.WorkerMode;
@@ -29,13 +22,12 @@ import org.ray.spi.impl.NonRayletStateStoreProxyImpl;
import org.ray.spi.impl.RayletStateStoreProxyImpl;
import org.ray.spi.impl.RedisClient;
import org.ray.spi.model.AddressInfo;
import org.ray.util.exception.TaskExecutionException;
import org.ray.util.logger.RayLog;
/**
* native runtime for local box and cluster run.
*/
public class RayNativeRuntime extends RayRuntime {
public final class RayNativeRuntime extends AbstractRayRuntime {
static {
System.err.println("Current working directory is " + System.getProperty("user.dir"));
@@ -46,8 +38,6 @@ public class RayNativeRuntime extends RayRuntime {
private StateStoreProxy stateStoreProxy;
private KeyValueStoreLink kvStore = null;
private RunManager manager = null;
private Object actor = null;
private UniqueID actorId = UniqueID.NIL;
protected RayNativeRuntime() {
}
@@ -103,12 +93,12 @@ public class RayNativeRuntime extends RayRuntime {
if (params.worker_mode != WorkerMode.NONE) {
String overwrites = "";
// initialize the links
int releaseDelay = RayRuntime.configReader
int releaseDelay = AbstractRayRuntime.configReader
.getIntegerValue("ray", "plasma_default_release_delay", 0,
"how many release requests should be delayed in plasma client");
if (!params.use_raylet) {
ObjectStoreLink plink = new PlasmaClient(params.object_store_name,
ObjectStoreLink plink = new PlasmaClient(params.object_store_name,
params.object_store_manager_name, releaseDelay);
LocalSchedulerLink slink = new DefaultLocalSchedulerClient(
@@ -152,24 +142,15 @@ public class RayNativeRuntime extends RayRuntime {
}
@Override
public void cleanUp() {
public void shutdown() {
if (null != manager) {
manager.cleanup(true);
}
}
@Override
public Object getLocalActor(UniqueID id) {
if (actorId.equals(id)) {
return actor;
} else {
return null;
}
}
private void startOnebox(RayParameters params, PathConfig paths) throws Exception {
params.cleanup = true;
manager = new RunManager(params, paths, RayRuntime.configReader);
manager = new RunManager(params, paths, AbstractRayRuntime.configReader);
manager.startRayHead();
params.redis_address = manager.info().redisAddress;
@@ -235,59 +216,4 @@ public class RayNativeRuntime extends RayRuntime {
kvStore.hmset("Workers:" + workerId, workerInfo);
}
}
@SuppressWarnings("unchecked")
@Override
public <T> RayActor<T> create(Class<T> cls) {
UniqueID createTaskId = localSchedulerProxy.generateTaskId(
WorkerContext.currentTask().driverId,
WorkerContext.currentTask().taskId,
WorkerContext.nextCallIndex()
);
UniqueID actorId = UniqueIdHelper.computeReturnId(createTaskId, 0);
RayActor<T> actor = new RayActor<>(actorId);
UniqueID cursorId;
RayFunc2<byte[], String, byte[]> createActorLambda = RayNativeRuntime::createActorInActor;
cursorId = worker.createActor(
createTaskId,
actorId,
createActorLambda,
new Object[]{actorId.getBytes(), cls.getName()}
).getId();
actor.setTaskCursor(cursorId);
return actor;
}
@RayRemote
public static byte[] createActorInActor(byte[] actorId, String className) {
((RayNativeRuntime) RayRuntime.getInstance()).localCreateActorInActor(actorId, className);
return actorId;
}
public Object localCreateActorInActor(byte[] actorId, String className) {
try {
this.actorId = new UniqueID(actorId);
Class<?> cls = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
Constructor<?>[] cts = cls.getConstructors();
for (Constructor<?> ct : cts) {
System.err.println(ct.getName() + ", param count = " + ct.getParameterCount());
}
actor = cls.getConstructor(new Class<?>[0]).newInstance();
RayLog.core.info("create actor " + this.actorId + " inside actor ok");
return actor;
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException | NoSuchMethodException
| SecurityException e) {
e.printStackTrace();
String log = "create actor " + this.actorId + " for " + className + " failed, ex = " + e
.getMessage();
System.err.println(log);
RayLog.core.error(log, e);
throw new TaskExecutionException(log, e);
}
}
}
@@ -12,7 +12,7 @@ import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.core.model.RayParameters;
import org.ray.core.model.RunMode;
import org.ray.runner.RunInfo.ProcessType;
@@ -101,7 +101,7 @@ public class RunManager {
startRayProcesses();
}
public Process startDriver(String mainClass, String redisAddress, UniqueID driverId,
public Process startDriver(String mainClass, String redisAddress, UniqueId driverId,
String logDir, String ip,
String driverClass, String driverArgs, String additonalClassPaths,
String additionalConfigs) {
@@ -369,7 +369,7 @@ public class RunManager {
for (int j = 0; j < localNumWorkers[i]; j++) {
startWorker(localStores.storeName, localStores.managerName, localStores.schedulerName,
"/worker" + i + "." + j, params.redis_address,
params.node_ip_address, UniqueID.NIL, "", params.redirect, params.cleanup);
params.node_ip_address, UniqueId.NIL, "", params.redirect, params.cleanup);
}
}
}
@@ -570,7 +570,7 @@ public class RunManager {
String workerCmd = null;
workerCmd = buildWorkerCommand(true, info.storeName, info.managerName, name,
UniqueID.NIL, "", ip, redisAddress);
UniqueId.NIL, "", ip, redisAddress);
cmd += " -w \"" + workerCmd + "\"";
if (redisAddress.length() > 0) {
@@ -614,7 +614,7 @@ public class RunManager {
//Create the worker command that the raylet will use to start workers.
String workerCommand = buildWorkerCommandRaylet(info.storeName, rayletSocketName,
UniqueID.NIL, "", ip, redisAddress);
UniqueId.NIL, "", ip, redisAddress);
int sep = redisAddress.indexOf(':');
assert (sep != -1);
@@ -654,13 +654,13 @@ public class RunManager {
}
private String buildWorkerCommandRaylet(String storeName, String rayletSocketName,
UniqueID actorId, String actorClass,
UniqueId actorId, String actorClass,
String ip, String redisAddress) {
String workerConfigs = "ray.java.start.object_store_name=" + storeName
+ ";ray.java.start.raylet_socket_name=" + rayletSocketName
+ ";ray.java.start.worker_mode=WORKER;ray.java.start.use_raylet=true";
workerConfigs += ";ray.java.start.deploy=" + params.deploy;
if (!actorId.equals(UniqueID.NIL)) {
if (!actorId.equals(UniqueId.NIL)) {
workerConfigs += ";ray.java.start.actor_id=" + actorId;
}
if (!actorClass.equals("")) {
@@ -685,14 +685,14 @@ public class RunManager {
private String buildWorkerCommand(boolean isFromLocalScheduler, String storeName,
String storeManagerName, String localSchedulerName,
UniqueID actorId, String actorClass, String
UniqueId actorId, String actorClass, String
ip, String redisAddress) {
String workerConfigs = "ray.java.start.object_store_name=" + storeName
+ ";ray.java.start.object_store_manager_name=" + storeManagerName
+ ";ray.java.start.worker_mode=WORKER"
+ ";ray.java.start.local_scheduler_name=" + localSchedulerName;
workerConfigs += ";ray.java.start.deploy=" + params.deploy;
if (!actorId.equals(UniqueID.NIL)) {
if (!actorId.equals(UniqueId.NIL)) {
workerConfigs += ";ray.java.start.actor_id=" + actorId;
}
if (!actorClass.equals("")) {
@@ -783,7 +783,7 @@ public class RunManager {
public void startWorker(String storeName, String storeManagerName,
String localSchedulerName, String workerName, String redisAddress,
String ip, UniqueID actorId, String actorClass,
String ip, UniqueId actorId, String actorClass,
boolean redirect, boolean cleanup) {
String cmd = buildWorkerCommand(false, storeName, storeManagerName, localSchedulerName, actorId,
actorClass, ip, redisAddress);
@@ -1,6 +1,6 @@
package org.ray.runner.worker;
import org.ray.core.RayRuntime;
import org.ray.core.AbstractRayRuntime;
import org.ray.core.model.WorkerMode;
/**
@@ -15,13 +15,13 @@ public class DefaultDriver {
//
public static void main(String[] args) {
try {
RayRuntime.init(args);
assert RayRuntime.getParams().worker_mode == WorkerMode.DRIVER;
AbstractRayRuntime.init(args);
assert AbstractRayRuntime.getParams().worker_mode == WorkerMode.DRIVER;
String driverClass = RayRuntime.configReader
String driverClass = AbstractRayRuntime.configReader
.getStringValue("ray.java.start", "driver_class", "",
"java class which main is served as the driver in a java worker");
String driverArgs = RayRuntime.configReader
String driverArgs = AbstractRayRuntime.configReader
.getStringValue("ray.java.start", "driver_args", "",
"arguments for the java class main function which is served at the driver");
Class<?> cls = Class.forName(driverClass);
@@ -1,6 +1,6 @@
package org.ray.runner.worker;
import org.ray.core.RayRuntime;
import org.ray.core.AbstractRayRuntime;
import org.ray.core.model.WorkerMode;
/**
@@ -16,9 +16,9 @@ public class DefaultWorker {
//
public static void main(String[] args) {
try {
RayRuntime.init(args);
assert RayRuntime.getParams().worker_mode == WorkerMode.WORKER;
RayRuntime.getInstance().loop();
AbstractRayRuntime.init(args);
assert AbstractRayRuntime.getParams().worker_mode == WorkerMode.WORKER;
AbstractRayRuntime.getInstance().loop();
throw new RuntimeException("Control flow should never reach here");
} catch (Throwable e) {
@@ -7,9 +7,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.ray.api.Ray;
import org.ray.api.UniqueID;
import org.ray.core.RayRuntime;
import org.ray.api.id.UniqueId;
import org.ray.core.AbstractRayRuntime;
import org.ray.core.UniqueIdHelper;
import org.ray.spi.LocalSchedulerLink;
import org.ray.spi.model.FunctionArg;
@@ -24,15 +23,15 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
private static ThreadLocal<ByteBuffer> _taskBuffer = ThreadLocal.withInitial(() -> {
ByteBuffer bb = ByteBuffer
.allocateDirect(RayRuntime.getParams().max_submit_task_buffer_size_bytes);
.allocateDirect(AbstractRayRuntime.getParams().max_submit_task_buffer_size_bytes);
bb.order(ByteOrder.LITTLE_ENDIAN);
return bb;
});
private long client = 0;
boolean useRaylet = false;
public DefaultLocalSchedulerClient(String schedulerSockName, UniqueID clientId,
boolean isWorker, UniqueID driverId, boolean useRaylet) {
public DefaultLocalSchedulerClient(String schedulerSockName, UniqueId clientId,
boolean isWorker, UniqueId driverId, boolean useRaylet) {
client = nativeInit(schedulerSockName, clientId.getBytes(),
isWorker, driverId.getBytes(), useRaylet);
this.useRaylet = useRaylet;
@@ -57,6 +56,7 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
@Override
public void submitTask(TaskSpec task) {
RayLog.core.debug("Submitting task: {}", task);
// We don't support resources management in non raylet mode.
if (!useRaylet) {
task.resources.clear();
@@ -72,12 +72,12 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
}
ByteBuffer info = taskSpec2Info(task);
byte[] a = null;
byte[] cursorId = null;
if (!task.actorId.isNil()) {
a = task.cursorId.getBytes();
cursorId = task.cursorId.getBytes();
}
nativeSubmitTask(client, a, info, info.position(), info.remaining(), useRaylet);
nativeSubmitTask(client, cursorId, info, info.position(), info.remaining(), useRaylet);
}
@Override
@@ -89,19 +89,19 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
}
@Override
public void markTaskPutDependency(UniqueID taskId, UniqueID objectId) {
public void markTaskPutDependency(UniqueId taskId, UniqueId objectId) {
nativePutObject(client, taskId.getBytes(), objectId.getBytes());
}
@Override
public void reconstructObject(UniqueID objectId, boolean fetchOnly) {
List<UniqueID> objects = new ArrayList<>();
public void reconstructObject(UniqueId objectId, boolean fetchOnly) {
List<UniqueId> objects = new ArrayList<>();
objects.add(objectId);
nativeReconstructObjects(client, getIdBytes(objects), fetchOnly);
}
@Override
public void reconstructObjects(List<UniqueID> objectIds, boolean fetchOnly) {
public void reconstructObjects(List<UniqueId> objectIds, boolean fetchOnly) {
if (RayLog.core.isInfoEnabled()) {
RayLog.core.info("Reconstructing objects for task {}, object IDs are {}",
UniqueIdHelper.computeTaskId(objectIds.get(0)), objectIds);
@@ -110,9 +110,9 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
}
@Override
public UniqueID generateTaskId(UniqueID driverId, UniqueID parentTaskId, int taskIndex) {
public UniqueId generateTaskId(UniqueId driverId, UniqueId parentTaskId, int taskIndex) {
byte[] bytes = nativeGenerateTaskId(driverId.getBytes(), parentTaskId.getBytes(), taskIndex);
return new UniqueID(bytes);
return new UniqueId(bytes);
}
@Override
@@ -125,49 +125,47 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
TaskInfo info = TaskInfo.getRootAsTaskInfo(bb);
TaskSpec spec = new TaskSpec();
spec.driverId = UniqueID.fromByteBuffer(info.driverIdAsByteBuffer());
spec.taskId = UniqueID.fromByteBuffer(info.taskIdAsByteBuffer());
spec.parentTaskId = UniqueID.fromByteBuffer(info.parentTaskIdAsByteBuffer());
spec.driverId = UniqueId.fromByteBuffer(info.driverIdAsByteBuffer());
spec.taskId = UniqueId.fromByteBuffer(info.taskIdAsByteBuffer());
spec.parentTaskId = UniqueId.fromByteBuffer(info.parentTaskIdAsByteBuffer());
spec.parentCounter = info.parentCounter();
spec.actorId = UniqueID.fromByteBuffer(info.actorIdAsByteBuffer());
spec.actorId = UniqueId.fromByteBuffer(info.actorIdAsByteBuffer());
spec.actorCounter = info.actorCounter();
spec.createActorId = UniqueID.fromByteBuffer(info.actorCreationIdAsByteBuffer());
spec.createActorId = UniqueId.fromByteBuffer(info.actorCreationIdAsByteBuffer());
spec.functionId = UniqueID.fromByteBuffer(info.functionIdAsByteBuffer());
spec.functionId = UniqueId.fromByteBuffer(info.functionIdAsByteBuffer());
List<FunctionArg> args = new ArrayList<>();
for (int i = 0; i < info.argsLength(); i++) {
FunctionArg darg = new FunctionArg();
UniqueId id = null;
byte[] data = null;
Arg sarg = info.args(i);
int idCount = sarg.objectIdsLength();
if (idCount > 0) {
darg.ids = new ArrayList<>();
for (int j = 0; j < idCount; j++) {
ByteBuffer lbb = sarg.objectIdAsByteBuffer(j);
assert (lbb != null && lbb.remaining() > 0);
darg.ids.add(UniqueID.fromByteBuffer(lbb));
}
ByteBuffer lbb = sarg.objectIdAsByteBuffer(0);
assert (lbb != null && lbb.remaining() > 0);
id = UniqueId.fromByteBuffer(lbb);
}
ByteBuffer lbb = sarg.dataAsByteBuffer();
if (lbb != null && lbb.remaining() > 0) {
// TODO: how to avoid memory copy
darg.data = new byte[lbb.remaining()];
lbb.get(darg.data);
data = new byte[lbb.remaining()];
lbb.get(data);
}
args.add(darg);
args.add(new FunctionArg(id, data));
}
spec.args = args.toArray(new FunctionArg[0]);
List<UniqueID> rids = new ArrayList<>();
List<UniqueId> rids = new ArrayList<>();
for (int i = 0; i < info.returnsLength(); i++) {
ByteBuffer lbb = info.returnsAsByteBuffer(i);
assert (lbb != null && lbb.remaining() > 0);
rids.add(UniqueID.fromByteBuffer(lbb));
rids.add(UniqueId.fromByteBuffer(lbb));
}
spec.returnIds = rids.toArray(new UniqueID[0]);
spec.returnIds = rids.toArray(new UniqueId[0]);
return spec;
}
@@ -183,7 +181,7 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
final int parentTaskIdOffset = fbb.createString(task.parentTaskId.toByteBuffer());
final int parentCounter = task.parentCounter;
final int actorCreateIdOffset = fbb.createString(task.createActorId.toByteBuffer());
final int actorCreateDummyIdOffset = fbb.createString(UniqueID.NIL.toByteBuffer());
final int actorCreateDummyIdOffset = fbb.createString(UniqueId.NIL.toByteBuffer());
final int actorIdOffset = fbb.createString(task.actorId.toByteBuffer());
final int actorHandleIdOffset = fbb.createString(task.actorHandleId.toByteBuffer());
final int actorCounter = task.actorCounter;
@@ -195,12 +193,10 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
int objectIdOffset = 0;
int dataOffset = 0;
if (task.args[i].ids != null) {
int idCount = task.args[i].ids.size();
int[] idOffsets = new int[idCount];
for (int k = 0; k < idCount; k++) {
idOffsets[k] = fbb.createString(task.args[i].ids.get(k).toByteBuffer());
}
if (task.args[i].id != null) {
int[] idOffsets = new int[] {
fbb.createString(task.args[i].id.toByteBuffer())
};
objectIdOffset = fbb.createVectorOfTables(idOffsets);
} else {
objectIdOffset = fbb.createVectorOfTables(new int[0]);
@@ -248,9 +244,9 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
fbb.finish(root);
ByteBuffer buffer = fbb.dataBuffer();
if (buffer.remaining() > RayRuntime.getParams().max_submit_task_buffer_size_bytes) {
if (buffer.remaining() > AbstractRayRuntime.getParams().max_submit_task_buffer_size_bytes) {
RayLog.core.error(
"Allocated buffer is not enough to transfer the task specification: " + RayRuntime
"Allocated buffer is not enough to transfer the task specification: " + AbstractRayRuntime
.getParams().max_submit_task_buffer_size_bytes + " vs " + buffer.remaining());
assert (false);
}
@@ -258,7 +254,7 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
return buffer;
}
private static byte[][] getIdBytes(List<UniqueID> objectIds) {
private static byte[][] getIdBytes(List<UniqueId> objectIds) {
int size = objectIds.size();
byte[][] ids = new byte[size][];
for (int i = 0; i < size; i++) {
@@ -5,7 +5,7 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.ConcurrentHashMap;
import net.lingala.zip4j.core.ZipFile;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.spi.KeyValueStoreLink;
import org.ray.spi.RemoteFunctionManager;
import org.ray.util.FileUtil;
@@ -18,7 +18,7 @@ import org.ray.util.logger.RayLog;
*/
public class NativeRemoteFunctionManager implements RemoteFunctionManager {
private final ConcurrentHashMap<UniqueID, ClassLoader> loadedApps = new ConcurrentHashMap<>();
private final ConcurrentHashMap<UniqueId, ClassLoader> loadedApps = new ConcurrentHashMap<>();
private MessageDigest md;
private final String appDir = System.getProperty("user.dir") + "/apps";
private final KeyValueStoreLink kvStore;
@@ -35,11 +35,11 @@ public class NativeRemoteFunctionManager implements RemoteFunctionManager {
}
@Override
public UniqueID registerResource(byte[] resourceZip) {
public UniqueId registerResource(byte[] resourceZip) {
byte[] digest = Sha1Digestor.digest(resourceZip);
assert (digest.length == UniqueID.LENGTH);
assert (digest.length == UniqueId.LENGTH);
UniqueID resourceId = new UniqueID(digest);
UniqueId resourceId = new UniqueId(digest);
// TODO: resources must be saved in persistent store
kvStore.set(resourceId.getBytes(), resourceZip, null);
@@ -48,32 +48,32 @@ public class NativeRemoteFunctionManager implements RemoteFunctionManager {
}
@Override
public byte[] getResource(UniqueID resourceId) {
public byte[] getResource(UniqueId resourceId) {
return kvStore.get(resourceId.getBytes(), null);
}
@Override
public void unregisterResource(UniqueID resourceId) {
public void unregisterResource(UniqueId resourceId) {
kvStore.delete(resourceId.getBytes(), null);
}
@Override
public void registerApp(UniqueID driverId, UniqueID resourceId) {
public void registerApp(UniqueId driverId, UniqueId resourceId) {
kvStore.set("App2ResMap", resourceId.toString(), driverId.toString());
}
@Override
public UniqueID getAppResourceId(UniqueID driverId) {
return UniqueID.fromHexString(kvStore.get("App2ResMap", driverId.toString()));
public UniqueId getAppResourceId(UniqueId driverId) {
return UniqueId.fromHexString(kvStore.get("App2ResMap", driverId.toString()));
}
@Override
public void unregisterApp(UniqueID driverId) {
public void unregisterApp(UniqueId driverId) {
kvStore.delete("App2ResMap", driverId.toString());
}
@Override
public ClassLoader loadResource(UniqueID driverId) {
public ClassLoader loadResource(UniqueId driverId) {
ClassLoader classLoader = loadedApps.get(driverId);
if (classLoader == null) {
synchronized (this) {
@@ -86,13 +86,13 @@ public class NativeRemoteFunctionManager implements RemoteFunctionManager {
return classLoader;
}
private ClassLoader initLoadedApps(UniqueID driverId) {
private ClassLoader initLoadedApps(UniqueId driverId) {
try {
RayLog.core.info("initLoadedApps" + driverId.toString());
ClassLoader cl = loadedApps.get(driverId);
if (cl == null) {
UniqueID resId = UniqueID.fromHexString(kvStore.get("App2ResMap", driverId.toString()));
UniqueId resId = UniqueId.fromHexString(kvStore.get("App2ResMap", driverId.toString()));
byte[] res = getResource(resId);
if (res == null) {
throw new RuntimeException("get resource null, the resId " + resId.toString());
@@ -120,7 +120,7 @@ public class NativeRemoteFunctionManager implements RemoteFunctionManager {
}
@Override
public synchronized void unloadFunctions(UniqueID driverId) {
public synchronized void unloadFunctions(UniqueId driverId) {
ClassLoader cl = loadedApps.get(driverId);
try {
JarLoader.unloadJars(cl);
@@ -5,7 +5,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.format.gcs.ClientTableData;
import org.ray.spi.KeyValueStoreLink;
import org.ray.spi.model.AddressInfo;
@@ -29,7 +29,7 @@ public class RayletStateStoreProxyImpl extends BaseStateStoreProxyImpl {
List<AddressInfo> schedulerInfo = new ArrayList<>();
byte[] prefix = "CLIENT".getBytes();
byte[] postfix = UniqueID.genNil().getBytes();
byte[] postfix = UniqueId.genNil().getBytes();
byte[] clientKey = new byte[prefix.length + postfix.length];
System.arraycopy(prefix, 0, clientKey, 0, prefix.length);
System.arraycopy(postfix, 0, clientKey, prefix.length, postfix.length);
@@ -5,7 +5,7 @@ import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.api.annotation.RayRemote;
import org.ray.api.test.MyRunner;
@RunWith(MyRunner.class)
@@ -14,7 +14,7 @@ public class ActorPressTest extends RayBenchmarkTest {
@Test
public void singleLatencyTest() {
int times = 10;
RayActor<ActorPressTest.Adder> adder = Ray.create(ActorPressTest.Adder.class);
RayActor<ActorPressTest.Adder> adder = Ray.createActor(ActorPressTest.Adder.class);
super.singleLatencyTest(times, adder);
}
@@ -22,7 +22,7 @@ public class ActorPressTest extends RayBenchmarkTest {
public void maxTest() {
int clientNum = 2;
int totalNum = 20;
RayActor<ActorPressTest.Adder> adder = Ray.create(ActorPressTest.Adder.class);
RayActor<ActorPressTest.Adder> adder = Ray.createActor(ActorPressTest.Adder.class);
PressureTestParameter pressureTestParameter = new PressureTestParameter();
pressureTestParameter.setClientNum(clientNum);
pressureTestParameter.setTotalNum(totalNum);
@@ -36,7 +36,7 @@ public class ActorPressTest extends RayBenchmarkTest {
int clientNum = 2;
int totalQps = 2;
int duration = 3;
RayActor<ActorPressTest.Adder> adder = Ray.create(ActorPressTest.Adder.class);
RayActor<ActorPressTest.Adder> adder = Ray.createActor(ActorPressTest.Adder.class);
PressureTestParameter pressureTestParameter = new PressureTestParameter();
pressureTestParameter.setClientNum(clientNum);
pressureTestParameter.setTotalQps(totalQps);
@@ -5,7 +5,7 @@ import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.api.annotation.RayRemote;
import org.ray.api.test.MyRunner;
@RunWith(MyRunner.class)
@@ -5,7 +5,7 @@ import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.api.annotation.RayRemote;
import org.ray.api.test.MyRunner;
@RunWith(MyRunner.class)
@@ -10,7 +10,7 @@ import org.junit.Assert;
import org.ray.api.Ray;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.api.annotation.RayRemote;
import org.ray.util.logger.RayLog;
public abstract class RayBenchmarkTest<T> implements Serializable {
@@ -5,7 +5,7 @@ import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.api.annotation.RayRemote;
import org.ray.api.test.MyRunner;
@RunWith(MyRunner.class)
@@ -1,152 +1,59 @@
package org.ray.api.test;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.api.UniqueID;
import org.ray.api.annotation.RayRemote;
import org.ray.api.function.RayFunc2;
import org.ray.api.id.UniqueId;
@RunWith(MyRunner.class)
public class ActorTest {
@RayRemote
public static Integer sayWorld(Integer n, RayActor<ActorTest.Adder> adder) {
RayObject<Integer> result = Ray.call(ActorTest.Adder::add, adder, 1);
return result.get() + n;
public static class Counter {
private int value = 0;
public int incr(int delta) {
value += delta;
return value;
}
}
@RayRemote
public static int testActorAsFirstParameter(RayActor<Counter> actor, int delta) {
RayObject<Integer> res = Ray.call(Counter::incr, actor, delta);
return res.get();
}
@RayRemote
public static int testActorAsSecondParameter(int delta, RayActor<Counter> actor) {
RayObject<Integer> res = Ray.call(Counter::incr, actor, delta);
return res.get();
}
@Test
public void test() {
RayActor<ActorTest.Adder> adder = Ray.create(ActorTest.Adder.class);
Ray.call(Adder::set, adder, 10);
RayObject<Integer> result = Ray.call(Adder::add, adder, 1);
Assert.assertEquals(11, (int) result.get());
RayActor<Adder> secondAdder = Ray.create(Adder.class);
RayObject<Integer> result2 = Ray.call(Adder::add, secondAdder, 1);
Assert.assertEquals(1, (int) result2.get());
RayObject<Integer> result3 = Ray.call(Adder::add2, 1);
Assert.assertEquals(2, (int) result3.get());
RayObject<Integer> result4 = Ray.call(ActorTest::sayWorld, 2, adder);
Assert.assertEquals(14, (int) result4.get());
RayActor<Adder2> adder2 = Ray.create(Adder2.class);
Ray.call(Adder2::setAdder, adder2, adder);
RayObject<Integer> result5 = Ray.call(Adder2::increase, adder2);
Assert.assertEquals(1, (int) result5.get());
List list = new ArrayList<>();
list.add(adder);
Ray.call(Adder2::setAdderList, adder2, list);
RayObject<Integer> result7 = Ray.call(Adder2::testActorList, adder2);
Assert.assertEquals(14, (int) result7.get());
List tempList = new ArrayList<>();
tempList.add(result);
Ray.call(Adder::setObjectList, adder, tempList);
RayObject<Integer> result8 = Ray.call(Adder::testObjectList, adder);
Assert.assertEquals(11, (int) result8.get());
public void testCreateAndCallActor() {
// Test creating an actor
RayActor<Counter> actor = Ray.createActor(Counter.class);
Assert.assertNotEquals(actor.getId(), UniqueId.NIL);
// Test calling an actor
RayFunc2<Counter, Integer, Integer> f = Counter::incr;
Assert.assertEquals(Integer.valueOf(1), Ray.call(f, actor, 1).get());
Assert.assertEquals(Integer.valueOf(11), Ray.call(Counter::incr, actor, 10).get());
}
@RayRemote
public static class Adder {
private List<RayObject<Integer>> objectList;
private Integer sum = 0;
public static Integer add2(Integer n) {
return n + 1;
}
public Integer set(Integer n) {
sum = n;
return sum;
}
public Integer increase() {
return (++sum);
}
public Integer add(Integer n) {
return (sum += n);
}
public Integer setObjectList(List<RayObject<Integer>> objectList) {
this.objectList = objectList;
return 1;
}
public Integer testObjectList() {
return ((RayObject<Integer>) objectList.get(0)).get();
}
}
@RayRemote
public static class Adder2 {
private RayActor<Adder> adder;
private List<RayActor<Adder>> adderList;
private UniqueID id;
private Integer sum = 0;
public static Integer add2(Adder a, Integer n) {
return n + 1;
}
public Integer set(Integer n) {
sum = n;
return sum;
}
public Integer increase() {
RayObject<Integer> result = Ray.call(Adder::increase, adder);
Assert.assertEquals(13, (int) result.get());
return (++sum);
}
public Integer testActorList() {
RayActor<Adder> temp = adderList.get(0);
RayObject<Integer> result = Ray.call(Adder::increase, temp);
return result.get();
}
public Integer add(Integer n) {
return (sum += n);
}
public RayActor<Adder> getAdder() {
return adder;
}
public Integer setAdder(RayActor<Adder> adder) {
this.adder = adder;
return 0;
}
public UniqueID getId() {
return id;
}
public Integer setId(UniqueID id) {
this.id = id;
adder = new RayActor<>(id);
return 0;
}
public Integer setAdderList(List<RayActor<Adder>> adderList) {
this.adderList = adderList;
return 0;
}
@Test
public void testPassActorAsParameter() {
RayActor<Counter> actor = Ray.createActor(Counter.class);
RayFunc2<RayActor, Integer, Integer> f = ActorTest::testActorAsFirstParameter;
Assert.assertEquals(Integer.valueOf(1),
Ray.call(ActorTest::testActorAsFirstParameter, actor, 1).get());
Assert.assertEquals(Integer.valueOf(11),
Ray.call(ActorTest::testActorAsSecondParameter, 10, actor).get());
}
}
@@ -3,7 +3,7 @@ package org.ray.api.test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayRemote;
import org.ray.api.annotation.RayRemote;
@RunWith(MyRunner.class)
public class EchoTest {
@@ -5,7 +5,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.api.annotation.RayRemote;
/**
* Hello world.
@@ -8,9 +8,9 @@ import java.lang.reflect.Method;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.funcs.RayFunc0;
import org.ray.api.funcs.RayFunc1;
import org.ray.api.funcs.RayFunc3;
import org.ray.api.function.RayFunc0;
import org.ray.api.function.RayFunc1;
import org.ray.api.function.RayFunc3;
import org.ray.util.MethodId;
import org.ray.util.logger.RayLog;
@@ -4,7 +4,7 @@ package org.ray.api.test;
import java.lang.reflect.Method;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.funcs.RayFunc3;
import org.ray.api.function.RayFunc3;
import org.ray.util.MethodId;
import org.ray.util.logger.RayLog;
@@ -0,0 +1,32 @@
package org.ray.api.test;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayObject;
import org.ray.api.id.UniqueId;
/**
* Test putting and getting objects.
*/
@RunWith(MyRunner.class)
public class ObjectStoreTest {
@Test
public void testPutAndGet() {
RayObject<Integer> obj = Ray.put(1);
Assert.assertEquals(1, (int) obj.get());
}
@Test
public void testGetMultipleObjects() {
List<Integer> ints = ImmutableList.of(1, 2, 3, 4, 5);
List<UniqueId> ids = ints.stream().map(obj -> Ray.put(obj).getId())
.collect(Collectors.toList());
Assert.assertEquals(ints, Ray.get(ids));
}
}
@@ -2,24 +2,28 @@ package org.ray.api.test;
import org.junit.Assert;
import org.junit.Test;
import org.ray.api.annotation.RayRemote;
import org.ray.spi.model.RayActorMethods;
import org.ray.util.logger.RayLog;
public class RayActorMethodsTest {
@Test
public void testActor() throws Exception {
RayActorMethods methods = RayActorMethods
.fromClass(ActorTest.Adder.class.getName(), RayActorMethodsTest.class.getClassLoader());
RayLog.core.info(methods.toString());
Assert.assertEquals(methods.functions.size(), 5);
Assert.assertEquals(methods.staticFunctions.size(), 1);
@RayRemote
public static class ExampleActor {
RayActorMethods methods2 = RayActorMethods
.fromClass(ActorTest.Adder2.class.getName(), RayActorMethodsTest.class.getClassLoader());
RayLog.core.info(methods2.toString());
public void func1() {}
Assert.assertEquals(methods2.functions.size(), 9);
Assert.assertEquals(methods2.staticFunctions.size(), 1);
public void func2() {}
public static void func3() {}
}
}
@Test
public void testActorMethods() {
RayActorMethods methods = RayActorMethods
.fromClass(ExampleActor.class.getName(), RayActorMethodsTest.class.getClassLoader());
RayLog.core.info(methods.toString());
Assert.assertEquals(methods.functions.size(), 2);
Assert.assertEquals(methods.staticFunctions.size(), 1);
}
}
@@ -0,0 +1,133 @@
package org.ray.api.test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.annotation.RayRemote;
/**
* Test Ray.call API
*/
@RunWith(MyRunner.class)
public class RayCallTest {
@RayRemote
private static int testInt(int val) {
return val;
}
@RayRemote
private static byte testByte(byte val) {
return val;
}
@RayRemote
private static short testShort(short val) {
return val;
}
@RayRemote
private static long testLong(long val) {
return val;
}
@RayRemote
private static double testDouble(double val) {
return val;
}
@RayRemote
private static float testFloat(float val) {
return val;
}
@RayRemote
private static boolean testBool(boolean val) {
return val;
}
@RayRemote
private static String testString(String val) {
return val;
}
@RayRemote
private static List<Integer> testList(List<Integer> val) {
return val;
}
@RayRemote
private static Map<String, Integer> testMap(Map<String, Integer> val) {
return val;
}
/**
* Test calling and returning different types.
*/
@Test
public void testType() {
Assert.assertEquals(1, (int) Ray.call(RayCallTest::testInt, 1).get());
Assert.assertEquals(1, (byte) Ray.call(RayCallTest::testByte, (byte) 1).get());
Assert.assertEquals(1, (short) Ray.call(RayCallTest::testShort, (short) 1).get());
Assert.assertEquals(1, (long) Ray.call(RayCallTest::testLong, 1L).get());
Assert.assertEquals(1.0, Ray.call(RayCallTest::testDouble, 1.0).get(), 0.0);
Assert.assertEquals(1.0f, Ray.call(RayCallTest::testFloat, 1.0f).get(), 0.0);
Assert.assertEquals(true, Ray.call(RayCallTest::testBool, true).get());
Assert.assertEquals("foo", Ray.call(RayCallTest::testString, "foo").get());
List<Integer> list = ImmutableList.of(1, 2, 3);
Assert.assertEquals(list, Ray.call(RayCallTest::testList, list).get());
Map<String, Integer> map = ImmutableMap.of("1", 1, "2", 2);
Assert.assertEquals(map, Ray.call(RayCallTest::testMap, map).get());
}
@RayRemote
private static int testNoParam() {
return 0;
}
@RayRemote
private static int testOneParam(int a) {
return a;
}
@RayRemote
private static int testTwoParams(int a, int b) {
return a + b;
}
@RayRemote
private static int testThreeParams(int a, int b, int c) {
return a + b + c;
}
@RayRemote
private static int testFourParams(int a, int b, int c, int d) {
return a + b + c + d;
}
@RayRemote
private static int testFiveParams(int a, int b, int c, int d, int e) {
return a + b + c + d + e;
}
@RayRemote
private static int testSixParams(int a, int b, int c, int d, int e, int f) {
return a + b + c + d + e + f;
}
@Test
public void testNumberOfParameters() {
Assert.assertEquals(0, (int) Ray.call(RayCallTest::testNoParam).get());
Assert.assertEquals(1, (int) Ray.call(RayCallTest::testOneParam, 1).get());
Assert.assertEquals(2, (int) Ray.call(RayCallTest::testTwoParams, 1, 1).get());
Assert.assertEquals(3, (int) Ray.call(RayCallTest::testThreeParams, 1, 1, 1).get());
Assert.assertEquals(4, (int) Ray.call(RayCallTest::testFourParams, 1, 1, 1, 1).get());
Assert.assertEquals(5, (int) Ray.call(RayCallTest::testFiveParams, 1, 1, 1, 1, 1).get());
Assert.assertEquals(6, (int) Ray.call(RayCallTest::testSixParams, 1, 1, 1, 1, 1, 1).get());
}
}
@@ -26,9 +26,9 @@ public class RayMethodsTest {
RayObject<String> s2Id = Ray.put(String.valueOf("World!"));
RayObject<Object> n1Id = Ray.put(null);
WaitResult<String> res = Ray.wait(ImmutableList.of(s1Id, s2Id), 2);
WaitResult<String> res = Ray.wait(ImmutableList.of(s1Id, s2Id), 2, 1000);
List<String> ss = res.getReadyOnes().stream().map(RayObject::get).collect(Collectors.toList());
List<String> ss = res.getReady().stream().map(RayObject::get).collect(Collectors.toList());
int i1 = i1Id.get();
double f1 = f1Id.get();
Object n1 = n1Id.get();
@@ -40,12 +40,5 @@ public class RayMethodsTest {
Assert.assertEquals(3.14, f1, Double.MIN_NORMAL);
Assert.assertNull(n1);
// metadata test
RayObject<Integer> vid = Ray.put(643, "test metadata");
Integer v = vid.get();
String m = vid.getMeta();
Assert.assertEquals(643L, v.longValue());
Assert.assertEquals("test metadata", m);
}
}
@@ -1,41 +0,0 @@
package org.ray.api.test;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.util.RemoteFunction;
@RunWith(MyRunner.class)
public class RemoteLambdaTest {
public static <T> String remoteToString(T o) {
return o.toString();
}
@Test
public void test() {
RemoteFunction<String, String> f0 = RemoteLambdaTest::remoteToString;
byte[] bytes = SerializationUtils.serialize(f0);
//System.out.println(new String(bytes));
//Object m = SerializationUtils.deserialize(bytes);
RemoteFunction<Integer, Integer> f = x -> {
System.out.println("remote function " + x);
return x + 1;
};
RemoteFunction<Integer, Integer> f2 = SerializationUtils.clone(f);
Assert.assertEquals(101, (int) f2.apply(100));
Integer y = 100;
RemoteFunction<Integer, Integer> f3 = x -> {
System.out.println("remote function " + x);
return x + y + 1;
};
RemoteFunction<Integer, Integer> f4 = SerializationUtils.clone(f3);
Assert.assertEquals(201, (int) f4.apply(100));
Assert.assertEquals(201, (int) f4.apply(100));
}
}
@@ -8,10 +8,10 @@ import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.api.WaitResult;
import org.ray.core.RayRuntime;
import org.ray.util.ResourceItem;
import org.ray.api.annotation.RayRemote;
import org.ray.api.annotation.ResourceItem;
import org.ray.core.AbstractRayRuntime;
/**
* Resources Management Test.
@@ -49,7 +49,7 @@ public class ResourcesManagementTest {
@Test
public void testMethods() {
Assume.assumeTrue(RayRuntime.getParams().use_raylet);
Assume.assumeTrue(AbstractRayRuntime.getParams().use_raylet);
// This is a case that can satisfy required resources.
RayObject<Integer> result1 = Ray.call(ResourcesManagementTest::echo1, 100);
Assert.assertEquals(100, (int) result1.get());
@@ -58,25 +58,25 @@ public class ResourcesManagementTest {
final RayObject<Integer> result2 = Ray.call(ResourcesManagementTest::echo2, 200);
WaitResult<Integer> waitResult = Ray.wait(ImmutableList.of(result2), 1, 1000);
Assert.assertEquals(0, waitResult.getReadyOnes().size());
Assert.assertEquals(1, waitResult.getRemainOnes().size());
Assert.assertEquals(0, waitResult.getReady().size());
Assert.assertEquals(1, waitResult.getUnready().size());
}
@Test
public void testActors() {
Assume.assumeTrue(RayRuntime.getParams().use_raylet);
Assume.assumeTrue(AbstractRayRuntime.getParams().use_raylet);
// This is a case that can satisfy required resources.
RayActor<ResourcesManagementTest.Echo1> echo1 = Ray.create(Echo1.class);
RayActor<ResourcesManagementTest.Echo1> echo1 = Ray.createActor(Echo1.class);
final RayObject<Integer> result1 = Ray.call(Echo1::echo, echo1, 100);
Assert.assertEquals(100, (int) result1.get());
// This is a case that can't satisfy required resources.
RayActor<ResourcesManagementTest.Echo2> echo2 = Ray.create(Echo2.class);
RayActor<ResourcesManagementTest.Echo2> echo2 = Ray.createActor(Echo2.class);
final RayObject<Integer> result2 = Ray.call(Echo2::echo, echo2, 100);
WaitResult<Integer> waitResult = Ray.wait(ImmutableList.of(result2), 1, 1000);
Assert.assertEquals(0, waitResult.getReadyOnes().size());
Assert.assertEquals(1, waitResult.getRemainOnes().size());
Assert.assertEquals(0, waitResult.getReady().size());
Assert.assertEquals(1, waitResult.getUnready().size());
}
}
@@ -1,39 +0,0 @@
package org.ray.api.test;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayRemote;
@RunWith(MyRunner.class)
public class RpcTest {
@RayRemote
public static Integer with0Params() {
return 0;
}
@RayRemote
public static Integer with1Params(Integer x) {
return x;
}
@RayRemote
public static Integer with2Params(Integer x, Integer y) {
return x + y;
}
@RayRemote
public static Integer with3Params(Integer x, Integer y, Integer z) {
return x + y + z;
}
@Test
public void test() {
Assert.assertEquals(0, (int) Ray.call(RpcTest::with0Params).get());
Assert.assertEquals(1, (int) Ray.call(RpcTest::with1Params, 1).get());
Assert.assertEquals(3, (int) Ray.call(RpcTest::with2Params, 1, 2).get());
Assert.assertEquals(6, (int) Ray.call(RpcTest::with3Params, 1, 2, 3).get());
}
}
@@ -4,7 +4,6 @@ import org.junit.runner.Description;
import org.junit.runner.Result;
import org.junit.runner.notification.RunListener;
import org.ray.api.Ray;
import org.ray.core.RayRuntime;
public class TestListener extends RunListener {
@@ -15,6 +14,6 @@ public class TestListener extends RunListener {
@Override
public void testRunFinished(Result result) {
RayRuntime.getInstance().cleanUp();
Ray.shutdown();
}
}
}
@@ -1,82 +0,0 @@
package org.ray.api.test;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayRemote;
/**
* Test returning different types.
*/
@RunWith(MyRunner.class)
public class TypesTest {
@RayRemote
private static int testInt() {
return 1;
}
@RayRemote
private static byte testByte() {
return 1;
}
@RayRemote
private static short testShort() {
return 1;
}
@RayRemote
private static long testLong() {
return 1;
}
@RayRemote
private static double testDouble() {
return 1;
}
@RayRemote
private static float testFloat() {
return 1;
}
@RayRemote
private static boolean testBool() {
return true;
}
@RayRemote
private static String testString() {
return "foo";
}
@RayRemote
private static List<Integer> testList() {
return ImmutableList.of(1, 2, 3);
}
@RayRemote
private static Map<String, Integer> testMap() {
return ImmutableMap.of("1", 1, "2", 2);
}
@Test
public void test() {
Assert.assertEquals(1, (int) Ray.call(TypesTest::testInt).get());
Assert.assertEquals(1, (byte) Ray.call(TypesTest::testByte).get());
Assert.assertEquals(1, (short) Ray.call(TypesTest::testShort).get());
Assert.assertEquals(1, (long) Ray.call(TypesTest::testLong).get());
Assert.assertEquals(1.0, Ray.call(TypesTest::testDouble).get(), 0.0);
Assert.assertEquals(1.0f, Ray.call(TypesTest::testFloat).get(), 0.0);
Assert.assertEquals(true, Ray.call(TypesTest::testBool).get());
Assert.assertEquals("foo", Ray.call(TypesTest::testString).get());
Assert.assertEquals(ImmutableList.of(1, 2, 3), Ray.call(TypesTest::testList).get());
Assert.assertEquals(ImmutableMap.of("1", 1, "2", 2), Ray.call(TypesTest::testMap).get());
}
}
@@ -6,7 +6,7 @@ import javax.xml.bind.DatatypeConverter;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.core.UniqueIdHelper;
@RunWith(MyRunner.class)
@@ -15,12 +15,12 @@ public class UniqueIdTest {
@Test
public void testConstructUniqueId() {
// Test `fromHexString()`
UniqueID id1 = UniqueID.fromHexString("00000000123456789ABCDEF123456789ABCDEF00");
UniqueId id1 = UniqueId.fromHexString("00000000123456789ABCDEF123456789ABCDEF00");
Assert.assertEquals("00000000123456789ABCDEF123456789ABCDEF00", id1.toString());
Assert.assertFalse(id1.isNil());
try {
UniqueID id2 = UniqueID.fromHexString("000000123456789ABCDEF123456789ABCDEF00");
UniqueId id2 = UniqueId.fromHexString("000000123456789ABCDEF123456789ABCDEF00");
// This shouldn't be happened.
Assert.assertTrue(false);
} catch (IllegalArgumentException e) {
@@ -28,7 +28,7 @@ public class UniqueIdTest {
}
try {
UniqueID id3 = UniqueID.fromHexString("GGGGGGGGGGGGG");
UniqueId id3 = UniqueId.fromHexString("GGGGGGGGGGGGG");
// This shouldn't be happened.
Assert.assertTrue(false);
} catch (IllegalArgumentException e) {
@@ -38,13 +38,13 @@ public class UniqueIdTest {
// Test `fromByteBuffer()`
byte[] bytes = DatatypeConverter.parseHexBinary("0123456789ABCDEF0123456789ABCDEF01234567");
ByteBuffer byteBuffer = ByteBuffer.wrap(bytes, 0, 20);
UniqueID id4 = UniqueID.fromByteBuffer(byteBuffer);
UniqueId id4 = UniqueId.fromByteBuffer(byteBuffer);
Assert.assertTrue(Arrays.equals(bytes, id4.getBytes()));
Assert.assertEquals("0123456789ABCDEF0123456789ABCDEF01234567", id4.toString());
// Test `genNil()`
UniqueID id6 = UniqueID.genNil();
UniqueId id6 = UniqueId.genNil();
Assert.assertEquals("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", id6.toString());
Assert.assertTrue(id6.isNil());
}
@@ -52,9 +52,9 @@ public class UniqueIdTest {
@Test
public void testComputeReturnId() {
// Mock a taskId, and the lowest 4 bytes should be 0.
UniqueID taskId = UniqueID.fromHexString("00000000123456789ABCDEF123456789ABCDEF00");
UniqueId taskId = UniqueId.fromHexString("00000000123456789ABCDEF123456789ABCDEF00");
UniqueID returnId = UniqueIdHelper.computeReturnId(taskId, 1);
UniqueId returnId = UniqueIdHelper.computeReturnId(taskId, 1);
Assert.assertEquals("01000000123456789ABCDEF123456789ABCDEF00", returnId.toString());
returnId = UniqueIdHelper.computeReturnId(taskId, 0x01020304);
@@ -63,8 +63,8 @@ public class UniqueIdTest {
@Test
public void testComputeTaskId() {
UniqueID objId = UniqueID.fromHexString("34421980123456789ABCDEF123456789ABCDEF00");
UniqueID taskId = UniqueIdHelper.computeTaskId(objId);
UniqueId objId = UniqueId.fromHexString("34421980123456789ABCDEF123456789ABCDEF00");
UniqueId taskId = UniqueIdHelper.computeTaskId(objId);
Assert.assertEquals("00000000123456789ABCDEF123456789ABCDEF00", taskId.toString());
}
@@ -72,9 +72,9 @@ public class UniqueIdTest {
@Test
public void testComputePutId() {
// Mock a taskId, the lowest 4 bytes should be 0.
UniqueID taskId = UniqueID.fromHexString("00000000123456789ABCDEF123456789ABCDEF00");
UniqueId taskId = UniqueId.fromHexString("00000000123456789ABCDEF123456789ABCDEF00");
UniqueID putId = UniqueIdHelper.computePutId(taskId, 1);
UniqueId putId = UniqueIdHelper.computePutId(taskId, 1);
Assert.assertEquals("FFFFFFFF123456789ABCDEF123456789ABCDEF00", putId.toString());
putId = UniqueIdHelper.computePutId(taskId, 0x01020304);
@@ -7,45 +7,40 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.ray.api.Ray;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.api.WaitResult;
import org.ray.api.annotation.RayRemote;
@RunWith(MyRunner.class)
public class WaitTest {
@RayRemote
public static String hi() {
private static String hi() {
return "hi";
}
@RayRemote
public static String delayHi() {
private static String delayedHi() {
try {
Thread.sleep(100 * 1000);
} catch (Exception e) {
e.printStackTrace();
}
return "hi";
}
@Test
public void test() {
RayObject<String> obj1 = Ray.call(WaitTest::hi);
RayObject<String> obj2 = Ray.call(WaitTest::delayHi);
RayObject<String> obj2 = Ray.call(WaitTest::delayedHi);
List<RayObject<String>> waitfor = ImmutableList.of(obj1, obj2);
WaitResult<String> waitResult = Ray.wait(waitfor, 2, 2 * 1000);
List<RayObject<String>> readys = waitResult.getReadyOnes();
List<RayObject<String>> waitList = ImmutableList.of(obj1, obj2);
WaitResult<String> waitResult = Ray.wait(waitList, 2, 2 * 1000);
if (!readys.isEmpty()) {
Assert.assertEquals(1, waitResult.getReadyOnes().size());
Assert.assertEquals(1, waitResult.getRemainOnes().size());
Assert.assertEquals("hi", readys.get(0).get());
} else {
Assert.assertEquals(0, waitResult.getReadyOnes().size());
Assert.assertEquals(2, waitResult.getRemainOnes().size());
}
List<RayObject<String>> readyList = waitResult.getReady();
Assert.assertEquals(1, waitResult.getReady().size());
Assert.assertEquals(1, waitResult.getUnready().size());
Assert.assertEquals("hi", readyList.get(0).get());
}
}
@@ -6,7 +6,7 @@ import java.util.List;
import org.junit.Assert;
import org.ray.api.Ray;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.api.annotation.RayRemote;
import org.ray.util.FileUtil;
/**
@@ -3,8 +3,7 @@ package org.ray.exercise;
import java.io.Serializable;
import org.ray.api.Ray;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.core.RayRuntime;
import org.ray.api.annotation.RayRemote;
/**
* Define a remote function, and execute multiple remote functions in parallel.
@@ -41,7 +40,7 @@ public class Exercise01 implements Serializable {
} catch (Throwable t) {
t.printStackTrace();
} finally {
RayRuntime.getInstance().cleanUp();
Ray.shutdown();
}
}
}
@@ -2,8 +2,7 @@ package org.ray.exercise;
import org.ray.api.Ray;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.core.RayRuntime;
import org.ray.api.annotation.RayRemote;
/**
* Execute remote functions in parallel with some dependencies.
@@ -48,7 +47,7 @@ public class Exercise02 {
} catch (Throwable t) {
t.printStackTrace();
} finally {
RayRuntime.getInstance().cleanUp();
Ray.shutdown();
}
}
}
@@ -2,8 +2,7 @@ package org.ray.exercise;
import org.ray.api.Ray;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.core.RayRuntime;
import org.ray.api.annotation.RayRemote;
/**
* Call a remote function from within another remote function.
@@ -39,7 +38,7 @@ public class Exercise03 {
} catch (Throwable t) {
t.printStackTrace();
} finally {
RayRuntime.getInstance().cleanUp();
Ray.shutdown();
}
}
}
@@ -4,9 +4,8 @@ import com.google.common.collect.ImmutableList;
import java.util.List;
import org.ray.api.Ray;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.api.WaitResult;
import org.ray.core.RayRuntime;
import org.ray.api.annotation.RayRemote;
/**
* Use Ray.wait to ignore stragglers
@@ -15,16 +14,14 @@ public class Exercise04 {
@RayRemote
public static String f1() {
String ret = "f1";
System.out.println(ret);
return ret;
System.out.println("Executing f1");
return "f1";
}
@RayRemote
public static String f2() {
String ret = "f2";
System.out.println(ret);
return ret;
System.out.println("Executing f2");
return "f2";
}
/**
@@ -32,14 +29,14 @@ public class Exercise04 {
*/
@RayRemote
public static String f3() {
String ret = "f3";
System.out.println("Executing f3");
try {
Thread.sleep(5000L);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(ret);
return ret;
System.out.println("Finished executing f3");
return "f3";
}
public static void main(String[] args) throws Exception {
@@ -54,20 +51,14 @@ public class Exercise04 {
// or specified timeout have passed.
// In this case, the result of f3 will be ignored.
WaitResult<String> waitResult = Ray.wait(waitList, 2, 3000);
List<RayObject<String>> readyOnes = waitResult.getReadyOnes();
List<RayObject<String>> remainOnes = waitResult.getRemainOnes();
System.out.println("Number of readyOnes: " + readyOnes.size());
for (int i = 0; i < readyOnes.size(); i++) {
System.out.println("The value of readyOnes " + i + " is " + readyOnes.get(i).get());
}
System.out.println("Number of remainOnes: " + remainOnes.size());
for (int i = 0; i < remainOnes.size(); i++) {
System.out.println("The value of remainOnes " + i + " is " + remainOnes.get(i).get());
}
System.out.printf("%d ready object(s): \n", waitResult.getReady().size());
waitResult.getReady().forEach(rayObject -> System.out.println(rayObject.get()));
System.out.printf("%d unready object(s): \n", waitResult.getUnready().size());
waitResult.getUnready().forEach(rayObject -> System.out.println(rayObject.getId()));
} catch (Throwable t) {
t.printStackTrace();
} finally {
RayRuntime.getInstance().cleanUp();
Ray.shutdown();
}
}
}
@@ -3,8 +3,7 @@ package org.ray.exercise;
import org.ray.api.Ray;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.RayRemote;
import org.ray.core.RayRuntime;
import org.ray.api.annotation.RayRemote;
/**
* Show usage of actors.
@@ -14,8 +13,8 @@ public class Exercise05 {
public static void main(String[] args) {
try {
Ray.init();
// `Ray.create` creates an actor instance.
RayActor<Adder> adder = Ray.create(Adder.class);
// `Ray.createActor` creates an actor instance.
RayActor<Adder> adder = Ray.createActor(Adder.class);
// Use `Ray.call(actor, parameters)` to call an actor method.
RayObject<Integer> result1 = Ray.call(Adder::add, adder, 1);
System.out.println(result1.get());
@@ -24,7 +23,7 @@ public class Exercise05 {
} catch (Throwable t) {
t.printStackTrace();
} finally {
RayRuntime.getInstance().cleanUp();
Ray.shutdown();
}
}