diff --git a/.travis.yml b/.travis.yml index e781f3f6468b..c8aed3461545 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,17 @@ matrix: osx_image: xcode7 env: PYTHON=3.5 + - os: linux + dist: trusty + env: + - JDK='Oracle JDK 8' + - PYTHON=3.5 + install: + - ./.travis/install-dependencies.sh + - export PATH="$HOME/miniconda/bin:$PATH" + script: + - ./java/test.sh + - os: linux dist: trusty env: LINT=1 diff --git a/build.sh b/build.sh index 93d0b201a64c..7ab0ba3b1721 100755 --- a/build.sh +++ b/build.sh @@ -79,7 +79,7 @@ if [[ -z "$PYTHON_EXECUTABLE" ]]; then fi echo "Using Python executable $PYTHON_EXECUTABLE." -bash $ROOT_DIR/setup_thirdparty.sh $PYTHON_EXECUTABLE +bash $ROOT_DIR/setup_thirdparty.sh $PYTHON_EXECUTABLE $LANGUAGE # Now we build everything. if [[ "$LANGUAGE" == "java" ]]; then diff --git a/java/README.rst b/java/README.rst new file mode 100644 index 000000000000..d9205bd146af --- /dev/null +++ b/java/README.rst @@ -0,0 +1,395 @@ +This directory contains the java worker, with the following components. + +- java/api: Ray API definition +- java/common: utilities +- java/hook: binary rewrite of the Java byte-code for remote execution +- java/runtime-common: common implementation of the runtime in worker +- java/runtime-dev: a pure-java mock implementation of the runtime for + fast development +- java/runtime-native: a native implementation of the runtime +- java/test: various tests +- src/local\_scheduler/lib/java: JNI client library for local scheduler +- src/plasma/lib/java: JNI client library for plasma storage + +Build and test +============== + +:: + + # build native components + ../build.sh -l java + + # build java worker + mvn clean install -Dmaven.test.skip + + # test + export RAY_CONFIG=ray.config.ini + mvn test + +Quick start +=========== + +Starting Ray +------------ + +.. code:: java + + Ray.init(); + +Read and write remote objects +----------------------------- + +Each remote object is considered a ``RayObject`` where ``T`` is the +type for this object. You can use ``Ray.put`` and ``RayObject.get`` +to write and read the objects. + +.. code:: java + + Integer x = 1; + RayObject obj = Ray.put(x); + Integer x1 = obj.get(); + assert (x.equals(x1)); + +Remote functions +---------------- + +Here is an ordinary java code piece for composing +``hello world example``. + +.. code:: java + + public class ExampleClass { + public static void main(String[] args) { + String str1 = add("hello", "world"); + String str = add(str1, "example"); + System.out.println(str); + } + public static String add(String a, String b) { + return a + " " + b; + } + } + +We use ``@RayRemote`` to indicate that a function is remote, and use +``Ray.call`` to invoke it. The result from the latter is a +``RayObject`` where ``R`` is the return type of the target function. +The following shows the changed example with ``add`` annotated, and +correspondent calls executed on remote machines. + +.. code:: java + + public class ExampleClass { + public static void main(String[] args) { + Ray.init(); + RayObject objStr1 = Ray.call(ExampleClass::add, "hello", "world"); + RayObject objStr2 = Ray.call(ExampleClass::add, objStr1, "example"); + String str = objStr2.get(); + System.out.println(str); + } + + @RayRemote + public static String add(String a, String b) { + return a + " " + b; + } + } + +Ray Java API +============ + +Basic API +--------- + +``Ray.init()`` +~~~~~~~~~~~~~~ + +Ray.init should be invoked before any other Ray functions to initialize +the runtime. + +``@RayRemote`` +~~~~~~~~~~~~~~ + +The annotation of ``@RayRemote`` can be used to decorate static java +method or class. The former indicates that a target function is a remote +function, which is valid with the follow requirements. \* it must be a +public static method \* parameters and return value must not be the +primitive type of java such as int, double, but could use the wrapper +class like Integer,Double \* the return value of the method must always +be the same with the same input + +When the annotation is used for classes, the classes are considered +actors(a mechanism to share state among many remote functions). The +member functions can be invoked using ``Ray.call``. The requirements for +an actor class are as follows. \* it must have an constructor without +any parameter \* if it is an inner class, it must be public static \* it +must not have a member field or method decorated using +``public static``, as the semantic is undefined with multiple instances +of this same class on different machines \* an actor method must be +decorated using ``public`` but no ``static``, and the other requirements +are the same as above. + +``Ray.call`` +~~~~~~~~~~~~ + +.. code:: java + + RayObject call(Func func, ...); + +``func`` is the target method, continued with appropriate parameters. +There are some requirements here: + +- the return type of ``func`` must be ``R`` +- currently at most 6 parameters of ``func`` are allowed +- each parameter must be of type ``T`` of the correspondent ``func``'s + parameter, or be the lifted ``RayObject`` to indicate a result + from another ray call + +The returned object is labled as ``RayObject`` and its value will be +put into memory of the machine where the function call is executed. + +``Ray.put`` +~~~~~~~~~~~ + +You can also invoke ``Ray.put`` to explicitly place an object into local +memory. + +.. code:: java + + public static RayObject put(T object); + public static RayObject put(T obj, TM metadata); + +``RayObject.get/getMeta`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code:: java + + public class RayObject { + public T get() throws TaskExecutionException; + public M getMeta() throws TaskExecutionException; + } + +This method blocks current thread until requested data gets ready and is +fetched (if needed) from remote memory to local. + +``Ray.wait`` +~~~~~~~~~~~~ + +Calling ``Ray.wait`` will block current thread and wait for specified +ray calls. It returns when at least ``numReturns`` calls are completed, +or the ``timeout`` expires. See multi-value support for ``RayList``. + +.. code:: java + + public static WaitResult wait(RayList waitfor, int numReturns, int timeout); + public static WaitResult wait(RayList waitfor, int numReturns); + public static WaitResult wait(RayList waitfor); + +Multi-value API +--------------- + +Multi-value Types +~~~~~~~~~~~~~~~~~ + +Java worker supports multiple ``RayObject``\ s in a single data +structure as a return value or a ray call parameter, through the +following container types. + +``MultipleReturnsX`` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +There are multiple heterogeneous values, with their types as ``R0``, +``R1``,... respectively. Note currently this container type is only +supported as the return type of a ray call, therefore you can not use it +as the type of an input parameter. + +``RayList`` +'''''''''''''' + +A list of ``RayObject``, inherited from ``List`` in Java. It can +be used as the type for both return value and parameters. + +``RayMap`` +'''''''''''''''' + +A map of ``RayObject`` with each indexed using a label with type +``L``, inherited from ``Map``. It can be used as the type for both +return value and parameters. + +Enable multiple heterogeneous return values +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Java worker support at most four multiple heterogeneous return values, +and in order to let the runtime know the number of return values we +supply the method of ``Ray.call_X`` as follows. + +.. code:: java + + RayObjects2 call_2(Func func, ...); + RayObjects3 call_3(Func func, ...); + RayObjects4 call_4(Func func, ...); + +Note ``func`` must match the following requirements. + +- It must hava the return value of ``MultipleReturnsX``, and must be + invoked using correspondent ``Ray.call_X`` + +Here is an example. + +.. code:: java + + public class MultiRExample { + public static void main(String[] args) { + Ray.init(); + RayObjects2 refs = Ray.call_2(MultiRExample::sayMultiRet); + Integer obj1 = refs.r0().get(); + String obj2 = refs.r1().get(); + Assert.assertTrue(obj1.equals(123)); + Assert.assertTrue(obj2.equals("123")); + } + + @RayRemote + public static MultipleReturns2 sayMultiRet() { + return new MultipleReturns2(123, "123"); + } + } + +Return with ``RayList`` +~~~~~~~~~~~~~~~~~~~~~~~ + +We use ``Ray.call_n`` to do so, which is similar to ``Ray.call`` except +an additional parameter ``returnCount`` which tells the number of return +``RayObject`` in ``RayList``. This is because Ray core engines +needs to know it before the method is really called. + +.. code:: java + + RayList call_n(Func func, Integer returnCount, ...); + +Here is an example. + +.. code:: java + + public class ListRExample { + public static void main(String[] args) { + Ray.init(); + RayList ns = Ray.call_n(ListRExample::sayList, 10, 10); + for (int i = 0; i < 10; i++) { + RayObject obj = ns.Get(i); + Assert.assertTrue(i == obj.get()); + } + } + + @RayRemote + public static List sayList(Integer count) { + ArrayList rets = new ArrayList<>(); + for (int i = 0; i < count; i++) + rets.add(i); + return rets; + } + } + +Return with ``RayMap`` +~~~~~~~~~~~~~~~~~~~~~~ + +This is similar to ``RayList`` case, except that now each return +``RayObject`` in ``RayMap`` has a given label when +``Ray.call_n`` is made. + +.. code:: java + + RayMap call_n(Func func, Collection returnLabels, ...); + +Here is an example. + +.. code:: java + + public class MapRExample { + public static void main(String[] args) { + Ray.init(); + RayMap ns = Ray.call_n(MapRExample::sayMap, + Arrays.asList(1, 2, 4, 3), "n_futures_"); + for (Entry> ne : ns.EntrySet()) { + Integer key = ne.getKey(); + RayObject obj = ne.getValue(); + Assert.assertTrue(obj.get().equals("n_futures_" + key)); + } + } + + @RayRemote(externalIO = true) + public static Map sayMap(Collection ids, + String prefix) { + Map ret = new HashMap<>(); + for (int id : ids) { + ret.put(id, prefix + id); + } + return ret; + } + } + +Enable ``RayList`` and ``RayMap`` as parameters +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code:: java + + public class ListTExample { + public static void main(String[] args) { + Ray.init(); + RayList ints = new RayList<>(); + ints.add(Ray.put(new Integer(1))); + ints.add(Ray.put(new Integer(1))); + ints.add(Ray.put(new Integer(1))); + RayObject obj = Ray.call(ListTExample::sayReadRayList, + (List)ints); + Assert.assertTrue(obj.get().equals(3)); + } + + @RayRemote + public static int sayReadRayList(List ints) { + int sum = 0; + for (Integer i : ints) { + sum += i; + } + return sum; + } + } + +Actor Support +------------- + +Create Actors +~~~~~~~~~~~~~ + +A regular class annotated with ``@RayRemote`` is an actor class. + +.. code:: java + + @RayRemote + public class Adder { + public Adder() { + sum = 0; + } + + public Integer add(Integer n) { + return sum += n; + } + + private Integer sum; + } + +Whenever you call ``Ray.create()`` method, an actor will be created, and +you get a local ``RayActor`` of that actor as the return value. + +.. code:: java + + RayActor adder = Ray.create(Adder.class); + +Call Actor Methods +~~~~~~~~~~~~~~~~~~ + +The same ``Ray.call`` or its extended versions (e.g., ``Ray.call_n``) is +applied, except that the first argument becomes ``RayActor``. + +.. code:: java + + RayObject Ray.call(Func func, RayActor actor, ...); + RayObject result1 = Ray.call(Adder::add, adder, 1); + RayObject result2 = Ray.call(Adder::add, adder, 10); + result2.get(); // 11 \ No newline at end of file diff --git a/java/api/pom.xml b/java/api/pom.xml new file mode 100644 index 000000000000..8972aba8c6ad --- /dev/null +++ b/java/api/pom.xml @@ -0,0 +1,54 @@ + + + + + org.ray.parent + ray-superpom + 1.0 + + 4.0.0 + + org.ray + ray-api + java api for ray + java api for ray + + + jar + + + + + org.ray + ray-common + 1.0 + + + + + commons-cli + commons-cli + 1.2 + + + + + org.apache.commons + commons-lang3 + 3.4 + + + de.ruedigermoeller + fst + 2.47 + + + org.apache.arrow + arrow-plasma + + + + + diff --git a/java/api/src/main/java/org/ray/api/Ray.java b/java/api/src/main/java/org/ray/api/Ray.java new file mode 100644 index 000000000000..38e14f1b844d --- /dev/null +++ b/java/api/src/main/java/org/ray/api/Ray.java @@ -0,0 +1,119 @@ +package org.ray.api; + +import java.util.List; +import org.ray.api.internal.RayConnector; +import org.ray.util.exception.TaskExecutionException; +import org.ray.util.logger.DynamicLog; +import org.ray.util.logger.RayLog; + +/** + * Ray API + */ +public final class Ray extends Rpc { + + /** + * initialize the current worker or the single-box cluster + */ + public static void init() { + if (impl == null) { + impl = RayConnector.run(); + } + } + + /** + * Put obj into object store + */ + public static RayObject put(T obj) { + return impl.put(obj); + } + + public static RayObject put(T obj, TM metadata) { + return impl.put(obj, metadata); + } + + /** + * Get obj(s) from object store + */ + static T get(UniqueID objectId) throws TaskExecutionException { + return impl.get(objectId); + } + + static T getMeta(UniqueID objectId) throws TaskExecutionException { + return impl.getMeta(objectId); + } + + static List get(List objectIds) throws TaskExecutionException { + return impl.get(objectIds); + } + + static List getMeta(List objectIds) throws TaskExecutionException { + return impl.getMeta(objectIds); + } + + /** + * wait until timeout or enough RayObject are ready + * + * @param waitfor wait for who + * @param numReturns how many of ready is enough + * @param timeoutMilliseconds in millisecond + */ + public static WaitResult wait(RayList waitfor, int numReturns, + int timeoutMilliseconds) { + return impl.wait(waitfor, numReturns, timeoutMilliseconds); + } + + public static WaitResult wait(RayList waitfor, int numReturns) { + return impl.wait(waitfor, numReturns, Integer.MAX_VALUE); + } + + public static WaitResult wait(RayList waitfor) { + return impl.wait(waitfor, waitfor.size(), Integer.MAX_VALUE); + } + + public static WaitResult wait(RayObject waitfor, int timeoutMilliseconds) { + RayList waits = new RayList<>(); + waits.add(waitfor); + return impl.wait(waits, 1, timeoutMilliseconds); + } + + /** + * create actor object + */ + public static RayActor create(Class 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 " + cls.getName() + + " does not (actors must) have a constructor with no arguments"); + } + } catch (Exception e) { + System.exit(1); + return null; + } + return impl.create(cls); + } + + /** + * get underlying runtime + */ + static RayApi internal() { + return impl; + } + + /** + * whether to use remote lambda + */ + public static boolean isRemoteLambda() { + return impl.isRemoteLambda(); + } + + private static RayApi impl = null; + + /** + * for ray's app's log + */ + public static DynamicLog getRappLogger() { + return RayLog.rapp; + } +} diff --git a/java/api/src/main/java/org/ray/api/RayActor.java b/java/api/src/main/java/org/ray/api/RayActor.java new file mode 100644 index 000000000000..6f00a6e781f1 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/RayActor.java @@ -0,0 +1,87 @@ +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; + +/** + * Ray actor abstraction + */ +public class RayActor extends RayObject implements Externalizable { + + 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++; + } + + /** + * Getter method for property taskCursor + * + * @return property value of taskCursor + */ + public UniqueID getTaskCursor() { + return taskCursor; + } + + /** + * Setter method for property taskCursor + * + * @param taskCursor value to be assigned to property taskCursor + */ + public void setTaskCursor(UniqueID taskCursor) { + this.taskCursor = taskCursor; + } + + public UniqueID computeNextActorHandleId() { + byte[] bytes = Sha1Digestor.digest(actorHandleId.id, ++forksNum); + return new UniqueID(bytes); + } + + 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); + } + + @Override + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + + this.id = (UniqueID) in.readObject(); + this.actorHandleId = (UniqueID) in.readObject(); + this.taskCursor = (UniqueID) in.readObject(); + } +} diff --git a/java/api/src/main/java/org/ray/api/RayApi.java b/java/api/src/main/java/org/ray/api/RayApi.java new file mode 100644 index 000000000000..23c075d11215 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/RayApi.java @@ -0,0 +1,101 @@ +package org.ray.api; + +import java.io.Serializable; +import java.util.Collection; +import java.util.List; +import org.ray.api.internal.Callable; +import org.ray.util.exception.TaskExecutionException; + +/** + * Ray runtime abstraction + */ +public interface RayApi { + + /** + * Put obj into object store + * + * @return RayObject + */ + RayObject put(T obj); + + RayObject put(T obj, TM metadata); + + /** + * Get real obj from object store + */ + T get(UniqueID objectId) throws TaskExecutionException; + + T getMeta(UniqueID objectId) throws TaskExecutionException; + + /** + * Get real objects from object store + * + * @param objectIds list of ids of objects to get + */ + List get(List objectIds) throws TaskExecutionException; + + List getMeta(List 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 + */ + WaitResult wait(RayList waitfor, int numReturns, int timeout); + + /** + * create remote actor + */ + RayActor create(Class cls); + + /** + * submit a new task by invoking a remote function + * + * @param taskId nil + * @param funcRun the target running function with @RayRemote + * @param returnCount the number of to-be-returned objects from funcRun + * @param args arguments to this funcRun, can be its original form or RayObject + * @return a set of ray objects with their return ids + */ + RayObjects call(UniqueID taskId, Callable funcRun, int returnCount, Object... args); + + RayObjects call(UniqueID taskId, Class funcCls, Serializable lambda, int returnCount, + Object... args); + + /** + * In some cases, we would like the return value of a remote function to be splitted into multiple + * parts so that they are consumed by multiple further functions separately (potentially on + * different machines). We therefore introduce this API so that developers can annotate the + * outputs with a set of labels (usually with Integer or String) + * + * @param taskId nil + * @param funcRun the target running function with @RayRemote + * @param returnIds a set of labels to be used by the returned objects + * @param args arguments to this funcRun, can be its original form or RayObject + * @return a set of ray objects with their labels and return ids + */ + RayMap callWithReturnLabels(UniqueID taskId, Callable funcRun, + Collection returnIds, Object... args); + + RayMap callWithReturnLabels(UniqueID taskId, Class funcCls, + Serializable lambda, Collection returnids, Object... args); + + /** + * a special case for the above RID-based labeling as <0...returnCount - 1> + * + * @param taskId nil + * @param funcRun the target running function with @RayRemote + * @param returnCount the number of to-be-returned objects from funcRun + * @param args arguments to this funcRun, can be its original form or RayObject + * @return an array of returned objects with their Unique ids + */ + RayList callWithReturnIndices(UniqueID taskId, Callable funcRun, Integer returnCount, + Object... args); + + RayList callWithReturnIndices(UniqueID taskId, Class funcCls, Serializable lambda, + Integer returnCount, Object... args); + + boolean isRemoteLambda(); +} diff --git a/java/api/src/main/java/org/ray/api/RayDisabled.java b/java/api/src/main/java/org/ray/api/RayDisabled.java new file mode 100644 index 000000000000..d123f9cdce55 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/RayDisabled.java @@ -0,0 +1,5 @@ +package org.ray.api; + +public @interface RayDisabled { + +} diff --git a/java/api/src/main/java/org/ray/api/RayList.java b/java/api/src/main/java/org/ray/api/RayList.java new file mode 100644 index 000000000000..4d3d240181fa --- /dev/null +++ b/java/api/src/main/java/org/ray/api/RayList.java @@ -0,0 +1,213 @@ +package org.ray.api; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +/** + * A RayList<E> holds a list of RayObject<E>, + * and can serves as parameters and/or return values of Ray calls. + */ +public class RayList extends ArrayList { + + private static final long serialVersionUID = 2129403593610953658L; + + private final ArrayList> ids = new ArrayList<>(); + + public List> Objects() { + return ids; + } + + @Override + public int size() { + // throw new UnsupportedOperationException(); + return ids.size(); + } + + @Override + public boolean isEmpty() { + // throw new UnsupportedOperationException(); + return ids.isEmpty(); + } + + @Override + public boolean contains(Object o) { + // throw new UnsupportedOperationException(); + return ids.contains(o); + } + + @RayDisabled + @Deprecated + @Override + public Iterator iterator() { + throw new UnsupportedOperationException(); + } + + public Iterator> Iterator() { + return ids.iterator(); + } + + @Override + public Object[] toArray() { + //throw new UnsupportedOperationException(); + return ids.toArray(); + } + + @Override + public T[] toArray(T[] a) { + //throw new UnsupportedOperationException(); + return ids.toArray(a); + } + + @RayDisabled + @Deprecated + @Override + public boolean add(E e) { + throw new UnsupportedOperationException(); + } + + public boolean add(RayObject e) { + return ids.add(e); + } + + @Override + public boolean remove(Object o) { + //throw new UnsupportedOperationException(); + return ids.remove(o); + } + + @Override + public boolean containsAll(Collection c) { + //throw new UnsupportedOperationException(); + return ids.containsAll(c); + } + + @RayDisabled + @Deprecated + @Override + public boolean addAll(Collection c) { + throw new UnsupportedOperationException(); + } + + @RayDisabled + @Deprecated + @Override + public boolean addAll(int index, Collection c) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean removeAll(Collection c) { + //throw new UnsupportedOperationException(); + return ids.removeAll(c); + } + + @Override + public boolean retainAll(Collection c) { + //throw new UnsupportedOperationException(); + return ids.retainAll(c); + } + + @Override + public void clear() { + //throw new UnsupportedOperationException(); + ids.clear(); + } + + public List get() { + List objectIds = new ArrayList<>(); + for (RayObject id : ids) { + objectIds.add(id.getId()); + } + return Ray.get(objectIds); + } + + public List getMeta() { + List objectIds = new ArrayList<>(); + for (RayObject id : ids) { + objectIds.add(id.getId()); + } + return Ray.getMeta(objectIds); + } + + @Override + public E get(int index) { + return ids.get(index).get(); + } + + public TM getMeta(int index) { + return ids.get(index).getMeta(); + } + + public RayObject Get(int index) { + return ids.get(index); + } + + @RayDisabled + @Deprecated + @Override + public E set(int index, E element) { + throw new UnsupportedOperationException(); + } + + public RayObject set(int index, RayObject element) { + return ids.set(index, element); + } + + @RayDisabled + @Deprecated + @Override + public void add(int index, E element) { + throw new UnsupportedOperationException(); + } + + public void add(int index, RayObject element) { + ids.add(index, element); + } + + @RayDisabled + @Deprecated + @Override + public E remove(int index) { + throw new UnsupportedOperationException(); + } + + public RayObject Remove(int index) { + return ids.remove(index); + } + + @Override + public int indexOf(Object o) { + //throw new UnsupportedOperationException(); + return ids.indexOf(o); + } + + @Override + public int lastIndexOf(Object o) { + //throw new UnsupportedOperationException(); + return ids.lastIndexOf(o); + } + + @RayDisabled + @Deprecated + @Override + public ListIterator listIterator() { + throw new UnsupportedOperationException(); + } + + @RayDisabled + @Deprecated + @Override + public ListIterator listIterator(int index) { + throw new UnsupportedOperationException(); + } + + @RayDisabled + @Deprecated + @Override + public List subList(int fromIndex, int toIndex) { + throw new UnsupportedOperationException(); + } +} diff --git a/java/api/src/main/java/org/ray/api/RayMap.java b/java/api/src/main/java/org/ray/api/RayMap.java new file mode 100644 index 000000000000..031aaf7fe3dc --- /dev/null +++ b/java/api/src/main/java/org/ray/api/RayMap.java @@ -0,0 +1,138 @@ +package org.ray.api; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * A RayMap<K> maintains a map from K to RayObject<V>, + * and serves as parameters and/or return values of Ray calls. + */ +public class RayMap extends HashMap { + + private static final long serialVersionUID = 7296072498584721265L; + + private final HashMap> ids = new HashMap<>(); + + public HashMap> Objects() { + return ids; + } + + @Override + public int size() { + // throw new UnsupportedOperationException(); + return ids.size(); + } + + @Override + public boolean isEmpty() { + //throw new UnsupportedOperationException(); + return ids.isEmpty(); + } + + @Override + public boolean containsKey(Object key) { + //throw new UnsupportedOperationException(); + return ids.containsKey(key); + } + + @Override + public boolean containsValue(Object value) { + //throw new UnsupportedOperationException(); + return ids.containsValue(value); + } + + // TODO: try to use multiple get + public Map get() { + Map objs = new HashMap<>(); + for (Map.Entry> id : ids.entrySet()) { + objs.put(id.getKey(), id.getValue().get()); + } + return objs; + } + + public Map getMeta() { + Map metas = new HashMap<>(); + for (Map.Entry> id : ids.entrySet()) { + TM meta = id.getValue().getMeta(); + metas.put(id.getKey(), meta); + } + return metas; + } + + @Override + public V get(Object key) { + return ids.get(key).get(); + } + + public TM getMeta(K key) { + return ids.get(key).getMeta(); + } + + public RayObject Get(K key) { + return ids.get(key); + } + + @RayDisabled + @Deprecated + @Override + public V put(K key, V value) { + throw new UnsupportedOperationException(); + } + + public RayObject put(K key, RayObject value) { + return ids.put(key, value); + } + + @RayDisabled + @Deprecated + @Override + public V remove(Object key) { + throw new UnsupportedOperationException(); + } + + public RayObject Remove(K key) { + return ids.remove(key); + } + + @RayDisabled + @Deprecated + @Override + public void putAll(Map m) { + throw new UnsupportedOperationException(); + } + + @Override + public void clear() { + //throw new UnsupportedOperationException(); + ids.clear(); + } + + @Override + public Set keySet() { + return ids.keySet(); + } + + @RayDisabled + @Deprecated + @Override + public Collection values() { + throw new UnsupportedOperationException(); + } + + public Collection> Values() { + return ids.values(); + } + + @RayDisabled + @Deprecated + @Override + public Set> entrySet() { + throw new UnsupportedOperationException(); + } + + public Set>> EntrySet() { + return ids.entrySet(); + } +} diff --git a/java/api/src/main/java/org/ray/api/RayObject.java b/java/api/src/main/java/org/ray/api/RayObject.java new file mode 100644 index 000000000000..2493e19d023a --- /dev/null +++ b/java/api/src/main/java/org/ray/api/RayObject.java @@ -0,0 +1,35 @@ +package org.ray.api; + +import java.io.Serializable; +import org.ray.util.exception.TaskExecutionException; + +/** + * RayObject<T> 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. + */ +public class RayObject implements Serializable { + + private static final long serialVersionUID = 3250003902037418062L; + + UniqueID id; + + public RayObject() { + } + + public RayObject(UniqueID id) { + this.id = id; + } + + public T get() throws TaskExecutionException { + return Ray.get(id); + } + + public TM getMeta() throws TaskExecutionException { + return Ray.getMeta(id); + } + + public UniqueID getId() { + return id; + } + +} diff --git a/java/api/src/main/java/org/ray/api/RayObjects.java b/java/api/src/main/java/org/ray/api/RayObjects.java new file mode 100644 index 000000000000..d56b2673e756 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/RayObjects.java @@ -0,0 +1,32 @@ +package org.ray.api; + +import org.apache.commons.lang3.ArrayUtils; + +/** + * Real object or ray future proxy for multiple returns + */ +public class RayObjects { + + protected RayObject[] objs; + + public RayObjects(UniqueID[] ids) { + this.objs = new RayObject[ids.length]; + for (int k = 0; k < ids.length; k++) { + this.objs[k] = new RayObject<>(ids[k]); + } + } + + public RayObjects(RayObject[] objs) { + this.objs = objs; + } + + public RayObject pop() { + RayObject lastObj = objs[objs.length - 1]; + objs = ArrayUtils.subarray(objs, 0, objs.length - 1); + return lastObj; + } + + public RayObject[] getObjs() { + return objs; + } +} diff --git a/java/api/src/main/java/org/ray/api/RayRemote.java b/java/api/src/main/java/org/ray/api/RayRemote.java new file mode 100644 index 000000000000..23c5399e9ed5 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/RayRemote.java @@ -0,0 +1,20 @@ +package org.ray.api; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * a ray remote function or class (as an actor) + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +public @interface RayRemote { + + /** + * whether to use external I/O pool to execute the function + */ + boolean externalIO() default false; + +} diff --git a/java/api/src/main/java/org/ray/api/RayService.java b/java/api/src/main/java/org/ray/api/RayService.java new file mode 100644 index 000000000000..3dfefcf2915b --- /dev/null +++ b/java/api/src/main/java/org/ray/api/RayService.java @@ -0,0 +1,10 @@ +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 { + +} diff --git a/java/api/src/main/java/org/ray/api/Rpc.java b/java/api/src/main/java/org/ray/api/Rpc.java new file mode 100644 index 000000000000..d774c7df7b66 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/Rpc.java @@ -0,0 +1,9325 @@ +package org.ray.api; + +import java.util.Collection; +import org.ray.api.funcs.RayFunc_0_1; +import org.ray.api.funcs.RayFunc_0_2; +import org.ray.api.funcs.RayFunc_0_3; +import org.ray.api.funcs.RayFunc_0_4; +import org.ray.api.funcs.RayFunc_0_n; +import org.ray.api.funcs.RayFunc_0_n_list; +import org.ray.api.funcs.RayFunc_1_1; +import org.ray.api.funcs.RayFunc_1_2; +import org.ray.api.funcs.RayFunc_1_3; +import org.ray.api.funcs.RayFunc_1_4; +import org.ray.api.funcs.RayFunc_1_n; +import org.ray.api.funcs.RayFunc_1_n_list; +import org.ray.api.funcs.RayFunc_2_1; +import org.ray.api.funcs.RayFunc_2_2; +import org.ray.api.funcs.RayFunc_2_3; +import org.ray.api.funcs.RayFunc_2_4; +import org.ray.api.funcs.RayFunc_2_n; +import org.ray.api.funcs.RayFunc_2_n_list; +import org.ray.api.funcs.RayFunc_3_1; +import org.ray.api.funcs.RayFunc_3_2; +import org.ray.api.funcs.RayFunc_3_3; +import org.ray.api.funcs.RayFunc_3_4; +import org.ray.api.funcs.RayFunc_3_n; +import org.ray.api.funcs.RayFunc_3_n_list; +import org.ray.api.funcs.RayFunc_4_1; +import org.ray.api.funcs.RayFunc_4_2; +import org.ray.api.funcs.RayFunc_4_3; +import org.ray.api.funcs.RayFunc_4_4; +import org.ray.api.funcs.RayFunc_4_n; +import org.ray.api.funcs.RayFunc_4_n_list; +import org.ray.api.funcs.RayFunc_5_1; +import org.ray.api.funcs.RayFunc_5_2; +import org.ray.api.funcs.RayFunc_5_3; +import org.ray.api.funcs.RayFunc_5_4; +import org.ray.api.funcs.RayFunc_5_n; +import org.ray.api.funcs.RayFunc_5_n_list; +import org.ray.api.funcs.RayFunc_6_1; +import org.ray.api.funcs.RayFunc_6_2; +import org.ray.api.funcs.RayFunc_6_3; +import org.ray.api.funcs.RayFunc_6_4; +import org.ray.api.funcs.RayFunc_6_n; +import org.ray.api.funcs.RayFunc_6_n_list; +import org.ray.api.returns.RayObjects2; +import org.ray.api.returns.RayObjects3; +import org.ray.api.returns.RayObjects4; + +@SuppressWarnings({"rawtypes", "unchecked"}) +class Rpc { + + public static RayList call_n(RayFunc_0_n_list f, Integer returnCount) { + if (Ray.isRemoteLambda()) { + return Ray.internal().callWithReturnIndices(null, RayFunc_0_n_list.class, f, returnCount); + } else { + return Ray.internal().callWithReturnIndices(null, () -> f.apply(), returnCount); + } + } + + public static RayMap call_n(RayFunc_0_n f, Collection returnids) { + if (Ray.isRemoteLambda()) { + return Ray.internal().callWithReturnLabels(null, RayFunc_0_n.class, f, returnids); + } else { + return Ray.internal().callWithReturnLabels(null, () -> f.apply(null), returnids); + } + } + + public static RayObject call(RayFunc_0_1 f) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_0_1.class, f, 1).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(), 1).objs[0]; + } + } + + public static RayObjects2 call_2(RayFunc_0_2 f) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_0_2.class, f, 2).objs); + } else { + return new RayObjects2(Ray.internal().call(null, () -> f.apply(), 2).objs); + } + } + + public static RayObjects3 call_3(RayFunc_0_3 f) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_0_3.class, f, 3).objs); + } else { + return new RayObjects3(Ray.internal().call(null, () -> f.apply(), 3).objs); + } + } + + public static RayObjects4 call_4(RayFunc_0_4 f) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_0_4.class, f, 4).objs); + } else { + return new RayObjects4(Ray.internal().call(null, () -> f.apply(), 4).objs); + } + } + + public static RayList call_n(RayFunc_1_n_list f, Integer returnCount, T0 t0) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_1_n_list.class, f, returnCount, t0); + } else { + return Ray.internal().callWithReturnIndices(null, () -> f.apply(null), returnCount, t0); + } + } + + public static RayList call_n(RayFunc_1_n_list f, Integer returnCount, + RayObject t0) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_1_n_list.class, f, returnCount, t0); + } else { + return Ray.internal().callWithReturnIndices(null, () -> f.apply(null), returnCount, t0); + } + } + + public static RayMap call_n(RayFunc_1_n f, + Collection returnids, T0 t0) { + if (Ray.isRemoteLambda()) { + return Ray.internal().callWithReturnLabels(null, RayFunc_1_n.class, f, returnids, t0); + } else { + return Ray.internal().callWithReturnLabels(null, () -> f.apply(null, null), returnids, t0); + } + } + + public static RayMap call_n(RayFunc_1_n f, + Collection returnids, RayObject t0) { + if (Ray.isRemoteLambda()) { + return Ray.internal().callWithReturnLabels(null, RayFunc_1_n.class, f, returnids, t0); + } else { + return Ray.internal().callWithReturnLabels(null, () -> f.apply(null, null), returnids, t0); + } + } + + public static RayObject call(RayFunc_1_1 f, T0 t0) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_1_1.class, f, 1, t0).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null), 1, t0).objs[0]; + } + } + + public static RayObject call(RayFunc_1_1 f, RayObject t0) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_1_1.class, f, 1, t0).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null), 1, t0).objs[0]; + } + } + + public static RayObjects2 call_2(RayFunc_1_2 f, T0 t0) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_1_2.class, f, 2, t0).objs); + } else { + return new RayObjects2(Ray.internal().call(null, () -> f.apply(null), 2, t0).objs); + } + } + + public static RayObjects2 call_2(RayFunc_1_2 f, + RayObject t0) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_1_2.class, f, 2, t0).objs); + } else { + return new RayObjects2(Ray.internal().call(null, () -> f.apply(null), 2, t0).objs); + } + } + + public static RayObjects3 call_3(RayFunc_1_3 f, + T0 t0) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_1_3.class, f, 3, t0).objs); + } else { + return new RayObjects3(Ray.internal().call(null, () -> f.apply(null), 3, t0).objs); + } + } + + public static RayObjects3 call_3(RayFunc_1_3 f, + RayObject t0) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_1_3.class, f, 3, t0).objs); + } else { + return new RayObjects3(Ray.internal().call(null, () -> f.apply(null), 3, t0).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_1_4 f, T0 t0) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_1_4.class, f, 4, t0).objs); + } else { + return new RayObjects4(Ray.internal().call(null, () -> f.apply(null), 4, t0).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_1_4 f, RayObject t0) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_1_4.class, f, 4, t0).objs); + } else { + return new RayObjects4(Ray.internal().call(null, () -> f.apply(null), 4, t0).objs); + } + } + + public static RayList call_n(RayFunc_2_n_list f, Integer returnCount, + T0 t0, T1 t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_2_n_list.class, f, returnCount, t0, t1); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null), returnCount, t0, t1); + } + } + + public static RayList call_n(RayFunc_2_n_list f, Integer returnCount, + RayObject t0, T1 t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_2_n_list.class, f, returnCount, t0, t1); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null), returnCount, t0, t1); + } + } + + public static RayList call_n(RayFunc_2_n_list f, Integer returnCount, + T0 t0, RayObject t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_2_n_list.class, f, returnCount, t0, t1); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null), returnCount, t0, t1); + } + } + + public static RayList call_n(RayFunc_2_n_list f, Integer returnCount, + RayObject t0, RayObject t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_2_n_list.class, f, returnCount, t0, t1); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null), returnCount, t0, t1); + } + } + + public static RayMap call_n(RayFunc_2_n f, + Collection returnids, T0 t0, T1 t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal().callWithReturnLabels(null, RayFunc_2_n.class, f, returnids, t0, t1); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null), returnids, t0, t1); + } + } + + public static RayMap call_n(RayFunc_2_n f, + Collection returnids, RayObject t0, T1 t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal().callWithReturnLabels(null, RayFunc_2_n.class, f, returnids, t0, t1); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null), returnids, t0, t1); + } + } + + public static RayMap call_n(RayFunc_2_n f, + Collection returnids, T0 t0, RayObject t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal().callWithReturnLabels(null, RayFunc_2_n.class, f, returnids, t0, t1); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null), returnids, t0, t1); + } + } + + public static RayMap call_n(RayFunc_2_n f, + Collection returnids, RayObject t0, RayObject t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal().callWithReturnLabels(null, RayFunc_2_n.class, f, returnids, t0, t1); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null), returnids, t0, t1); + } + } + + public static RayObject call(RayFunc_2_1 f, T0 t0, T1 t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_2_1.class, f, 1, t0, t1).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null), 1, t0, t1).objs[0]; + } + } + + public static RayObject call(RayFunc_2_1 f, RayObject t0, + T1 t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_2_1.class, f, 1, t0, t1).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null), 1, t0, t1).objs[0]; + } + } + + public static RayObject call(RayFunc_2_1 f, T0 t0, + RayObject t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_2_1.class, f, 1, t0, t1).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null), 1, t0, t1).objs[0]; + } + } + + public static RayObject call(RayFunc_2_1 f, RayObject t0, + RayObject t1) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_2_1.class, f, 1, t0, t1).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null), 1, t0, t1).objs[0]; + } + } + + public static RayObjects2 call_2(RayFunc_2_2 f, T0 t0, + T1 t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_2_2.class, f, 2, t0, t1).objs); + } else { + return new RayObjects2(Ray.internal().call(null, () -> f.apply(null, null), 2, t0, t1).objs); + } + } + + public static RayObjects2 call_2(RayFunc_2_2 f, + RayObject t0, T1 t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_2_2.class, f, 2, t0, t1).objs); + } else { + return new RayObjects2(Ray.internal().call(null, () -> f.apply(null, null), 2, t0, t1).objs); + } + } + + public static RayObjects2 call_2(RayFunc_2_2 f, T0 t0, + RayObject t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_2_2.class, f, 2, t0, t1).objs); + } else { + return new RayObjects2(Ray.internal().call(null, () -> f.apply(null, null), 2, t0, t1).objs); + } + } + + public static RayObjects2 call_2(RayFunc_2_2 f, + RayObject t0, RayObject t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_2_2.class, f, 2, t0, t1).objs); + } else { + return new RayObjects2(Ray.internal().call(null, () -> f.apply(null, null), 2, t0, t1).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_2_3 f, T0 t0, T1 t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_2_3.class, f, 3, t0, t1).objs); + } else { + return new RayObjects3(Ray.internal().call(null, () -> f.apply(null, null), 3, t0, t1).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_2_3 f, RayObject t0, T1 t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_2_3.class, f, 3, t0, t1).objs); + } else { + return new RayObjects3(Ray.internal().call(null, () -> f.apply(null, null), 3, t0, t1).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_2_3 f, T0 t0, RayObject t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_2_3.class, f, 3, t0, t1).objs); + } else { + return new RayObjects3(Ray.internal().call(null, () -> f.apply(null, null), 3, t0, t1).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_2_3 f, RayObject t0, RayObject t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_2_3.class, f, 3, t0, t1).objs); + } else { + return new RayObjects3(Ray.internal().call(null, () -> f.apply(null, null), 3, t0, t1).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_2_4 f, T0 t0, T1 t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_2_4.class, f, 4, t0, t1).objs); + } else { + return new RayObjects4(Ray.internal().call(null, () -> f.apply(null, null), 4, t0, t1).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_2_4 f, RayObject t0, T1 t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_2_4.class, f, 4, t0, t1).objs); + } else { + return new RayObjects4(Ray.internal().call(null, () -> f.apply(null, null), 4, t0, t1).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_2_4 f, T0 t0, RayObject t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_2_4.class, f, 4, t0, t1).objs); + } else { + return new RayObjects4(Ray.internal().call(null, () -> f.apply(null, null), 4, t0, t1).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_2_4 f, RayObject t0, RayObject t1) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_2_4.class, f, 4, t0, t1).objs); + } else { + return new RayObjects4(Ray.internal().call(null, () -> f.apply(null, null), 4, t0, t1).objs); + } + } + + public static RayList call_n(RayFunc_3_n_list f, + Integer returnCount, T0 t0, T1 t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_3_n_list.class, f, returnCount, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null), returnCount, t0, t1, t2); + } + } + + public static RayList call_n(RayFunc_3_n_list f, + Integer returnCount, RayObject t0, T1 t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_3_n_list.class, f, returnCount, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null), returnCount, t0, t1, t2); + } + } + + public static RayList call_n(RayFunc_3_n_list f, + Integer returnCount, T0 t0, RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_3_n_list.class, f, returnCount, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null), returnCount, t0, t1, t2); + } + } + + public static RayList call_n(RayFunc_3_n_list f, + Integer returnCount, RayObject t0, RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_3_n_list.class, f, returnCount, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null), returnCount, t0, t1, t2); + } + } + + public static RayList call_n(RayFunc_3_n_list f, + Integer returnCount, T0 t0, T1 t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_3_n_list.class, f, returnCount, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null), returnCount, t0, t1, t2); + } + } + + public static RayList call_n(RayFunc_3_n_list f, + Integer returnCount, RayObject t0, T1 t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_3_n_list.class, f, returnCount, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null), returnCount, t0, t1, t2); + } + } + + public static RayList call_n(RayFunc_3_n_list f, + Integer returnCount, T0 t0, RayObject t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_3_n_list.class, f, returnCount, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null), returnCount, t0, t1, t2); + } + } + + public static RayList call_n(RayFunc_3_n_list f, + Integer returnCount, RayObject t0, RayObject t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_3_n_list.class, f, returnCount, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null), returnCount, t0, t1, t2); + } + } + + public static RayMap call_n(RayFunc_3_n f, + Collection returnids, T0 t0, T1 t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_3_n.class, f, returnids, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null), returnids, t0, t1, + t2); + } + } + + public static RayMap call_n(RayFunc_3_n f, + Collection returnids, RayObject t0, T1 t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_3_n.class, f, returnids, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null), returnids, t0, t1, + t2); + } + } + + public static RayMap call_n(RayFunc_3_n f, + Collection returnids, T0 t0, RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_3_n.class, f, returnids, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null), returnids, t0, t1, + t2); + } + } + + public static RayMap call_n(RayFunc_3_n f, + Collection returnids, RayObject t0, RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_3_n.class, f, returnids, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null), returnids, t0, t1, + t2); + } + } + + public static RayMap call_n(RayFunc_3_n f, + Collection returnids, T0 t0, T1 t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_3_n.class, f, returnids, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null), returnids, t0, t1, + t2); + } + } + + public static RayMap call_n(RayFunc_3_n f, + Collection returnids, RayObject t0, T1 t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_3_n.class, f, returnids, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null), returnids, t0, t1, + t2); + } + } + + public static RayMap call_n(RayFunc_3_n f, + Collection returnids, T0 t0, RayObject t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_3_n.class, f, returnids, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null), returnids, t0, t1, + t2); + } + } + + public static RayMap call_n(RayFunc_3_n f, + Collection returnids, RayObject t0, RayObject t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_3_n.class, f, returnids, t0, t1, t2); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null), returnids, t0, t1, + t2); + } + } + + public static RayObject call(RayFunc_3_1 f, T0 t0, T1 t1, + T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_3_1.class, f, 1, t0, t1, t2).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null, null), 1, t0, t1, t2).objs[0]; + } + } + + public static RayObject call(RayFunc_3_1 f, RayObject t0, + T1 t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_3_1.class, f, 1, t0, t1, t2).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null, null), 1, t0, t1, t2).objs[0]; + } + } + + public static RayObject call(RayFunc_3_1 f, T0 t0, + RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_3_1.class, f, 1, t0, t1, t2).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null, null), 1, t0, t1, t2).objs[0]; + } + } + + public static RayObject call(RayFunc_3_1 f, RayObject t0, + RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_3_1.class, f, 1, t0, t1, t2).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null, null), 1, t0, t1, t2).objs[0]; + } + } + + public static RayObject call(RayFunc_3_1 f, T0 t0, T1 t1, + RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_3_1.class, f, 1, t0, t1, t2).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null, null), 1, t0, t1, t2).objs[0]; + } + } + + public static RayObject call(RayFunc_3_1 f, RayObject t0, + T1 t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_3_1.class, f, 1, t0, t1, t2).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null, null), 1, t0, t1, t2).objs[0]; + } + } + + public static RayObject call(RayFunc_3_1 f, T0 t0, + RayObject t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_3_1.class, f, 1, t0, t1, t2).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null, null), 1, t0, t1, t2).objs[0]; + } + } + + public static RayObject call(RayFunc_3_1 f, RayObject t0, + RayObject t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_3_1.class, f, 1, t0, t1, t2).objs[0]; + } else { + return Ray.internal().call(null, () -> f.apply(null, null, null), 1, t0, t1, t2).objs[0]; + } + } + + public static RayObjects2 call_2(RayFunc_3_2 f, + T0 t0, T1 t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_3_2.class, f, 2, t0, t1, t2).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null), 2, t0, t1, t2).objs); + } + } + + public static RayObjects2 call_2(RayFunc_3_2 f, + RayObject t0, T1 t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_3_2.class, f, 2, t0, t1, t2).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null), 2, t0, t1, t2).objs); + } + } + + public static RayObjects2 call_2(RayFunc_3_2 f, + T0 t0, RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_3_2.class, f, 2, t0, t1, t2).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null), 2, t0, t1, t2).objs); + } + } + + public static RayObjects2 call_2(RayFunc_3_2 f, + RayObject t0, RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_3_2.class, f, 2, t0, t1, t2).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null), 2, t0, t1, t2).objs); + } + } + + public static RayObjects2 call_2(RayFunc_3_2 f, + T0 t0, T1 t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_3_2.class, f, 2, t0, t1, t2).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null), 2, t0, t1, t2).objs); + } + } + + public static RayObjects2 call_2(RayFunc_3_2 f, + RayObject t0, T1 t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_3_2.class, f, 2, t0, t1, t2).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null), 2, t0, t1, t2).objs); + } + } + + public static RayObjects2 call_2(RayFunc_3_2 f, + T0 t0, RayObject t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_3_2.class, f, 2, t0, t1, t2).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null), 2, t0, t1, t2).objs); + } + } + + public static RayObjects2 call_2(RayFunc_3_2 f, + RayObject t0, RayObject t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects2(Ray.internal().call(null, RayFunc_3_2.class, f, 2, t0, t1, t2).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null), 2, t0, t1, t2).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_3_3 f, T0 t0, T1 t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_3_3.class, f, 3, t0, t1, t2).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null), 3, t0, t1, t2).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_3_3 f, RayObject t0, T1 t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_3_3.class, f, 3, t0, t1, t2).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null), 3, t0, t1, t2).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_3_3 f, T0 t0, RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_3_3.class, f, 3, t0, t1, t2).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null), 3, t0, t1, t2).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_3_3 f, RayObject t0, RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_3_3.class, f, 3, t0, t1, t2).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null), 3, t0, t1, t2).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_3_3 f, T0 t0, T1 t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_3_3.class, f, 3, t0, t1, t2).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null), 3, t0, t1, t2).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_3_3 f, RayObject t0, T1 t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_3_3.class, f, 3, t0, t1, t2).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null), 3, t0, t1, t2).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_3_3 f, T0 t0, RayObject t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_3_3.class, f, 3, t0, t1, t2).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null), 3, t0, t1, t2).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_3_3 f, RayObject t0, RayObject t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects3(Ray.internal().call(null, RayFunc_3_3.class, f, 3, t0, t1, t2).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null), 3, t0, t1, t2).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_3_4 f, T0 t0, T1 t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_3_4.class, f, 4, t0, t1, t2).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null), 4, t0, t1, t2).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_3_4 f, RayObject t0, T1 t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_3_4.class, f, 4, t0, t1, t2).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null), 4, t0, t1, t2).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_3_4 f, T0 t0, RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_3_4.class, f, 4, t0, t1, t2).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null), 4, t0, t1, t2).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_3_4 f, RayObject t0, RayObject t1, T2 t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_3_4.class, f, 4, t0, t1, t2).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null), 4, t0, t1, t2).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_3_4 f, T0 t0, T1 t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_3_4.class, f, 4, t0, t1, t2).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null), 4, t0, t1, t2).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_3_4 f, RayObject t0, T1 t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_3_4.class, f, 4, t0, t1, t2).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null), 4, t0, t1, t2).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_3_4 f, T0 t0, RayObject t1, RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_3_4.class, f, 4, t0, t1, t2).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null), 4, t0, t1, t2).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_3_4 f, RayObject t0, RayObject t1, + RayObject t2) { + if (Ray.isRemoteLambda()) { + return new RayObjects4(Ray.internal().call(null, RayFunc_3_4.class, f, 4, t0, t1, t2).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null), 4, t0, t1, t2).objs); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, T0 t0, T1 t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, RayObject t0, T1 t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, T0 t0, RayObject t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, RayObject t0, RayObject t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, T0 t0, T1 t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, RayObject t0, T1 t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, T0 t0, T1 t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, RayObject t0, T1 t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, T0 t0, RayObject t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, RayObject t0, RayObject t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, T0 t0, RayObject t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, RayObject t0, RayObject t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, T0 t0, T1 t1, RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, RayObject t0, T1 t1, RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, T0 t0, RayObject t1, RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayList call_n(RayFunc_4_n_list f, + Integer returnCount, RayObject t0, RayObject t1, RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_4_n_list.class, f, returnCount, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null), returnCount, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, RayObject t0, T1 t1, + T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, T0 t0, RayObject t1, + T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, RayObject t0, T1 t1, + RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, RayObject t0, T1 t1, + T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, T0 t0, RayObject t1, + RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, T0 t0, RayObject t1, + T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, RayObject t0, T1 t1, + RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, T0 t0, RayObject t1, + RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayMap call_n( + RayFunc_4_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_4_n.class, f, returnids, t0, t1, t2, t3); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null), returnids, t0, + t1, t2, t3); + } + } + + public static RayObject call(RayFunc_4_1 f, T0 t0, + T1 t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, + RayObject t0, T1 t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, T0 t0, + RayObject t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, + RayObject t0, RayObject t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, T0 t0, + T1 t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, + RayObject t0, T1 t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, T0 t0, + T1 t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, + RayObject t0, T1 t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, T0 t0, + RayObject t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, + RayObject t0, RayObject t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, T0 t0, + RayObject t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, + RayObject t0, RayObject t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, T0 t0, + T1 t1, RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, + RayObject t0, T1 t1, RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, T0 t0, + RayObject t1, RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObject call(RayFunc_4_1 f, + RayObject t0, RayObject t1, RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_4_1.class, f, 1, t0, t1, t2, t3).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null), 1, t0, t1, t2, t3).objs[0]; + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, T0 t0, T1 t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, RayObject t0, T1 t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, T0 t0, RayObject t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, RayObject t0, RayObject t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, T0 t0, T1 t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, RayObject t0, T1 t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, T0 t0, T1 t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, RayObject t0, T1 t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, T0 t0, RayObject t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, RayObject t0, RayObject t1, RayObject t2, + T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, T0 t0, RayObject t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, T0 t0, T1 t1, RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_4_2 f, RayObject t0, RayObject t1, RayObject t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_4_2.class, f, 2, t0, t1, t2, t3).objs); + } else { + return new RayObjects2( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 2, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, T0 t0, T1 t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, RayObject t0, T1 t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, T0 t0, RayObject t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, RayObject t0, RayObject t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, T0 t0, T1 t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, RayObject t0, T1 t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, T0 t0, T1 t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, RayObject t0, T1 t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, T0 t0, RayObject t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, T0 t0, RayObject t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, T0 t0, T1 t1, RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_4_3 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_4_3.class, f, 3, t0, t1, t2, t3).objs); + } else { + return new RayObjects3( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 3, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, T0 t0, T1 t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, RayObject t0, T1 t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, T0 t0, RayObject t1, T2 t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, RayObject t0, RayObject t1, T2 t2, + T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, T0 t0, T1 t1, RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, RayObject t0, T1 t1, RayObject t2, + T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, T0 t0, T1 t1, T2 t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, RayObject t0, T1 t1, T2 t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, T0 t0, RayObject t1, RayObject t2, + T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, T0 t0, RayObject t1, T2 t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, T0 t0, T1 t1, RayObject t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_4_4 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_4_4.class, f, 4, t0, t1, t2, t3).objs); + } else { + return new RayObjects4( + Ray.internal().call(null, () -> f.apply(null, null, null, null), 4, t0, t1, t2, t3).objs); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, T1 t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, RayObject t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, RayObject t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, T1 t1, RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, T1 t1, RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, T1 t1, T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, T1 t1, T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, RayObject t1, RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, RayObject t1, RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, T1 t1, T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, T1 t1, T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, RayObject t1, T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, RayObject t1, T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, RayObject t1, T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, T1 t1, RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, RayObject t1, T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, T1 t1, RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, T1 t1, RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, T1 t1, RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, RayObject t1, RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, RayObject t1, RayObject t2, RayObject t3, + T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, T1 t1, T2 t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, T1 t1, T2 t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, RayObject t1, RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, RayObject t1, RayObject t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, RayObject t1, T2 t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, RayObject t1, T2 t2, RayObject t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, T1 t1, RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, T1 t1, RayObject t2, RayObject t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, T0 t0, RayObject t1, RayObject t2, RayObject t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayList call_n(RayFunc_5_n_list f, + Integer returnCount, RayObject t0, RayObject t1, RayObject t2, RayObject t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_5_n_list.class, f, returnCount, t0, t1, t2, t3, + t4); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null), returnCount, + t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, T1 t1, + T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, RayObject t1, + T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, T1 t1, + RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, T1 t1, + T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, RayObject t1, + RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, T1 t1, + T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, RayObject t1, + T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, RayObject t1, + T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, T1 t1, + RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, T1 t1, + RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, T1 t1, + T2 t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, RayObject t1, + T2 t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, T1 t1, + RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, T0 t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayMap call_n( + RayFunc_5_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_5_n.class, f, returnids, t0, t1, t2, t3, t4); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4); + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, T1 t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, RayObject t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, RayObject t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, T1 t1, RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, T1 t1, RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, T1 t1, T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, T1 t1, T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, RayObject t1, RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, RayObject t1, RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, T1 t1, T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, T1 t1, T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, RayObject t1, T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, RayObject t1, T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, RayObject t1, T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, T1 t1, RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, RayObject t1, T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, T1 t1, RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, T1 t1, RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, T1 t1, RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, RayObject t1, RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, RayObject t1, RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, T1 t1, T2 t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, T1 t1, T2 t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, RayObject t1, RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, RayObject t1, RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, RayObject t1, T2 t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, RayObject t1, T2 t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, T1 t1, RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, T1 t1, RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + T0 t0, RayObject t1, RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObject call(RayFunc_5_1 f, + RayObject t0, RayObject t1, RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_5_1.class, f, 1, t0, t1, t2, t3, t4).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 1, t0, t1, t2, t3, t4).objs[0]; + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, T1 t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, RayObject t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, RayObject t1, T2 t2, T3 t3, + T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, T1 t1, RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, T1 t1, RayObject t2, T3 t3, + T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, T1 t1, T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, T1 t1, T2 t2, RayObject t3, + T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, RayObject t1, RayObject t2, T3 t3, + T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, T1 t1, T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, T1 t1, T2 t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, RayObject t1, T2 t2, RayObject t3, + T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, RayObject t1, T2 t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, T1 t1, RayObject t2, RayObject t3, + T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, RayObject t1, T2 t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, T1 t1, RayObject t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, T1 t1, RayObject t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, T1 t1, T2 t2, RayObject t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, T1 t1, T2 t2, RayObject t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, RayObject t1, RayObject t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, RayObject t1, T2 t2, RayObject t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, T1 t1, RayObject t2, RayObject t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_5_2 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_5_2.class, f, 2, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 2, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, T1 t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, RayObject t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, T1 t1, RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, T1 t1, T2 t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, T1 t1, T2 t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, T1 t1, T2 t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, RayObject t1, T2 t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, T1 t1, RayObject t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, T1 t1, T2 t2, RayObject t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_5_3 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_5_3.class, f, 3, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 3, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, T1 t1, T2 t2, T3 t3, + T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, RayObject t1, T2 t2, T3 t3, + T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, T1 t1, RayObject t2, T3 t3, + T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, T1 t1, T2 t2, RayObject t3, + T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, T1 t1, T2 t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, T1 t1, T2 t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, RayObject t1, T2 t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, T1 t1, RayObject t2, T3 t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, T1 t1, T2 t2, RayObject t3, + RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_5_4 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_5_4.class, f, 4, t0, t1, t2, t3, t4).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null), 4, t0, t1, t2, t3, t4).objs); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, T2 t2, + T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + T2 t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + T2 t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, T2 t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, + RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, T2 t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + T2 t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, T2 t2, + T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + T2 t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + T2 t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, T2 t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, T2 t2, + T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + T2 t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + T2 t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, + RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, T2 t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + T2 t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, + RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, T2 t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, + RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, T2 t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + T2 t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, T2 t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + T2 t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + T2 t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, T2 t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, T2 t2, + T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + T2 t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + T2 t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, + RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, T2 t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + T2 t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, + RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, T2 t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, + RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, T2 t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + T2 t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + T2 t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, T2 t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, T1 t1, + RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, T1 t1, + RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, T0 t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayList call_n( + RayFunc_6_n_list f, Integer returnCount, RayObject t0, + RayObject t1, RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnIndices(null, RayFunc_6_n_list.class, f, returnCount, t0, t1, t2, t3, + t4, t5); + } else { + return Ray.internal() + .callWithReturnIndices(null, () -> f.apply(null, null, null, null, null, null), + returnCount, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, T2 t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, T2 t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, T2 t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, T2 t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, T2 t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, T2 t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, T2 t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, T2 t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, T2 t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, T2 t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, T2 t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, T2 t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, T2 t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, T2 t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, T2 t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, T2 t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, T2 t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, T1 t1, + RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + T1 t1, RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, T0 t0, + RayObject t1, RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayMap call_n( + RayFunc_6_n f, Collection returnids, RayObject t0, + RayObject t1, RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal() + .callWithReturnLabels(null, RayFunc_6_n.class, f, returnids, t0, t1, t2, t3, t4, t5); + } else { + return Ray.internal() + .callWithReturnLabels(null, () -> f.apply(null, null, null, null, null, null, null), + returnids, t0, t1, t2, t3, t4, t5); + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, T2 t2, T3 t3, T4 t4, + T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, T2 t2, T3 t3, T4 t4, + T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, T2 t2, T3 t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, RayObject t2, T3 t3, T4 t4, + T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, RayObject t2, T3 t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, T2 t2, RayObject t3, T4 t4, + T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, T2 t2, RayObject t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, RayObject t2, T3 t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, T2 t2, T3 t3, RayObject t4, + T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, T2 t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, T2 t2, RayObject t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, T2 t2, T3 t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, T2 t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, RayObject t2, RayObject t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, T2 t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, T2 t2, T3 t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, RayObject t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, T2 t2, T3 t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, RayObject t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, RayObject t2, T3 t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, T2 t2, RayObject t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, RayObject t2, T3 t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, T2 t2, RayObject t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, RayObject t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, T2 t2, RayObject t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, T2 t2, RayObject t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, RayObject t2, T3 t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, T2 t2, RayObject t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, T2 t2, T3 t3, RayObject t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, T2 t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, T2 t2, RayObject t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, RayObject t2, RayObject t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, T2 t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, RayObject t2, RayObject t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, T2 t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, RayObject t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, RayObject t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, T2 t2, RayObject t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, T2 t2, RayObject t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, RayObject t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, T2 t2, RayObject t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, T1 t1, RayObject t2, RayObject t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObject call( + RayFunc_6_1 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return Ray.internal().call(null, RayFunc_6_1.class, f, 1, t0, t1, t2, t3, t4, t5).objs[0]; + } else { + return Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 1, t0, t1, t2, t3, t4, + t5).objs[0]; + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, T2 t2, T3 t3, T4 t4, + T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, T2 t2, T3 t3, T4 t4, + T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, RayObject t2, T3 t3, T4 t4, + T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, T2 t2, RayObject t3, T4 t4, + T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, T2 t2, T3 t3, RayObject t4, + T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, T2 t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, T2 t2, T3 t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, T2 t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, T2 t2, T3 t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, RayObject t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, RayObject t2, T3 t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, T2 t2, RayObject t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, T2 t2, RayObject t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, T2 t2, T3 t3, RayObject t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, T2 t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, T2 t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, RayObject t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, T2 t2, RayObject t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects2 call_2( + RayFunc_6_2 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects2( + Ray.internal().call(null, RayFunc_6_2.class, f, 2, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects2(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 2, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, T2 t2, T3 t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, T2 t2, T3 t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, RayObject t2, T3 t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, T2 t2, RayObject t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, T2 t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, T2 t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, T2 t2, T3 t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, T2 t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, T2 t2, T3 t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, RayObject t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, RayObject t2, T3 t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, T2 t2, RayObject t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, T2 t2, RayObject t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, T2 t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, T2 t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, T2 t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, T2 t2, + T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, RayObject t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, RayObject t2, + T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, T2 t2, RayObject t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, RayObject t2, + T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, T0 t0, RayObject t1, RayObject t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects3 call_3( + RayFunc_6_3 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects3( + Ray.internal().call(null, RayFunc_6_3.class, f, 3, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects3(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 3, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, + T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, T2 t2, T3 t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, T2 t2, T3 t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + T2 t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, RayObject t2, T3 t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, + RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, T2 t2, RayObject t3, + T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, T2 t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, T2 t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + T2 t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, + RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, T2 t2, T3 t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, T2 t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + T2 t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, + RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, T2 t2, T3 t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, RayObject t2, T3 t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + T2 t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, + RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, RayObject t2, T3 t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, T2 t2, RayObject t3, + RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, + RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, T2 t2, RayObject t3, + T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + T2 t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, T2 t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, T2 t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + T2 t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, + RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, T2 t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + T2 t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, + RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, T5 t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, RayObject t2, T3 t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, + RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, T4 t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, T2 t2, RayObject t3, + RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, T2 t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + RayObject t2, T3 t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, T2 t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + T2 t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, T1 t1, RayObject t2, + RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, T1 t1, + RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, T0 t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } + + public static RayObjects4 call_4( + RayFunc_6_4 f, RayObject t0, RayObject t1, + RayObject t2, RayObject t3, RayObject t4, RayObject t5) { + if (Ray.isRemoteLambda()) { + return new RayObjects4( + Ray.internal().call(null, RayFunc_6_4.class, f, 4, t0, t1, t2, t3, t4, t5).objs); + } else { + return new RayObjects4(Ray.internal() + .call(null, () -> f.apply(null, null, null, null, null, null), 4, t0, t1, t2, t3, t4, + t5).objs); + } + } +} diff --git a/java/api/src/main/java/org/ray/api/TaskStatus.java b/java/api/src/main/java/org/ray/api/TaskStatus.java new file mode 100644 index 000000000000..bd5532f7edeb --- /dev/null +++ b/java/api/src/main/java/org/ray/api/TaskStatus.java @@ -0,0 +1,13 @@ +package org.ray.api; + +import java.io.Serializable; + +/** + * Represents a status of type T of a task. + */ +public class TaskStatus implements Serializable { + + private static final long serialVersionUID = -3382082416577683751L; + + public T status; +} diff --git a/java/api/src/main/java/org/ray/api/UniqueID.java b/java/api/src/main/java/org/ray/api/UniqueID.java new file mode 100644 index 000000000000..97e2a298882a --- /dev/null +++ b/java/api/src/main/java/org/ray/api/UniqueID.java @@ -0,0 +1,119 @@ +package org.ray.api; + + +import java.io.Serializable; +import java.nio.ByteBuffer; +import java.nio.IntBuffer; +import java.util.Arrays; +import java.util.Random; + +/** + * Unique ID for task, worker, function... + */ +public class UniqueID implements Serializable { + + private static final long serialVersionUID = 8588849129675565761L; + + public static final int LENGTH = 20; + + byte[] id; + + public UniqueID(byte[] id) { + this.id = id; + } + + public UniqueID(ByteBuffer bb) { + assert (bb.remaining() == LENGTH); + id = new byte[bb.remaining()]; + bb.get(id); + } + + public UniqueID(String optionValue) { + assert (optionValue.length() == 2 * LENGTH); + int j = 0; + + id = new byte[LENGTH]; + for (int i = 0; i < LENGTH; i++) { + char c1 = optionValue.charAt(j++); + char c2 = optionValue.charAt(j++); + int first = c1 <= '9' ? (c1 - '0') : (c1 - 'a' + 0xa); + int second = c2 <= '9' ? (c2 - '0') : (c2 - 'a' + 0xa); + id[i] = (byte) (first * 16 + second); + } + } + + @Override + public String toString() { + String s = ""; + String hex = "0123456789abcdef"; + for (int i = 0; i < LENGTH; i++) { + int val = id[i] & 0xff; + s += hex.charAt(val >> 4); + s += hex.charAt(val & 0xf); + } + return s; + } + + public byte[] getBytes() { + return id; + } + + public ByteBuffer ToByteBuffer() { + return ByteBuffer.wrap(id); + } + + public UniqueID copy() { + byte[] nid = Arrays.copyOf(id, id.length); + return new UniqueID(nid); + } + + @Override + public int hashCode() { + int hash = 0xdeadbeef; + IntBuffer bb = ByteBuffer.wrap(id).asIntBuffer(); + while (bb.hasRemaining()) { + hash ^= bb.get(); + } + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + if (!(obj instanceof UniqueID)) { + return false; + } + + UniqueID r = (UniqueID) obj; + return Arrays.equals(id, r.id); + } + + public boolean isNil() { + for (byte b : id) { + if (b != (byte) 0xFF) { + return false; + } + } + return true; + } + + public static final UniqueID nil = genNil(); + + public static UniqueID genNil() { + byte[] b = new byte[LENGTH]; + for (int i = 0; i < b.length; i++) { + b[i] = (byte) 0xFF; + } + + return new UniqueID(b); + } + + public static UniqueID randomID() { + byte[] b = new byte[LENGTH]; + new Random().nextBytes(b); + return new UniqueID(b); + } +} diff --git a/java/api/src/main/java/org/ray/api/WaitResult.java b/java/api/src/main/java/org/ray/api/WaitResult.java new file mode 100644 index 000000000000..8706724b9c91 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/WaitResult.java @@ -0,0 +1,25 @@ +package org.ray.api; + + +/** + * The result of Ray.wait() distinguish the ready ones and the remain ones + */ +public class WaitResult { + + private final RayList readyOnes; + private final RayList remainOnes; + + public WaitResult(RayList readyOnes, RayList remainOnes) { + this.readyOnes = readyOnes; + this.remainOnes = remainOnes; + } + + public RayList getReadyOnes() { + return readyOnes; + } + + public RayList getRemainOnes() { + return remainOnes; + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_1.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_1.java new file mode 100644 index 000000000000..123e9023fa23 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_1.java @@ -0,0 +1,19 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_0_1 extends RayFunc { + + R0 apply() throws Throwable; + + static R0 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_0_1.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_0_1 f = SerializationUtils.deserialize(funcBytes); + return f.apply(); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_2.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_2.java new file mode 100644 index 000000000000..65fb65a198a7 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_2.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns2; + +@FunctionalInterface +public interface RayFunc_0_2 extends RayFunc { + + MultipleReturns2 apply() throws Throwable; + + static MultipleReturns2 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_0_2.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_0_2 f = SerializationUtils.deserialize(funcBytes); + return f.apply(); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_3.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_3.java new file mode 100644 index 000000000000..e2b43e9013a0 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_3.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns3; + +@FunctionalInterface +public interface RayFunc_0_3 extends RayFunc { + + MultipleReturns3 apply() throws Throwable; + + static MultipleReturns3 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_0_3.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_0_3 f = SerializationUtils.deserialize(funcBytes); + return f.apply(); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_4.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_4.java new file mode 100644 index 000000000000..60c0691653d0 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_4.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns4; + +@FunctionalInterface +public interface RayFunc_0_4 extends RayFunc { + + MultipleReturns4 apply() throws Throwable; + + static MultipleReturns4 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_0_4.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_0_4 f = SerializationUtils.deserialize(funcBytes); + return f.apply(); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_n.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_n.java new file mode 100644 index 000000000000..d651fb429eef --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_n.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import java.util.Collection; +import java.util.Map; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_0_n extends RayFunc { + + Map apply(Collection returnids) throws Throwable; + + static Map execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_0_n.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_0_n f = SerializationUtils.deserialize(funcBytes); + return f.apply((Collection) args[0]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_n_list.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_n_list.java new file mode 100644 index 000000000000..1d2a008dea2a --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_0_n_list.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import java.util.List; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_0_n_list extends RayFunc { + + List apply() throws Throwable; + + static List execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_0_n_list.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_0_n_list f = SerializationUtils.deserialize(funcBytes); + return f.apply(); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_1.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_1.java new file mode 100644 index 000000000000..866c98f7ba0b --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_1.java @@ -0,0 +1,19 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_1_1 extends RayFunc { + + R0 apply(T0 t0) throws Throwable; + + static R0 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_1_1.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_1_1 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_2.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_2.java new file mode 100644 index 000000000000..6ec1117c3f63 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_2.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns2; + +@FunctionalInterface +public interface RayFunc_1_2 extends RayFunc { + + MultipleReturns2 apply(T0 t0) throws Throwable; + + static MultipleReturns2 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_1_2.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_1_2 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_3.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_3.java new file mode 100644 index 000000000000..c7e78f859536 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_3.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns3; + +@FunctionalInterface +public interface RayFunc_1_3 extends RayFunc { + + MultipleReturns3 apply(T0 t0) throws Throwable; + + static MultipleReturns3 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_1_3.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_1_3 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_4.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_4.java new file mode 100644 index 000000000000..29871e79a901 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_4.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns4; + +@FunctionalInterface +public interface RayFunc_1_4 extends RayFunc { + + MultipleReturns4 apply(T0 t0) throws Throwable; + + static MultipleReturns4 execute(Object[] args) + throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_1_4.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_1_4 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_n.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_n.java new file mode 100644 index 000000000000..d057486a9f3d --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_n.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import java.util.Collection; +import java.util.Map; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_1_n extends RayFunc { + + Map apply(Collection returnids, T0 t0) throws Throwable; + + static Map execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_1_n.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_1_n f = SerializationUtils.deserialize(funcBytes); + return f.apply((Collection) args[0], (T0) args[1]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_n_list.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_n_list.java new file mode 100644 index 000000000000..8853c80f8f7e --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_1_n_list.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import java.util.List; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_1_n_list extends RayFunc { + + List apply(T0 t0) throws Throwable; + + static List execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_1_n_list.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_1_n_list f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_1.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_1.java new file mode 100644 index 000000000000..0c9ed3fc3a08 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_1.java @@ -0,0 +1,19 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_2_1 extends RayFunc { + + R0 apply(T0 t0, T1 t1) throws Throwable; + + static R0 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_2_1.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_2_1 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_2.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_2.java new file mode 100644 index 000000000000..c5faa49bd307 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_2.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns2; + +@FunctionalInterface +public interface RayFunc_2_2 extends RayFunc { + + MultipleReturns2 apply(T0 t0, T1 t1) throws Throwable; + + static MultipleReturns2 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_2_2.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_2_2 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_3.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_3.java new file mode 100644 index 000000000000..49847b1c6966 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_3.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns3; + +@FunctionalInterface +public interface RayFunc_2_3 extends RayFunc { + + MultipleReturns3 apply(T0 t0, T1 t1) throws Throwable; + + static MultipleReturns3 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_2_3.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_2_3 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_4.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_4.java new file mode 100644 index 000000000000..bc40c02c3340 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_4.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns4; + +@FunctionalInterface +public interface RayFunc_2_4 extends RayFunc { + + MultipleReturns4 apply(T0 t0, T1 t1) throws Throwable; + + static MultipleReturns4 execute(Object[] args) + throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_2_4.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_2_4 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_n.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_n.java new file mode 100644 index 000000000000..1961ba67e360 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_n.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import java.util.Collection; +import java.util.Map; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_2_n extends RayFunc { + + Map apply(Collection returnids, T0 t0, T1 t1) throws Throwable; + + static Map execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_2_n.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_2_n f = SerializationUtils.deserialize(funcBytes); + return f.apply((Collection) args[0], (T0) args[1], (T1) args[2]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_n_list.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_n_list.java new file mode 100644 index 000000000000..4c0591a471e1 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_2_n_list.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import java.util.List; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_2_n_list extends RayFunc { + + List apply(T0 t0, T1 t1) throws Throwable; + + static List execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_2_n_list.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_2_n_list f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_1.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_1.java new file mode 100644 index 000000000000..2751f9eaa65d --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_1.java @@ -0,0 +1,19 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_3_1 extends RayFunc { + + R0 apply(T0 t0, T1 t1, T2 t2) throws Throwable; + + static R0 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_3_1.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_3_1 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_2.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_2.java new file mode 100644 index 000000000000..880b89d47286 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_2.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns2; + +@FunctionalInterface +public interface RayFunc_3_2 extends RayFunc { + + MultipleReturns2 apply(T0 t0, T1 t1, T2 t2) throws Throwable; + + static MultipleReturns2 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_3_2.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_3_2 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_3.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_3.java new file mode 100644 index 000000000000..97ec6af1e15f --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_3.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns3; + +@FunctionalInterface +public interface RayFunc_3_3 extends RayFunc { + + MultipleReturns3 apply(T0 t0, T1 t1, T2 t2) throws Throwable; + + static MultipleReturns3 execute(Object[] args) + throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_3_3.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_3_3 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_4.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_4.java new file mode 100644 index 000000000000..977aedca24df --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_4.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns4; + +@FunctionalInterface +public interface RayFunc_3_4 extends RayFunc { + + MultipleReturns4 apply(T0 t0, T1 t1, T2 t2) throws Throwable; + + static MultipleReturns4 execute(Object[] args) + throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_3_4.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_3_4 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_n.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_n.java new file mode 100644 index 000000000000..a79edea3bf8b --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_n.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import java.util.Collection; +import java.util.Map; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_3_n extends RayFunc { + + Map apply(Collection returnids, T0 t0, T1 t1, T2 t2) throws Throwable; + + static Map execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_3_n.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_3_n f = SerializationUtils.deserialize(funcBytes); + return f.apply((Collection) args[0], (T0) args[1], (T1) args[2], (T2) args[3]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_n_list.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_n_list.java new file mode 100644 index 000000000000..de0976a67c46 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_3_n_list.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import java.util.List; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_3_n_list extends RayFunc { + + List apply(T0 t0, T1 t1, T2 t2) throws Throwable; + + static List execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_3_n_list.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_3_n_list f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_1.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_1.java new file mode 100644 index 000000000000..352df12eadb6 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_1.java @@ -0,0 +1,19 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_4_1 extends RayFunc { + + R0 apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable; + + static R0 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_4_1.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_4_1 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_2.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_2.java new file mode 100644 index 000000000000..cc655e6489c0 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_2.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns2; + +@FunctionalInterface +public interface RayFunc_4_2 extends RayFunc { + + MultipleReturns2 apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable; + + static MultipleReturns2 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_4_2.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_4_2 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_3.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_3.java new file mode 100644 index 000000000000..c161c5aae9e0 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_3.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns3; + +@FunctionalInterface +public interface RayFunc_4_3 extends RayFunc { + + MultipleReturns3 apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable; + + static MultipleReturns3 execute(Object[] args) + throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_4_3.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_4_3 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_4.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_4.java new file mode 100644 index 000000000000..ec9183835714 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_4.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns4; + +@FunctionalInterface +public interface RayFunc_4_4 extends RayFunc { + + MultipleReturns4 apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable; + + static MultipleReturns4 execute(Object[] args) + throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_4_4.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_4_4 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_n.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_n.java new file mode 100644 index 000000000000..9ffc8c55ee6c --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_n.java @@ -0,0 +1,22 @@ +package org.ray.api.funcs; + +import java.util.Collection; +import java.util.Map; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_4_n extends RayFunc { + + Map apply(Collection returnids, T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable; + + static Map execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_4_n.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_4_n f = SerializationUtils.deserialize(funcBytes); + return f + .apply((Collection) args[0], (T0) args[1], (T1) args[2], (T2) args[3], (T3) args[4]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_n_list.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_n_list.java new file mode 100644 index 000000000000..299411babfcc --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_4_n_list.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import java.util.List; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_4_n_list extends RayFunc { + + List apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable; + + static List execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_4_n_list.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_4_n_list f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_1.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_1.java new file mode 100644 index 000000000000..423565f8ef06 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_1.java @@ -0,0 +1,19 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_5_1 extends RayFunc { + + R0 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable; + + static R0 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_5_1.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_5_1 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_2.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_2.java new file mode 100644 index 000000000000..fcd903e872ab --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_2.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns2; + +@FunctionalInterface +public interface RayFunc_5_2 extends RayFunc { + + MultipleReturns2 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable; + + static MultipleReturns2 execute(Object[] args) + throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_5_2.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_5_2 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_3.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_3.java new file mode 100644 index 000000000000..1ba58f95b84c --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_3.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns3; + +@FunctionalInterface +public interface RayFunc_5_3 extends RayFunc { + + MultipleReturns3 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable; + + static MultipleReturns3 execute(Object[] args) + throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_5_3.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_5_3 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_4.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_4.java new file mode 100644 index 000000000000..39f019310cde --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_4.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns4; + +@FunctionalInterface +public interface RayFunc_5_4 extends RayFunc { + + MultipleReturns4 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable; + + static MultipleReturns4 execute( + Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_5_4.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_5_4 f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_n.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_n.java new file mode 100644 index 000000000000..eea116f56d92 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_n.java @@ -0,0 +1,23 @@ +package org.ray.api.funcs; + +import java.util.Collection; +import java.util.Map; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_5_n extends RayFunc { + + Map apply(Collection returnids, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable; + + static Map execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_5_n.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_5_n f = SerializationUtils.deserialize(funcBytes); + return f + .apply((Collection) args[0], (T0) args[1], (T1) args[2], (T2) args[3], (T3) args[4], + (T4) args[5]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_n_list.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_n_list.java new file mode 100644 index 000000000000..0f85cc160141 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_5_n_list.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import java.util.List; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_5_n_list extends RayFunc { + + List apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable; + + static List execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_5_n_list.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_5_n_list f = SerializationUtils.deserialize(funcBytes); + return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_1.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_1.java new file mode 100644 index 000000000000..b0e54690b108 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_1.java @@ -0,0 +1,20 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_6_1 extends RayFunc { + + R0 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable; + + static R0 execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_6_1.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_6_1 f = SerializationUtils.deserialize(funcBytes); + return f + .apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_2.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_2.java new file mode 100644 index 000000000000..38a33840f02d --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_2.java @@ -0,0 +1,22 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns2; + +@FunctionalInterface +public interface RayFunc_6_2 extends RayFunc { + + MultipleReturns2 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable; + + static MultipleReturns2 execute(Object[] args) + throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_6_2.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_6_2 f = SerializationUtils.deserialize(funcBytes); + return f + .apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_3.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_3.java new file mode 100644 index 000000000000..93b4823db1f6 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_3.java @@ -0,0 +1,22 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns3; + +@FunctionalInterface +public interface RayFunc_6_3 extends RayFunc { + + MultipleReturns3 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable; + + static MultipleReturns3 execute(Object[] args) + throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_6_3.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_6_3 f = SerializationUtils.deserialize(funcBytes); + return f + .apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_4.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_4.java new file mode 100644 index 000000000000..7db9f0bf6cde --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_4.java @@ -0,0 +1,23 @@ +package org.ray.api.funcs; + +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; +import org.ray.api.returns.MultipleReturns4; + +@FunctionalInterface +public interface RayFunc_6_4 extends RayFunc { + + MultipleReturns4 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable; + + static MultipleReturns4 execute( + Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_6_4.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_6_4 f = SerializationUtils + .deserialize(funcBytes); + return f + .apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_n.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_n.java new file mode 100644 index 000000000000..f755141410e5 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_n.java @@ -0,0 +1,24 @@ +package org.ray.api.funcs; + +import java.util.Collection; +import java.util.Map; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_6_n extends RayFunc { + + Map apply(Collection returnids, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) + throws Throwable; + + static Map execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_6_n.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_6_n f = SerializationUtils.deserialize(funcBytes); + return f + .apply((Collection) args[0], (T0) args[1], (T1) args[2], (T2) args[3], (T3) args[4], + (T4) args[5], (T5) args[6]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_n_list.java b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_n_list.java new file mode 100644 index 000000000000..123f3abcc940 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/funcs/RayFunc_6_n_list.java @@ -0,0 +1,21 @@ +package org.ray.api.funcs; + +import java.util.List; +import org.apache.commons.lang3.SerializationUtils; +import org.ray.api.internal.RayFunc; + +@FunctionalInterface +public interface RayFunc_6_n_list extends RayFunc { + + List apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable; + + static List execute(Object[] args) throws Throwable { + String name = (String) args[args.length - 2]; + assert (name.equals(RayFunc_6_n_list.class.getName())); + byte[] funcBytes = (byte[]) args[args.length - 1]; + RayFunc_6_n_list f = SerializationUtils.deserialize(funcBytes); + return f + .apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5]); + } + +} diff --git a/java/api/src/main/java/org/ray/api/internal/Callable.java b/java/api/src/main/java/org/ray/api/internal/Callable.java new file mode 100644 index 000000000000..d0c500130fe5 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/internal/Callable.java @@ -0,0 +1,9 @@ +package org.ray.api.internal; + +/** + * hold the remote call + */ +public interface Callable { + + void run() throws Throwable; +} diff --git a/java/api/src/main/java/org/ray/api/internal/RayConnector.java b/java/api/src/main/java/org/ray/api/internal/RayConnector.java new file mode 100644 index 000000000000..3d54dcc54875 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/internal/RayConnector.java @@ -0,0 +1,26 @@ +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 " + className + " class failed.", e); + throw new Error("RayApi is not successfully initiated."); + } + } +} diff --git a/java/api/src/main/java/org/ray/api/internal/RayFunc.java b/java/api/src/main/java/org/ray/api/internal/RayFunc.java new file mode 100644 index 000000000000..a8d0dde01c9d --- /dev/null +++ b/java/api/src/main/java/org/ray/api/internal/RayFunc.java @@ -0,0 +1,10 @@ +package org.ray.api.internal; + +import java.io.Serializable; + +/** + * Base of the ray remote function + */ +public interface RayFunc extends Serializable { + +} diff --git a/java/api/src/main/java/org/ray/api/returns/MultipleReturns.java b/java/api/src/main/java/org/ray/api/returns/MultipleReturns.java new file mode 100644 index 000000000000..15bd79b1ee9c --- /dev/null +++ b/java/api/src/main/java/org/ray/api/returns/MultipleReturns.java @@ -0,0 +1,18 @@ +package org.ray.api.returns; + +/** + * Multiple return objects for user's method + */ +public class MultipleReturns { + + protected final Object[] values; + + public MultipleReturns(Object values[]) { + this.values = values; + } + + public Object[] getValues() { + return values; + } + +} diff --git a/java/api/src/main/java/org/ray/api/returns/MultipleReturns2.java b/java/api/src/main/java/org/ray/api/returns/MultipleReturns2.java new file mode 100644 index 000000000000..6f898decfeb2 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/returns/MultipleReturns2.java @@ -0,0 +1,17 @@ +package org.ray.api.returns; + +@SuppressWarnings("unchecked") +public class MultipleReturns2 extends MultipleReturns { + + public MultipleReturns2(R0 r0, R1 r1) { + super(new Object[]{r0, r1}); + } + + public R0 get0() { + return (R0) this.values[0]; + } + + public R1 get1() { + return (R1) this.values[1]; + } +} diff --git a/java/api/src/main/java/org/ray/api/returns/MultipleReturns3.java b/java/api/src/main/java/org/ray/api/returns/MultipleReturns3.java new file mode 100644 index 000000000000..7f1ce4c72466 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/returns/MultipleReturns3.java @@ -0,0 +1,21 @@ +package org.ray.api.returns; + +@SuppressWarnings("unchecked") +public class MultipleReturns3 extends MultipleReturns { + + public MultipleReturns3(R0 r0, R1 r1, R2 r2) { + super(new Object[]{r0, r1, r2}); + } + + public R0 get0() { + return (R0) this.values[0]; + } + + public R1 get1() { + return (R1) this.values[1]; + } + + public R2 get2() { + return (R2) this.values[2]; + } +} diff --git a/java/api/src/main/java/org/ray/api/returns/MultipleReturns4.java b/java/api/src/main/java/org/ray/api/returns/MultipleReturns4.java new file mode 100644 index 000000000000..bb9b7fe17d62 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/returns/MultipleReturns4.java @@ -0,0 +1,25 @@ +package org.ray.api.returns; + +@SuppressWarnings("unchecked") +public class MultipleReturns4 extends MultipleReturns { + + public MultipleReturns4(R0 r0, R1 r1, R2 r2, R3 r3) { + super(new Object[]{r0, r1, r2, r3}); + } + + public R0 get0() { + return (R0) this.values[0]; + } + + public R1 get1() { + return (R1) this.values[1]; + } + + public R2 get2() { + return (R2) this.values[2]; + } + + public R3 get3() { + return (R3) this.values[3]; + } +} diff --git a/java/api/src/main/java/org/ray/api/returns/RayObjects2.java b/java/api/src/main/java/org/ray/api/returns/RayObjects2.java new file mode 100644 index 000000000000..bb2e3b89cfb2 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/returns/RayObjects2.java @@ -0,0 +1,25 @@ +package org.ray.api.returns; + +import org.ray.api.RayObject; +import org.ray.api.RayObjects; +import org.ray.api.UniqueID; + +@SuppressWarnings({"rawtypes", "unchecked"}) +public class RayObjects2 extends RayObjects { + + public RayObjects2(UniqueID[] ids) { + super(ids); + } + + public RayObjects2(RayObject objs[]) { + super(objs); + } + + public RayObject r0() { + return objs[0]; + } + + public RayObject r1() { + return objs[1]; + } +} diff --git a/java/api/src/main/java/org/ray/api/returns/RayObjects3.java b/java/api/src/main/java/org/ray/api/returns/RayObjects3.java new file mode 100644 index 000000000000..7b9dc62ac8c7 --- /dev/null +++ b/java/api/src/main/java/org/ray/api/returns/RayObjects3.java @@ -0,0 +1,29 @@ +package org.ray.api.returns; + +import org.ray.api.RayObject; +import org.ray.api.RayObjects; +import org.ray.api.UniqueID; + +@SuppressWarnings({"rawtypes", "unchecked"}) +public class RayObjects3 extends RayObjects { + + public RayObjects3(UniqueID[] ids) { + super(ids); + } + + public RayObjects3(RayObject objs[]) { + super(objs); + } + + public RayObject r0() { + return objs[0]; + } + + public RayObject r1() { + return objs[1]; + } + + public RayObject r2() { + return objs[2]; + } +} diff --git a/java/api/src/main/java/org/ray/api/returns/RayObjects4.java b/java/api/src/main/java/org/ray/api/returns/RayObjects4.java new file mode 100644 index 000000000000..e045f4e5db8c --- /dev/null +++ b/java/api/src/main/java/org/ray/api/returns/RayObjects4.java @@ -0,0 +1,33 @@ +package org.ray.api.returns; + +import org.ray.api.RayObject; +import org.ray.api.RayObjects; +import org.ray.api.UniqueID; + +@SuppressWarnings({"rawtypes", "unchecked"}) +public class RayObjects4 extends RayObjects { + + public RayObjects4(UniqueID[] ids) { + super(ids); + } + + public RayObjects4(RayObject objs[]) { + super(objs); + } + + public RayObject r0() { + return objs[0]; + } + + public RayObject r1() { + return objs[1]; + } + + public RayObject r2() { + return objs[2]; + } + + public RayObject r3() { + return objs[3]; + } +} diff --git a/java/build.sh b/java/build.sh new file mode 100755 index 000000000000..6232f73acbcc --- /dev/null +++ b/java/build.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +pushd ../thirdparty/build/arrow/java/plasma +mvn clean install -Dmaven.test.skip +popd +mvn clean install -Dmaven.test.skip \ No newline at end of file diff --git a/java/cleanup.sh b/java/cleanup.sh new file mode 100755 index 000000000000..3d73e626a2d3 --- /dev/null +++ b/java/cleanup.sh @@ -0,0 +1,8 @@ +pkill -9 python +pkill -9 local_scheduler +pkill -9 plasma_manager +pkill -9 plasma_store +pkill -9 global_scheduler +pkill -9 redis-server +pkill -9 redis +ps aux | grep ray | awk '{system("kill "$2);}' diff --git a/java/common/pom.xml b/java/common/pom.xml new file mode 100644 index 000000000000..c6b19f45761b --- /dev/null +++ b/java/common/pom.xml @@ -0,0 +1,40 @@ + + + + + org.ray.parent + ray-superpom + 1.0 + + 4.0.0 + + org.ray + ray-common + java common and util for ray + java common and util for ray + + + jar + + + + log4j + log4j + 1.2.17 + + + quartz + quartz + 1.5.2 + + + org.ini4j + ini4j + 0.5.2 + + + + + diff --git a/java/common/src/main/java/org/ray/util/CommonUtil.java b/java/common/src/main/java/org/ray/util/CommonUtil.java new file mode 100644 index 000000000000..85744153459a --- /dev/null +++ b/java/common/src/main/java/org/ray/util/CommonUtil.java @@ -0,0 +1,19 @@ +package org.ray.util; + +import java.util.Random; + +/** + * Common utilities + */ +public class CommonUtil { + + private static final Random seed = new Random(); + + /** + * Get random number between 0 and (max-1) + */ + public static int getRandom(int max) { + return Math.abs(seed.nextInt() % max); + } + +} diff --git a/java/common/src/main/java/org/ray/util/FileUtil.java b/java/common/src/main/java/org/ray/util/FileUtil.java new file mode 100644 index 000000000000..7e479461900f --- /dev/null +++ b/java/common/src/main/java/org/ray/util/FileUtil.java @@ -0,0 +1,134 @@ +package org.ray.util; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Scanner; + +public class FileUtil { + + public static String getFilename(String logPath) { + if (logPath != null && !logPath.isEmpty()) { + int lastPos = logPath.lastIndexOf('/'); + if (lastPos != -1) { + return logPath.substring(lastPos + 1); + } else { + return logPath; + } + } + + return null; + } + + public static boolean deleteFile(String filePath) { + File file = new File(filePath); + if (!file.exists()) { + return true; + } else { + if (file.isFile()) { + return file.delete(); + } else { + for (File f : file.listFiles()) { + deleteFile(f.getAbsolutePath()); + } + return file.delete(); + } + } + } + + public static void mkDir(File dir) { + if (dir.exists()) { + return; + } + if (dir.getParentFile().exists()) { + dir.mkdir(); + } else { + mkDir(dir.getParentFile()); + dir.mkdir(); + } + } + + public static void mkDirAndFile(File file) throws IOException { + if (file.exists()) { + return; + } + if (!file.getParentFile().exists()) { + mkDir(file.getParentFile()); + } + file.createNewFile(); + } + + public static String readResourceFile(String fileName) throws FileNotFoundException { + ClassLoader classLoader = FileUtil.class.getClassLoader(); + File file = new File(classLoader.getResource(fileName).getFile()); + StringBuilder result = new StringBuilder(); + try (Scanner scanner = new Scanner(file)) { + + //Get file from resources folder + + while (scanner.hasNextLine()) { + String line = scanner.nextLine(); + result.append(line).append("\n"); + } + return result.toString(); + } + + } + + public static void overrideFile(String file, String str) throws IOException { + try (FileWriter fw = new FileWriter(file)) { + fw.write(str); + } + } + + public static boolean createDir(String dirName, boolean failIfExist) { + File wdir = new File(dirName); + if (wdir.isFile()) { + return false; + } + + if (!wdir.exists()) { + wdir.mkdirs(); + } else if (failIfExist) { + return false; + } + + return true; + } + + public static void bytesToFile(byte[] bytes, String name) throws IOException { + Path path = Paths.get(name); + Files.write(path, bytes); + } + + public static byte[] fileToBytes(String name) throws IOException { + Path path = Paths.get(name); + return Files.readAllBytes(path); + } + + /** + * If the given string is the empty string, then the result is the current directory. + * + * @param rawDir a path in any legal form, such as a relative path + * @return the absolute and unique path in String + */ + public static String getCanonicalDirectory(final String rawDir) throws IOException { + String dir = rawDir.length() == 0 ? "." : rawDir; + + // create working dir if necessary + File dd = new File(dir); + if (!dd.exists()) { + dd.mkdirs(); + } + + if (!dir.startsWith("/")) { + dir = dd.getCanonicalPath(); + } + + return dir; + } +} diff --git a/java/common/src/main/java/org/ray/util/MD5Digestor.java b/java/common/src/main/java/org/ray/util/MD5Digestor.java new file mode 100644 index 000000000000..16a22e557612 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/MD5Digestor.java @@ -0,0 +1,30 @@ +package org.ray.util; + +import java.nio.ByteBuffer; +import java.security.MessageDigest; +import org.ray.util.logger.RayLog; + +public class MD5Digestor { + + private static final ThreadLocal md = ThreadLocal.withInitial(() -> { + try { + return MessageDigest.getInstance("MD5"); + } catch (Exception e) { + RayLog.core.error("cannot get MD5 MessageDigest", e); + throw new RuntimeException("cannot get MD5 digest", e); + } + }); + + private static final ThreadLocal longBuffer = ThreadLocal + .withInitial(() -> ByteBuffer.allocate(Long.SIZE / Byte.SIZE)); + + public static byte[] digest(byte[] src, long addIndex) { + MessageDigest dg = md.get(); + longBuffer.get().clear(); + dg.reset(); + + dg.update(src); + dg.update(longBuffer.get().putLong(addIndex).array()); + return dg.digest(); + } +} diff --git a/java/common/src/main/java/org/ray/util/NetworkUtil.java b/java/common/src/main/java/org/ray/util/NetworkUtil.java new file mode 100644 index 000000000000..268959552e7e --- /dev/null +++ b/java/common/src/main/java/org/ray/util/NetworkUtil.java @@ -0,0 +1,62 @@ +package org.ray.util; + +import java.io.IOException; +import java.net.DatagramSocket; +import java.net.Inet6Address; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.ServerSocket; +import java.util.Enumeration; +import org.ray.util.logger.RayLog; + +public class NetworkUtil { + + public static String getIpAddress(String interfaceName) { + try { + Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); + while (interfaces.hasMoreElements()) { + NetworkInterface current = interfaces.nextElement(); + if (!current.isUp() || current.isLoopback() || current.isVirtual()) { + continue; + } + if (!StringUtil.isNullOrEmpty(interfaceName) && !interfaceName + .equals(current.getDisplayName())) { + continue; + } + Enumeration addresses = current.getInetAddresses(); + while (addresses.hasMoreElements()) { + InetAddress addr = addresses.nextElement(); + if (addr.isLoopbackAddress()) { + continue; + } + if (addr instanceof Inet6Address) { + continue; + } + return addr.getHostAddress(); + } + } + RayLog.core.warn("you may need to correctly specify [ray.java] net_interface in config"); + } catch (Exception e) { + RayLog.core.error("Can't get our ip address, use 127.0.0.1 as default.", e); + } + + return "127.0.0.1"; + } + + public static boolean isPortAvailable(int port) { + if (port < 1 || port > 65535) { + throw new IllegalArgumentException("Invalid start port: " + port); + } + + try (ServerSocket ss = new ServerSocket(port); DatagramSocket ds = new DatagramSocket(port)) { + ss.setReuseAddress(true); + ds.setReuseAddress(true); + return true; + } catch (IOException ignored) { + } + + /* should not be thrown */ + + return false; + } +} diff --git a/java/common/src/main/java/org/ray/util/ObjectUtil.java b/java/common/src/main/java/org/ray/util/ObjectUtil.java new file mode 100644 index 000000000000..e4d33c8626c7 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/ObjectUtil.java @@ -0,0 +1,24 @@ +package org.ray.util; + +import java.lang.reflect.InvocationTargetException; + +public class ObjectUtil { + + public static T newObject(Class cls) { + try { + return cls.getConstructor().newInstance(); + } catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { + e.printStackTrace(); + return null; + } + } + + public static boolean[] toBooleanArray(Object[] vs) { + boolean[] nvs = new boolean[vs.length]; + for (int i = 0; i < vs.length; i++) { + nvs[i] = (boolean) vs[i]; + } + return nvs; + } + +} diff --git a/java/common/src/main/java/org/ray/util/RemoteBiFunction.java b/java/common/src/main/java/org/ray/util/RemoteBiFunction.java new file mode 100644 index 000000000000..722e3c74ec6c --- /dev/null +++ b/java/common/src/main/java/org/ray/util/RemoteBiFunction.java @@ -0,0 +1,10 @@ +package org.ray.util; + +import java.io.Serializable; +import java.util.function.BiFunction; + +@FunctionalInterface +public interface RemoteBiFunction extends BiFunction, Serializable { + +} + diff --git a/java/common/src/main/java/org/ray/util/RemoteFunction.java b/java/common/src/main/java/org/ray/util/RemoteFunction.java new file mode 100644 index 000000000000..b05184e3b16e --- /dev/null +++ b/java/common/src/main/java/org/ray/util/RemoteFunction.java @@ -0,0 +1,9 @@ +package org.ray.util; + +import java.io.Serializable; +import java.util.function.Function; + +@FunctionalInterface +public interface RemoteFunction extends Function, Serializable { + +} diff --git a/java/common/src/main/java/org/ray/util/Sha1Digestor.java b/java/common/src/main/java/org/ray/util/Sha1Digestor.java new file mode 100644 index 000000000000..d46d8f3d5a1e --- /dev/null +++ b/java/common/src/main/java/org/ray/util/Sha1Digestor.java @@ -0,0 +1,30 @@ +package org.ray.util; + +import java.nio.ByteBuffer; +import java.security.MessageDigest; +import org.ray.util.logger.RayLog; + +public class Sha1Digestor { + + private static final ThreadLocal md = ThreadLocal.withInitial(() -> { + try { + return MessageDigest.getInstance("SHA1"); + } catch (Exception e) { + RayLog.core.error("cannot get SHA1 MessageDigest", e); + throw new RuntimeException("cannot get SHA1 digest", e); + } + }); + + private static final ThreadLocal longBuffer = ThreadLocal + .withInitial(() -> ByteBuffer.allocate(Long.SIZE / Byte.SIZE)); + + public static byte[] digest(byte[] src, long addIndex) { + MessageDigest dg = md.get(); + longBuffer.get().clear(); + dg.reset(); + + dg.update(src); + dg.update(longBuffer.get().putLong(addIndex).array()); + return dg.digest(); + } +} diff --git a/java/common/src/main/java/org/ray/util/StringUtil.java b/java/common/src/main/java/org/ray/util/StringUtil.java new file mode 100644 index 000000000000..ecd235951e14 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/StringUtil.java @@ -0,0 +1,134 @@ +package org.ray.util; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Vector; + +public class StringUtil { + + // Holds the start of an element and which brace started it. + private static class Start { + + // The brace number from the braces string in use. + final int brace; + // The position in the string it was seen. + final int pos; + + // Constructor. + public Start(int brace, int pos) { + this.brace = brace; + this.pos = pos; + } + } + + /** + * @param s input string + * @param splitters common splitters + * @param open open braces + * @param close close braces + * @return output array list + */ + public static Vector Split(String s, String splitters, String open, String close) { + // The splits. + Vector split = new Vector<>(); + // The stack. + ArrayList stack = new ArrayList<>(); + + int lastPos = 0; + + // Walk the string. + for (int i = 0; i < s.length(); i++) { + // Get the char there. + char ch = s.charAt(i); + + // Is it an open brace? + int o = open.indexOf(ch); + + // Is it a close brace? + int c = close.indexOf(ch); + + // Is it a splitter? + int sp = splitters.indexOf(ch); + + if (stack.size() == 0 && sp >= 0) { + if (i == lastPos) { + ++lastPos; + continue; + } + + split.add(s.substring(lastPos, i)); + lastPos = i + 1; + } else if (o >= 0 && (c < 0 || stack.size() == 0)) { + // Its an open! Push it. + stack.add(new Start(o, i)); + } else if (c >= 0 && stack.size() > 0) { + // Pop (if matches). + int tosPos = stack.size() - 1; + Start tos = stack.get(tosPos); + // Does the brace match? + if (tos.brace == c) { + // Done with that one. + stack.remove(tosPos); + } + } + } + + if (lastPos < s.length()) { + split.add(s.substring(lastPos, s.length())); + } + + // build removal filter set + HashSet removals = new HashSet<>(); + for (int i = 0; i < splitters.length(); i++) { + removals.add(splitters.charAt(i)); + } + + for (int i = 0; i < open.length(); i++) { + removals.add(open.charAt(i)); + } + + for (int i = 0; i < close.length(); i++) { + removals.add(close.charAt(i)); + } + + // apply removal filter set + for (int i = 0; i < split.size(); i++) { + String cs = split.get(i); + + // remove heading chars + int j; + for (j = 0; j < cs.length(); j++) { + if (!removals.contains(cs.charAt(j))) { + break; + } + } + cs = cs.substring(j); + + // remove tail chars + for (j = cs.length() - 1; j >= 0; j--) { + if (!removals.contains(cs.charAt(j))) { + break; + } + } + cs = cs.substring(0, j + 1); + + // reset cs + split.set(i, cs); + } + + return split; + } + + public static boolean isNullOrEmpty(String s) { + return s == null || s.length() == 0; + } + + public static String mergeArray(T[] objs, String concatenator) { + StringBuilder sb = new StringBuilder(); + for (T obj : objs) { + sb.append(obj).append(concatenator); + } + return objs.length == 0 ? "" : sb.substring(0, sb.length() - concatenator.length()); + } +} + diff --git a/java/common/src/main/java/org/ray/util/SystemUtil.java b/java/common/src/main/java/org/ray/util/SystemUtil.java new file mode 100644 index 000000000000..e05b65a29366 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/SystemUtil.java @@ -0,0 +1,64 @@ +package org.ray.util; + +import java.lang.management.ManagementFactory; +import java.lang.management.RuntimeMXBean; +import java.util.concurrent.locks.ReentrantLock; +import org.ray.util.logger.RayLog; + +/** + * some utilities for system process + */ +public class SystemUtil { + + public static String userHome() { + return System.getProperty("user.home"); + } + + public static String userDir() { + return System.getProperty("user.dir"); + } + + public static boolean startWithJar(Class cls) { + return cls.getResource(cls.getSimpleName() + ".class").getFile().split("!")[0].endsWith(".jar"); + } + + public static boolean startWithJar(String clsName) { + Class cls; + try { + cls = Class.forName(clsName); + return cls.getResource(cls.getSimpleName() + ".class").getFile().split("!")[0] + .endsWith(".jar"); + } catch (ClassNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + RayLog.core.error("error at SystemUtil startWithJar", e); + return false; + } + } + + static Integer pid; + static final ReentrantLock pidlock = new ReentrantLock(); + + public static int pid() { + if (pid == null) { + pidlock.lock(); + try { + if (pid == null) { + RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); + String name = runtime.getName(); + int index = name.indexOf("@"); + if (index != -1) { + pid = Integer.parseInt(name.substring(0, index)); + } else { + throw new RuntimeException("parse pid error:" + name); + } + } + + } finally { + pidlock.unlock(); + } + } + return pid; + + } +} diff --git a/java/common/src/main/java/org/ray/util/config/AConfig.java b/java/common/src/main/java/org/ray/util/config/AConfig.java new file mode 100644 index 000000000000..e17a11c3cf19 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/config/AConfig.java @@ -0,0 +1,36 @@ +package org.ray.util.config; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotate a field as a ray configuration item. + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface AConfig { + + /** + * comments for this configuration field + */ + String comment(); + + /** + * when the config is an array list, a splitter set is specified, e.g., " \t" to use ' ' and '\t' + * as possible splits + */ + String splitters() default ", \t"; + + /** + * indirect with value as the new section name, the field name remains the same + */ + String defaultIndirectSectionName() default ""; + + /** + * see ConfigReader.getIndirectStringArray this config tells which is the default + * indirectSectionName in that function + */ + String defaultArrayIndirectSectionName() default ""; +} diff --git a/java/common/src/main/java/org/ray/util/config/ConfigItem.java b/java/common/src/main/java/org/ray/util/config/ConfigItem.java new file mode 100644 index 000000000000..0a6263310635 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/config/ConfigItem.java @@ -0,0 +1,15 @@ +package org.ray.util.config; + +/** + * A ray configuration item of type {@code T}. + */ +public class ConfigItem { + + public String key; + + public String oriValue; + + public T defaultValue; + + public String desc; +} diff --git a/java/common/src/main/java/org/ray/util/config/ConfigReader.java b/java/common/src/main/java/org/ray/util/config/ConfigReader.java new file mode 100644 index 000000000000..aea8e2ce7c10 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/config/ConfigReader.java @@ -0,0 +1,385 @@ +package org.ray.util.config; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Vector; +import org.ini4j.Config; +import org.ini4j.Ini; +import org.ini4j.Profile; +import org.ray.util.ObjectUtil; +import org.ray.util.StringUtil; + +/** + * Loads configurations from a file. + */ +public class ConfigReader { + + private final CurrentUseConfig currentUseConfig = new CurrentUseConfig(); + + private final Ini ini = new Ini(); + + private String file = ""; + + public ConfigReader(String filePath) throws Exception { + this(filePath, null); + } + + public ConfigReader(String filePath, String updateConfigStr) throws Exception { + System.out.println("Build ConfigReader, the file path " + filePath + " ,the update config str " + + updateConfigStr); + try { + loadConfigFile(filePath); + updateConfigFile(updateConfigStr); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + + } + + public String filePath() { + return file; + } + + private void loadConfigFile(String filePath) throws Exception { + + this.currentUseConfig.filePath = filePath; + String configFileDir = (new File(filePath)).getAbsoluteFile().getParent(); + byte[] encoded = Files.readAllBytes(Paths.get(filePath)); + String content = new String(encoded, StandardCharsets.UTF_8); + content = content.replaceAll("%CONFIG_FILE_DIR%", configFileDir); + + InputStream fis = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); + Config config = new Config(); + ini.setConfig(config); + ini.load(fis); + file = currentUseConfig.filePath; + } + + private void updateConfigFile(String updateConfigStr) { + + if (updateConfigStr == null) { + return; + } + String[] updateConfigArray = updateConfigStr.split(";"); + for (String currentUpdateConfig : updateConfigArray) { + if (StringUtil.isNullOrEmpty(currentUpdateConfig)) { + continue; + } + + String[] currentUpdateConfigArray = currentUpdateConfig.split("="); + String sectionAndItemKey; + String value = ""; + if (currentUpdateConfigArray.length == 2) { + sectionAndItemKey = currentUpdateConfigArray[0]; + value = currentUpdateConfigArray[1]; + } else if (currentUpdateConfigArray.length == 1) { + sectionAndItemKey = currentUpdateConfigArray[0]; + } else { + String errorMsg = "invalid config (must be of k=v or k or k=): " + currentUpdateConfig; + System.err.println(errorMsg); + throw new RuntimeException(errorMsg); + } + + int splitOffset = sectionAndItemKey.lastIndexOf("."); + int len = sectionAndItemKey.length(); + if (splitOffset < 1 || splitOffset == len - 1) { + String errorMsg = + "invalid config (no '.' found for section name and key):" + currentUpdateConfig; + System.err.println(errorMsg); + throw new RuntimeException(errorMsg); + } + + String sectionKey = sectionAndItemKey.substring(0, splitOffset); + String itemKey = sectionAndItemKey.substring(splitOffset + 1); + if (ini.containsKey(sectionKey)) { + ini.get(sectionKey).put(itemKey, value); + } else { + ini.add(sectionKey, itemKey, value); + } + } + } + + public CurrentUseConfig getCurrentUseConfig() { + return currentUseConfig; + } + + private synchronized String getOriValue(String sectionKey, String configKey, T defaultValue, + String deptr) { + if (null == deptr) { + throw new RuntimeException("desc must not be empty of the key:" + configKey); + } + Profile.Section section = ini.get(sectionKey); + String oriValue = null; + if (section != null && section.containsKey(configKey)) { + oriValue = section.get(configKey); + } + + if (!currentUseConfig.sectionMap.containsKey(sectionKey)) { + ConfigSection configSection = new ConfigSection(); + configSection.sectionKey = sectionKey; + updateConfigSection(configSection, configKey, defaultValue, deptr, oriValue); + currentUseConfig.sectionMap.put(sectionKey, configSection); + } else if (!currentUseConfig.sectionMap.get(sectionKey).itemMap.containsKey(configKey)) { + ConfigSection configSection = currentUseConfig.sectionMap.get(sectionKey); + updateConfigSection(configSection, configKey, defaultValue, deptr, oriValue); + } + return oriValue; + } + + private void updateConfigSection(ConfigSection configSection, String configKey, + T defaultValue, String deptr, String oriValue) { + ConfigItem configItem = new ConfigItem<>(); + configItem.defaultValue = defaultValue; + configItem.key = configKey; + configItem.oriValue = oriValue; + configItem.desc = deptr; + configSection.itemMap.put(configKey, configItem); + } + + + public String getStringValue(String sectionKey, String configKey, String defaultValue, + String dsptr) { + String value = getOriValue(sectionKey, configKey, defaultValue, dsptr); + if (value != null) { + return value; + } else { + return defaultValue; + } + } + + public boolean getBooleanValue(String sectionKey, String configKey, boolean defaultValue, + String dsptr) { + String value = getOriValue(sectionKey, configKey, defaultValue, dsptr); + if (value != null) { + if (value.length() == 0) { + return defaultValue; + } else { + return Boolean.valueOf(value); + } + } else { + return defaultValue; + } + } + + public int getIntegerValue(String sectionKey, String configKey, int defaultValue, String dsptr) { + String value = getOriValue(sectionKey, configKey, defaultValue, dsptr); + if (value != null) { + if (value.length() == 0) { + return defaultValue; + } else { + return Integer.valueOf(value); + } + } else { + return defaultValue; + } + } + + public long getLongValue(String sectionKey, String configKey, long defaultValue, String dsptr) { + String value = getOriValue(sectionKey, configKey, defaultValue, dsptr); + if (value != null) { + if (value.length() == 0) { + return defaultValue; + } else { + return Long.valueOf(value); + } + } else { + return defaultValue; + } + } + + public double getDoubleValue(String sectionKey, String configKey, double defaultValue, + String dsptr) { + String value = getOriValue(sectionKey, configKey, defaultValue, dsptr); + if (value != null) { + if (value.length() == 0) { + return defaultValue; + } else { + return Double.valueOf(value); + } + } else { + return defaultValue; + } + } + + + public int[] getIntegerArray(String sectionKey, String configKey, int[] defaultValue, + String dsptr) { + String value = getOriValue(sectionKey, configKey, defaultValue, dsptr); + int[] array = defaultValue; + if (value != null) { + String[] list = value.split(","); + array = new int[list.length]; + for (int i = 0; i < list.length; i++) { + array[i] = Integer.valueOf(list[i]); + } + } + return array; + } + + /** + * get a string list from a whole section as keys e.g., [core] data_dirs = local.dirs # or + * cluster.dirs + * + * [local.dirs] /home/xxx/1 /home/yyy/2 + * + * [cluster.dirs] ... + * + * @param sectionKey e.g., core + * @param configKey e.g., data_dirs + * @param indirectSectionName e.g., cluster.dirs + * @return string list + */ + public String[] getIndirectStringArray(String sectionKey, String configKey, + String indirectSectionName, String dsptr) { + String s = getStringValue(sectionKey, configKey, indirectSectionName, dsptr); + Profile.Section section = ini.get(s); + if (section == null) { + return new String[]{}; + } else { + return section.keySet().toArray(new String[]{}); + } + } + + public void readObject(String sectionKey, T obj, T defaultValues) { + for (Field fld : obj.getClass().getFields()) { + Object defaultFldValue; + try { + defaultFldValue = defaultValues != null ? fld.get(defaultValues) : null; + } catch (IllegalArgumentException | IllegalAccessException e) { + defaultFldValue = null; + } + + String section = sectionKey; + String comment; + String splitters = ", \t"; + String defaultArrayIndirectSectionName; + AConfig[] anns = fld.getAnnotationsByType(AConfig.class); + if (anns.length > 0) { + comment = anns[0].comment(); + if (!StringUtil.isNullOrEmpty(anns[0].splitters())) { + splitters = anns[0].splitters(); + } + defaultArrayIndirectSectionName = anns[0].defaultArrayIndirectSectionName(); + + // redirect the section if necessary + if (!StringUtil.isNullOrEmpty(anns[0].defaultIndirectSectionName())) { + section = this + .getStringValue(sectionKey, fld.getName(), anns[0].defaultIndirectSectionName(), + comment); + } + } else { + throw new RuntimeException("unspecified comment, please use @AConfig(comment = xxxx) for " + + obj.getClass().getName() + "." + fld.getName() + "'s configuration descriptions "); + } + + try { + if (fld.getType().isPrimitive()) { + if (fld.getType().equals(boolean.class)) { + boolean v = getBooleanValue(section, fld.getName(), (boolean) defaultFldValue, comment); + fld.set(obj, v); + } else if (fld.getType().equals(float.class)) { + float v = (float) getDoubleValue(section, fld.getName(), + (double) (float) defaultFldValue, comment); + fld.set(obj, v); + } else if (fld.getType().equals(double.class)) { + double v = getDoubleValue(section, fld.getName(), (double) defaultFldValue, comment); + fld.set(obj, v); + } else if (fld.getType().equals(byte.class)) { + byte v = (byte) getLongValue(section, fld.getName(), (long) (byte) defaultFldValue, + comment); + fld.set(obj, v); + } else if (fld.getType().equals(char.class)) { + char v = (char) getLongValue(section, fld.getName(), (long) (char) defaultFldValue, + comment); + fld.set(obj, v); + } else if (fld.getType().equals(short.class)) { + short v = (short) getLongValue(section, fld.getName(), (long) (short) defaultFldValue, + comment); + fld.set(obj, v); + } else if (fld.getType().equals(int.class)) { + int v = (int) getLongValue(section, fld.getName(), (long) (int) defaultFldValue, + comment); + fld.set(obj, v); + } else if (fld.getType().equals(long.class)) { + long v = getLongValue(section, fld.getName(), (long) defaultFldValue, comment); + fld.set(obj, v); + } else { + throw new RuntimeException("unhandled type " + fld.getType().getName()); + } + } else if (fld.getType().equals(String.class)) { + String v = getStringValue(section, fld.getName(), (String) defaultFldValue, comment); + fld.set(obj, v); + } else if (fld.getType().isEnum()) { + String sv = getStringValue(section, fld.getName(), defaultFldValue.toString(), comment); + @SuppressWarnings({"unchecked", "rawtypes"}) + Object v = Enum.valueOf((Class) 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")) { + String sv = getStringValue(section, fld.getName(), defaultFldValue.toString(), comment); + Object v; + try { + v = fld.getType().getConstructor(new Class[]{String.class}).newInstance(sv); + } catch (NoSuchMethodException | SecurityException | InstantiationException | InvocationTargetException e) { + System.err.println( + section + "." + fld.getName() + "'s format (" + sv + ") is invalid, default to " + + defaultFldValue.toString()); + v = defaultFldValue; + } + fld.set(obj, v); + } else if (fld.getType().isArray()) { + Class ccls = fld.getType().getComponentType(); + String ss = getStringValue(section, fld.getName(), null, comment); + if (null == ss) { + fld.set(obj, defaultFldValue); + } else { + Vector ls = StringUtil.Split(ss, splitters, "", ""); + if (ccls.equals(boolean.class)) { + boolean[] v = ObjectUtil + .toBooleanArray(ls.stream().map(Boolean::parseBoolean).toArray()); + fld.set(obj, v); + } else if (ccls.equals(double.class)) { + double[] v = ls.stream().mapToDouble(Double::parseDouble).toArray(); + fld.set(obj, v); + } else if (ccls.equals(int.class)) { + int[] v = ls.stream().mapToInt(Integer::parseInt).toArray(); + fld.set(obj, v); + } else if (ccls.equals(long.class)) { + long[] v = ls.stream().mapToLong(Long::parseLong).toArray(); + fld.set(obj, v); + } else if (ccls.equals(String.class)) { + String[] v; + if (StringUtil.isNullOrEmpty(defaultArrayIndirectSectionName)) { + v = ls.toArray(new String[]{}); + } else { + v = this + .getIndirectStringArray(section, fld.getName(), + defaultArrayIndirectSectionName, + comment); + } + fld.set(obj, v); + } else { + throw new RuntimeException( + "Array with component type " + ccls.getName() + " is not supported yet"); + } + } + } else { + Object fldObj = ObjectUtil.newObject(fld.getType()); + fld.set(obj, fldObj); + readObject(section + "." + fld.getName(), fldObj, defaultFldValue); + } + } catch (IllegalArgumentException | IllegalAccessException e) { + throw new RuntimeException("set fld " + fld.getName() + " failed, err = " + e.getMessage(), + e); + } + } + } + +} diff --git a/java/common/src/main/java/org/ray/util/config/ConfigSection.java b/java/common/src/main/java/org/ray/util/config/ConfigSection.java new file mode 100644 index 000000000000..95f5c1b4c256 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/config/ConfigSection.java @@ -0,0 +1,14 @@ +package org.ray.util.config; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * A configuration section of related items. + */ +public class ConfigSection { + + public String sectionKey; + + public final Map> itemMap = new ConcurrentHashMap<>(); +} diff --git a/java/common/src/main/java/org/ray/util/config/CurrentUseConfig.java b/java/common/src/main/java/org/ray/util/config/CurrentUseConfig.java new file mode 100644 index 000000000000..4367fa163d1a --- /dev/null +++ b/java/common/src/main/java/org/ray/util/config/CurrentUseConfig.java @@ -0,0 +1,16 @@ +package org.ray.util.config; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + + +/** + * The configuration which is currently in use. + */ +public class CurrentUseConfig { + + public String filePath; + + public final Map sectionMap = new ConcurrentHashMap<>(); + +} diff --git a/java/common/src/main/java/org/ray/util/exception/TaskExecutionException.java b/java/common/src/main/java/org/ray/util/exception/TaskExecutionException.java new file mode 100644 index 000000000000..d68759b144cc --- /dev/null +++ b/java/common/src/main/java/org/ray/util/exception/TaskExecutionException.java @@ -0,0 +1,15 @@ +package org.ray.util.exception; + +/** + * An exception which is thrown when a ray task encounters an error when executing. + */ +public class TaskExecutionException extends RuntimeException { + + public TaskExecutionException(Throwable cause) { + super(cause); + } + + public TaskExecutionException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/java/common/src/main/java/org/ray/util/generator/Composition.java b/java/common/src/main/java/org/ray/util/generator/Composition.java new file mode 100644 index 000000000000..46c59278738e --- /dev/null +++ b/java/common/src/main/java/org/ray/util/generator/Composition.java @@ -0,0 +1,38 @@ +package org.ray.util.generator; + +import java.util.ArrayList; +import java.util.List; + +/** + * Calculate all compositions for Parameter's count + Return's count, this class is used by code + * generators. + */ +public class Composition { + + public static class TR { + + public final int Tcount; + public final int Rcount; + + public TR(int tcount, int rcount) { + super(); + Tcount = tcount; + Rcount = rcount; + } + } + + public static List calculate(int maxT, int maxR) { + List ret = new ArrayList<>(); + for (int t = 0; t <= maxT; t++) { + + // <= 0 for dynamic return count + // 0 for call_n returns RayMap + // -1 for call_n returns RayObject<>[N] + + for (int r = -1; r <= maxR; r++) { + ret.add(new TR(t, r)); + } + } + return ret; + } +} diff --git a/java/common/src/main/java/org/ray/util/generator/FuncsGenerator.java b/java/common/src/main/java/org/ray/util/generator/FuncsGenerator.java new file mode 100644 index 000000000000..70c7bb190729 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/generator/FuncsGenerator.java @@ -0,0 +1,87 @@ +package org.ray.util.generator; + +import java.io.IOException; +import org.ray.util.FileUtil; +import org.ray.util.generator.Composition.TR; + +/** + * Generate all classes in org.ray.api.funcs + */ +public class FuncsGenerator { + + public static void main(String[] args) throws IOException { + String rootdir = System.getProperty("user.dir") + "/../api/src/main/java"; + rootdir += "/org/ray/api/funcs"; + generate(rootdir); + } + + private static void generate(String rootdir) throws IOException { + for (TR tr : Composition.calculate(Share.MAX_T, Share.MAX_R)) { + String str = build(tr.Tcount, tr.Rcount); + String file = rootdir + "/RayFunc_" + tr.Tcount + "_" + + (tr.Rcount <= 0 ? (tr.Rcount == 0 ? "n" : "n_list") : tr.Rcount) + ".java"; + FileUtil.overrideFile(file, str); + System.err.println("override " + file); + } + } + + /* + * package org.ray.api.funcs; + * + * @FunctionalInterface + * public interface RayFunc_4_1 extends RayFunc { R0 + * apply(); + * + * public static R0 execute(Object[] args) throws Throwable { String name = + * (String)args[args.length - 2]; assert (name.equals(RayFunc_0_1.class.getName())); byte[] + * funcBytes = (byte[])args[args.length - 1]; RayFunc_0_1 f = (RayFunc_0_1)SerializationUtils.deserialize(funcBytes); + * return f.apply(); } } + */ + private static String build(int Tcount, int Rcount) { + StringBuilder sb = new StringBuilder(); + String tname = + "Ray" + "Func_" + Tcount + "_" + (Rcount <= 0 ? (Rcount == 0 ? "n" : "n_list") : Rcount); + String gname = tname + "<" + Share.buildClassDeclare(Tcount, Rcount) + ">"; + + sb.append("package org.ray.api.funcs;").append("\n"); + if (Rcount > 1) { + sb.append("import org.ray.api.returns.*;").append("\n"); + } + if (Rcount <= 0) { + sb.append("import java.util.Collection;").append("\n"); + sb.append("import java.util.List;").append("\n"); + sb.append("import java.util.Map;").append("\n"); + } + sb.append("import org.ray.api.*;").append("\n"); + sb.append("import org.ray.api.internal.*;").append("\n"); + sb.append("import org.apache.commons.lang3.SerializationUtils;").append("\n"); + sb.append("\n"); + + sb.append("@FunctionalInterface").append("\n"); + sb.append("public interface ").append(gname).append(" extends RayFunc {") + .append("\n"); + sb.append("\t").append(Share.buildFuncReturn(Rcount)).append(" apply(") + .append(Rcount == 0 ? ("Collection returnids" + (Tcount > 0 ? ", " : "")) : "") + .append(Share.buildParameter(Tcount, "T", null)).append(") throws Throwable;") + .append("\n"); + + sb.append("\t\n"); + sb.append("\tpublic static " + "<").append(Share.buildClassDeclare(Tcount, Rcount)) + .append(">").append(" ").append(Share.buildFuncReturn(Rcount)) + .append(" execute(Object[] args) throws Throwable {").append("\n"); + sb.append("\t\tString name = (String)args[args.length - 2];").append("\n"); + sb.append("\t\tassert (name.equals(").append(tname).append(".class.getName()));").append("\n"); + sb.append("\t\tbyte[] funcBytes = (byte[])args[args.length - 1];").append("\n"); + sb.append("\t\t").append(gname).append(" f = SerializationUtils.deserialize(funcBytes);") + .append("\n"); + sb.append("\t\treturn f.apply(") + .append(Rcount == 0 ? ("(Collection)args[0]" + (Tcount > 0 ? ", " : "")) : "") + .append(Share.buildParameterUse2(Tcount, Rcount == 0 ? 1 : 0, "T", "args[", "]")) + .append(");").append("\n"); + sb.append("\t}").append("\n"); + sb.append("\t\n"); + sb.append("}").append("\n"); + return sb.toString(); + } + +} diff --git a/java/common/src/main/java/org/ray/util/generator/MultipleReturnGenerator.java b/java/common/src/main/java/org/ray/util/generator/MultipleReturnGenerator.java new file mode 100644 index 000000000000..e6d2c83bf69e --- /dev/null +++ b/java/common/src/main/java/org/ray/util/generator/MultipleReturnGenerator.java @@ -0,0 +1,68 @@ +package org.ray.util.generator; + +import java.io.IOException; +import org.ray.util.FileUtil; + +/** + * Generate all classes in org.ray.api.returns.MultipleReturnsX + */ +public class MultipleReturnGenerator { + + public static void main(String[] args) throws IOException { + String rootdir = System.getProperty("user.dir") + "/../api/src/main/java"; + rootdir += "/org/ray/api/returns"; + for (int r = 2; r <= Share.MAX_R; r++) { + String str = build(r); + String file = rootdir + "/MultipleReturns" + r + ".java"; + FileUtil.overrideFile(file, str); + System.err.println("override " + file); + } + } + + /** + * package org.ray.api.returns; + * + * public class MultipleReturns2 extends MultipleReturns { + * + * public MultipleReturns2(R0 r0, R1 r1) { super(new Object[] { r0, r1 }); } + * + * public R0 get0() { return (R0) this.values[0]; } + * + * public R1 get1() { return (R1) this.values[1]; } + * + * } + */ + private static String build(int Rcount) { + StringBuilder sb = new StringBuilder(); + sb.append("package org.ray.api.returns;").append("\n"); + sb.append("import org.ray.api.*;").append("\n"); + sb.append("@SuppressWarnings(\"unchecked\")"); + sb.append("public class MultipleReturns").append(Rcount).append("<") + .append(Share.buildClassDeclare(0, Rcount)).append("> extends MultipleReturns {") + .append("\n"); + sb.append("\tpublic MultipleReturns").append(Rcount).append("(") + .append(Share.buildParameter(Rcount, "R", null)).append(") {") + .append("\n"); + sb.append("\t\tsuper(new Object[] { ").append(Share.buildParameterUse(Rcount, "R")) + .append(" });") + .append("\n"); + sb.append("\t}").append("\n"); + + for (int k = 0; k < Rcount; k++) { + sb.append(buildGetter(k)); + } + + sb.append("}").append("\n"); + return sb.toString(); + } + + /* + * @SuppressWarnings("unchecked") public R1 get1() { return (R1) this.values[1]; } + */ + private static String buildGetter(int index) { + return ("\tpublic R" + index + " get" + index + "() {\n") + + "\t\treturn (R" + index + ") this.values[" + index + "];\n" + + "\t}\n"; + } + +} diff --git a/java/common/src/main/java/org/ray/util/generator/RayObjectsGenerator.java b/java/common/src/main/java/org/ray/util/generator/RayObjectsGenerator.java new file mode 100644 index 000000000000..5af1a67516ec --- /dev/null +++ b/java/common/src/main/java/org/ray/util/generator/RayObjectsGenerator.java @@ -0,0 +1,71 @@ +package org.ray.util.generator; + +import java.io.IOException; +import org.ray.util.FileUtil; + +/** + * Generate all classes in org.ray.api.returns.RayObjectsX + */ +public class RayObjectsGenerator { + + public static void main(String[] args) throws IOException { + String rootdir = System.getProperty("user.dir") + "/../api/src/main/java"; + rootdir += "/org/ray/api/returns"; + for (int r = 2; r <= Share.MAX_R; r++) { + String str = build(r); + String file = rootdir + "/RayObjects" + r + ".java"; + FileUtil.overrideFile(file, str); + System.err.println("override " + file); + } + } + + /* + * package org.ray.api.returns; + * + * import org.ray.api.RayObject; import org.ray.spi.model.UniqueID; + * + * @SuppressWarnings({"rawtypes", "unchecked"}) public class RayObjects2 extends + * RayObjects { + * + * public RayObjects2(UniqueID[] ids) { super(ids); } + * + * public RayObjects2(RayObject objs[]) { super(objs); } + * + * public RayObject r0() { return objs[0]; } + * + * public RayObject r1() { return objs[1]; } } + */ + private static String build(int Rcount) { + StringBuilder sb = new StringBuilder(); + sb.append("package org.ray.api.returns;\n"); + sb.append("import org.ray.api.*;\n"); + sb.append("import org.ray.spi.model.UniqueID;\n"); + sb.append("@SuppressWarnings({\"rawtypes\", \"unchecked\"})"); + sb.append("public class RayObjects").append(Rcount).append("<") + .append(Share.buildClassDeclare(0, Rcount)).append("> extends RayObjects {") + .append("\n"); + sb.append("\tpublic RayObjects").append(Rcount).append("(UniqueID[] ids) {").append("\n"); + sb.append("\t\tsuper(ids);").append("\n"); + sb.append("\t}").append("\n"); + sb.append("\tpublic RayObjects").append(Rcount).append("(RayObject objs[]) {").append("\n"); + sb.append("\t\tsuper(objs);").append("\n"); + sb.append("\t}").append("\n"); + + for (int k = 0; k < Rcount; k++) { + sb.append(buildGetter(k)); + } + + sb.append("}").append("\n"); + return sb.toString(); + } + + /** + * public RayObject r0() { return objs[0]; } + */ + private static String buildGetter(int index) { + return "\tpublic RayObject r" + index + "() {\n" + + "\t\treturn objs[" + index + "];\n" + + "\t}\n"; + } + +} diff --git a/java/common/src/main/java/org/ray/util/generator/RpcGenerator.java b/java/common/src/main/java/org/ray/util/generator/RpcGenerator.java new file mode 100644 index 000000000000..f7112b49b518 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/generator/RpcGenerator.java @@ -0,0 +1,175 @@ +package org.ray.util.generator; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; +import org.ray.util.FileUtil; +import org.ray.util.generator.Composition.TR; + +/** + * Generate Rpc.java + */ +public class RpcGenerator { + + public static void main(String[] args) throws IOException { + String rootdir = System.getProperty("user.dir") + "/../api/src/main/java"; + rootdir += "/org/ray/api/Rpc.java"; + FileUtil.overrideFile(rootdir, build()); + } + + private static String build() { + StringBuilder sb = new StringBuilder(); + + sb.append("package org.ray.api.internal;\n"); + sb.append("import org.ray.api.funcs.*;\n"); + sb.append("import org.ray.api.returns.*;\n"); + sb.append("import org.ray.api.*;\n"); + sb.append("import java.util.Collection;\n"); + sb.append("import java.util.Map;\n"); + + sb.append("@SuppressWarnings({\"rawtypes\", \"unchecked\"})\n"); + sb.append("class Rpc {\n"); + for (TR tr : Composition.calculate(Share.MAX_T, Share.MAX_R)) { + buildCall(sb, tr.Tcount, tr.Rcount); + } + sb.append("}\n"); + return sb.toString(); + } + + private static void buildCall(StringBuilder sb, int Tcount, int Rcount) { + for (Set whichTisFuture : whichTisFutureComposition(Tcount)) { + sb.append(buildCall(Tcount, Rcount, whichTisFuture)); + } + } + + /** + * public static RayObject call(RayFunc_1_1 f, RayObject arg) { return + * Ray.runtime().rpc(() -> f.apply(null), arg).objs[0]; } + */ + private static String buildCall(int Tcount, int Rcount, Set whichTisFuture) { + StringBuilder sb = new StringBuilder(); + String parameter = (Tcount == 0 ? "" + : ", " + Share.buildParameter(Tcount, "T", whichTisFuture)); + sb.append("\tpublic static <").append(Share.buildClassDeclare(Tcount, Rcount)).append("> ") + .append(Share.buildRpcReturn(Rcount)).append(" call") + .append(Rcount == 1 ? "" : (Rcount <= 0 ? "_n" : ("_" + Rcount))).append("(RayFunc_") + .append(Tcount).append("_") + .append(Rcount <= 0 ? (Rcount == 0 ? "n" : "n_list") : Rcount).append("<") + .append(Share.buildClassDeclare(Tcount, Rcount)).append("> f").append( + Rcount <= 0 ? (Rcount == 0 ? ", Collection returnids" : ", Integer returnCount") + : "").append(parameter).append(") {\n"); + + /* + * public static RayObject call(RayFunc_0_1 f) { + if (Ray.Parameters().remoteLambda()) { + return Ray.internal().call(RayFunc_0_1.class, f, 1).objs[0]; + } + else { + return Ray.internal().call(() -> f.apply(), 1).objs[0]; + } + } + */ + + String nulls = Share.buildRepeat("null", + Tcount + (Rcount == 0 ? 1/*for first arg map*/ : 0)); + String parameterUse = (Tcount == 0 ? "" : (", " + Share.buildParameterUse(Tcount, "T"))); + String labmdaUse = "RayFunc_" + + Tcount + "_" + (Rcount <= 0 ? (Rcount == 0 ? "n" : "n_list") : Rcount) + + ".class, f"; + + sb.append("\t\tif (Ray.Parameters().remoteLambda()) {\n"); + if (Rcount == 1) { + sb.append("\t\t\treturn Ray.internal().call(null, ").append(labmdaUse).append(", 1") + .append(parameterUse).append(").objs[0];") + .append("\n"); + } else if (Rcount == 0) { + sb.append("\t\t\treturn Ray.internal().callWithReturnLabels(null, ") + .append(labmdaUse).append(", returnids").append(parameterUse).append(");") + .append("\n"); + } else if (Rcount < 0) { + sb.append("\t\t\treturn Ray.internal().callWithReturnIndices(null, ") + .append(labmdaUse).append(", returnCount").append(parameterUse).append(");") + .append("\n"); + } else { + sb.append("\t\t\treturn new RayObjects").append(Rcount) + .append("(Ray.internal().call(null, ").append(labmdaUse).append(", ").append(Rcount) + .append(parameterUse).append(").objs);") + .append("\n"); + } + sb.append("\t\t} else {\n"); + if (Rcount == 1) { + sb.append("\t\t\treturn Ray.internal().call(null, () -> f.apply(").append(nulls) + .append("), 1").append(parameterUse).append(").objs[0];") + .append("\n"); + } else if (Rcount == 0) { + sb.append("\t\t\treturn Ray.internal().callWithReturnLabels(null, () -> f.apply(") + .append(nulls).append("), returnids").append(parameterUse).append(");") + .append("\n"); + } else if (Rcount < 0) { + sb.append("\t\t\treturn Ray.internal().callWithReturnIndices(null, () -> f.apply(") + .append(nulls).append("), returnCount").append(parameterUse).append(");") + .append("\n"); + } else { + sb.append("\t\t\treturn new RayObjects").append(Rcount) + .append("(Ray.internal().call(null, () -> f.apply(").append(nulls).append("), ") + .append(Rcount).append(parameterUse).append(").objs);") + .append("\n"); + } + sb.append("\t\t}\n"); + sb.append("\t}\n"); + return sb.toString(); + } + + private static Set> whichTisFutureComposition(int Tcount) { + Set> ret = new HashSet<>(); + Set N = new HashSet<>(); + for (int k = 0; k < Tcount; k++) { + N.add(k); + } + for (int k = 0; k <= Tcount; k++) { + ret.addAll(CNn(N, k)); + } + return ret; + } + + //pick n numbers in N + private static Set> CNn(Set N, int n) { + C c = new C(); + for (int k = 0; k < n; k++) { + c.mul(N); + } + return c.v; + } + + static class C { + + Set> v; + + public C() { + v = new HashSet<>(); + v.add(new HashSet<>()); + } + + void mul(Set ns) { + Set> ret = new HashSet<>(); + for (int n : ns) { + ret.addAll(mul(n)); + } + this.v = ret; + } + + Set> mul(int n) { + Set> ret = new HashSet<>(); + for (Set s : v) { + if (s.contains(n)) { + continue; + } + Set ns = new HashSet<>(s); + ns.add(n); + ret.add(ns); + } + return ret; + } + } + +} diff --git a/java/common/src/main/java/org/ray/util/generator/Share.java b/java/common/src/main/java/org/ray/util/generator/Share.java new file mode 100644 index 000000000000..44acf70eb65b --- /dev/null +++ b/java/common/src/main/java/org/ray/util/generator/Share.java @@ -0,0 +1,139 @@ +package org.ray.util.generator; + +import java.util.Set; + +/** + * Share util for generators + */ +public class Share { + + public static final int MAX_T = 6; + public static final int MAX_R = 4; + + /** + * T0, T1, T2, T3, R + */ + public static String buildClassDeclare(int Tcount, int Rcount) { + StringBuilder sb = new StringBuilder(); + for (int k = 0; k < Tcount; k++) { + sb.append("T").append(k).append(", "); + } + if (Rcount == 0) { + sb.append("R, RID"); + } else if (Rcount < 0) { + assert (Rcount == -1); + sb.append("R"); + } else { + for (int k = 0; k < Rcount; k++) { + sb.append("R").append(k).append(", "); + } + sb.deleteCharAt(sb.length() - 1); + sb.deleteCharAt(sb.length() - 1); + } + return sb.toString(); + } + + /** + * T0 t0, T1 t1, T2 t2, T3 t3 + */ + public static String buildParameter(int Tcount, String TR, Set whichTisFuture) { + StringBuilder sb = new StringBuilder(); + for (int k = 0; k < Tcount; k++) { + sb.append(whichTisFuture != null && whichTisFuture.contains(k) + ? "RayObject<" + (TR + k) + ">" : (TR + k)).append(" ").append(TR.toLowerCase()) + .append(k).append(", "); + } + if (Tcount > 0) { + sb.deleteCharAt(sb.length() - 1); + sb.deleteCharAt(sb.length() - 1); + } + return sb.toString(); + } + + /** + * t0, t1, t2 + */ + public static String buildParameterUse(int Tcount, String TR) { + StringBuilder sb = new StringBuilder(); + for (int k = 0; k < Tcount; k++) { + sb.append(TR.toLowerCase()).append(k).append(", "); + } + if (Tcount > 0) { + sb.deleteCharAt(sb.length() - 1); + sb.deleteCharAt(sb.length() - 1); + } + return sb.toString(); + } + + public static String buildParameterUse2(int Tcount, int startIndex, String TR, String pre, + String post) { + StringBuilder sb = new StringBuilder(); + for (int k = 0; k < Tcount; k++) { + sb.append("(").append(TR).append(k).append(")").append(pre).append(k + startIndex) + .append(post).append(", "); + } + if (Tcount > 0) { + sb.deleteCharAt(sb.length() - 1); + sb.deleteCharAt(sb.length() - 1); + } + return sb.toString(); + } + + /** + * MultipleReturns2 apply(); R0 + */ + public static String buildFuncReturn(int Rcount) { + if (Rcount == 0) { + return "Map"; + } else if (Rcount < 0) { + assert (-1 == Rcount); + return "List"; + } + if (Rcount == 1) { + return "R0"; + } + StringBuilder sb = new StringBuilder(); + for (int k = 0; k < Rcount; k++) { + sb.append("R").append(k).append(", "); + } + sb.deleteCharAt(sb.length() - 1); + sb.deleteCharAt(sb.length() - 1); + return "MultipleReturns" + Rcount + "<" + sb.toString() + ">"; + + } + + /** + */ + public static String buildRpcReturn(int Rcount) { + if (Rcount == 0) { + return "RayMap"; + } else if (Rcount < 0) { + assert (Rcount == -1); + return "RayList"; + } + + if (Rcount == 1) { + return "RayObject"; + } + StringBuilder sb = new StringBuilder(); + for (int k = 0; k < Rcount; k++) { + sb.append("R").append(k).append(", "); + } + sb.deleteCharAt(sb.length() - 1); + sb.deleteCharAt(sb.length() - 1); + return "RayObjects" + Rcount + "<" + sb.toString() + ">"; + + } + + public static String buildRepeat(String toRepeat, int count) { + StringBuilder ret = new StringBuilder(); + for (int k = 0; k < count; k++) { + ret.append(toRepeat).append(", "); + } + if (count > 0) { + ret.deleteCharAt(ret.length() - 1); + ret.deleteCharAt(ret.length() - 1); + } + return ret.toString(); + } +} diff --git a/java/common/src/main/java/org/ray/util/logger/ConsoleLogger.java b/java/common/src/main/java/org/ray/util/logger/ConsoleLogger.java new file mode 100644 index 000000000000..c3d0c590860d --- /dev/null +++ b/java/common/src/main/java/org/ray/util/logger/ConsoleLogger.java @@ -0,0 +1,46 @@ +package org.ray.util.logger; + +import org.apache.log4j.Logger; + +/** + * A logger which prints output to console + */ +public class ConsoleLogger extends Logger { + + final Logger realLogger; + + protected ConsoleLogger(String name, Logger realLogger) { + super(name); + this.realLogger = realLogger; + } + + @Override + public void info(Object log) { + realLogger.info("(" + this.getName() + ") " + log); + } + + @Override + public void warn(Object log) { + realLogger.warn("(" + this.getName() + ") " + log); + } + + @Override + public void warn(Object log, Throwable e) { + realLogger.warn("(" + this.getName() + ") " + log, e); + } + + @Override + public void debug(Object log) { + realLogger.debug("(" + this.getName() + ") " + log); + } + + @Override + public void error(Object log) { + realLogger.error("(" + this.getName() + ") " + log); + } + + @Override + public void error(Object log, Throwable e) { + realLogger.error("(" + this.getName() + ") " + log, e); + } +} diff --git a/java/common/src/main/java/org/ray/util/logger/DynamicLog.java b/java/common/src/main/java/org/ray/util/logger/DynamicLog.java new file mode 100644 index 000000000000..bf308fa00ec3 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/logger/DynamicLog.java @@ -0,0 +1,260 @@ +package org.ray.util.logger; + +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import org.apache.log4j.Logger; +import org.ray.util.CommonUtil; + +/** + * Dynamic logger without properties configuration file + */ +public class DynamicLog { + + static final ThreadLocal PREFIX = new ThreadLocal<>(); + + private static LogLevel logLevel = LogLevel.DEBUG; + + private static Boolean logLevelSetFlag = false; + + /** + * set the context prefix for all logs + */ + public static void setContextPrefix(String prefix) { + PREFIX.set(prefix); + } + + public static String getContextPrefix() { + return PREFIX.get(); + } + + /** + * set the level for all logs + */ + public static void setLogLevel(String level) { + if (logLevelSetFlag) { /* one shot, avoid the risk of multithreading */ + return; + } + logLevelSetFlag = true; + logLevel = LogLevel.of(level); + } + + private static LogLevel getenumLogLevel() { + return logLevel; + } + + @Override + public String toString() { + return this.getKey(); + } + + @Override + public boolean equals(Object o) { + return this.toString().equals(o.toString()); + } + + @Override + public int hashCode() { + return this.toString().hashCode(); + } + + private String wrap(String level, String log) { + StackTraceElement stes[] = Thread.currentThread().getStackTrace(); + String ret = "[" + level + "]" + "[" + stes[3].getFileName() + ":" + stes[3].getLineNumber() + + "] - " + (log == null ? "" : log); + String prefix = PREFIX.get(); + if (prefix != null) { + ret = "[" + prefix + "]" + ret; + } + return ret; + } + + public void debug(String log) { + if (!getenumLogLevel().needLog(LogLevel.DEBUG)) { + return; + } + log = wrap("debug", log); + Logger loggers[] = DynamicLogManager.getLogs(this); + for (Logger logger : loggers) { + logger.debug(log); + } + } + + public void info(String log) { + if (!getenumLogLevel().needLog(LogLevel.INFO)) { + return; + } + log = wrap("info", log); + Logger loggers[] = DynamicLogManager.getLogs(this); + for (Logger logger : loggers) { + logger.info(log); + } + } + + public void warn(String log) { + if (!getenumLogLevel().needLog(LogLevel.WARN)) { + return; + } + log = wrap("warn", log); + Logger loggers[] = DynamicLogManager.getLogs(this); + for (Logger logger : loggers) { + logger.warn(log); + } + } + + public void warn(String log, Throwable e) { + if (!getenumLogLevel().needLog(LogLevel.WARN)) { + return; + } + log = wrap("warn", log); + Logger loggers[] = DynamicLogManager.getLogs(this); + for (Logger logger : loggers) { + logger.warn(log, e); + } + } + + public void error(String log) { + if (!getenumLogLevel().needLog(LogLevel.ERROR)) { + return; + } + log = wrap("error", log); + Logger loggers[] = DynamicLogManager.getLogs(this); + for (Logger logger : loggers) { + logger.error(log); + } + } + + public void error(String log, Throwable e) { + if (!getenumLogLevel().needLog(LogLevel.ERROR)) { + return; + } + log = wrap("error", log); + if (e == null) { + error(log); + return; + } + + Logger loggers[] = DynamicLogManager.getLogs(this); + for (Logger logger : loggers) { + logger.error(log, e); + } + } + + public void error(Throwable e) { + if (!getenumLogLevel().needLog(LogLevel.ERROR)) { + return; + } + String log = wrap("error", e == null ? null : e.getMessage()); + if (e == null) { + error(log); + return; + } + Logger loggers[] = DynamicLogManager.getLogs(this); + for (Logger logger : loggers) { + logger.error(log, e); + } + } + + //statistic for sampling + private static class SampleStatis { + + int total; + + public boolean gamble() { + int randomRange; + + if (total < 100) { + randomRange = 1; + } else if (total < 1000) { + randomRange = 1000; + } else if (total < 100000) { + randomRange = 10000; + } else if (total < 1000000) { + randomRange = 100000; + } else { + total = 0; + randomRange = 1; + } + if (CommonUtil.getRandom(randomRange) == 0) { + total++; + return true; + } else { + total++; + return false; + } + } + } + + private static Map sampleStatis = new ConcurrentHashMap<>(); + + /** + * Print sample error log + */ + public boolean sampleError(Object sampleKeyO, String log, Throwable e) { + String sampleKey = sampleKeyO.toString(); + try { + SampleStatis ss = sampleStatis.computeIfAbsent(sampleKey, k -> new SampleStatis()); + if (ss.gamble()) { + Logger loggers[] = DynamicLogManager.getLogs(this); + for (Logger logger : loggers) { + if (e != null) { + logger.error("[" + sampleKey + "] - " + log, e); + } else { + logger.error("[" + sampleKey + "] - " + log); + } + } + return true; + } else { + return false; + } + } finally { + if (sampleStatis.size() > 100000) { + sampleStatis = new ConcurrentHashMap<>(); + } + } + } + + private final String key; + + private DynamicLog(String key) { + this.key = key; + } + + public String getKey() { + return this.key; + } + + public String getDefaultLogFileName() { + return this.key + ".log"; + } + + public static DynamicLog registerName(String name) { + return DynamicLogNameRegister.registerName(name); + } + + public static Collection values() { + return DynamicLogNameRegister.names.values(); + } + + public static class DynamicLogNameRegister { + + static final Map names = new ConcurrentHashMap<>(); + + public static DynamicLog registerName(String name) { + DynamicLog ret = names.get(name); + if (ret != null) { + return ret; + } + synchronized (names) { + ret = names.get(name); + if (ret != null) { + return ret; + } + ret = new DynamicLog(name); + names.put(name, ret); + return ret; + } + } + } + +} diff --git a/java/common/src/main/java/org/ray/util/logger/DynamicLogManager.java b/java/common/src/main/java/org/ray/util/logger/DynamicLogManager.java new file mode 100644 index 000000000000..d684e7a0e883 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/logger/DynamicLogManager.java @@ -0,0 +1,161 @@ +package org.ray.util.logger; + +import java.io.File; +import java.io.IOException; +import java.util.concurrent.ConcurrentHashMap; +import org.apache.log4j.ConsoleAppender; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.PatternLayout; +import org.apache.log4j.RollingFileAppender; +import org.ray.util.SystemUtil; + +/** + * Manager for dynamic loggers + */ +public class DynamicLogManager { + + //whether to print the log on std(ie. console) + public static boolean printOnStd = false; + //the root directory of log files + public static String logsDir; + public static String logsSuffix; + public static Level level = Level.DEBUG; //Level.INFO; + /** */ + private static final int LOG_CACHE_SIZE = 32 * 1024; + protected final static String DAY_DATE_PATTERN = "'.'yyyy-MM-dd"; + // private final static String HOUR_DATE_PATTERN = "'.'yyyy-MM-dd_HH"; + // private final static String GBK = "GBK"; + private final static String DAILY_APPENDER_NAME = "_DAILY_APPENDER_NAME"; + // private final static String CONSOLE_APPENDER_NAME = "_CONSOLE_APPENDER_NAME"; + private final static String LAYOUT_PATTERN = "%d [%t]%m%n"; + + private static final ConcurrentHashMap loggers = new ConcurrentHashMap<>(); + + private static int MAX_FILE_NUM = 10; + + private static String MAX_FILE_SIZE = "500MB"; + + private static boolean initFinished = false; + + + /** + * init from system properties + * -DlogOutput=console/file_path + * if file_path contains *pid*, it will be replaced with real PID of this JAVA process + * if file_path contains *pid_suffix*, all log file will append the suffix -> xxx-pid.log + */ + static { + String logOutput = System.getProperty("logOutput"); + if (null == logOutput + || logOutput.equalsIgnoreCase("console") + || logOutput.equalsIgnoreCase("std") + || logOutput.equals("")) { + DynamicLogManager.printOnStd = true; + System.out.println("config log output as std"); + } else { + if (logOutput.contains("*pid*")) { + logOutput = logOutput.replaceAll("\\*pid\\*", String.valueOf(SystemUtil.pid())); + } + if (logOutput.contains("*pid_suffix*")) { + logOutput = logOutput.replaceAll("\\*pid_suffix\\*", ""); + if (logOutput.endsWith("/")) { + logOutput = logOutput.substring(0, logOutput.length() - 1); + } + DynamicLogManager.logsSuffix = String.valueOf(SystemUtil.pid()); + } + System.out.println("config log output as " + logOutput); + DynamicLogManager.logsDir = logOutput; + } + String logLevel = System.getProperty("logLevel"); + if (logLevel != null && logLevel.equals("debug")) { + level = Level.DEBUG; + } + } + + public static synchronized void init(int maxFileNum, String maxFileSize) { + if (initFinished) { + return; + } + initFinished = true; + System.out.println( + "DynamicLogManager init with maxFileNum:" + maxFileNum + " maxFileSize:" + maxFileSize); + if (loggers.size() > 0) { + System.err + .println("already have logger be maked before init log file system, please check it"); + } + MAX_FILE_NUM = maxFileNum; + MAX_FILE_SIZE = maxFileSize; + } + + public static Logger[] getLogs(DynamicLog dynLog) { + Logger logger = loggers.get(dynLog); + if (logger == null) { + synchronized (loggers) { + logger = loggers.get(dynLog); + if (logger == null) { + logger = initLogger(dynLog); + } + } + } + return new Logger[]{logger}; + } + + private static Logger initLogger(DynamicLog dynLog) { + if (printOnStd) { + Logger reallogger = Logger.getLogger(dynLog.getKey()); + ConsoleLogger logger = new ConsoleLogger(dynLog.getKey(), reallogger); + PatternLayout layout = new PatternLayout(LAYOUT_PATTERN); + ConsoleAppender appender = new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT); + reallogger.removeAllAppenders(); + reallogger.addAppender(appender); + reallogger.setLevel(level); + reallogger.setAdditivity(false); + loggers.putIfAbsent(dynLog, logger); + return logger; + } else { + Logger logger = makeLogger(dynLog.getKey(), dynLog.getDefaultLogFileName()); + loggers.putIfAbsent(dynLog, logger); + return logger; + } + + } + + protected static Logger makeLogger(String loggerName, String filename) { + Logger logger = Logger.getLogger(loggerName); + PatternLayout layout = new PatternLayout(LAYOUT_PATTERN); + File dir = new File(logsDir); + if (!dir.exists()) { + dir.mkdirs(); + } + String logFileName = logsDir + "/" + filename; + if (logsSuffix != null) { + logFileName = logFileName.substring(0, logFileName.length() - 4) + "-" + logsSuffix + + ".log"; + } + System.out.println("new_log_path:" + logFileName); + RollingFileAppender appender; + try { + appender = new TimedFlushDailyRollingFileAppender(layout, logFileName); + appender.setAppend(true); + appender.setEncoding("UTF-8"); + appender.setName(DAILY_APPENDER_NAME); + appender.setBufferSize(LOG_CACHE_SIZE); + appender.setBufferedIO(true); + appender.setImmediateFlush(false); + appender.setMaxBackupIndex(MAX_FILE_NUM); + appender.setMaxFileSize(MAX_FILE_SIZE); + appender.activateOptions(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + logger.removeAllAppenders(); + logger.addAppender(appender); + + logger.setLevel(level); + logger.setAdditivity(false); + return logger; + } + +} diff --git a/java/common/src/main/java/org/ray/util/logger/LogLevel.java b/java/common/src/main/java/org/ray/util/logger/LogLevel.java new file mode 100644 index 000000000000..9e93b95f13d6 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/logger/LogLevel.java @@ -0,0 +1,29 @@ +package org.ray.util.logger; + +public enum LogLevel { + ERROR("error", 0), + WARN("warn", 1), + INFO("info", 2), + DEBUG("debug", 3); + + private final String name; + private final int index; + + LogLevel(String name, int index) { + this.name = name; + this.index = index; + } + + public static LogLevel of(String name) { + for (LogLevel level : values()) { + if (level.name.equals(name)) { + return level; + } + } + return null; + } + + public Boolean needLog(LogLevel level) { + return level.index <= this.index; + } +} \ No newline at end of file diff --git a/java/common/src/main/java/org/ray/util/logger/RayLog.java b/java/common/src/main/java/org/ray/util/logger/RayLog.java new file mode 100644 index 000000000000..62a8bfa54c7a --- /dev/null +++ b/java/common/src/main/java/org/ray/util/logger/RayLog.java @@ -0,0 +1,17 @@ +package org.ray.util.logger; + +/** + * Dynamic loggers in Ray + */ +public class RayLog { + + /** + * for ray itself + */ + public static final DynamicLog core = DynamicLog.registerName("core"); + + /** + * for ray's app's log + */ + public static DynamicLog rapp = core; //DynamicLog.registerName("rapp"); +} diff --git a/java/common/src/main/java/org/ray/util/logger/TimedFlushDailyRollingFileAppender.java b/java/common/src/main/java/org/ray/util/logger/TimedFlushDailyRollingFileAppender.java new file mode 100644 index 000000000000..282c4d131370 --- /dev/null +++ b/java/common/src/main/java/org/ray/util/logger/TimedFlushDailyRollingFileAppender.java @@ -0,0 +1,68 @@ +package org.ray.util.logger; + +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; +import org.apache.log4j.Layout; +import org.apache.log4j.RollingFileAppender; + +/** + * Normal log appender + */ +public class TimedFlushDailyRollingFileAppender extends RollingFileAppender { + + private final static Set all = new HashSet<>(); + + public TimedFlushDailyRollingFileAppender() { + super(); + synchronized (all) { + all.add(this); + } + } + + public TimedFlushDailyRollingFileAppender(Layout layout, String filename) throws IOException { + super(layout, filename); + synchronized (all) { + all.add(this); + } + } + + static { + new TimedFlushLogThread().start(); + } + + private void flush() { + try { + if (!checkEntryConditions()) { + return; + } + qw.flush(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static class TimedFlushLogThread extends Thread { + + public TimedFlushLogThread() { + super(); + setName("TimedFlushLogThread"); + setDaemon(true); + } + + public void run() { + while (true) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + synchronized (all) { + for (TimedFlushDailyRollingFileAppender appender : all) { + appender.flush(); + } + } + } + } + } +} diff --git a/java/example/pom.xml b/java/example/pom.xml new file mode 100644 index 000000000000..d6f253f91a0d --- /dev/null +++ b/java/example/pom.xml @@ -0,0 +1,102 @@ + + + + + org.ray.parent + ray-superpom + 1.0 + + 4.0.0 + + org.ray + ray-example + + java example for ray + java example for ray + + + jar + + + + org.ray + ray-api + 1.0 + + + + org.ray + ray-runtime-common + 1.0 + + + + org.ray + ray-runtime-native + 1.0 + + + + org.ray + ray-runtime-dev + 1.0 + + + + org.ray + ray-common + 1.0 + + + + org.ray + ray-hook + 1.0 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20.1 + + + ${basedir}/../ray.config.ini + + -ea + -Djava.library.path=${basedir}/../../build/src/plasma:${basedir}/../../build/src/local_scheduler + -noverify + -DlogOutput=console + + ${basedir}/src/main/java/ + ${project.build.directory}/classes/ + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + ${basedir}/lib + false + false + true + + + + + + + + + diff --git a/java/example/run.sh b/java/example/run.sh new file mode 100755 index 000000000000..cdf65a44086f --- /dev/null +++ b/java/example/run.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +#first you should run the ../test.sh to build +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd) +export RAY_CONFIG=$ROOT_DIR/../ray.config.ini +java -Djava.library.path=../../build/src/plasma:../../build/src/local_scheduler -cp .:target/ray-example-1.0.jar:lib/* org.ray.example.HelloWorld \ No newline at end of file diff --git a/java/example/src/main/java/org/ray/example/HelloWorld.java b/java/example/src/main/java/org/ray/example/HelloWorld.java new file mode 100644 index 000000000000..bdfaef068ac6 --- /dev/null +++ b/java/example/src/main/java/org/ray/example/HelloWorld.java @@ -0,0 +1,56 @@ +package org.ray.example; + +import org.ray.api.Ray; +import org.ray.api.RayObject; +import org.ray.api.RayRemote; +import org.ray.core.RayRuntime; +import org.ray.util.logger.RayLog; + +import java.io.Serializable; + +public class HelloWorld implements Serializable{ + + + public static String sayHelloWorld() { + RayObject hello = Ray.call(HelloWorld::sayHello); + RayObject world = Ray.call(HelloWorld::sayWorld); + return Ray.call(HelloWorld::merge, hello, world).get(); + } + + @RayRemote + public static String sayHello() { + String ret = "he"; + ret += "llo"; + RayLog.rapp.info("real say hello"); + return ret; + } + + @RayRemote + public static String sayWorld() { + String ret = "world"; + ret += "!"; + return ret; + } + + @RayRemote + public static String merge(String hello, String world) { + return hello + "," + world; + } + + public static void main(String[] args) throws Exception { + try { + Ray.init(); + String helloWorld = HelloWorld.sayHelloWorld(); + RayLog.rapp.info(helloWorld); + assert helloWorld.equals("hello,world!"); + } + catch (Throwable t) { + t.printStackTrace(); + } + finally { + RayRuntime.getInstance().cleanUp(); + } + + + } +} diff --git a/java/hook/pom.xml b/java/hook/pom.xml new file mode 100644 index 000000000000..b45a1c9ec482 --- /dev/null +++ b/java/hook/pom.xml @@ -0,0 +1,88 @@ + + + + + org.ray.parent + ray-superpom + 1.0 + + 4.0.0 + + org.ray + ray-hook + java api hook for ray + java api hook for ray + + + jar + + + + + + org.ow2.asm + asm + 6.0 + + + + commons-codec + commons-codec + 1.4 + + + + commons-io + commons-io + 2.5 + + + + org.ray + ray-common + 1.0 + + + + + + + + maven-jar-plugin + 2.5 + + + + org.ray.hook.Agent + true + + + + + + + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + org.objectweb.asm + agent.org.objectweb.asm + + + false + + + + + + + diff --git a/java/hook/src/main/java/org/ray/hook/ClassAdapter.java b/java/hook/src/main/java/org/ray/hook/ClassAdapter.java new file mode 100644 index 000000000000..b8fa1662f077 --- /dev/null +++ b/java/hook/src/main/java/org/ray/hook/ClassAdapter.java @@ -0,0 +1,49 @@ +package org.ray.hook; + +import java.util.Set; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassWriter; + +public class ClassAdapter { + + public static class Result { + + public byte[] classBuffer; + public Set changedMethods; + } + + public static Result hookClass(ClassLoader loader, String className, byte[] classfileBuffer) { + // we have to comment out this quick filter as this is not accurate + // e.g., org/ray/api/test/ActorTest$Adder.class is skipped!!! + // even worse, this is non-deterministic... + /* + if (detectBody.contains("org/ray/hook/")) { + return classfileBuffer; + } + */ + + ClassReader reader = new ClassReader(classfileBuffer); + ClassWriter writer = new ClassWriter(reader, 0); + ClassDetectVisitor pre = new ClassDetectVisitor(loader, writer, className); + byte[] result; + + reader.accept(pre, ClassReader.SKIP_FRAMES); + if (pre.detectedMethods().isEmpty() && pre.actorCalls() == 0) { + result = classfileBuffer; + } else { + if (pre.actorCalls() > 0) { + reader = new ClassReader(writer.toByteArray()); + } + + writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES); + reader.accept(new ClassOverrideVisitor(writer, className, pre.detectedMethods()), + ClassReader.SKIP_FRAMES); + result = writer.toByteArray(); + } + + Result rr = new Result(); + rr.changedMethods = pre.detectedMethods(); + rr.classBuffer = result; + return rr; + } +} diff --git a/java/hook/src/main/java/org/ray/hook/ClassDetectVisitor.java b/java/hook/src/main/java/org/ray/hook/ClassDetectVisitor.java new file mode 100644 index 000000000000..f733fc71495b --- /dev/null +++ b/java/hook/src/main/java/org/ray/hook/ClassDetectVisitor.java @@ -0,0 +1,164 @@ +package org.ray.hook; + +import java.security.InvalidParameterException; +import java.util.HashSet; +import java.util.Set; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.Handle; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; + +/** + * rewrite phase 1 + */ +public class ClassDetectVisitor extends ClassVisitor { + + final String className; + final Set rayMethods = new HashSet<>(); + boolean isActor = false; + static int count = 0; + int actorCalls = 0; + final ClassLoader loader; + + public int actorCalls() { + return actorCalls; + } + + public ClassDetectVisitor(ClassLoader loader, ClassVisitor origin, String className) { + super(Opcodes.ASM6, origin); + this.className = className; + this.loader = loader; + } + + public Set detectedMethods() { + return rayMethods; + } + + @Override + public void visitInnerClass(String name, String outerName, + String innerName, int access) { + // System.err.println("visist inner class " + outerName + "$" + innerName); + super.visitInnerClass(name, outerName, innerName, access); + } + + @Override + public AnnotationVisitor visitAnnotation(String desc, boolean visible) { + if (desc.contains("Lorg/ray/api/RayRemote;")) { + isActor = true; + } + return super.visitAnnotation(desc, visible); + } + + private void visitRayMethod(int access, String name, String mdesc) { + if (name.equals("")) { + return; + } + + MethodId m = new MethodId(className, name, mdesc, (access & Opcodes.ACC_STATIC) != 0, loader); + rayMethods.add(m); + //System.err.println("Visit " + m.toString()); + count++; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String mdesc, String signature, + String[] exceptions) { + //System.out.println("Visit " + className + "." + name); + if (isActor && (access & Opcodes.ACC_PUBLIC) != 0) { + visitRayMethod(access, name, mdesc); + } + + MethodVisitor origin = super.visitMethod(access, name, mdesc, signature, exceptions); + return new MethodVisitor(this.api, origin) { + @Override + public AnnotationVisitor visitAnnotation(String adesc, boolean visible) { + //handle rayRemote annotation + if (adesc.contains("Lorg/ray/api/RayRemote;")) { + visitRayMethod(access, name, mdesc); + } + return super.visitAnnotation(adesc, visible); + } + + private boolean isValidCallParameterOrReturnType(Type t) { + if (t.equals(Type.VOID_TYPE)) { + return false; + } + if (t.equals(Type.BOOLEAN_TYPE)) { + return false; + } + if (t.equals(Type.CHAR_TYPE)) { + return false; + } + if (t.equals(Type.BYTE_TYPE)) { + return false; + } + if (t.equals(Type.SHORT_TYPE)) { + return false; + } + if (t.equals(Type.INT_TYPE)) { + return false; + } + if (t.equals(Type.FLOAT_TYPE)) { + return false; + } + if (t.equals(Type.LONG_TYPE)) { + return false; + } + if (t.equals(Type.DOUBLE_TYPE)) { + return false; + } + + return true; + } + + @Override + public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, + Object... bsmArgs) { + + // fix all actor calls from InvokeVirtual to InvokeStatic + if (desc.contains("org/ray/api/funcs/RayFunc_")) { + int count = bsmArgs.length; + for (int i = 0; i < count; ++i) { + Object arg = bsmArgs[i]; + // System.err.println(arg.getClass().getName() + " " + arg.toString()); + if (arg.getClass().equals(Handle.class)) { + Handle h = (Handle) arg; + if (h.getTag() == Opcodes.H_INVOKEVIRTUAL) { + String dsptr = h.getDesc(); + + Type[] argTypes = Type.getArgumentTypes(dsptr); + for (Type argt : argTypes) { + if (!isValidCallParameterOrReturnType(argt)) { + throw new InvalidParameterException( + "cannot use primitive parameter type '" + argt.getClassName() + + "' in method " + h.getOwner() + "." + h.getName()); + } + } + Type retType = Type.getReturnType(dsptr); + if (!isValidCallParameterOrReturnType(retType)) { + throw new InvalidParameterException( + "cannot use primitive return type '" + retType.getClassName() + "' in method " + + h.getOwner() + "." + h.getName()); + } + + dsptr = "(L" + h.getOwner() + ";" + dsptr.substring(1); + Handle newh = new Handle( + Opcodes.H_INVOKESTATIC, + h.getOwner(), + h.getName() + MethodId.getFunctionIdPostfix, + dsptr, + h.isInterface()); + bsmArgs[i] = newh; + //System.err.println("Change ray.call from " + h + " -> " + newh + ", isInterface = " + h.isInterface()); + ++actorCalls; + } + } + } + } + super.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs); + } + }; + } +} diff --git a/java/hook/src/main/java/org/ray/hook/ClassOverrideVisitor.java b/java/hook/src/main/java/org/ray/hook/ClassOverrideVisitor.java new file mode 100644 index 000000000000..58024d6982f1 --- /dev/null +++ b/java/hook/src/main/java/org/ray/hook/ClassOverrideVisitor.java @@ -0,0 +1,223 @@ +package org.ray.hook; + +import java.util.Set; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +/** + * rewrite phase 2 + */ +public class ClassOverrideVisitor extends ClassVisitor { + + final String className; + final Set rayRemoteMethods; + MethodVisitor ClinitVisitor; + + // init the static added field in + // static { + // assign value to _hashOf_XXX + // } + class StaticBlockVisitor extends MethodVisitor { + + StaticBlockVisitor(MethodVisitor mv) { + super(Opcodes.ASM6, mv); + } + + @Override + public void visitCode() { + super.visitCode(); + + // assign value for added hash fields within + for (MethodId m : rayRemoteMethods) { + byte[] hash = m.getSha1Hash(); + insertByteArray(hash); + mv.visitFieldInsn(Opcodes.PUTSTATIC, className, m.getStaticHashValueFieldName(), "[B"); + + System.out.println("assign field: " + m.getStaticHashValueFieldName() + " = " + MethodId + .toHexHashString(hash)); + } + } + + private void insertByteArray(byte[] bytes) { + int length = bytes.length; + assert (length < Short.MAX_VALUE); + mv.visitIntInsn(Opcodes.SIPUSH, length); + mv.visitIntInsn(Opcodes.NEWARRAY, Opcodes.T_BYTE); + mv.visitInsn(Opcodes.DUP); + for (int i = 0; i < length; ++i) { + mv.visitIntInsn(Opcodes.BIPUSH, i); + mv.visitIntInsn(Opcodes.BIPUSH, bytes[i]); + mv.visitInsn(Opcodes.BASTORE); + if (i < (length - 1)) { + mv.visitInsn(Opcodes.DUP); + } + } + } + + } + + public ClassOverrideVisitor(ClassVisitor origin, String className, + Set rayRemoteMethods) { + super(Opcodes.ASM6, origin); + this.className = className; + this.rayRemoteMethods = rayRemoteMethods; + this.ClinitVisitor = null; + } + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, + String[] exceptions) { + if ("".equals(name) && ClinitVisitor == null) { + MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions); + ClinitVisitor = new StaticBlockVisitor(mv); + return ClinitVisitor;// dispatch the ASM modifications (assign values to the preComputedxxx static field) to the ClinitVisitor + } + + ClassVisitor this_ = this; + MethodId m = new MethodId(className, name, desc, (access & Opcodes.ACC_STATIC) != 0, null); + if (rayRemoteMethods.contains(m)) { + if (m.isStaticMethod()) { + return new MethodVisitor(api, + super.visitMethod(access, name, desc, signature, exceptions)) { + @Override + public void visitCode() { + // step 1: add a field for the function id of this method + System.out.println("add field: " + m.getStaticHashValueFieldName()); + String fieldName = m.getStaticHashValueFieldName(); + this_.visitField(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, fieldName, "[B", + null, null); + + // step 2: rewrite current method so if MethodSwitcher returns true, returns the added function id directly + // else call the original method + mv.visitFieldInsn(Opcodes.GETSTATIC, className, fieldName, "[B"); + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "org/ray/hook/runtime/MethodSwitcher", + "execute", + "([B)Z", false); + Label dorealwork = new Label(); + mv.visitJumpInsn(Opcodes.IFEQ, dorealwork); + properReturn(sayReturnType(desc), mv);// proper return on + // different types + mv.visitLabel(dorealwork); + mv.visitCode();// real work + } + }; + } + + // non-static + else { + return super.visitMethod(access, name, desc, signature, exceptions); + } + } else { + return super.visitMethod(access, name, desc, signature, exceptions); + } + } + + @Override + public void visitEnd() { + if (ClinitVisitor == null) { // works fine + // Create an empty static block and let our method + // visitor modify it the same way it modifies an + // existing static block + { + MethodVisitor mv = super.visitMethod(Opcodes.ACC_STATIC, "", "()V", null, null); + mv = new StaticBlockVisitor(mv); + mv.visitCode(); + mv.visitInsn(Opcodes.RETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + } + } + + // for each non-static method, create a method for returning hash + for (MethodId mid : this.rayRemoteMethods) { + if (!mid.isStaticMethod()) { + + // step 1: create a new method called method_name_function_id() + System.out.println("add method: " + mid.getIdMethodName()); + MethodVisitor mv = super.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, + mid.getIdMethodName(), mid.getIdMethodDesc(), null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + + // step 2: add a new static field as the function id of this method + System.out.println("add field: " + mid.getStaticHashValueFieldName()); + String fieldName = mid.getStaticHashValueFieldName(); + this.visitField(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, fieldName, "[B", + null, null); + mv.visitFieldInsn(Opcodes.GETSTATIC, className, fieldName, "[B"); + + // step 3: call method switcher, and returns the function id when the mode is rewritten + mv.visitMethodInsn(Opcodes.INVOKESTATIC, "org/ray/hook/runtime/MethodSwitcher", "execute", + "([B)Z", false); + mv.visitInsn(Opcodes.POP); + Label l1 = new Label(); + mv.visitLabel(l1); + properReturn(sayReturnType(mid.getMethodDesc()), mv); + + Label l2 = new Label(); + mv.visitLabel(l2); + + org.objectweb.asm.Type[] args = org.objectweb.asm.Type + .getArgumentTypes(mid.getIdMethodDesc()); + int argCount = args.length; + /* + for (int i = 0; i < argCount; ++i) { + String ldsptr = args[i].getDescriptor(); + if (!ldsptr.endsWith(";")) + ldsptr = "L" + ldsptr + ";"; + mv.visitLocalVariable("arg" + i, ldsptr, null, l0, l2, i); + } + */ + mv.visitMaxs(2, argCount); + mv.visitEnd(); + } + } + } + + private void properReturn(String returnType, MethodVisitor mv) { + int returnCode; + Object returnValue = null; + switch (returnType) { + case "V": + mv.visitInsn(Opcodes.RETURN); + return; + case "I": + case "B": + case "S": + case "Z": // int byte short boolean + returnCode = Opcodes.IRETURN; + returnValue = 0; + break; + case "J": // long + returnCode = Opcodes.LRETURN; + returnValue = 0L; + break; + case "D": // double + returnCode = Opcodes.DRETURN; + returnValue = 0D; + break; + case "F": // float + returnCode = Opcodes.FRETURN; + returnValue = 0F; + break; + default: // reference + returnCode = Opcodes.ARETURN; + break; + } + if (returnValue != null) { + mv.visitLdcInsn(returnValue); + } else { + mv.visitInsn(Opcodes.ACONST_NULL); + } + mv.visitInsn(returnCode); + } + + private String sayReturnType(String str) { + int left = str.lastIndexOf(")") + 1; + return str.substring(left); + } + +} diff --git a/java/hook/src/main/java/org/ray/hook/JarRewriter.java b/java/hook/src/main/java/org/ray/hook/JarRewriter.java new file mode 100644 index 000000000000..6dcce96d1557 --- /dev/null +++ b/java/hook/src/main/java/org/ray/hook/JarRewriter.java @@ -0,0 +1,201 @@ +package org.ray.hook; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.List; +import java.util.Scanner; +import java.util.function.BiConsumer; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.JarOutputStream; +import java.util.zip.DataFormatException; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.io.filefilter.DirectoryFileFilter; +import org.apache.commons.io.filefilter.RegexFileFilter; +import org.ray.hook.runtime.JarLoader; +import org.ray.hook.runtime.LoadedFunctions; +import org.ray.util.logger.RayLog; + +/** + * rewrite jars to new jars with methods marked using Ray annotations + */ +public class JarRewriter { + + private static final String FUNCTIONS_FILE = "ray.functions.txt"; + + public static void main(String[] args) + throws IOException, SecurityException, DataFormatException { + if (args.length == 1) { + LoadedFunctions funcs = load(args[0], null); + for (MethodId mi : funcs.functions) { + System.err.println(mi.getIdMethodDesc()); + Method m = mi.load(); + String logInfo = "load: " + m.getDeclaringClass().getName() + "." + m.getName(); + RayLog.core.info(logInfo); + } + return; + } else if (args.length < 2) { + System.err.println("org.ray.hook.JarRewriter source-jar-dir dest-jar-dir"); + System.exit(1); + } + + rewrite(args[0], args[1]); + } + + public static void rewrite(String fromDir, String toDir) throws IOException, DataFormatException { + File fromDirFile = new File(fromDir); + File toDirFileTmp = new File(toDir + ".tmp"); + File toDirFile = new File(toDir); + + File[] topFiles = fromDirFile.listFiles(); + if (topFiles.length != 1 || !topFiles[0].isDirectory()) { + throw new DataFormatException("There should be a top dir in the Ray app zip file."); + } + String topDir = topFiles[0].getName(); + + if (toDirFileTmp.exists()) { + FileUtils.deleteDirectory(toDirFileTmp); + } + //toDirFileTmp.mkdir(); + FileUtils.copyDirectory(fromDirFile, toDirFileTmp); + + PrintWriter functionCollector = new PrintWriter(toDir + ".tmp/" + FUNCTIONS_FILE, "UTF-8"); + + // get all jars + Collection files = FileUtils.listFiles( + fromDirFile, + new RegexFileFilter(".*\\.jar"), + DirectoryFileFilter.DIRECTORY + ); + + // load and rewrite + int prefixLength = fromDirFile.getAbsolutePath().length() + topDir.length() + 2; + for (File appJar : files) { + String fromPath = appJar.getAbsolutePath(); + if (fromPath.substring(prefixLength).contains("/")) { + functionCollector.close(); + throw new DataFormatException("There should not be any subdir" + + " containing jar file in the top dir of the Ray app zip file."); + } + JarFile jar = new JarFile(appJar.getAbsolutePath()); + String to = fromPath + .replaceFirst(fromDirFile.getAbsolutePath(), toDirFileTmp.getAbsolutePath()); + rewrite(jar, to, (l, m) -> functionCollector.println(m.toEncodingString())); + jar.close(); + } + + // rename the whole dir + functionCollector.close(); + + if (toDirFile.exists()) { + FileUtils.deleteDirectory(toDirFile); + } + + FileUtils.moveDirectory(toDirFileTmp, toDirFile); + } + + public static LoadedFunctions load(String dir, String baseDir) + throws FileNotFoundException, SecurityException { + List functions = JarRewriter.getRewrittenFunctions(dir); + LoadedFunctions efuncs = new LoadedFunctions(); + efuncs.loader = JarLoader.loadJars(dir, false); + + for (String func : functions) { + MethodId mid = new MethodId(func, efuncs.loader); + efuncs.functions.add(mid); + } + + if (baseDir != null && !baseDir.equals("")) { + List baseFunctions = JarRewriter.getRewrittenFunctions(baseDir); + for (String func : baseFunctions) { + MethodId mid = new MethodId(func, efuncs.loader); + efuncs.functions.add(mid); + } + } + + return efuncs; + } + + public static LoadedFunctions loadBase(String baseDir) + throws FileNotFoundException, SecurityException { + List functions = JarRewriter.getRewrittenFunctions(baseDir); + LoadedFunctions efuncs = new LoadedFunctions(); + efuncs.loader = null; + + for (String func : functions) { + MethodId mid = new MethodId(func, efuncs.loader); + efuncs.functions.add(mid); + } + + return efuncs; + } + + public static List getRewrittenFunctions(String rewrittenDir) + throws FileNotFoundException { + ArrayList functions = new ArrayList<>(); + Scanner s = new Scanner(new File(rewrittenDir + "/" + FUNCTIONS_FILE)); + while (s.hasNext()) { + String f = s.next(); + if (!f.startsWith("(")) { + functions.add(f); + } + } + s.close(); + + return functions; + } + + public static void rewrite(JarFile from, String to, BiConsumer consumer) + throws IOException { + + FileOutputStream ofStream = new FileOutputStream(to); + JarOutputStream ojStream = new JarOutputStream(ofStream); + Enumeration e = from.entries(); + String className; + + while (e.hasMoreElements()) { + JarEntry je = e.nextElement(); + byte[] jeBytes = IOUtils.toByteArray(from.getInputStream(je)); + + //System.err.println("XXXXXX " + from.getName() + " :: " + je.getName()); + if (!je.isDirectory() && je.getName().endsWith(".class")) { + className = je.getName().substring(0, je.getName().length() - ".class".length()); + + //System.err.println("XXXXXX " + from.getName() + " :: " + je.getName() + " - " + className); + ClassAdapter.Result result = ClassAdapter.hookClass(null, className, jeBytes); + if (result.classBuffer != jeBytes) { + String logInfo = "Rewrite class " + className + " from " + jeBytes.length + " bytes to " + + result.classBuffer.length + " bytes "; + RayLog.core.info(logInfo); + } + + if (result.changedMethods != null) { + for (MethodId m : result.changedMethods) { + consumer.accept(null, m); + } + } + + je = new JarEntry(je.getName()); + je.setTime(System.currentTimeMillis()); + je.setSize(result.classBuffer.length); + jeBytes = result.classBuffer; + } + + ojStream.putNextEntry(je); + ojStream.write(jeBytes); + //ojStream.closeEntry(); + } + + ojStream.close(); + ofStream.close(); + } +} diff --git a/java/hook/src/main/java/org/ray/hook/MethodId.java b/java/hook/src/main/java/org/ray/hook/MethodId.java new file mode 100644 index 000000000000..dd8e9e2efb91 --- /dev/null +++ b/java/hook/src/main/java/org/ray/hook/MethodId.java @@ -0,0 +1,226 @@ +package org.ray.hook; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.ArrayList; +import java.util.Arrays; +import org.apache.commons.codec.digest.DigestUtils; +import org.objectweb.asm.Type; +import org.ray.util.logger.RayLog; + +/** + * Represent a Method in a Class + */ +public class MethodId { + + String className; + String methodName; + String methodDesc; + boolean isStatic; + ClassLoader loader; + + static final String getFunctionIdPostfix = "_function_id"; + + public MethodId(String cls, String method, String mdesc, boolean isstatic, ClassLoader loader_) { + className = cls; + methodName = method; + methodDesc = mdesc; + isStatic = isstatic; + loader = loader_; + } + + public MethodId(String encodedString, ClassLoader loader_) { + // className + "." + methodName + "::" + methodDesc + "&&" + isStatic; + int lastPos3 = encodedString.lastIndexOf("&&"); + int lastPos2 = encodedString.lastIndexOf("::"); + int lastPos1 = encodedString.lastIndexOf("."); + if (lastPos1 == -1 || lastPos2 == -1 || lastPos3 == -1) { + throw new RuntimeException("invalid given method id " + encodedString + + " - it must be className.methodName::methodDesc&&isStatic"); + } + + className = encodedString.substring(0, lastPos1); + methodName = encodedString.substring(lastPos1 + ".".length(), lastPos2); + methodDesc = encodedString.substring(lastPos2 + "::".length(), lastPos3); + isStatic = Boolean.parseBoolean(encodedString.substring(lastPos3 + "&&".length())); + loader = loader_; + } + + public String getClassName() { + return className; + } + + public String getMethodName() { + return methodName; + } + + public String getMethodDesc() { + return methodDesc; + } + + public ClassLoader getLoader() { + return loader; + } + + public Boolean isStaticMethod() { + return isStatic; + } + + public String getIdMethodName() { + return this.methodName + getFunctionIdPostfix; + } + + public String getIdMethodDesc() { + return "(L" + this.className + ";" + this.methodDesc.substring(1); + } + + public static String toHexHashString(byte[] id) { + String s = ""; + String hex = "0123456789abcdef"; + assert (id.length == 20); + for (int i = 0; i < 20; i++) { + int val = id[i] & 0xff; + s += hex.charAt(val >> 4); + s += hex.charAt(val & 0xf); + } + return s; + } + + private String toHexHashString() { + byte[] id = this.getSha1Hash(); + return toHexHashString(id); + } + + public Method load() { + String loadClsName = className.replace('/', '.'); + Class cls; + try { + RayLog.core.debug( + "load class " + loadClsName + " from class loader " + (loader == null ? this.getClass() + .getClassLoader() : loader) + + " for method " + toString() + " with ID = " + toHexHashString() + ); + cls = Class + .forName(loadClsName, true, loader == null ? this.getClass().getClassLoader() : loader); + } catch (Throwable e) { + RayLog.core.error("Cannot load class " + loadClsName, e); + return null; + } + + Method[] ms = cls.getDeclaredMethods(); + ArrayList methods = new ArrayList<>(); + Type t = Type.getMethodType(this.methodDesc); + Type[] params = t.getArgumentTypes(); + String rt = t.getReturnType().getDescriptor(); + + for (Method m : ms) { + if (m.getName().equals(methodName)) { + if (!Arrays.equals(params, Type.getArgumentTypes(m))) { + continue; + } + + String mrt = Type.getDescriptor(m.getReturnType()); + if (!rt.equals(mrt)) { + continue; + } + + methods.add(m); + } + } + + if (methods.size() != 1) { + RayLog.core.error( + "Load method " + toString() + " failed as there are " + methods.size() + " definitions"); + return null; + } + + Method m = methods.get(0); + try { + Field fld = cls.getField(getStaticHashValueFieldName()); + Object hashValue = fld.get(null); + if (hashValue instanceof byte[] && Arrays.equals((byte[]) hashValue, this.getSha1Hash())) { + RayLog.core.debug("Method " + toString() + " hash: " + toHexHashString((byte[]) hashValue)); + } else { + if (hashValue instanceof byte[]) { + RayLog.core.error( + "Method " + toString() + " hash-field: " + toHexHashString((byte[]) hashValue) + + " vs id-hash: " + toHexHashString()); + } else { + RayLog.core.error( + "Method " + toString() + " hash-field: " + (hashValue != null ? hashValue.toString() + : "") + " vs id-hash: " + toHexHashString()); + } + } + } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + RayLog.core.error("load method hash field failed for " + toString(), e); + } + return m; + } + + public String toEncodingString() { + return className + "." + methodName + "::" + methodDesc + "&&" + isStatic; + } + + public byte[] getSha1Hash() { + byte[] digests = DigestUtils.sha(toEncodingString()); + ByteBuffer bb = ByteBuffer.wrap(digests); + bb.order(ByteOrder.LITTLE_ENDIAN); + if (methodName.contains("createActorStage1")) { + bb.putLong(Long.BYTES, 1); + } else { + bb.putLong(Long.BYTES, 0); + } + return digests; + } + + public String getStaticHashValueFieldName() { + // _hashOf_([Ljava/lang/String;)V + String r = "_hashOf" + methodName + "_" + methodDesc; + r = r.replace("<", "_") + .replace(">", "_") + .replace("(", "_") + .replace("[", "_") + .replace("/", "_") + .replace(";", "_") + .replace(")", "_") + ; + // System.err.println(r); + return r; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + className.hashCode(); + result = prime * result + methodName.hashCode(); + result = prime * result + methodDesc.hashCode(); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MethodId other = (MethodId) obj; + return className.equals(other.className) + && methodName.equals(other.methodName) + && methodDesc.equals(other.methodDesc) + && isStatic == other.isStatic + ; + } + + @Override + public String toString() { + return toEncodingString(); + } +} diff --git a/java/hook/src/main/java/org/ray/hook/runtime/JarLoader.java b/java/hook/src/main/java/org/ray/hook/runtime/JarLoader.java new file mode 100644 index 000000000000..ffbc9d1d0eed --- /dev/null +++ b/java/hook/src/main/java/org/ray/hook/runtime/JarLoader.java @@ -0,0 +1,131 @@ +package org.ray.hook.runtime; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.filefilter.DirectoryFileFilter; +import org.apache.commons.io.filefilter.RegexFileFilter; +import org.ray.util.logger.RayLog; + +/** + * load and unload jars from a dir + */ +public class JarLoader { + + private static Method AddUrl = InitAddUrl(); + + private static Method InitAddUrl() { + try { + Method m = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); + m.setAccessible(true); + return m; + } catch (NoSuchMethodException | SecurityException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + return null; + } + } + + public static URLClassLoader loadJars(String dir, boolean explicitLoadForHook) { + // get all jars + Collection jars = FileUtils.listFiles( + new File(dir), + new RegexFileFilter(".*\\.jar"), + DirectoryFileFilter.DIRECTORY + ); + return loadJar(jars, explicitLoadForHook); + } + + public static ClassLoader loadJars(String[] appJars, boolean explicitLoadForHook) { + List jars = new ArrayList<>(); + + for (String jar : appJars) { + if (jar.endsWith(".jar")) { + jars.add(new File(jar)); + } else { + loadJarDir(jar, jars); + } + } + + return loadJar(jars, explicitLoadForHook); + } + + public static void unloadJars(ClassLoader loader) { + // TODO: + } + + private static URLClassLoader loadJar(Collection appJars, boolean explicitLoadForHook) { + List jars = new ArrayList<>(); + List urls = new ArrayList<>(); + + for (File appJar : appJars) { + try { + RayLog.core.info("load jar " + appJar.getAbsolutePath() + " in ray hook"); + JarFile jar = new JarFile(appJar.getAbsolutePath()); + jars.add(jar); + urls.add(appJar.toURI().toURL()); + } catch (IOException e) { + e.printStackTrace(); + System.err.println( + "invalid app jar path: " + appJar.getAbsolutePath() + ", load failed with exception " + + e.getMessage()); + System.exit(1); + return null; + } + } + + URLClassLoader cl = URLClassLoader.newInstance(urls.toArray(new URL[0])); + + if (!explicitLoadForHook) { + return cl; + } + + for (JarFile jar : jars) { + Enumeration e = jar.entries(); + while (e.hasMoreElements()) { + JarEntry je = e.nextElement(); + //System.err.println("check " + je.getName()); + if (je.isDirectory() || !je.getName().endsWith(".class")) { + continue; + } + + // -6 because of .class + String className = je.getName().substring(0, je.getName().length() - 6); + className = className.replace('/', '.'); + try { + Class.forName(className, true, cl); + //System.err.println("load class " + className + " OK"); + } catch (ClassNotFoundException e1) { + e1.printStackTrace(); + } + } + + try { + jar.close(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + return cl; + } + + private static void loadJarDir(String jarDir, List jars) { + Collection files = FileUtils.listFiles( + new File(jarDir), + new RegexFileFilter(".*\\.jar"), + DirectoryFileFilter.DIRECTORY + ); + + jars.addAll(files); + } +} diff --git a/java/hook/src/main/java/org/ray/hook/runtime/LoadedFunctions.java b/java/hook/src/main/java/org/ray/hook/runtime/LoadedFunctions.java new file mode 100644 index 000000000000..ec418c53dc30 --- /dev/null +++ b/java/hook/src/main/java/org/ray/hook/runtime/LoadedFunctions.java @@ -0,0 +1,12 @@ +package org.ray.hook.runtime; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import org.ray.hook.MethodId; + +public class LoadedFunctions { + + public ClassLoader loader = null; + public final Set functions = Collections.synchronizedSet(new HashSet<>()); +} diff --git a/java/hook/src/main/java/org/ray/hook/runtime/MethodHash.java b/java/hook/src/main/java/org/ray/hook/runtime/MethodHash.java new file mode 100644 index 000000000000..873d1e0be30b --- /dev/null +++ b/java/hook/src/main/java/org/ray/hook/runtime/MethodHash.java @@ -0,0 +1,36 @@ +package org.ray.hook.runtime; + +import java.util.Arrays; + +public class MethodHash { + + private final byte[] hash; + + public MethodHash(byte[] hash) { + this.hash = hash; + } + + public byte[] getHash() { + return hash; + } + + @Override + public int hashCode() { + return Arrays.hashCode(getHash()); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + MethodHash other = (MethodHash) obj; + return Arrays.equals(this.getHash(), other.getHash()); + } +} diff --git a/java/hook/src/main/java/org/ray/hook/runtime/MethodSwitcher.java b/java/hook/src/main/java/org/ray/hook/runtime/MethodSwitcher.java new file mode 100644 index 000000000000..196062c77e3f --- /dev/null +++ b/java/hook/src/main/java/org/ray/hook/runtime/MethodSwitcher.java @@ -0,0 +1,21 @@ +package org.ray.hook.runtime; + +/** + * method mode switch at runtime + */ +public class MethodSwitcher { + + public static final ThreadLocal IsRemoteCall = new ThreadLocal<>(); + + public static final ThreadLocal MethodId = new ThreadLocal<>(); + + public static boolean execute(byte[] id) { + Boolean hooking = IsRemoteCall.get(); + if (Boolean.TRUE.equals(hooking)) { + MethodId.set(id); + return true; + } else { + return false; + } + } +} diff --git a/java/logfilter.sh b/java/logfilter.sh new file mode 100755 index 000000000000..2551aaac9720 --- /dev/null +++ b/java/logfilter.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +function for_in_file(){ + if [ -f $1 ]; then + echo "THIS IS THE NEXT TASKID HERE:\n" >> logfilter + b="nextTaskId:" + for i in `cat $1` + do + grep -r $i *|awk -v prefix=$b '/Task .+ Object .+ get/{print prefix$(6) >> "logfilter"}' + done + fi +} + +cd ./$1/ +if [ -f logfilter ]; then + rm logfilter +fi +if [ -f tempobjectid ]; then + rm tempobjectid +fi +grep -r "$2" * > logfilter +cat logfilter|awk '/Task .+ Object .+ put/{print $(NF-1) > "tempobjectid"}' +for_in_file tempobjectid +cat logfilter + + + diff --git a/java/pom.xml b/java/pom.xml new file mode 100644 index 000000000000..5515c19af173 --- /dev/null +++ b/java/pom.xml @@ -0,0 +1,122 @@ + + + 4.0.0 + pom + + org.ray.parent + ray-superpom + 1.0 + + api + common + hook + runtime-common + runtime-native + runtime-dev + test + example + + + + 1.8 + UTF-8 + + + + + + org.apache.arrow + arrow-plasma + 0.10.0-SNAPSHOT + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.6.1 + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + -parameters + -parameters + + + + + org.apache.maven.plugins + maven-source-plugin + 3.0.1 + + + attach-sources + deploy + + jar + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.10 + + + org.apache.maven.plugins + maven-clean-plugin + 3.0.0 + + + + org.mortbay.jetty + maven-jetty-plugin + 6.1.26 + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2 + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.10.4 + + + attach-javadocs + deploy + + jar + + + + + + maven-deploy-plugin + 2.8.2 + + + deploy + deploy + + deploy + + + + + + + + + diff --git a/java/ray.config.ini b/java/ray.config.ini new file mode 100644 index 000000000000..4712dd241173 --- /dev/null +++ b/java/ray.config.ini @@ -0,0 +1,160 @@ +[ray] +ray_protocol_version = 0x0000000000000000 +heartbeat_timeout_milliseconds = 1000 +num_heartbeats_timeout = 100 +get_timeout_milliseconds = 1000 +worker_get_request_size = 1000 +worker_fetch_request_size = 1000 +num_connect_attempts = 50 +connect_timeout_milliseconds = 1000 +local_scheduler_fetch_timeout_milliseconds = 1000 +local_scheduler_reconstruction_timeout_milliseconds = 1000 +max_num_to_reconstruct = 1000 +local_scheduler_fetch_request_size = 10000 +kill_worker_timeout_milliseconds = 1000 +manager_timeout_milliseconds = 1000 +buf_size = 4096 +max_time_for_handler_milliseconds = 1000 +size_limit = 100 +num_elements_limit = 1000 +max_time_for_loop = 1000 +redis_db_connect_retries = 50 +redis_db_connect_wait_milliseconds = 1000 +plasma_default_release_delay = 0 +L3_cache_size_bytes = 100000000 +simple_fail_over = false +;store_evict_soft_max_count = 10 + +[ray.java] +;network_interface = en0 + +; set log level: debug info warn error +log_level = debug +;log_level = warn + +[ray.java.start] + +; run mode for this app SINGLE_PROCESS | SINGLE_BOX | CLUSTER +;run_mode = SINGLE_PROCESS +run_mode = SINGLE_BOX + +; worker mode for this app DRIVER | WORKER | NONE +worker_mode = DRIVER + +; number of workers initially started +num_workers = 2 + +driver_id = 0123456789abcdef0123456789abcdef01234567 + +working_directory = %CONFIG_FILE_DIR%/run + +logging_directory = %CONFIG_FILE_DIR%/run/logs + +redis_port = 34111 + +num_local_schedulers = 1 + +max_submit_task_buffer_size_bytes = 51200 + +default_first_check_timeout_ms = 1000 + +default_get_check_interval_ms = 5000 + +;jvm_parameters = -XX:+TraceClassLoading + +object_store_occupied_memory_MB = 2 + +deploy = false + +max_java_log_file_num = 10 + +max_java_log_file_size = 500MB + +onebox_delay_seconds_before_run_app_logic = 0 + +[ray.java.start.job] + +; java class which main is served as the driver in a java worker +driver_class = + +[ray.java.path.classes.source] +%CONFIG_FILE_DIR%/common/target/classes = +%CONFIG_FILE_DIR%/common/target/test-classes = + +%CONFIG_FILE_DIR%/api/target/classes = +%CONFIG_FILE_DIR%/api/target/test-classes = + +%CONFIG_FILE_DIR%/runtime-common/target/classes = +%CONFIG_FILE_DIR%/runtime-common/target/test-classes = + +%CONFIG_FILE_DIR%/runtime-dev/target/classes = +%CONFIG_FILE_DIR%/runtime-dev/target/test-classes = + +%CONFIG_FILE_DIR%/runtime-native/target/classes = +%CONFIG_FILE_DIR%/runtime-native/target/test-classes = + +%CONFIG_FILE_DIR%/example/target/classes = + +%CONFIG_FILE_DIR%/test/target/classes = +%CONFIG_FILE_DIR%/test/target/test-classes = +%CONFIG_FILE_DIR%/test/lib/* = + +[ray.java.path.classes.package] +%CONFIG_FILE_DIR%/common/target/ray-common-1.0.jar = +%CONFIG_FILE_DIR%/api/target/ray-api-1.0.jar = +%CONFIG_FILE_DIR%/runtime-common/target/ray-runtime-common-1.0.jar = +%CONFIG_FILE_DIR%/runtime-dev/target/ray-runtime-dev-1.0.jar = +%CONFIG_FILE_DIR%/runtime-native/target/ray-runtime-native-1.0.jar = + +%CONFIG_FILE_DIR%/test/target/ray-test-1.0.jar = +%CONFIG_FILE_DIR%/test/target/test-classes = +%CONFIG_FILE_DIR%/test/lib/* = + +%CONFIG_FILE_DIR%/example/target/ray-example-1.0.jar = + +[ray.java.path.classes.deploy] +%CONFIG_FILE_DIR%/java/lib/* = + +[ray.java.path.jni.package] +%CONFIG_FILE_DIR%/../build/src/plasma = +%CONFIG_FILE_DIR%/../build/src/local_scheduler = + +[ray.java.path.jni.deploy] +%CONFIG_FILE_DIR%/native/lib = + +[ray.java.path.source] +redis_server = %CONFIG_FILE_DIR%/../build/src/common/thirdparty/redis/src/redis-server +redis_module = %CONFIG_FILE_DIR%/../build/src/common/redis_module/libray_redis_module.so +store = %CONFIG_FILE_DIR%/../build/src/plasma/plasma_store +store_manager = %CONFIG_FILE_DIR%/../build/src/plasma/plasma_manager +local_scheduler = %CONFIG_FILE_DIR%/../build/src/local_scheduler/local_scheduler +global_scheduler = %CONFIG_FILE_DIR%/../build/src/global_scheduler/global_scheduler +python_dir = %CONFIG_FILE_DIR%/../build/ +java_runtime_rewritten_jars_dir = +java_class_paths = ray.java.path.classes.source +java_jnilib_paths = ray.java.path.jni.package + +[ray.java.path.package] +redis_server = %CONFIG_FILE_DIR%/../build/src/common/thirdparty/redis/src/redis-server +redis_module = %CONFIG_FILE_DIR%/../build/src/common/redis_module/libray_redis_module.so +store = %CONFIG_FILE_DIR%/../build/src/plasma/plasma_store +store_manager = %CONFIG_FILE_DIR%/../build/src/plasma/plasma_manager +local_scheduler = %CONFIG_FILE_DIR%/../build/src/local_scheduler/local_scheduler +global_scheduler = %CONFIG_FILE_DIR%/../build/src/global_scheduler/global_scheduler +python_dir = %CONFIG_FILE_DIR%/../build/ +java_runtime_rewritten_jars_dir = +java_class_paths = ray.java.path.classes.package +java_jnilib_paths = ray.java.path.jni.package + +[ray.java.path.deploy] +redis_server = %CONFIG_FILE_DIR%/native/bin/redis-server +redis_module = %CONFIG_FILE_DIR%/native/lib/libray_redis_module.so +store = %CONFIG_FILE_DIR%/native/bin/plasma_store +store_manager = %CONFIG_FILE_DIR%/native/bin/plasma_manager +local_scheduler = %CONFIG_FILE_DIR%/native/bin/local_scheduler +global_scheduler = %CONFIG_FILE_DIR%/native/bin/global_scheduler +python_dir = %CONFIG_FILE_DIR%/python +java_runtime_rewritten_jars_dir = %CONFIG_FILE_DIR%/java/lib/ +java_class_paths = ray.java.path.classes.deploy +java_jnilib_paths = ray.java.path.jni.deploy + diff --git a/java/runtime-common/pom.xml b/java/runtime-common/pom.xml new file mode 100644 index 000000000000..f8688667ba67 --- /dev/null +++ b/java/runtime-common/pom.xml @@ -0,0 +1,58 @@ + + + + + org.ray.parent + ray-superpom + 1.0 + + 4.0.0 + org.ray + ray-runtime-common + + runtime common + runtime common + + + jar + + + + org.ray + ray-api + 1.0 + + + org.ray + ray-hook + 1.0 + + + de.ruedigermoeller + fst + 2.47 + + + + + com.github.davidmoten + flatbuffers-java + 1.7.0.1 + + + + + redis.clients + jedis + 2.8.0 + + + org.apache.arrow + arrow-plasma + + + + + diff --git a/java/runtime-common/src/main/java/org/ray/core/ArgumentsBuilder.java b/java/runtime-common/src/main/java/org/ray/core/ArgumentsBuilder.java new file mode 100644 index 000000000000..f1486fdb0245 --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/core/ArgumentsBuilder.java @@ -0,0 +1,169 @@ +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.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.RayActor; +import org.ray.api.RayList; +import org.ray.api.RayMap; +import org.ray.api.RayObject; +import org.ray.api.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 + */ +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); + } + // serialize actor handle + else { + 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 (oarg instanceof RayMap) { + fargs[k].ids = new ArrayList<>(); + RayMap rm = (RayMap) oarg; + RayMapArg narg = new RayMapArg(); + for (Entry e : rm.EntrySet()) { + narg.put(e.getKey(), ((RayObject) e.getValue()).getId()); + fargs[k].ids.add(((RayObject) e.getValue()).getId()); + } + fargs[k].data = Serializer.encode(narg); + } else if (oarg instanceof RayList) { + fargs[k].ids = new ArrayList<>(); + RayList rl = (RayList) oarg; + RayListArg narg = new RayListArg(); + for (RayObject e : rl.Objects()) { + // narg.add(e.getId()); // we don't really need to use the ids + fargs[k].ids.add(e.getId()); + } + fargs[k].data = Serializer.encode(narg); + } else if (checkSimpleValue(oarg)) { + fargs[k].data = Serializer.encode(oarg); + } else { + //big parameter, use object store and pass future + fargs[k].ids = new ArrayList<>(); + fargs[k].ids.add(RayRuntime.getInstance().put(oarg).getId()); + } + k++; + } + return fargs; + } + + private static boolean checkSimpleValue(Object o) { + return true;//TODO I think Ray don't want to pass big parameter + } + + @SuppressWarnings({"rawtypes", "unchecked"}) + public static Pair unwrap(TaskSpec task, Method m, ClassLoader classLoader) + throws TaskExecutionException { + FunctionArg fargs[] = task.args; + Object this_ = null; + Object realArgs[]; + + int start = 0; + + // check actor method + if (!Modifier.isStatic(m.getModifiers())) { + start = 1; + RayActorID actorId = Serializer.decode(fargs[0].data, classLoader); + this_ = 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; + } + } + + // only ids, big data or single object id + else if (farg.data == null) { + assert (farg.ids.size() == 1); + realArgs[raIndex] = RayRuntime.getInstance().get(farg.ids.get(0)); + } + + // both id and data, could be RayList or RayMap only + else { + Object idBag = Serializer.decode(farg.data, classLoader); + if (idBag instanceof RayMapArg) { + Map newMap = new HashMap<>(); + RayMapArg oldmap = (RayMapArg) idBag; + assert (farg.ids.size() == oldmap.size()); + for (Entry e : oldmap.entrySet()) { + newMap.put(e.getKey(), RayRuntime.getInstance().get(e.getValue())); + } + realArgs[raIndex] = newMap; + } else { + List newlist = new ArrayList<>(); + for (UniqueID old : farg.ids) { + newlist.add(RayRuntime.getInstance().get(old)); + } + realArgs[raIndex] = newlist; + } + } + } + return Pair.of(this_, realArgs); + } + + //for recognition + public static class RayMapArg extends HashMap { + + private static final long serialVersionUID = 8529310038241410256L; + + } + + //for recognition + public static class RayListArg extends ArrayList { + + private static final long serialVersionUID = 8529310038241410256L; + + } + + public static class RayActorID implements Serializable { + + private static final long serialVersionUID = 3993646395842605166L; + public UniqueID Id; + } +} diff --git a/java/runtime-common/src/main/java/org/ray/core/InvocationExecutor.java b/java/runtime-common/src/main/java/org/ray/core/InvocationExecutor.java new file mode 100644 index 000000000000..1d663c362e44 --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/core/InvocationExecutor.java @@ -0,0 +1,150 @@ +package org.ray.core; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import org.apache.commons.lang3.tuple.Pair; +import org.ray.api.UniqueID; +import org.ray.api.returns.MultipleReturns; +import org.ray.spi.model.RayMethod; +import org.ray.spi.model.TaskSpec; +import org.ray.util.exception.TaskExecutionException; +import org.ray.util.logger.RayLog; + +/** + * how to execute a invocation + */ +public class InvocationExecutor { + + + public static void execute(TaskSpec task, Pair pr) + throws TaskExecutionException { + String taskdesc = + "[" + pr.getRight().fullName + "_" + task.taskId.toString() + " actorId = " + task.actorId + + "]"; + TaskExecutionException ex = null; + + // switch to current driver's loader + ClassLoader oldLoader = Thread.currentThread().getContextClassLoader(); + if (pr.getLeft() != null) { + Thread.currentThread().setContextClassLoader(pr.getLeft()); + } + + // execute + try { + //RayLog.core.debug(task.toString()); + executeInternal(task, pr, taskdesc); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + if (!task.actorId.isNil() && RayRuntime.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 + + " failed as the actor is not present ", e); + } else { + ex = new TaskExecutionException( + formatTaskExecutionExceptionMsg(task, pr.getRight().fullName), e); + RayLog.core.error("Task " + taskdesc + " execution failed ", e); + } + RayLog.core.error(e.getMessage()); + RayLog.core.error("task info: \n" + task.toString()); + } catch (Throwable e) { + ex = new TaskExecutionException(formatTaskExecutionExceptionMsg(task, pr.getRight().fullName), + e); + RayLog.core.error("Task " + taskdesc + " execution with unknown error ", e); + RayLog.core.error(e.getMessage()); + } + + // recover loader + if (pr.getLeft() != null) { + Thread.currentThread().setContextClassLoader(oldLoader); + } + + // set exception as the output results + if (ex != null) { + throw ex; + } + } + + private static void safePut(UniqueID objectId, Object obj) { + RayRuntime.getInstance().putRaw(objectId, obj); + } + + private static void executeInternal(TaskSpec task, Pair pr, + String taskdesc) + throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { + Method m = pr.getRight().invokable; + Map userRayReturnIdMap = null; + Class returnType = m.getReturnType(); // TODO: not ready for multiple return etc. + boolean hasMultiReturn = false; + if(task.returnIds != null && task.returnIds.length > 0) { + hasMultiReturn = UniqueIdHelper.hasMultipleReturnOrNotFromReturnObjectId(task.returnIds[0]); + } + + Pair realArgs = ArgumentsBuilder.unwrap(task, m, pr.getLeft()); + if (hasMultiReturn && returnType.equals(Map.class)) { + //first arg is Map + userRayReturnIdMap = (Map) realArgs.getRight()[0]; + realArgs.getRight()[0] = userRayReturnIdMap.keySet(); + } + + // execute + Object result; + if (!UniqueIdHelper.isLambdaFunction(task.functionId)) { + result = m.invoke(realArgs.getLeft(), realArgs.getRight()); + } else { + result = m.invoke(realArgs.getLeft(), new Object[]{realArgs.getRight()}); + } + + if(task.returnIds == null || task.returnIds.length == 0) { + return; + } + // set result into storage + if (MultipleReturns.class.isAssignableFrom(returnType)) { + MultipleReturns returns = (MultipleReturns) result; + if (task.returnIds.length != returns.getValues().length) { + throw new RuntimeException("Mismatched return object count for task " + taskdesc + + " " + task.returnIds.length + " vs " + + returns.getValues().length); + } + + for (int k = 0; k < returns.getValues().length; k++) { + RayRuntime.getInstance().putRaw(task.returnIds[k], returns.getValues()[k]); + } + } else if (hasMultiReturn && returnType.equals(Map.class)) { + Map returns = (Map) result; + if (task.returnIds.length != returns.size()) { + throw new RuntimeException("Mismatched return object count for task " + taskdesc + + " " + task.returnIds.length + " vs " + + returns.size()); + } + + for (Entry e : returns.entrySet()) { + Object userReturnId = e.getKey(); + Object value = e.getValue(); + UniqueID returnId = userRayReturnIdMap.get(userReturnId); + RayRuntime.getInstance().putRaw(returnId, value); + } + + } else if (hasMultiReturn && returnType.equals(List.class)) { + List returns = (List) result; + if (task.returnIds.length != returns.size()) { + throw new RuntimeException("Mismatched return object count for task " + taskdesc + + " " + task.returnIds.length + " vs " + + returns.size()); + } + + for (int k = 0; k < returns.size(); k++) { + RayRuntime.getInstance().putRaw(task.returnIds[k], returns.get(k)); + } + } else { + RayRuntime.getInstance().putRaw(task.returnIds[0], result); + } + } + + private static String formatTaskExecutionExceptionMsg(TaskSpec task, String funcName) { + return "Execute task " + task.taskId + + " failed with function name = " + funcName; + } +} diff --git a/java/runtime-common/src/main/java/org/ray/core/LocalFunctionManager.java b/java/runtime-common/src/main/java/org/ray/core/LocalFunctionManager.java new file mode 100644 index 000000000000..6ef058856f2e --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/core/LocalFunctionManager.java @@ -0,0 +1,121 @@ +package org.ray.core; + +import java.lang.reflect.Method; +import java.util.concurrent.ConcurrentHashMap; +import org.apache.commons.lang3.tuple.Pair; +import org.ray.api.UniqueID; +import org.ray.hook.MethodId; +import org.ray.hook.runtime.JarLoader; +import org.ray.hook.runtime.LoadedFunctions; +import org.ray.spi.RemoteFunctionManager; +import org.ray.spi.model.FunctionArg; +import org.ray.spi.model.RayMethod; +import org.ray.util.logger.RayLog; + +/** + * local function manager which pulls remote functions on demand + */ +public class LocalFunctionManager { + + /** + * initialize load function manager using remote function manager to pull remote functions on + * demand + */ + public LocalFunctionManager(RemoteFunctionManager remoteLoader) { + this.remoteLoader = remoteLoader; + } + + private synchronized FunctionTable loadDriverFunctions(UniqueID driverId) { + FunctionTable funcs = functionTables.get(driverId); + if (null == funcs) { + RayLog.core.debug("DriverId " + driverId + " Try to load functions"); + LoadedFunctions funcs2 = remoteLoader.loadFunctions(driverId); + if (funcs2 == null) { + throw new RuntimeException("Cannot find resource for app " + driverId.toString()); + } + funcs = new FunctionTable(); + funcs.linkedFunctions = funcs2; + for (MethodId mid : funcs.linkedFunctions.functions) { + Method m = mid.load(); + assert (m != null); + RayMethod v = new RayMethod(m); + v.check(); + UniqueID k = new UniqueID(mid.getSha1Hash()); + String logInfo = + "DriverId" + driverId + " load remote function " + m.getName() + ", hash = " + k + .toString(); + RayLog.core.debug(logInfo); + System.err.println(logInfo); + funcs.functions.put(k, v); + } + + functionTables.put(driverId, funcs); + } + // reSync automatically + else { + // more functions are loaded + if (funcs.linkedFunctions.functions.size() > funcs.functions.size()) { + for (MethodId mid : funcs.linkedFunctions.functions) { + UniqueID k = new UniqueID(mid.getSha1Hash()); + if (!funcs.functions.containsKey(k)) { + Method m = mid.load(); + assert (m != null); + RayMethod v = new RayMethod(m); + v.check(); + funcs.functions.put(k, v); + } + } + } + } + return funcs; + } + + /** + * 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 getMethod(UniqueID driverId, UniqueID methodId, + FunctionArg[] args) throws NoSuchMethodException, SecurityException, ClassNotFoundException { + FunctionTable funcs = loadDriverFunctions(driverId); + RayMethod m; + + // hooked methods + if (!UniqueIdHelper.isLambdaFunction(methodId)) { + m = funcs.functions.get(methodId); + if (null == m) { + throw new RuntimeException( + "DriverId " + driverId + " load remote function methodId:" + methodId + " failed"); + } + } + + // remote lambda + else { + assert args.length >= 2; + String fname = Serializer.decode(args[args.length - 2].data); + Method fm = Class.forName(fname).getMethod("execute", Object[].class); + m = new RayMethod(fm); + } + + return Pair.of(funcs.linkedFunctions.loader, m); + } + + /** + * unload the functions when the driver is declared dead + */ + public synchronized void removeApp(UniqueID driverId) { + FunctionTable funcs = functionTables.get(driverId); + if (funcs != null) { + functionTables.remove(driverId); + JarLoader.unloadJars(funcs.linkedFunctions.loader); + } + } + + static class FunctionTable { + + public final ConcurrentHashMap functions = new ConcurrentHashMap<>(); + public LoadedFunctions linkedFunctions; + } + + private final RemoteFunctionManager remoteLoader; + private final ConcurrentHashMap functionTables = new ConcurrentHashMap<>(); +} diff --git a/java/runtime-common/src/main/java/org/ray/core/RayRuntime.java b/java/runtime-common/src/main/java/org/ray/core/RayRuntime.java new file mode 100644 index 000000000000..441ce83ae35c --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/core/RayRuntime.java @@ -0,0 +1,466 @@ +package org.ray.core; + +import java.io.Serializable; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +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.RayList; +import org.ray.api.RayMap; +import org.ray.api.RayObject; +import org.ray.api.RayObjects; +import org.ray.api.UniqueID; +import org.ray.api.WaitResult; +import org.ray.api.internal.Callable; +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.util.config.ConfigReader; +import org.ray.util.exception.TaskExecutionException; +import org.ray.util.logger.DynamicLog; +import org.ray.util.logger.DynamicLogManager; +import org.ray.util.logger.RayLog; + +/** + * Core functionality to implement Ray APIs + */ +public abstract class RayRuntime implements RayApi { + + protected static RayRuntime ins = null; + + protected static RayParameters params = null; + + private static boolean fromRayInit = false; + + public static ConfigReader configReader; + + public abstract void cleanUp(); + + // app level Ray.init() + // make it private so there is no direct usage but only from Ray.init + private static RayRuntime init() { + if (ins == null) { + try { + fromRayInit = true; + RayRuntime.init(null, null); + fromRayInit = false; + } catch (Exception e) { + e.printStackTrace(); + throw new RuntimeException("Ray.init failed", e); + } + } + return ins; + } + + // init with command line args + // --config=ray.config.ini --overwrite=updateConfigStr + public static RayRuntime init(String[] args) throws Exception { + String config = null; + String updateConfig = null; + for (String arg : args) { + if (arg.startsWith("--config=")) { + config = arg.substring("--config=".length()); + } else if (arg.startsWith("--overwrite=")) { + updateConfig = arg.substring("--overwrite=".length()); + } else { + throw new RuntimeException("Input argument " + arg + + " is not recognized, please use --overwrite to merge it into config file"); + } + } + return init(config, updateConfig); + } + + // engine level RayRuntime.init(xx, xx) + // updateConfigStr is sth like section1.k1=v1;section2.k2=v2 + public static RayRuntime init(String configPath, String updateConfigStr) throws Exception { + if (ins == null) { + if (configPath == null) { + configPath = System.getenv("RAY_CONFIG"); + if (configPath == null) { + configPath = System.getProperty("ray.config"); + } + if (configPath == null) { + throw new Exception( + "Please set config file path in env RAY_CONFIG or property ray.config"); + } + } + configReader = new ConfigReader(configPath, updateConfigStr); + + String loglevel = configReader.getStringValue("ray.java", "log_level", "debug", + "set the log output level(debug, info, warn, error)"); + DynamicLog.setLogLevel(loglevel); + RayRuntime.params = new RayParameters(configReader); + DynamicLogManager.init(params.max_java_log_file_num, params.max_java_log_file_size); + ins = instantiate(params); + assert (ins != null); + + if (!fromRayInit) { + Ray.init(); // assign Ray._impl + } + } + return ins; + } + + private static RayRuntime instantiate(RayParameters params) { + String className = params.run_mode.isNativeRuntime() ? + "org.ray.core.impl.RayNativeRuntime" : "org.ray.core.impl.RayDevRuntime"; + + RayRuntime 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."); + } + Constructor cons = cls.getDeclaredConstructor(); + cons.setAccessible(true); + runtime = (RayRuntime) cons.newInstance(); + cons.setAccessible(false); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | SecurityException | ClassNotFoundException | NoSuchMethodException e) { + 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()); + } + + RayLog.core + .info("Start " + runtime.getClass().getName() + " with " + params.run_mode.toString()); + 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); + System.exit(-1); + } + + return runtime; + } + + public static RayRuntime getInstance() { + return ins; + } + + public static RayParameters getParams() { + return params; + } + + /*********** RayApi methods ***********/ + + public void putRaw(UniqueID taskId, UniqueID objectId, T obj, TM metadata) { + RayLog.core.info("Task " + taskId.toString() + " Object " + objectId.toString() + " put"); + localSchedulerProxy.markTaskPutDependency(taskId, objectId); + objectStoreProxy.put(objectId, obj, metadata); + } + + public void putRaw(UniqueID taskId, UniqueID objectId, T obj) { + putRaw(taskId, objectId, obj, null); + } + + public void putRaw(UniqueID objectId, T obj) { + UniqueID taskId = getCurrentTaskID(); + putRaw(taskId, objectId, obj, null); + } + + public void putRaw(T obj) { + UniqueID taskId = getCurrentTaskID(); + UniqueID objectId = getCurrentTaskNextPutID(); + putRaw(taskId, objectId, obj, null); + } + + @Override + public RayObject put(T obj) { + return put(obj, null); + } + + @Override + public RayObject put(T obj, TM metadata) { + UniqueID taskId = getCurrentTaskID(); + UniqueID objectId = getCurrentTaskNextPutID(); + putRaw(taskId, objectId, obj, metadata); + return new RayObject<>(objectId); + } + + @Override + public T get(UniqueID objectId) throws TaskExecutionException { + return doGet(objectId, false); + } + + @Override + public T getMeta(UniqueID objectId) throws TaskExecutionException { + return doGet(objectId, true); + } + + private T doGet(UniqueID objectId, boolean isMetadata) throws TaskExecutionException { + + boolean wasBlocked = false; + UniqueID taskId = getCurrentTaskID(); + try { + // Do an initial fetch. + objectStoreProxy.fetch(objectId); + + // Get the object. We initially try to get the object immediately. + Pair ret = objectStoreProxy + .get(objectId, params.default_first_check_timeout_ms, isMetadata); + + wasBlocked = (ret.getRight() != GetStatus.SUCCESS); + + // Try reconstructing the object. Try to get it until at least PlasmaLink.GET_TIMEOUT_MS + // milliseconds passes, then repeat. + while (ret.getRight() != GetStatus.SUCCESS) { + RayLog.core.warn( + "Task " + taskId + " Object " + objectId.toString() + " get failed, reconstruct ..."); + localSchedulerProxy.reconstructObject(objectId); + + // Do another fetch + objectStoreProxy.fetch(objectId); + + ret = objectStoreProxy.get(objectId, params.default_get_check_interval_ms, + isMetadata);//check the result every 5s, but it will return once available + } + RayLog.core.debug( + "Task " + taskId + " Object " + objectId.toString() + " get" + ", the result " + ret + .getLeft()); + return ret.getLeft(); + } catch (TaskExecutionException e) { + RayLog.core + .error("Task " + taskId + " Object " + objectId.toString() + " get with Exception", e); + throw e; + } finally { + // If the object was not able to get locally, let the local scheduler + // know that we're now unblocked. + if (wasBlocked) { + localSchedulerProxy.notifyUnblocked(); + } + } + + } + + @Override + public List get(List objectIds) throws TaskExecutionException { + return doGet(objectIds, false); + } + + @Override + public List getMeta(List objectIds) throws TaskExecutionException { + return doGet(objectIds, true); + } + + // We divide the fetch into smaller fetches so as to not block the manager + // for a prolonged period of time in a single call. + private void dividedFetch(List objectIds) { + int fetchSize = objectStoreProxy.getFetchSize(); + + int numObjectIds = objectIds.size(); + for (int i = 0; i < numObjectIds; i += fetchSize) { + int endIndex = i + fetchSize; + if (endIndex < numObjectIds) { + objectStoreProxy.fetch(objectIds.subList(i, endIndex)); + } else { + objectStoreProxy.fetch(objectIds.subList(i, numObjectIds)); + } + } + } + + private List doGet(List objectIds, boolean isMetadata) + throws TaskExecutionException { + boolean wasBlocked = false; + UniqueID taskId = getCurrentTaskID(); + try { + int numObjectIds = objectIds.size(); + + // Do an initial fetch for remote objects. + dividedFetch(objectIds); + + // Get the objects. We initially try to get the objects immediately. + List> ret = objectStoreProxy + .get(objectIds, params.default_first_check_timeout_ms, isMetadata); + assert ret.size() == numObjectIds; + + // mapping the object IDs that we haven't gotten yet to their original index in objectIds + Map unreadys = new HashMap<>(); + for (int i = 0; i < numObjectIds; i++) { + if (ret.get(i).getRight() != GetStatus.SUCCESS) { + unreadys.put(objectIds.get(i), i); + } + } + wasBlocked = (unreadys.size() > 0); + + // 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) { + for (UniqueID id : unreadys.keySet()) { + localSchedulerProxy.reconstructObject(id); + } + + // Do another fetch for objects that aren't available locally yet, in case + // they were evicted since the last fetch. + List unreadyList = new ArrayList<>(unreadys.keySet()); + + dividedFetch(unreadyList); + + List> results = objectStoreProxy + .get(unreadyList, params.default_get_check_interval_ms, isMetadata); + + // 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 value = results.get(i); + if (value.getRight() == GetStatus.SUCCESS) { + UniqueID id = unreadyList.get(i); + ret.set(unreadys.get(id), value); + unreadys.remove(id); + } + } + } + + RayLog.core + .debug("Task " + taskId + " Objects " + Arrays.toString(objectIds.toArray()) + " get"); + List finalRet = new ArrayList<>(); + for (Pair value : ret) { + finalRet.add(value.getLeft()); + } + return finalRet; + } catch (TaskExecutionException e) { + RayLog.core.error("Task " + taskId + " Objects " + Arrays.toString(objectIds.toArray()) + + " get with Exception", e); + throw e; + } finally { + // 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(); + } + } + + } + + @Override + public WaitResult wait(RayList waitfor, int numReturns, int timeout) { + return objectStoreProxy.wait(waitfor, numReturns, timeout); + } + + @Override + public RayObjects call(UniqueID taskId, Callable funcRun, int returnCount, Object... args) { + return worker.rpc(taskId, funcRun, returnCount, args); + } + + @Override + public RayObjects call(UniqueID taskId, Class funcCls, Serializable lambda, int returnCount, + Object... args) { + return worker.rpc(taskId, UniqueID.nil, funcCls, lambda, returnCount, args); + } + + @Override + public RayMap callWithReturnLabels(UniqueID taskId, Callable funcRun, + Collection returnIds, + Object... args) { + return worker.rpcWithReturnLabels(taskId, funcRun, returnIds, args); + } + + @Override + public RayMap callWithReturnLabels(UniqueID taskId, Class funcCls, + Serializable lambda, Collection returnids, + Object... args) { + return worker.rpcWithReturnLabels(taskId, funcCls, lambda, returnids, args); + } + + @Override + public RayList callWithReturnIndices(UniqueID taskId, Callable funcRun, + Integer returnCount, Object... args) { + return worker.rpcWithReturnIndices(taskId, funcRun, returnCount, args); + } + + @Override + public RayList callWithReturnIndices(UniqueID taskId, Class funcCls, + Serializable lambda, Integer returnCount, Object... args) { + return worker.rpcWithReturnIndices(taskId, funcCls, lambda, returnCount, args); + } + + /** + * get the task identity of the currently running task, UniqueID.Nil if not inside any + */ + public UniqueID getCurrentTaskID() { + return worker.getCurrentTaskID(); + } + + /** + * get the object put identity of the currently running task, UniqueID.Nil if not inside any + */ + public UniqueID[] getCurrentTaskReturnIDs() { + return worker.getCurrentTaskReturnIDs(); + } + + /** + * get the to-be-returned objects identities of the currently running task, empty array if not + * inside any + */ + public UniqueID getCurrentTaskNextPutID() { + return worker.getCurrentTaskNextPutID(); + } + + @Override + public boolean isRemoteLambda() { + return params.run_mode.isRemoteLambda(); + } + + protected void init( + LocalSchedulerLink slink, + ObjectStoreLink plink, + RemoteFunctionManager remoteLoader, + PathConfig pathManager + ) { + UniqueIdHelper.setThreadRandomSeed(UniqueIdHelper.getUniqueness(params.driver_id)); + remoteFunctionManager = remoteLoader; + pathConfig = pathManager; + + functions = new LocalFunctionManager(remoteLoader); + localSchedulerProxy = new LocalSchedulerProxy(slink); + objectStoreProxy = new ObjectStoreProxy(plink); + worker = new Worker(localSchedulerProxy, functions); + } + + /*********** Internal Methods ***********/ + + public void loop() { + worker.loop(); + } + + /** + * start runtime + */ + public abstract void start(RayParameters params) throws Exception; + + /** + * get actor with given id + */ + public abstract Object getLocalActor(UniqueID id); + + public PathConfig getPaths() { + return pathConfig; + } + + public RemoteFunctionManager getRemoteFunctionManager() { + return remoteFunctionManager; + } + + protected Worker worker; + protected LocalSchedulerProxy localSchedulerProxy; + protected ObjectStoreProxy objectStoreProxy; + protected LocalFunctionManager functions; + protected RemoteFunctionManager remoteFunctionManager; + protected PathConfig pathConfig; +} diff --git a/java/runtime-common/src/main/java/org/ray/core/Serializer.java b/java/runtime-common/src/main/java/org/ray/core/Serializer.java new file mode 100644 index 000000000000..7a48129e5eaf --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/core/Serializer.java @@ -0,0 +1,55 @@ +package org.ray.core; + +import org.nustaq.serialization.FSTConfiguration; + +/** + * Java object serialization TODO: use others (e.g. Arrow) for higher performance + */ +public class Serializer { + + static final ThreadLocal conf = ThreadLocal.withInitial( + FSTConfiguration::createDefaultConfiguration); + + public static byte[] encode(Object obj) { + return conf.get().asByteArray(obj); + } + + @SuppressWarnings("unchecked") + public static T decode(byte[] bs) { + return (T) conf.get().asObject(bs); + } + + public static byte[] encode(Object obj, ClassLoader classLoader) { + byte[] result; + FSTConfiguration current = conf.get(); + if (classLoader != null && classLoader != current.getClassLoader()) { + ClassLoader old = current.getClassLoader(); + current.setClassLoader(classLoader); + result = current.asByteArray(obj); + current.setClassLoader(old); + } else { + result = current.asByteArray(obj); + } + + return result; + } + + @SuppressWarnings("unchecked") + public static T decode(byte[] bs, ClassLoader classLoader) { + Object object; + FSTConfiguration current = conf.get(); + if (classLoader != null && classLoader != current.getClassLoader()) { + ClassLoader old = current.getClassLoader(); + current.setClassLoader(classLoader); + object = current.asObject(bs); + current.setClassLoader(old); + } else { + object = current.asObject(bs); + } + return (T) object; + } + + public static void setClassloader(ClassLoader classLoader) { + conf.get().setClassLoader(classLoader); + } +} diff --git a/java/runtime-common/src/main/java/org/ray/core/UniqueIdHelper.java b/java/runtime-common/src/main/java/org/ray/core/UniqueIdHelper.java new file mode 100644 index 000000000000..90a483ea9e36 --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/core/UniqueIdHelper.java @@ -0,0 +1,288 @@ +package org.ray.core; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; +import java.util.Random; +import org.apache.commons.lang3.BitField; +import org.ray.api.UniqueID; +import org.ray.util.MD5Digestor; +import org.ray.util.logger.RayLog; + + +// +// see src/common/common.h for UniqueID layout +// +public class UniqueIdHelper { + + public enum Type { + OBJECT, + TASK, + ACTOR, + } + + private static final ThreadLocal longBuffer = ThreadLocal + .withInitial(() -> ByteBuffer.allocate(Long.SIZE / Byte.SIZE)); + private static final ThreadLocal rand = ThreadLocal.withInitial(Random::new); + private static final ThreadLocal randSeed = new ThreadLocal<>(); + + public static void setThreadRandomSeed(long seed) { + if (randSeed.get() != null) { + RayLog.core.error("Thread random seed is already set to " + randSeed.get() + + " and now to be overwritten to " + seed); + throw new RuntimeException("Thread random seed is already set to " + randSeed.get() + + " and now to be overwritten to " + seed); + } + + RayLog.core.debug("Thread random seed is set to " + seed); + randSeed.set(seed); + rand.get().setSeed(seed); + } + + public static Long getNextCreateThreadRandomSeed() { + UniqueID currentTaskId = WorkerContext.currentTask().taskId; + byte[] bytes; + + ByteBuffer lBuffer = longBuffer.get(); + // similar to task id generation (see nextTaskId below) + if (!currentTaskId.isNil()) { + ByteBuffer rbb = ByteBuffer.wrap(currentTaskId.getBytes()); + rbb.order(ByteOrder.LITTLE_ENDIAN); + long cid = rbb.getLong(uniquenessPos); + byte[] cbuffer = lBuffer.putLong(cid).array(); + bytes = MD5Digestor.digest(cbuffer, WorkerContext.nextCallIndex()); + } else { + long cid = rand.get().nextLong(); + byte[] cbuffer = lBuffer.putLong(cid).array(); + bytes = MD5Digestor.digest(cbuffer, rand.get().nextLong()); + } + lBuffer.clear(); + + lBuffer.put(bytes, 0, Long.SIZE / Byte.SIZE); + long r = lBuffer.getLong(); + lBuffer.clear(); + return r; + } + + private static final int batchPos = 0; + + private static void setBatch(ByteBuffer bb, long batchId) { + bb.putLong(batchPos, batchId); + } + + private static long getBatch(ByteBuffer bb) { + return bb.getLong(batchPos); + } + + private static final int uniquenessPos = Long.SIZE / Byte.SIZE; + + private static void setUniqueness(ByteBuffer bb, long uniqueness) { + bb.putLong(uniquenessPos, uniqueness); + } + + private static void setUniqueness(ByteBuffer bb, byte[] uniqueness) { + for (int i = 0; i < Long.SIZE / Byte.SIZE; ++i) { + bb.put(uniquenessPos + i, uniqueness[i]); + } + } + + private static long getUniqueness(ByteBuffer bb) { + return bb.getLong(uniquenessPos); + } + + private static final int typePos = 2 * Long.SIZE / Byte.SIZE; + private static final BitField typeField = new BitField(0x7); + + private static void setType(ByteBuffer bb, Type type) { + byte v = bb.get(typePos); + v = (byte) typeField.setValue(v, type.ordinal()); + bb.put(typePos, v); + } + + private static Type getType(ByteBuffer bb) { + byte v = bb.get(typePos); + return Type.values()[typeField.getValue(v)]; + } + + private static final int testPos = 2 * Long.SIZE / Byte.SIZE; + private static final BitField testField = new BitField(0x1 << 3); + + private static void setIsTest(ByteBuffer bb, boolean isTest) { + byte v = bb.get(testPos); + v = (byte) testField.setValue(v, isTest ? 1 : 0); + bb.put(testPos, v); + } + + private static boolean getIsTest(ByteBuffer bb) { + byte v = bb.get(testPos); + return testField.getValue(v) == 1; + } + + private static final int unionPos = 2 * Long.SIZE / Byte.SIZE; + private static final BitField multipleReturnField = new BitField(0x1 << 8); + private static final BitField isReturnIdField = new BitField(0x1 << 9); + private static final BitField withinTaskIndexField = new BitField(0xFFFFFC00); + + private static void setHasMultipleReturn(ByteBuffer bb, int hasMultipleReturnOrNot) { + int v = bb.getInt(unionPos); + v = multipleReturnField.setValue(v, hasMultipleReturnOrNot); + bb.putInt(unionPos, v); + } + + private static int getHasMultipleReturn(ByteBuffer bb) { + int v = bb.getInt(unionPos); + return multipleReturnField.getValue(v); + } + + private static void setIsReturn(ByteBuffer bb, int isReturn) { + int v = bb.getInt(unionPos); + v = isReturnIdField.setValue(v, isReturn); + bb.putInt(unionPos, v); + } + + private static int getIsReturn(ByteBuffer bb) { + int v = bb.getInt(unionPos); + return isReturnIdField.getValue(v); + } + + private static void setWithinTaskIndex(ByteBuffer bb, int index) { + int v = bb.getInt(unionPos); + v = withinTaskIndexField.setValue(v, index); + bb.putInt(unionPos, v); + } + + private static int getWithinTaskIndex(ByteBuffer bb) { + int v = bb.getInt(unionPos); + return withinTaskIndexField.getValue(v); + } + + private static UniqueID objectIdFromTaskId(UniqueID taskId, + boolean isReturn, + boolean hasMultipleReturn, + int index + ) { + UniqueID oid = newZero(); + ByteBuffer rbb = ByteBuffer.wrap(taskId.getBytes()); + rbb.order(ByteOrder.LITTLE_ENDIAN); + ByteBuffer wbb = ByteBuffer.wrap(oid.getBytes()); + wbb.order(ByteOrder.LITTLE_ENDIAN); + setBatch(wbb, getBatch(rbb)); + setUniqueness(wbb, getUniqueness(rbb)); + setType(wbb, Type.OBJECT); + setHasMultipleReturn(wbb, hasMultipleReturn ? 1 : 0); + setIsReturn(wbb, isReturn ? 1 : 0); + setWithinTaskIndex(wbb, index); + return oid; + } + + private static UniqueID newZero() { + byte[] b = new byte[UniqueID.LENGTH]; + Arrays.fill(b, (byte) 0); + return new UniqueID(b); + } + + public static void setTest(UniqueID id, boolean isTest) { + ByteBuffer bb = ByteBuffer.wrap(id.getBytes()); + setIsTest(bb, isTest); + } + + public static long getUniqueness(UniqueID id) { + ByteBuffer bb = ByteBuffer.wrap(id.getBytes()); + bb.order(ByteOrder.LITTLE_ENDIAN); + return getUniqueness(bb); + } + + public static UniqueID taskComputeReturnId( + UniqueID uid, + int returnIndex, + boolean hasMultipleReturn + ) { + return objectIdFromTaskId(uid, true, hasMultipleReturn, returnIndex); + } + + public static UniqueID taskComputePutId(UniqueID uid, int putIndex) { + return objectIdFromTaskId(uid, false, false, putIndex); + } + + public static boolean hasMultipleReturnOrNotFromReturnObjectId(UniqueID returnId) { + ByteBuffer bb = ByteBuffer.wrap(returnId.getBytes()); + bb.order(ByteOrder.LITTLE_ENDIAN); + return getHasMultipleReturn(bb) != 0; + } + + public static UniqueID taskIdFromObjectId(UniqueID objectId) { + UniqueID taskId = newZero(); + ByteBuffer rbb = ByteBuffer.wrap(objectId.getBytes()); + rbb.order(ByteOrder.LITTLE_ENDIAN); + ByteBuffer wbb = ByteBuffer.wrap(taskId.getBytes()); + wbb.order(ByteOrder.LITTLE_ENDIAN); + setBatch(wbb, getBatch(rbb)); + setUniqueness(wbb, getUniqueness(rbb)); + setType(wbb, Type.TASK); + return taskId; + } + + public static UniqueID nextTaskId(long batchId) { + UniqueID taskId = newZero(); + ByteBuffer wbb = ByteBuffer.wrap(taskId.getBytes()); + wbb.order(ByteOrder.LITTLE_ENDIAN); + setType(wbb, Type.TASK); + + UniqueID currentTaskId = WorkerContext.currentTask().taskId; + ByteBuffer rbb = ByteBuffer.wrap(currentTaskId.getBytes()); + rbb.order(ByteOrder.LITTLE_ENDIAN); + + // setup batch id + if (batchId == -1) { + setBatch(wbb, getBatch(rbb)); + } else { + setBatch(wbb, batchId); + } + + // setup unique id (task id) + byte[] idBytes; + + ByteBuffer lBuffer = longBuffer.get(); + // if inside a task + if (!currentTaskId.isNil()) { + long cid = rbb.getLong(uniquenessPos); + byte[] cbuffer = lBuffer.putLong(cid).array(); + idBytes = MD5Digestor.digest(cbuffer, WorkerContext.nextCallIndex()); + + // if not + } else { + long cid = rand.get().nextLong(); + byte[] cbuffer = lBuffer.putLong(cid).array(); + idBytes = MD5Digestor.digest(cbuffer, rand.get().nextLong()); + } + setUniqueness(wbb, idBytes); + lBuffer.clear(); + return taskId; + } + + + public static boolean isLambdaFunction(UniqueID functionId) { + ByteBuffer wbb = ByteBuffer.wrap(functionId.getBytes()); + wbb.order(ByteOrder.LITTLE_ENDIAN); + return wbb.getLong() == 0xffffffffffffffffL; + } + + public static void markCreateActorStage1Function(UniqueID functionId) { + ByteBuffer wbb = ByteBuffer.wrap(functionId.getBytes()); + wbb.order(ByteOrder.LITTLE_ENDIAN); + setUniqueness(wbb, 1); + } + + // WARNING: see hack in MethodId.java which must be aligned with here + public static boolean isNonLambdaCreateActorStage1Function(UniqueID functionId) { + ByteBuffer wbb = ByteBuffer.wrap(functionId.getBytes()); + wbb.order(ByteOrder.LITTLE_ENDIAN); + return getUniqueness(wbb) == 1; + } + + public static boolean isNonLambdaCommonFunction(UniqueID functionId) { + ByteBuffer wbb = ByteBuffer.wrap(functionId.getBytes()); + wbb.order(ByteOrder.LITTLE_ENDIAN); + return getUniqueness(wbb) == 0; + } +} diff --git a/java/runtime-common/src/main/java/org/ray/core/Worker.java b/java/runtime-common/src/main/java/org/ray/core/Worker.java new file mode 100644 index 000000000000..c8233d3797b4 --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/core/Worker.java @@ -0,0 +1,247 @@ +package org.ray.core; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collection; +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.SerializationUtils; +import org.apache.commons.lang3.tuple.Pair; +import org.ray.api.RayActor; +import org.ray.api.RayList; +import org.ray.api.RayMap; +import org.ray.api.RayObject; +import org.ray.api.RayObjects; +import org.ray.api.UniqueID; +import org.ray.api.internal.Callable; +import org.ray.hook.runtime.MethodSwitcher; +import org.ray.spi.LocalSchedulerProxy; +import org.ray.spi.model.RayInvocation; +import org.ray.spi.model.RayMethod; +import org.ray.spi.model.TaskSpec; +import org.ray.util.exception.TaskExecutionException; +import org.ray.util.logger.RayLog; + +/** + * The worker, which pulls tasks from {@code org.ray.spi.LocalSchedulerProxy} and executes them + * continuously. + */ +public class Worker { + + private final LocalSchedulerProxy scheduler; + private final LocalFunctionManager functions; + + public Worker(LocalSchedulerProxy scheduler, LocalFunctionManager functions) { + this.scheduler = scheduler; + this.functions = functions; + } + + public void loop() { + while (true) { + RayLog.core.info(Thread.currentThread().getName() + ":fetching new task..."); + TaskSpec task = scheduler.getTask(); + execute(task, functions); + } + } + + public static void execute(TaskSpec task, LocalFunctionManager funcs) { + RayLog.core.info("Task " + task.taskId + " start execute"); + Throwable ex = null; + + + if (!task.actorId.isNil() || (task.createActorId != null && !task.createActorId.isNil())) { + task.returnIds = ArrayUtils.subarray(task.returnIds, 0, task.returnIds.length - 1); + } + + try { + Pair pr = funcs.getMethod(task.driverId, 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 RayObjects taskSubmit(UniqueID taskId, + byte[] fid, + int returnCount, + boolean multiReturn, + Object[] args) { + RayInvocation ri = new RayInvocation(fid, args); + return scheduler.submit(taskId, ri, returnCount, multiReturn); + } + + private RayObjects actorTaskSubmit(UniqueID taskId, + byte[] fid, + int returnCount, + boolean multiReturn, + Object[] args, + RayActor actor) { + RayInvocation ri = new RayInvocation(fid, args, actor); + RayObjects returnObjs = scheduler.submit(taskId, ri, returnCount + 1, multiReturn); + actor.setTaskCursor(returnObjs.pop().getId()); + return returnObjs; + } + + private RayObjects submit(UniqueID taskId, + byte[] fid, + int returnCount, + boolean multiReturn, + Object[] args) { + if (taskId == null) { + taskId = UniqueIdHelper.nextTaskId(-1); + } + if (args.length > 0 && args[0].getClass().equals(RayActor.class)) { + return actorTaskSubmit(taskId, fid, returnCount, multiReturn, args, (RayActor) args[0]); + } else { + return taskSubmit(taskId, fid, returnCount, multiReturn, args); + } + } + + public RayObjects rpc(UniqueID taskId, Callable funcRun, int returnCount, Object[] args) { + byte[] fid = fidFromHook(funcRun); + return submit(taskId, fid, returnCount, false, args); + } + + public RayObjects rpcCreateActor(UniqueID taskId, UniqueID createActorId, Callable funcRun, + int returnCount, + Object[] args) { + byte[] fid = fidFromHook(funcRun); + RayInvocation ri = new RayInvocation(fid, new Object[]{}); + return scheduler.submit(taskId, createActorId, ri, returnCount, false); + } + + public RayObjects rpc(UniqueID taskId, UniqueID functionId, Class funcCls, Serializable lambda, + int returnCount, Object[] args) { + byte[] fid = functionId.getBytes(); + + Object[] ls = Arrays.copyOf(args, args.length + 2); + ls[args.length] = funcCls.getName(); + ls[args.length + 1] = SerializationUtils.serialize(lambda); + + return submit(taskId, fid, returnCount, false, ls); + } + + public RayObjects rpcCreateActor(UniqueID taskId, UniqueID createActorId, UniqueID functionId, + Class funcCls, Serializable lambda, int returnCount, Object[] args) { + byte[] fid = functionId.getBytes(); + + Object[] ls = Arrays.copyOf(args, args.length + 2); + ls[args.length] = funcCls.getName(); + ls[args.length + 1] = SerializationUtils.serialize(lambda); + + RayInvocation ri = new RayInvocation(fid, ls); + return scheduler.submit(taskId, createActorId, ri, returnCount, false); + } + + public RayObjects rpc(UniqueID taskId, RayActor actor, Callable funcRun, int returnCount, + Object[] args) { + byte[] fid = fidFromHook(funcRun); + return actorTaskSubmit(taskId, fid, returnCount, false, args, actor); + } + + public RayObjects rpc(UniqueID taskId, UniqueID functionId, RayActor actor, Class funcCls, + Serializable lambda, int returnCount, Object[] args) { + byte[] fid = functionId.getBytes(); + + Object[] ls = Arrays.copyOf(args, args.length + 2); + ls[args.length] = funcCls.getName(); + ls[args.length + 1] = SerializationUtils.serialize(lambda); + + return actorTaskSubmit(taskId, fid, returnCount, false, ls, actor); + } + + public RayMap rpcWithReturnLabels(UniqueID taskId, Callable funcRun, + Collection returnids, + Object[] args) { + byte[] fid = fidFromHook(funcRun); + if (taskId == null) { + taskId = UniqueIdHelper.nextTaskId(-1); + } + return scheduler.submit(taskId, new RayInvocation(fid, args), returnids); + } + + public RayMap rpcWithReturnLabels(UniqueID taskId, Class funcCls, + Serializable lambda, Collection returnids, + Object[] args) { + byte[] fid = UniqueID.nil.getBytes(); + if (taskId == null) { + taskId = UniqueIdHelper.nextTaskId(-1); + } + + Object[] ls = Arrays.copyOf(args, args.length + 2); + ls[args.length] = funcCls.getName(); + ls[args.length + 1] = SerializationUtils.serialize(lambda); + + return scheduler.submit(taskId, new RayInvocation(fid, ls), returnids); + } + + public RayList rpcWithReturnIndices(UniqueID taskId, Callable funcRun, + Integer returnCount, + Object[] args) { + byte[] fid = fidFromHook(funcRun); + RayObjects objs = submit(taskId, fid, returnCount, true, args); + RayList rets = new RayList<>(); + for (RayObject obj : objs.getObjs()) { + rets.add(obj); + } + return rets; + } + + @SuppressWarnings("unchecked") + public RayList rpcWithReturnIndices(UniqueID taskId, Class funcCls, + Serializable lambda, Integer returnCount, + Object[] args) { + byte[] fid = UniqueID.nil.getBytes(); + Object[] ls = Arrays.copyOf(args, args.length + 2); + ls[args.length] = funcCls.getName(); + ls[args.length + 1] = SerializationUtils.serialize(lambda); + + RayObjects objs = submit(taskId, fid, returnCount, true, ls); + + RayList rets = new RayList<>(); + for (RayObject obj : objs.getObjs()) { + rets.add(obj); + } + return rets; + } + + private byte[] fidFromHook(Callable funcRun) { + MethodSwitcher.IsRemoteCall.set(true); + try { + funcRun.run(); + } catch (Throwable e) { + RayLog.core.error( + "make sure you are using code rewritten using the rewrite tool, see JarRewriter for options", + e); + throw new RuntimeException( + "make sure you are using code rewritten using the rewrite tool, see JarRewriter for options"); + } + byte[] fid = MethodSwitcher.MethodId.get();//get the identity of function from hook + MethodSwitcher.IsRemoteCall.set(false); + return fid; + } + + public UniqueID getCurrentTaskID() { + return WorkerContext.currentTask().taskId; + } + + public UniqueID getCurrentTaskNextPutID() { + return UniqueIdHelper.taskComputePutId( + WorkerContext.currentTask().taskId, WorkerContext.nextPutIndex()); + } + + public UniqueID[] getCurrentTaskReturnIDs() { + return WorkerContext.currentTask().returnIds; + } +} diff --git a/java/runtime-common/src/main/java/org/ray/core/WorkerContext.java b/java/runtime-common/src/main/java/org/ray/core/WorkerContext.java new file mode 100644 index 000000000000..84d8e5ca3f43 --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/core/WorkerContext.java @@ -0,0 +1,82 @@ +package org.ray.core; + +import org.ray.api.UniqueID; +import org.ray.core.model.RayParameters; +import org.ray.spi.model.TaskSpec; + +public class WorkerContext { + + /** + * id of worker + */ + public static UniqueID workerID = UniqueID.randomID(); + + /** + * current doing task + */ + private TaskSpec currentTask; + + /** + * current app classloader + */ + private ClassLoader currentClassLoader; + + /** + * how many puts done by current task + */ + private int currentTaskPutCount; + + /** + * how many calls done by current task + */ + private int currentTaskCallCount; + + private static final ThreadLocal currentWorkerCtx = + ThreadLocal.withInitial(() -> init(RayRuntime.getParams())); + + public static WorkerContext init(RayParameters params) { + WorkerContext ctx = new WorkerContext(); + currentWorkerCtx.set(ctx); + + TaskSpec dummy = new TaskSpec(); + dummy.parentTaskId = UniqueID.nil; + dummy.taskId = UniqueID.nil; + dummy.actorId = UniqueID.nil; + dummy.driverId = params.driver_id; + prepare(dummy, null); + + return ctx; + } + + public static WorkerContext get() { + return currentWorkerCtx.get(); + } + + public static void prepare(TaskSpec task, ClassLoader classLoader) { + WorkerContext wc = get(); + wc.currentTask = task; + wc.currentTaskPutCount = 0; + wc.currentTaskCallCount = 0; + wc.currentClassLoader = classLoader; + } + + public static TaskSpec currentTask() { + return get().currentTask; + } + + public static int nextPutIndex() { + return ++get().currentTaskPutCount; + } + + public static int nextCallIndex() { + return ++get().currentTaskCallCount; + } + + public static UniqueID currentWorkerID() { + return WorkerContext.workerID; + } + + public static ClassLoader currentClassLoader() { + return get().currentClassLoader; + } +} diff --git a/java/runtime-common/src/main/java/org/ray/core/model/RayParameters.java b/java/runtime-common/src/main/java/org/ray/core/model/RayParameters.java new file mode 100644 index 000000000000..9108af8de8b4 --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/core/model/RayParameters.java @@ -0,0 +1,132 @@ +package org.ray.core.model; + +import org.ray.api.UniqueID; +import org.ray.util.NetworkUtil; +import org.ray.util.config.AConfig; +import org.ray.util.config.ConfigReader; + +/** + * Runtime parameters of Ray process + */ +public class RayParameters { + + @AConfig(comment = "worker mode for this process DRIVER | WORKER | NONE") + public WorkerMode worker_mode = WorkerMode.DRIVER; + + @AConfig(comment = "run mode for this app SINGLE_PROCESS | SINGLE_BOX | CLUSTER") + public RunMode run_mode = RunMode.SINGLE_PROCESS; + + @AConfig(comment = "local node ip") + public String node_ip_address = NetworkUtil.getIpAddress(null); + + @AConfig(comment = "primary redis address (e.g., 127.0.0.1:34222") + public String redis_address = ""; + + @AConfig(comment = "object store name (e.g., /tmp/store1111") + public String object_store_name = ""; + + @AConfig(comment = "object store rpc listen port") + public int object_store_rpc_port = 32567; + + @AConfig(comment = "object store manager name (e.g., /tmp/storeMgr1111") + public String object_store_manager_name = ""; + + @AConfig(comment = "object store manager rpc listen port") + public int object_store_manager_rpc_port = 33567; + + @AConfig(comment = "object store manager ray listen port") + public int object_store_manager_ray_listen_port = 33667; + + @AConfig(comment = "local scheduler name (e.g., /tmp/scheduler1111") + public String local_scheduler_name = ""; + + @AConfig(comment = "local scheduler rpc listen port") + 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; + + @AConfig(comment = "working directory") + public String working_directory = "./run"; + + @AConfig(comment = "directory for saving logs") + public String logging_directory = "./run/logs"; + + @AConfig(comment = "primary redis port") + public int redis_port = 34222; + + @AConfig(comment = "number of workers started initially") + public int num_workers = 1; + + @AConfig(comment = "redirect err and stdout to files for newly created processes") + public boolean redirect = true; + + @AConfig(comment = "whether to start the global scheduler") + public boolean include_global_scheduler = false; + + @AConfig(comment = "whether to start redis shard server in addition to the primary server") + public boolean start_redis_shards = false; + + @AConfig(comment = "whether to clean up the processes when there is a process start failure") + public boolean cleanup = false; + + @AConfig(comment = "whether to start workers from within the local schedulers") + public boolean start_workers_from_local_scheduler = true; + + @AConfig(comment = "number of cpus assigned to each local scheduler") + public int[] num_cpus = {}; + + @AConfig(comment = "number of gpus assigned to each local scheduler") + public int[] num_gpus = {}; + + @AConfig(comment = "number of redis shard servers to be started") + public int num_redis_shards = 0; + + @AConfig(comment = "number of local schedulers to be started") + public int num_local_schedulers = 1; + + @AConfig(comment = "whether this is a deployment in cluster") + public boolean deploy = false; + + @AConfig(comment = "whether this is for python deployment") + public boolean py = false; + + @AConfig(comment = "the max bytes of the buffer for task submit") + public int max_submit_task_buffer_size_bytes = 2 * 1024 * 1024; + + @AConfig(comment = "default first check timeout(ms)") + public int default_first_check_timeout_ms = 1000; + + @AConfig(comment = "default get check rate(ms)") + public int default_get_check_interval_ms = 5000; + + @AConfig(comment = "add the jvm parameters for java worker") + public String jvm_parameters = ""; + + @AConfig(comment = "set the occupied memory(MB) size of object store") + public int object_store_occupied_memory_MB = 1000; + + @AConfig(comment = "whether to use supreme failover strategy") + public boolean supremeFO = false; + + @AConfig(comment = "the max num of java log of each java worker") + public int max_java_log_file_num = 10; + + @AConfig(comment = "whether to disable process failover") + public boolean disable_process_failover = false; + + @AConfig(comment = "the max size of each file of java worker log, could be set as 10KB, 10MB, 1GB or something similar") + public String max_java_log_file_size = "500MB"; + + @AConfig(comment = "delay seconds under onebox before app logic for debugging") + public int onebox_delay_seconds_before_run_app_logic = 0; + + public RayParameters(ConfigReader config) { + if (null != config) { + String networkInterface = config.getStringValue("ray.java", "network_interface", null, + "Network interface to be specified for host ip address(e.g., en0, eth0), may use ifconfig to get options"); + node_ip_address = NetworkUtil.getIpAddress(networkInterface); + config.readObject("ray.java.start", this, this); + } + } +} diff --git a/java/runtime-common/src/main/java/org/ray/core/model/RunMode.java b/java/runtime-common/src/main/java/org/ray/core/model/RunMode.java new file mode 100644 index 000000000000..b230ea052357 --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/core/model/RunMode.java @@ -0,0 +1,59 @@ +package org.ray.core.model; + +public enum RunMode { + SINGLE_PROCESS(true, false, true, false), // remote lambda, dev path, dev runtime + SINGLE_BOX(true, false, true, true), // remote lambda, dev path, native runtime + CLUSTER(false, true, false, true); // static rewrite, deploy path, naive runtime + + RunMode(boolean remoteLambda, boolean staticRewrite, boolean devPathManager, + boolean nativeRuntime) { + this.remoteLambda = remoteLambda; + this.staticRewrite = staticRewrite; + this.devPathManager = devPathManager; + this.nativeRuntime = nativeRuntime; + } + + private final boolean remoteLambda; + + private final boolean staticRewrite; + + private final boolean devPathManager; + + private final boolean nativeRuntime; + + /** + * Getter method for property remoteLambda + * + * @return property value of remoteLambda + */ + public boolean isRemoteLambda() { + return remoteLambda; + } + + /** + * Getter method for property staticRewrite + * + * @return property value of staticRewrite + */ + public boolean isStaticRewrite() { + return staticRewrite; + } + + /** + * Getter method for property devPathManager + * + * @return property value of devPathManager + */ + public boolean isDevPathManager() { + return devPathManager; + } + + /** + * Getter method for property nativeRuntime + * + * @return property value of nativeRuntime + */ + public boolean isNativeRuntime() { + return nativeRuntime; + } +} diff --git a/java/runtime-common/src/main/java/org/ray/core/model/WorkerMode.java b/java/runtime-common/src/main/java/org/ray/core/model/WorkerMode.java new file mode 100644 index 000000000000..fdf476d974d8 --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/core/model/WorkerMode.java @@ -0,0 +1,7 @@ +package org.ray.core.model; + +public enum WorkerMode { + NONE, // not set + DRIVER, // driver + WORKER // worker +} diff --git a/java/runtime-common/src/main/java/org/ray/spi/LocalSchedulerLink.java b/java/runtime-common/src/main/java/org/ray/spi/LocalSchedulerLink.java new file mode 100644 index 000000000000..93852ea3c27b --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/spi/LocalSchedulerLink.java @@ -0,0 +1,20 @@ +package org.ray.spi; + +import org.ray.api.UniqueID; +import org.ray.spi.model.TaskSpec; + +/** + * Provides core functionalities of local scheduler. + */ +public interface LocalSchedulerLink { + + void submitTask(TaskSpec task); + + TaskSpec getTaskTodo(); + + void markTaskPutDependency(UniqueID taskId, UniqueID objectId); + + void reconstructObject(UniqueID objectId); + + void notifyUnblocked(); +} diff --git a/java/runtime-common/src/main/java/org/ray/spi/LocalSchedulerProxy.java b/java/runtime-common/src/main/java/org/ray/spi/LocalSchedulerProxy.java new file mode 100644 index 000000000000..1c75af967926 --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/spi/LocalSchedulerProxy.java @@ -0,0 +1,134 @@ +package org.ray.spi; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import org.ray.api.RayMap; +import org.ray.api.RayObject; +import org.ray.api.RayObjects; +import org.ray.api.UniqueID; +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.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 RayObjects submit(UniqueID taskId, RayInvocation invocation, int returnCount, + boolean multiReturn) { + UniqueID[] returnIds = buildReturnIds(taskId, returnCount, multiReturn); + this.doSubmit(invocation, taskId, returnIds, UniqueID.nil); + return new RayObjects(returnIds); + } + + public RayObjects submit(UniqueID taskId, UniqueID createActorId, RayInvocation invocation, + int returnCount, boolean multiReturn) { + UniqueID[] returnIds = buildReturnIds(taskId, returnCount, multiReturn); + this.doSubmit(invocation, taskId, returnIds, createActorId); + return new RayObjects(returnIds); + } + + public RayMap submit(UniqueID taskId, RayInvocation invocation, + Collection userReturnIds) { + UniqueID[] returnIds = buildReturnIds(taskId, userReturnIds.size(), true); + + RayMap ret = new RayMap<>(); + Map returnidmapArg = new HashMap<>(); + int index = 0; + for (RID userReturnId : userReturnIds) { + if (returnidmapArg.containsKey(userReturnId)) { + RayLog.core.error("TaskId " + taskId + " userReturnId is duplicate " + userReturnId); + continue; + } + returnidmapArg.put(userReturnId, returnIds[index]); + ret.put(userReturnId, new RayObject<>(returnIds[index])); + index++; + } + if (index < returnIds.length) { + UniqueID[] newReturnIds = new UniqueID[index]; + System.arraycopy(returnIds, 0, newReturnIds, 0, index); + returnIds = newReturnIds; + } + Object args[] = invocation.getArgs(); + Object[] newargs; + if (args == null) { + newargs = new Object[]{returnidmapArg}; + } else { + newargs = new Object[args.length + 1]; + newargs[0] = returnidmapArg; + System.arraycopy(args, 0, newargs, 1, args.length); + } + invocation.setArgs(newargs); + this.doSubmit(invocation, taskId, returnIds, UniqueID.nil); + return ret; + } + + private void doSubmit(RayInvocation invocation, UniqueID taskId, + UniqueID[] returnIds, UniqueID createActorId) { + + 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 = new UniqueID(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; + + //WorkerContext.onSubmitTask(); + RayLog.core.info( + "Task " + taskId + " submitted, functionId = " + task.functionId + " actorId = " + + task.actorId + ", driverId = " + task.driverId + ", return_ids = " + Arrays + .toString(returnIds) + ", currentTask " + WorkerContext.currentTask().taskId + + " cursorId = " + task.cursorId); + scheduler.submitTask(task); + } + + // build Object IDs of return values. + private UniqueID[] buildReturnIds(UniqueID taskId, int returnCount, boolean multiReturn) { + UniqueID[] returnIds = new UniqueID[returnCount]; + for (int k = 0; k < returnCount; k++) { + returnIds[k] = UniqueIdHelper.taskComputeReturnId(taskId, k, multiReturn); + } + return returnIds; + } + + public TaskSpec getTask() { + TaskSpec ts = scheduler.getTaskTodo(); + 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) { + scheduler.reconstructObject(objectId); + } + + public void notifyUnblocked() { + scheduler.notifyUnblocked(); + } +} diff --git a/java/runtime-common/src/main/java/org/ray/spi/NopRemoteFunctionManager.java b/java/runtime-common/src/main/java/org/ray/spi/NopRemoteFunctionManager.java new file mode 100644 index 000000000000..0f848dded30c --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/spi/NopRemoteFunctionManager.java @@ -0,0 +1,80 @@ +package org.ray.spi; + +import java.util.Set; +import org.ray.api.UniqueID; +import org.ray.hook.MethodId; +import org.ray.hook.runtime.LoadedFunctions; +import org.ray.util.logger.RayLog; + +/** + * mock version of remote function manager using local loaded jars + runtime hook + */ +public class NopRemoteFunctionManager implements RemoteFunctionManager { + + public NopRemoteFunctionManager(UniqueID driverId) { + //onLoad(driverId, Agent.hookedMethods); + //Agent.consumers.add(m -> { this.onLoad(m); }); + } + + @Override + public UniqueID registerResource(byte[] resourceZip) { + return null; + // nothing to do + } + + @Override + public byte[] getResource(UniqueID resourceId) { + return null; + } + + @Override + public void unregisterResource(UniqueID resourceId) { + // nothing to do + } + + @Override + public void registerApp(UniqueID driverId, UniqueID resourceId) { + // nothing to do + } + + @Override + public UniqueID getAppResourceId(UniqueID driverId) { + return null; + // nothing to do + } + + @Override + public void unregisterApp(UniqueID driverId) { + // nothing to do + } + + private void onLoad(UniqueID driverId, Set methods) { + //assert (startupDriverId().equals(driverId)); + for (MethodId mid : methods) { + onLoad(mid); + } + } + + private void onLoad(MethodId mid) { + loadedFunctions.functions.add(mid); + } + + @Override + public LoadedFunctions loadFunctions(UniqueID driverId) { + //assert (startupDriverId().equals(driverId)); + if (loadedFunctions == null) { + RayLog.rapp.error("cannot find functions for " + driverId); + return null; + } else { + return loadedFunctions; + } + } + + @Override + public void unloadFunctions(UniqueID driverId) { + // never + //assert (startupDriverId().equals(driverId)); + } + + private final LoadedFunctions loadedFunctions = new LoadedFunctions(); +} diff --git a/java/runtime-common/src/main/java/org/ray/spi/ObjectStoreProxy.java b/java/runtime-common/src/main/java/org/ray/spi/ObjectStoreProxy.java new file mode 100644 index 000000000000..e316db0f488c --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/spi/ObjectStoreProxy.java @@ -0,0 +1,122 @@ +package org.ray.spi; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.arrow.plasma.ObjectStoreLink; +import org.apache.commons.lang3.tuple.Pair; +import org.ray.api.RayList; +import org.ray.api.RayObject; +import org.ray.api.UniqueID; +import org.ray.api.WaitResult; +import org.ray.core.Serializer; +import org.ray.core.WorkerContext; +import org.ray.util.exception.TaskExecutionException; + +/** + * Object store proxy, which handles serialization and deserialization, and utilize a {@code + * org.ray.spi.ObjectStoreLink} to actually store data. + */ +public class ObjectStoreProxy { + + public enum GetStatus {SUCCESS, FAILED} + + private final ObjectStoreLink store; + + private final int GET_TIMEOUT_MS = 1000; + + public ObjectStoreProxy(ObjectStoreLink store) { + this.store = store; + } + + public Pair get(UniqueID id, int timeout_ms, boolean isMetadata) + throws TaskExecutionException { + byte[] obj = store.get(id.getBytes(), timeout_ms, isMetadata); + if (obj != null) { + T t = Serializer.decode(obj, WorkerContext.currentClassLoader()); + store.release(id.getBytes()); + if (t instanceof TaskExecutionException) { + throw (TaskExecutionException) t; + } + return Pair.of(t, GetStatus.SUCCESS); + } else { + return Pair.of(null, GetStatus.FAILED); + } + } + + public Pair get(UniqueID objectId, boolean isMetadata) + throws TaskExecutionException { + return get(objectId, GET_TIMEOUT_MS, isMetadata); + } + + public List> get(List ids, int timeoutMs, boolean isMetadata) + throws TaskExecutionException { + List objs = store.get(getIdBytes(ids), timeoutMs, isMetadata); + List> ret = new ArrayList<>(); + for (int i = 0; i < objs.size(); i++) { + byte[] obj = objs.get(i); + if (obj != null) { + T t = Serializer.decode(obj, WorkerContext.currentClassLoader()); + store.release(ids.get(i).getBytes()); + if (t instanceof TaskExecutionException) { + throw (TaskExecutionException) t; + } + ret.add(Pair.of(t, GetStatus.SUCCESS)); + } else { + ret.add(Pair.of(null, GetStatus.FAILED)); + } + } + return ret; + } + + public List> get(List objectIds, boolean isMetadata) + throws TaskExecutionException { + return get(objectIds, GET_TIMEOUT_MS, isMetadata); + } + + public void put(UniqueID id, Object obj, Object metadata) { + store.put(id.getBytes(), Serializer.encode(obj), Serializer.encode(metadata)); + } + + public WaitResult wait(RayList waitfor, int numReturns, int timeout) { + List ids = new ArrayList<>(); + for (RayObject obj : waitfor.Objects()) { + ids.add(obj.getId()); + } + List readys = store.wait(getIdBytes(ids), timeout, numReturns); + + RayList readyObjs = new RayList<>(); + RayList remainObjs = new RayList<>(); + for (RayObject obj : waitfor.Objects()) { + if (readys.contains(obj.getId().getBytes())) { + readyObjs.add(obj); + } else { + remainObjs.add(obj); + } + } + + return new WaitResult<>(readyObjs, remainObjs); + } + + public void fetch(UniqueID objectId) { + store.fetch(objectId.getBytes()); + } + + public void fetch(List objectIds) { + store.fetch(getIdBytes(objectIds)); + } + + public int getFetchSize() { + return 10000; + } + + + private static byte[][] getIdBytes(List 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; + } +} diff --git a/java/runtime-common/src/main/java/org/ray/spi/PathConfig.java b/java/runtime-common/src/main/java/org/ray/spi/PathConfig.java new file mode 100644 index 000000000000..f33e685b4e9a --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/spi/PathConfig.java @@ -0,0 +1,63 @@ +package org.ray.spi; + +import org.ray.util.config.AConfig; +import org.ray.util.config.ConfigReader; + +/** + * Path related configurations. + */ +public class PathConfig { + + @AConfig(comment = "additional class path for JAVA", + defaultArrayIndirectSectionName = "ray.java.path.classes.source") + public String[] java_class_paths; + + @AConfig(comment = "additional JNI library paths for JAVA", + defaultArrayIndirectSectionName = "ray.java.path.jni.build") + public String[] java_jnilib_paths; + + @AConfig(comment = "path to ray_functions.txt for the default rewritten functions in ray runtime") + public String java_runtime_rewritten_jars_dir = ""; + + @AConfig(comment = "path to redis-server") + public String redis_server; + + @AConfig(comment = "path to redis module") + public String redis_module; + + @AConfig(comment = "path to plasma storage") + public String store; + + @AConfig(comment = "path to plasma manager") + public String store_manager; + + @AConfig(comment = "path to local scheduler") + public String local_scheduler; + + @AConfig(comment = "path to global scheduler") + public String global_scheduler; + + @AConfig(comment = "path to python directory") + public String python_dir; + + @AConfig(comment = "path to log server") + public String log_server; + + @AConfig(comment = "path to log server config file") + public String log_server_config; + + public PathConfig(ConfigReader config) { + if (config.getBooleanValue("ray.java.start", "deploy", false, + "whether the package is used as a cluster deployment")) { + config.readObject("ray.java.path.deploy", this, this); + } else { + boolean isJar = this.getClass().getResource(this.getClass().getSimpleName() + ".class") + .getFile().split("!")[0].endsWith(".jar"); + if (isJar) { + config.readObject("ray.java.path.package", this, this); + } else { + config.readObject("ray.java.path.source", this, this); + } + } + } +} diff --git a/java/runtime-common/src/main/java/org/ray/spi/RemoteFunctionManager.java b/java/runtime-common/src/main/java/org/ray/spi/RemoteFunctionManager.java new file mode 100644 index 000000000000..d08c5eadd93e --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/spi/RemoteFunctionManager.java @@ -0,0 +1,71 @@ +package org.ray.spi; + +import org.ray.api.UniqueID; +import org.ray.hook.runtime.LoadedFunctions; + +/** + * register and load functions from function table + */ +public interface RemoteFunctionManager { + + /** + * register mapping, and upload resource + * + * this function is invoked by app proxy or other stand-alone tools it should detect for + * duplication first though + * + * @param resourceZip a directory zip from @JarRewriter + * @return SHA-1 hash of the content + */ + UniqueID registerResource(byte[] resourceZip); + + /** + * download resource content + * + * @return resource content + */ + byte[] getResource(UniqueID resourceId); + + /** + * remove resource by its hash id + * + * be careful of invoking this function to make sure it is no longer used + * + * @param resourceId SHA-1 hash of the resource zip bytes + */ + void unregisterResource(UniqueID resourceId); + + /** + * register the mapping to repo + * + * this function is invoked by whoever initiates the driver id + */ + void registerApp(UniqueID driverId, UniqueID resourceId); + + /** + * get the resourceId of one app + * + * @return resourceId of the app driver + */ + UniqueID getAppResourceId(UniqueID driverId); + + /** + * unregister mapping + * + * this function is called when the driver exits or detected dead + */ + void unregisterApp(UniqueID driverId); + + /** + * load resource and functions for this driver this function is used by the workers on demand when + * a required function is not found in {@code LocalFunctionManager} + */ + LoadedFunctions loadFunctions(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); +} diff --git a/java/runtime-common/src/main/java/org/ray/spi/model/AddressInfo.java b/java/runtime-common/src/main/java/org/ray/spi/model/AddressInfo.java new file mode 100644 index 000000000000..7276278d07c0 --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/spi/model/AddressInfo.java @@ -0,0 +1,16 @@ +package org.ray.spi.model; + +/** + * Represents information of different process roles. + */ +public class AddressInfo { + + public String managerName; + public String storeName; + public String schedulerName; + public int managerPort; + public int workerCount; + public String managerRpcAddr; + public String storeRpcAddr; + public String schedulerRpcAddr; +} diff --git a/java/runtime-common/src/main/java/org/ray/spi/model/FunctionArg.java b/java/runtime-common/src/main/java/org/ray/spi/model/FunctionArg.java new file mode 100644 index 000000000000..ab147bd68b8e --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/spi/model/FunctionArg.java @@ -0,0 +1,17 @@ +package org.ray.spi.model; + +import java.util.ArrayList; +import org.ray.api.UniqueID; + +/** + * Represents arguments for ray function calls. + */ +public class FunctionArg { + + public ArrayList ids; + public byte[] data; + + public void toString(StringBuilder builder) { + builder.append("ids: ").append(ids).append(", ").append(":").append(data); + } +} diff --git a/java/runtime-common/src/main/java/org/ray/spi/model/RayInvocation.java b/java/runtime-common/src/main/java/org/ray/spi/model/RayInvocation.java new file mode 100644 index 000000000000..5d7059e2642f --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/spi/model/RayInvocation.java @@ -0,0 +1,53 @@ +package org.ray.spi.model; + +import org.ray.api.RayActor; +import org.ray.api.UniqueID; + +/** + * Represents an invocation of ray remote function. + */ +public class RayInvocation { + + /** + * unique id for a method + * + * @see UniqueID + */ + private final byte[] id; + /** + * function arguments + */ + private Object[] args; + + private final RayActor actor; + + private static final RayActor nil = new RayActor<>(UniqueID.nil, UniqueID.nil); + + public RayInvocation(byte[] id, Object[] args) { + this(id, args, nil); + } + + public RayInvocation(byte[] id, Object[] args, RayActor actor) { + super(); + this.id = id; + this.args = args; + this.actor = actor; + } + + public byte[] getId() { + return id; + } + + public Object[] getArgs() { + return args; + } + + public void setArgs(Object[] args) { + this.args = args; + } + + public RayActor getActor() { + return actor; + } + +} diff --git a/java/runtime-common/src/main/java/org/ray/spi/model/RayMethod.java b/java/runtime-common/src/main/java/org/ray/spi/model/RayMethod.java new file mode 100644 index 000000000000..fac19e1d7e1a --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/spi/model/RayMethod.java @@ -0,0 +1,27 @@ +package org.ray.spi.model; + +import java.lang.reflect.Method; + +/** + * method info + */ +public class RayMethod { + + public final Method invokable; + public final String fullName; + // TODO: other annotated information + + public void check() { + for (Class paramCls : invokable.getParameterTypes()) { + if (paramCls.isPrimitive()) { + throw new RuntimeException( + "@RayRemote function " + fullName + " must have all non-primitive typed parameters"); + } + } + } + + public RayMethod(Method m) { + invokable = m; + fullName = m.getDeclaringClass().getName() + "." + m.getName(); + } +} diff --git a/java/runtime-common/src/main/java/org/ray/spi/model/TaskSpec.java b/java/runtime-common/src/main/java/org/ray/spi/model/TaskSpec.java new file mode 100644 index 000000000000..91d8eb09a177 --- /dev/null +++ b/java/runtime-common/src/main/java/org/ray/spi/model/TaskSpec.java @@ -0,0 +1,68 @@ +package org.ray.spi.model; + +import java.util.Arrays; +import org.ray.api.UniqueID; + +/** + * Represents necessary information of a task for scheduling and executing. + */ +public class TaskSpec { + + // ID of the driver that created this task. + public UniqueID driverId; + + // Task ID of the task. + public UniqueID taskId; + + // Task ID of the parent task. + 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; + + // Number of tasks that have been submitted to this actor so far. + public int actorCounter; + + // Function ID of the task. + public UniqueID functionId; + + // Task arguments. + public FunctionArg[] args; + + // return ids + public UniqueID[] returnIds; + + // ID per actor client for session consistency + public UniqueID actorHandleId; + + // Id for create a target actor + public UniqueID createActorId; + + public UniqueID cursorId; + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("\ttaskId: ").append(taskId).append("\n"); + builder.append("\tdriverId: ").append(driverId).append("\n"); + builder.append("\tparentCounter: ").append(parentCounter).append("\n"); + builder.append("\tactorId: ").append(actorId).append("\n"); + builder.append("\tactorCounter: ").append(actorCounter).append("\n"); + builder.append("\tfunctionId: ").append(functionId).append("\n"); + builder.append("\treturnIds: ").append(Arrays.toString(returnIds)).append("\n"); + builder.append("\tactorHandleId: ").append(actorHandleId).append("\n"); + builder.append("\tcreateActorId: ").append(createActorId).append("\n"); + builder.append("\tcursorId: ").append(cursorId).append("\n"); + builder.append("\targs:\n"); + for (FunctionArg arg : args) { + builder.append("\t\t"); + arg.toString(builder); + builder.append("\n"); + } + return builder.toString(); + } +} \ No newline at end of file diff --git a/java/runtime-dev/pom.xml b/java/runtime-dev/pom.xml new file mode 100644 index 000000000000..7f710ed870e8 --- /dev/null +++ b/java/runtime-dev/pom.xml @@ -0,0 +1,54 @@ + + + + + org.ray.parent + ray-superpom + 1.0 + + 4.0.0 + org.ray + ray-runtime-dev + + runtime-dev + runtime for app development + + + jar + + + + org.ray + ray-api + 1.0 + + + org.ray + ray-runtime-common + 1.0 + + + de.ruedigermoeller + fst + 2.47 + + + + + com.github.davidmoten + flatbuffers-java + 1.7.0.1 + + + + + redis.clients + jedis + 2.8.0 + + + + + diff --git a/java/runtime-dev/src/main/java/org/ray/core/impl/RayDevRuntime.java b/java/runtime-dev/src/main/java/org/ray/core/impl/RayDevRuntime.java new file mode 100644 index 000000000000..e3fcb6715f9c --- /dev/null +++ b/java/runtime-dev/src/main/java/org/ray/core/impl/RayDevRuntime.java @@ -0,0 +1,85 @@ +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.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 { + + protected RayDevRuntime() { + } + + @Override + public void start(RayParameters params) { + PathConfig pathConfig = new PathConfig(configReader); + RemoteFunctionManager rfm = new NopRemoteFunctionManager(params.driver_id); + MockObjectStore store = new MockObjectStore(); + MockLocalScheduler scheduler = new MockLocalScheduler(store); + init(scheduler, store, rfm, pathConfig); + scheduler.setLocalFunctionManager(this.functions); + } + + private final ConcurrentHashMap actors = new ConcurrentHashMap<>(); + + @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.taskComputeReturnId(taskId, 0, false); + 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); + } + } + + @Override + public RayActor create(Class cls) { + return new RayActor<>(Ray.call(RayDevRuntime::createActor, cls.getName()).getId()); + } + + @Override + public Object getLocalActor(UniqueID id) { + return actors.get(id); + } + + @Override + public void cleanUp() { + // nothing to do + } +} diff --git a/java/runtime-dev/src/main/java/org/ray/spi/impl/MockLocalScheduler.java b/java/runtime-dev/src/main/java/org/ray/spi/impl/MockLocalScheduler.java new file mode 100644 index 000000000000..c03895d3dcd6 --- /dev/null +++ b/java/runtime-dev/src/main/java/org/ray/spi/impl/MockLocalScheduler.java @@ -0,0 +1,85 @@ +package org.ray.spi.impl; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import org.ray.api.UniqueID; +import org.ray.core.LocalFunctionManager; +import org.ray.core.Worker; +import org.ray.spi.LocalSchedulerLink; +import org.ray.spi.model.FunctionArg; +import org.ray.spi.model.TaskSpec; + +/** + * A mock implementation of {@code org.ray.spi.LocalSchedulerLink}, which stores waiting tasks in a + * Map, and cooperates with a {@code org.ray.spi.impl.MockObjectStore}. + */ +public class MockLocalScheduler implements LocalSchedulerLink { + + private final Map> waitTasks_ = new ConcurrentHashMap<>(); + private final MockObjectStore store_; + private LocalFunctionManager functions_ = null; + + public MockLocalScheduler(MockObjectStore store) { + store_ = store; + store.registerScheduler(this); + } + + public void setLocalFunctionManager(LocalFunctionManager mgr) { + functions_ = mgr; + } + + public void onObjectPut(UniqueID id) { + Map bucket = waitTasks_.get(id); + if (bucket != null) { + waitTasks_.remove(id); + for (TaskSpec ts : bucket.values()) { + submitTask(ts); + } + } + } + + 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; + } + } + } + } + return null; + } + + @Override + public void submitTask(TaskSpec task) { + UniqueID id = isTaskReady(task); + if (id == null) { + Worker.execute(task, functions_); + } else { + Map bucket = waitTasks_ + .computeIfAbsent(id, id_ -> new ConcurrentHashMap<>()); + bucket.put(id, task); + } + } + + @Override + public TaskSpec getTaskTodo() { + throw new RuntimeException("invalid execution flow here"); + } + + @Override + public void markTaskPutDependency(UniqueID taskId, UniqueID objectId) { + + } + + @Override + public void reconstructObject(UniqueID objectId) { + + } + + @Override + public void notifyUnblocked() { + + } +} diff --git a/java/runtime-dev/src/main/java/org/ray/spi/impl/MockObjectStore.java b/java/runtime-dev/src/main/java/org/ray/spi/impl/MockObjectStore.java new file mode 100644 index 000000000000..5fe20065b6ee --- /dev/null +++ b/java/runtime-dev/src/main/java/org/ray/spi/impl/MockObjectStore.java @@ -0,0 +1,110 @@ +package org.ray.spi.impl; + +import java.util.ArrayList; +import java.util.Arrays; +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.core.WorkerContext; +import org.ray.util.logger.RayLog; + +/** + * A mock implementation of {@code org.ray.spi.ObjectStoreLink}, which use Map to store data. + */ +public class MockObjectStore implements ObjectStoreLink { + + private final Map data_ = new ConcurrentHashMap<>(); + private final Map metadata_ = new ConcurrentHashMap<>(); + private MockLocalScheduler scheduler_ = null; + + @Override + public void put(byte[] objectId, byte[] value, byte[] metadataValue) { + if (objectId == null || objectId.length == 0 || value == null) { + RayLog.core + .error(logPrefix() + "cannot put null: " + objectId + "," + Arrays.toString(value)); + System.exit(-1); + } + UniqueID uniqueID = new UniqueID(objectId); + data_.put(uniqueID, value); + metadata_.put(uniqueID, metadataValue); + + if (scheduler_ != null) { + scheduler_.onObjectPut(uniqueID); + } + } + + @Override + public List get(byte[][] objectIds, int timeoutMs, boolean isMetadata) { + final Map dataMap = isMetadata ? metadata_ : data_; + ArrayList rets = new ArrayList<>(objectIds.length); + for (byte[] objId : objectIds) { + UniqueID uniqueID = new UniqueID(objId); + RayLog.core.info(logPrefix() + " is notified for objectid " + uniqueID); + rets.add(dataMap.get(uniqueID)); + } + return rets; + } + + private String logPrefix() { + return WorkerContext.currentTask().taskId + "-" + getUserTrace() + " -> "; + } + + private String getUserTrace() { + StackTraceElement stes[] = Thread.currentThread().getStackTrace(); + int k = 1; + while (stes[k].getClassName().startsWith("org.ray") + && !stes[k].getClassName().contains("test")) { + k++; + } + return stes[k].getFileName() + ":" + stes[k].getLineNumber(); + } + + @Override + public List wait(byte[][] objectIds, int timeoutMs, int numReturns) { + ArrayList rets = new ArrayList<>(); + for (byte[] objId : objectIds) { + //tod test + if (data_.containsKey(new UniqueID(objId))) { + rets.add(objId); + } + } + return rets; + } + + @Override + public byte[] hash(byte[] objectId) { + return null; + } + + @Override + public void fetch(byte[][] objectIds) { + + } + + @Override + public long evict(long numBytes) { + return 0; + } + + public boolean isObjectReady(UniqueID id) { + return data_.containsKey(id); + } + + public void registerScheduler(MockLocalScheduler s) { + scheduler_ = s; + } + + @Override + public void release(byte[] objectId) { + return; + } + + @Override + public boolean contains(byte[] objectId) { + + return data_.containsKey(new UniqueID(objectId)); + } +} diff --git a/java/runtime-native/assembly.xml b/java/runtime-native/assembly.xml new file mode 100644 index 000000000000..1684a11d6f99 --- /dev/null +++ b/java/runtime-native/assembly.xml @@ -0,0 +1,15 @@ + + ear + + zip + + + + true + lib + + + + + + diff --git a/java/runtime-native/pom.xml b/java/runtime-native/pom.xml new file mode 100644 index 000000000000..2f7eca83e7ae --- /dev/null +++ b/java/runtime-native/pom.xml @@ -0,0 +1,82 @@ + + + + + org.ray.parent + ray-superpom + 1.0 + + 4.0.0 + + org.ray + ray-runtime-native + + native runtime for ray + native runtime for ray + + + jar + + + + org.ray + ray-runtime-common + 1.0 + + + + + commons-io + commons-io + 2.5 + + + + net.lingala.zip4j + zip4j + 1.3.2 + + + + commons-codec + commons-codec + 1.4 + + + com.google.guava + guava + 19.0 + + + org.apache.arrow + arrow-plasma + + + + ray-runtime-deploy + + + org.apache.maven.plugins + maven-assembly-plugin + + + assembly.xml + + + + + make-assembly + install + + single + + + + + + + + + diff --git a/java/runtime-native/src/main/java/org/ray/core/impl/RayNativeRuntime.java b/java/runtime-native/src/main/java/org/ray/core/impl/RayNativeRuntime.java new file mode 100644 index 000000000000..96ad00d5148c --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/core/impl/RayNativeRuntime.java @@ -0,0 +1,251 @@ +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.*; +import org.ray.api.funcs.RayFunc_2_1; +import org.ray.core.RayRuntime; +import org.ray.core.UniqueIdHelper; +import org.ray.core.WorkerContext; +import org.ray.core.model.RayParameters; +import org.ray.core.model.WorkerMode; +import org.ray.runner.RunManager; +import org.ray.spi.KeyValueStoreLink; +import org.ray.spi.LocalSchedulerLink; +import org.ray.spi.NopRemoteFunctionManager; +import org.ray.spi.PathConfig; +import org.ray.spi.RemoteFunctionManager; +import org.ray.spi.StateStoreProxy; +import org.ray.spi.impl.DefaultLocalSchedulerClient; +import org.ray.spi.impl.NativeRemoteFunctionManager; +import org.ray.spi.impl.RedisClient; +import org.ray.spi.impl.StateStoreProxyImpl; +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 { + + static { + System.err.println("Current working directory is " + System.getProperty("user.dir")); + System.loadLibrary("local_scheduler_library_java"); + System.loadLibrary("plasma_java"); + } + + private StateStoreProxy stateStoreProxy; + private KeyValueStoreLink kvStore = null; + private RunManager manager = null; + + @Override + public void cleanUp() { + if (null != manager) { + manager.cleanup(true); + } + } + + protected RayNativeRuntime() { + } + + private void initStateStore(String redisAddress) throws Exception { + kvStore = new RedisClient(); + kvStore.SetAddr(redisAddress); + stateStoreProxy = new StateStoreProxyImpl(kvStore); + //stateStoreProxy.setStore(kvStore); + stateStoreProxy.initializeGlobalState(); + } + + @Override + public void start(RayParameters params) throws Exception { + boolean isWorker = (params.worker_mode == WorkerMode.WORKER); + PathConfig pathConfig = new PathConfig(configReader); + + // initialize params + if (params.redis_address.length() == 0) { + if (isWorker) { + throw new Error("Redis address must be configured under Worker mode."); + } + startOnebox(params, pathConfig); + initStateStore(params.redis_address); + } else { + initStateStore(params.redis_address); + if (!isWorker) { + List nodes = stateStoreProxy.getAddressInfo(params.node_ip_address, 5); + params.object_store_name = nodes.get(0).storeName; + params.object_store_manager_name = nodes.get(0).managerName; + params.local_scheduler_name = nodes.get(0).schedulerName; + } + } + + // initialize remote function manager + RemoteFunctionManager funcMgr = params.run_mode.isStaticRewrite() ? + new NativeRemoteFunctionManager(kvStore) : + new NopRemoteFunctionManager(params.driver_id); + + // initialize worker context + if (params.worker_mode == WorkerMode.DRIVER) { + // TODO: The relationship between workerID, driver_id and dummy_task.driver_id should be recheck carefully + WorkerContext.workerID = params.driver_id; + } + WorkerContext.init(params); + + if (params.onebox_delay_seconds_before_run_app_logic > 0) { + for (int i = 0; i < params.onebox_delay_seconds_before_run_app_logic; ++i) { + System.err.println("Pause for debugger, " + + (params.onebox_delay_seconds_before_run_app_logic - i) + + " seconds left ..."); + Thread.sleep(1000); + } + } + + if (params.worker_mode != WorkerMode.NONE) { + String overwrites = ""; + // initialize the links + int release_delay = RayRuntime.configReader + .getIntegerValue("ray", "plasma_default_release_delay", 0, + "how many release requests should be delayed in plasma client"); + ObjectStoreLink pLink = new PlasmaClient(params.object_store_name, params.object_store_manager_name, release_delay); + + LocalSchedulerLink sLink = new DefaultLocalSchedulerClient( + params.local_scheduler_name, + WorkerContext.currentWorkerID(), + UniqueID.nil, + isWorker, + 0 + ); + + init(sLink, pLink, funcMgr, pathConfig); + + // register + registerWorker(isWorker, params.node_ip_address, params.object_store_name, + params.object_store_manager_name, params.local_scheduler_name); + } + + RayLog.core.info("RayNativeRuntime start with " + + "store " + params.object_store_name + + ", manager " + params.object_store_manager_name + + ", scheduler " + params.local_scheduler_name + ); + } + + private void startOnebox(RayParameters params, PathConfig paths) throws Exception { + params.cleanup = true; + manager = new RunManager(params, paths, RayRuntime.configReader); + manager.startRayHead(); + + params.redis_address = manager.info().redisAddress; + params.object_store_name = manager.info().local_stores.get(0).storeName; + params.object_store_manager_name = manager.info().local_stores.get(0).managerName; + params.local_scheduler_name = manager.info().local_stores.get(0).schedulerName; + //params.node_ip_address = NetworkUtil.getIpAddress(); + } + + private void registerWorker(boolean isWorker, String node_ip_address, String storeName, + String managerName, String schedulerName) { + Map workerInfo = new HashMap<>(); + String workerId = new String(WorkerContext.currentWorkerID().getBytes()); + if (!isWorker) { + workerInfo.put("node_ip_address", node_ip_address); + workerInfo.put("driver_id", workerId); + workerInfo.put("start_time", String.valueOf(System.currentTimeMillis())); + workerInfo.put("plasma_store_socket", storeName); + workerInfo.put("plasma_manager_socket", managerName); + workerInfo.put("local_scheduler_socket", schedulerName); + workerInfo.put("name", System.getProperty("user.dir")); + //TODO: worker.redis_client.hmset(b"Drivers:" + worker.workerId, driver_info) + kvStore.Hmset("Drivers:" + workerId, workerInfo); + } else { + workerInfo.put("node_ip_address", node_ip_address); + //TODO: + /* + "stdout_file": os.path.abspath(log_stdout_file.name), + "stderr_file": os.path.abspath(log_stderr_file.name), + */ + workerInfo.put("plasma_store_socket", storeName); + workerInfo.put("plasma_manager_socket", managerName); + workerInfo.put("local_scheduler_socket", schedulerName); + //TODO: b"Workers:" + worker.workerId, + kvStore.Hmset("Workers:" + workerId, workerInfo); + } + } + + private Object _actor = null; + private UniqueID actorID = UniqueID.nil; + + @RayRemote + public static byte[] createActorInActor(byte[] actorId, String className) { + ((RayNativeRuntime) RayRuntime.getInstance()).localCreateActorInActor(actorId, className); + return actorId; + } + + @SuppressWarnings("unchecked") + @Override + public RayActor create(Class cls) { + UniqueID createTaskId = UniqueIdHelper.nextTaskId(-1); + UniqueID actorId = UniqueIdHelper.taskComputeReturnId(createTaskId, 0, false); + RayActor actor = new RayActor<>(actorId); + UniqueID cursorId; + if (params.run_mode.isRemoteLambda()) { + RayFunc_2_1 createActorLambda = RayNativeRuntime::createActorInActor; + cursorId = worker.rpcCreateActor( + createTaskId, + actorId, + UniqueID.nil, + RayFunc_2_1.class, + createActorLambda, + 1, + new Object[]{actorId.getBytes(), cls.getName()} + ).getObjs()[0].getId(); + } else { + cursorId = worker.rpcCreateActor( + createTaskId, + actorId, + () -> RayNativeRuntime.createActorInActor(null, null), + 1, + new Object[]{actorId.getBytes(), cls.getName()} + ).getObjs()[0].getId(); + } + actor.setTaskCursor(cursorId); + return actor; + } + + public Object localCreateActorInActor(byte[] actorId, String className) { + try { + 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 " + actorID + " inside actor ok"); + return _actor; + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + String log = "create actor " + actorID + " for " + className + " failed, ex = " + e + .getMessage(); + System.err.println(log); + RayLog.core.error(log, e); + throw new TaskExecutionException(log, e); + } + } + + @Override + public Object getLocalActor(UniqueID id) { + if (actorID.equals(id)) { + return _actor; + } else { + return null; + } + } +} diff --git a/java/runtime-native/src/main/java/org/ray/runner/ProcessInfo.java b/java/runtime-native/src/main/java/org/ray/runner/ProcessInfo.java new file mode 100644 index 000000000000..c2489c69dddc --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/runner/ProcessInfo.java @@ -0,0 +1,13 @@ +package org.ray.runner; + +public class ProcessInfo { + + public Process process; + public String[] cmd; + public RunInfo.ProcessType type; + public String workDir; + public String redisAddress; + public String ip; + public boolean redirect; + public boolean cleanup; +} \ No newline at end of file diff --git a/java/runtime-native/src/main/java/org/ray/runner/RunInfo.java b/java/runtime-native/src/main/java/org/ray/runner/RunInfo.java new file mode 100644 index 000000000000..56bb28ff7e9c --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/runner/RunInfo.java @@ -0,0 +1,41 @@ +package org.ray.runner; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.ray.spi.model.AddressInfo; + +/** + * information of kinds of processes + */ +public class RunInfo { + + public String redisAddress; + public List redisShards; + public List local_stores = new ArrayList<>(); + public ArrayList> allProcesses = initProcessInfoArray(); + public ArrayList> toBeCleanedProcesses = initProcessArray(); + public ArrayList deadProcess = new ArrayList<>(); + + public enum ProcessType { + PT_WORKER, PT_LOCAL_SCHEDULER, PT_PLASMA_MANAGER, PT_PLASMA_STORE, + PT_GLOBAL_SCHEDULER, PT_REDIS_SERVER, PT_WEB_UI, + PT_DRIVER + } + + private ArrayList> initProcessArray() { + ArrayList> processes = new ArrayList<>(); + for (ProcessType ignored : ProcessType.values()) { + processes.add(Collections.synchronizedList(new ArrayList<>())); + } + return processes; + } + + private ArrayList> initProcessInfoArray() { + ArrayList> processes = new ArrayList<>(); + for (ProcessType ignored : ProcessType.values()) { + processes.add(Collections.synchronizedList(new ArrayList<>())); + } + return processes; + } +} diff --git a/java/runtime-native/src/main/java/org/ray/runner/RunManager.java b/java/runtime-native/src/main/java/org/ray/runner/RunManager.java new file mode 100644 index 000000000000..9c5f891832ca --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/runner/RunManager.java @@ -0,0 +1,766 @@ +package org.ray.runner; + +import java.io.File; +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; +import org.ray.api.UniqueID; +import org.ray.core.model.RayParameters; +import org.ray.core.model.RunMode; +import org.ray.runner.RunInfo.ProcessType; +import org.ray.spi.PathConfig; +import org.ray.spi.model.AddressInfo; +import org.ray.util.StringUtil; +import org.ray.util.config.ConfigReader; +import org.ray.util.logger.RayLog; +import redis.clients.jedis.Jedis; + +/** + * Ray service management on one box + */ +public class RunManager { + + public static final int INT16_MAX = 32767; + + private RayParameters params; + + private PathConfig paths; + + private ConfigReader configReader; + + private String procStdoutFileName = ""; + + private String procStderrFileName = ""; + + private RunInfo runInfo = new RunInfo(); + + public RunInfo info() { + return runInfo; + } + + public PathConfig getPathManager() { + return paths; + } + + public String getProcStdoutFileName() { + return procStdoutFileName; + } + + public String getProcStderrFileName() { + return procStderrFileName; + } + + public RunManager(RayParameters params, PathConfig paths, ConfigReader configReader) { + this.params = params; + this.paths = paths; + this.configReader = configReader; + } + + public void startRayHead() throws Exception { + if (params.redis_address.length() != 0) { + throw new Exception("Redis address must be empty in head node."); + } + if (params.num_redis_shards <= 0) { + params.num_redis_shards = 1; + } + if (params.num_local_schedulers <= 0) { + params.num_local_schedulers = 1; + } + + params.start_workers_from_local_scheduler = params.run_mode != RunMode.SINGLE_BOX; + + params.include_global_scheduler = true; + params.start_redis_shards = true; + + startRayProcesses(); + } + + public void startRayNode() throws Exception { + if (params.redis_address.length() == 0) { + throw new Exception("Redis address cannot be empty in non-head node."); + } + if (params.num_redis_shards != 0) { + throw new Exception("Number of redis shards should be zero in non-head node."); + } + if (params.num_local_schedulers <= 0) { + params.num_local_schedulers = 1; + } + + //params.start_workers_from_local_scheduler = true; + params.include_global_scheduler = false; + params.start_redis_shards = false; + + startRayProcesses(); + } + + private String buildJavaProcessCommand( + RunInfo.ProcessType pt, String mainClass, String additionalClassPaths, + String additionalConfigs, + String additionalJvmArgs, String workDir, String ip, String redisAddr, String agentlibAddr) { + String cmd = "java -ea -noverify " + params.jvm_parameters + " "; + if (agentlibAddr != null && !agentlibAddr.equals("")) { + cmd += " -agentlib:jdwp=transport=dt_socket,address=" + agentlibAddr + ",server=y,suspend=n"; + } + + cmd += " -Djava.library.path=" + StringUtil.mergeArray(paths.java_jnilib_paths, ":"); + cmd += " -classpath " + StringUtil.mergeArray(paths.java_class_paths, ":"); + + if (additionalClassPaths.length() > 0) { + cmd += ":" + additionalClassPaths; + } + + if (additionalJvmArgs.length() > 0) { + cmd += " " + additionalJvmArgs; + } + + cmd += " " + mainClass; + + String section = "ray.java.start."; + cmd += " --config=" + configReader.filePath(); + cmd += " --overwrite=" + + section + "node_ip_address=" + ip + ";" + + section + "redis_address=" + redisAddr + ";" + + section + "working_directory=" + workDir + ";" + + section + "logging_directory=" + params.logging_directory + ";" + + section + "working_directory=" + workDir; + + if (additionalConfigs.length() > 0) { + cmd += ";" + additionalConfigs; + } + + return cmd; + } + + private Process startJavaProcess(RunInfo.ProcessType pt, String mainClass, + String additonalClassPaths, String additionalConfigs, + String additionalJvmArgs, String workDir, String ip, String redisAddr, boolean redirect, + boolean cleanup, String agentlibAddr) { + + String cmd = buildJavaProcessCommand(pt, mainClass, additonalClassPaths, additionalConfigs, + additionalJvmArgs, workDir, ip, redisAddr, agentlibAddr); + return startProcess(cmd.split(" "), null, pt, workDir, redisAddr, ip, redirect, cleanup); + } + + public Process startDriver(String mainClass, String redisAddress, UniqueID driverId, + String workDir, String ip, + String driverClass, String additonalClassPaths, String additionalConfigs) { + String driverConfigs = + "ray.java.start.driver_id=" + driverId + ";ray.java.start.driver_class=" + driverClass; + if (null != additionalConfigs) { + additionalConfigs += ";" + driverConfigs; + } else { + additionalConfigs = driverConfigs; + } + + return startJavaProcess( + RunInfo.ProcessType.PT_DRIVER, + mainClass, + additonalClassPaths, + additionalConfigs, + "", + workDir, + ip, + redisAddress, + true, + false, + null + ); + } + + public void startRayProcesses() { + Jedis _redis_client = null; + + RayLog.core.info("start ray processes @ " + params.node_ip_address + " ..."); + + // start primary redis + if (params.redis_address.length() == 0) { + List primaryShards = startRedis(params.working_directory + "/redis", + params.node_ip_address, params.redis_port, 1, params.redirect, params.cleanup); + params.redis_address = primaryShards.get(0); + + String[] args = params.redis_address.split(":"); + _redis_client = new Jedis(args[0], Integer.parseInt(args[1])); + + // Register the number of Redis shards in the primary shard, so that clients + // know how many redis shards to expect under RedisShards. + _redis_client.set("NumRedisShards", Integer.toString(params.num_redis_shards)); + } else { + String[] args = params.redis_address.split(":"); + _redis_client = new Jedis(args[0], Integer.parseInt(args[1])); + } + runInfo.redisAddress = params.redis_address; + + // start redis shards + if (params.start_redis_shards) { + runInfo.redisShards = startRedis(params.working_directory + "/redis/shards", + params.node_ip_address, params.redis_port + 1, params.num_redis_shards, + params.redirect, + params.cleanup); + + // Store redis shard information in the primary redis shard. + for (int i = 0; i < runInfo.redisShards.size(); i++) { + String addr = runInfo.redisShards.get(i); + _redis_client.rpush("RedisShards", addr); + } + } + _redis_client.close(); + + // start global scheduler + if (params.include_global_scheduler) { + startGlobalScheduler(params.working_directory + "/globalScheduler", + params.redis_address, params.node_ip_address, params.redirect, params.cleanup); + } + + // prepare parameters for node processes + if (params.num_cpus.length == 0) { + params.num_cpus = new int[params.num_local_schedulers]; + for (int i = 0; i < params.num_local_schedulers; i++) { + params.num_cpus[i] = 1; + } + } else { + assert (params.num_cpus.length == params.num_local_schedulers); + } + + if (params.num_gpus.length == 0) { + params.num_gpus = new int[params.num_local_schedulers]; + for (int i = 0; i < params.num_local_schedulers; i++) { + params.num_gpus[i] = 0; + } + } else { + assert (params.num_gpus.length == params.num_local_schedulers); + } + + int[] local_num_workers = new int[params.num_local_schedulers]; + if (params.num_workers == 0) { + System.arraycopy(params.num_cpus, 0, local_num_workers, 0, params.num_local_schedulers); + } else { + for (int i = 0; i < params.num_local_schedulers; i++) { + local_num_workers[i] = params.num_workers; + } + } + + // start object stores + for (int i = 0; i < params.num_local_schedulers; i++) { + AddressInfo info = new AddressInfo(); + // store + startObjectStore(i, info, params.working_directory + "/store", + params.redis_address, params.node_ip_address, params.redirect, params.cleanup); + + // store manager + startObjectManager(i, info, + params.working_directory + "/storeManager", params.redis_address, + params.node_ip_address, params.redirect, params.cleanup); + + runInfo.local_stores.add(info); + } + + // start local scheduler + for (int i = 0; i < params.num_local_schedulers; i++) { + int workerCount = 0; + + if (params.start_workers_from_local_scheduler) { + workerCount = local_num_workers[i]; + local_num_workers[i] = 0; + } + + startLocalScheduler(i, runInfo.local_stores.get(i), + params.num_cpus[i], params.num_gpus[i], workerCount, + params.working_directory + "/localScheduler", params.redis_address, + params.node_ip_address, params.redirect, params.cleanup); + } + + // start local workers + for (int i = 0; i < params.num_local_schedulers; i++) { + runInfo.local_stores.get(i).workerCount = local_num_workers[i]; + for (int j = 0; j < local_num_workers[i]; j++) { + startWorker(runInfo.local_stores.get(i).storeName, + runInfo.local_stores.get(i).managerName, runInfo.local_stores.get(i).schedulerName, + params.working_directory + "/worker" + i + "." + j, params.redis_address, + params.node_ip_address, UniqueID.nil, "", + params.redirect, params.cleanup); + } + } + + HashSet excludeTypes = new HashSet<>(); + if (!checkAlive(excludeTypes)) { + cleanup(true); + throw new RuntimeException("Start Ray processes failed"); + } + } + + public boolean checkAlive(HashSet excludeTypes) { + RunInfo.ProcessType[] types = RunInfo.ProcessType.values(); + for (int i = 0; i < types.length; i++) { + if (excludeTypes.contains(types[i])) { + continue; + } + + ProcessInfo p; + for (int j = 0; j < runInfo.allProcesses.get(i).size();) { + p = runInfo.allProcesses.get(i).get(j); + if (!p.process.isAlive()) { + RayLog.core.error("Process " + p.hashCode() + " is not alive!" + " Process Type " + types[i].name()); + runInfo.deadProcess.add(p); + runInfo.allProcesses.get(i).remove(j); + } else { + j++; + } + } + } + + return runInfo.deadProcess.isEmpty(); + } + + public boolean tryRecoverDeadProcess() { + + if (runInfo.deadProcess.isEmpty()) { + return true; + } + + /* check the dead process */ + for (ProcessInfo info : runInfo.deadProcess) { + if (info.type == RunInfo.ProcessType.PT_LOCAL_SCHEDULER + || info.type == RunInfo.ProcessType.PT_PLASMA_STORE + || info.type == RunInfo.ProcessType.PT_PLASMA_MANAGER) { + /* When local scheduler or plasma store or plasma manager process dead, we can not + * recover this node simply by restarting the dead process. Instead, We need to restart + * all the node processes + * */ + RayLog.core + .error(info.type.name() + "process dead, we can not simply restart this process"); + return false; + } + } + + /* try to recover */ + ProcessInfo info; + for (int i = 0; i < runInfo.deadProcess.size(); i++) { + info = runInfo.deadProcess.get(i); + if (info.type == RunInfo.ProcessType.PT_GLOBAL_SCHEDULER) { + RayLog.core.error(info.type.name() + "process dead, restart this process"); + startProcess(info.cmd, null, info.type, info.workDir, info.redisAddress, info.ip, + info.redirect, info.cleanup); + } else { + RayLog.core.error(info.type.name() + "process dead, we don't deal with it"); + } + } + runInfo.deadProcess.clear(); + return true; + } + + // kill all processes started by startRayHead + public void cleanup(boolean killAll) { + // clean up the process in reverse order + for (int i = ProcessType.values().length - 1; i >= 0; i--) { + if (killAll) { + runInfo.allProcesses.get(i).forEach(p -> { + if (killProcess(p.process)) { + RayLog.core.info("Kill process " + p.hashCode() + " forcely"); + } + }); + } else { + runInfo.toBeCleanedProcesses.get(i).forEach(p -> { + if (killProcess(p)) { + RayLog.core.info("Kill process " + p.hashCode() + " forcely"); + } + }); + } + + runInfo.toBeCleanedProcesses.get(i).clear(); + runInfo.allProcesses.get(i).clear(); + runInfo.deadProcess.clear(); + } + + if (killAll) { + // kill all workers that are forked by local scheduler + // ps aux | grep DefaultWorker | awk '{system("kill "$2);}' + String[] cmd = {"/bin/sh", "-c", ""}; + cmd[2] = "ps aux | grep DefaultWorker | grep -v grep | awk \"{print \\$2}\" | xargs kill"; + try { + Runtime.getRuntime().exec(cmd); + } catch (IOException e) { + } + } + } + + private void record_log_files_in_redis(String redis_address, String node_ip_address, + List logfiles) { + if (redis_address != null && !redis_address.isEmpty() && node_ip_address != null + && !node_ip_address.isEmpty() && logfiles.size() > 0) { + String[] ip_port = redis_address.split(":"); + Jedis jedis_client = new Jedis(ip_port[0], Integer.parseInt(ip_port[1])); + String log_file_list_key = String.format("LOG_FILENAMES:{%s}", node_ip_address); + for (String logfile : logfiles) { + jedis_client.rpush(log_file_list_key, logfile); + } + jedis_client.close(); + } + } + + private Process startProcess(String[] cmd, Map env, RunInfo.ProcessType type, + String workDir, + String redisAddress, String ip, boolean redirect, + boolean cleanup) { + File wdir = new File(workDir); + if (!wdir.exists()) { + wdir.mkdirs(); + } + + int processIndex = runInfo.allProcesses.get(type.ordinal()).size(); + ProcessBuilder builder; + List newCmd = Arrays.stream(cmd).filter(s -> s.length() > 0) + .collect(Collectors.toList()); + builder = new ProcessBuilder(newCmd); + builder.directory(new File(workDir)); + if (redirect) { + String stdout_file; + String stderr_file; + stdout_file = workDir + "/" + processIndex + ".out.txt"; + stderr_file = workDir + "/" + processIndex + ".err.txt"; + builder.redirectOutput(new File(stdout_file)); + builder.redirectError(new File(stderr_file)); + List std_file_list = new ArrayList<>(); + std_file_list.add(stdout_file); + std_file_list.add(stderr_file); + record_log_files_in_redis(redisAddress, ip, std_file_list); + procStdoutFileName = stdout_file; + procStderrFileName = stderr_file; + } + + if (env != null && !env.isEmpty()) { + builder.environment().putAll(env); + } + + Process p = null; + try { + p = builder.start(); + } catch (IOException e) { + RayLog.core + .error("Start process " + Arrays.toString(cmd).replace(',', ' ') + " in working dir '" + + workDir + "' failed", + e); + return null; + } + + RayLog.core.info( + "Start process " + p.hashCode() + " OK, cmd = " + Arrays.toString(cmd).replace(',', ' ') + + ", working dir = '" + workDir + "'" + (redirect ? ", redirect" : ", no redirect")); + + if (cleanup) { + runInfo.toBeCleanedProcesses.get(type.ordinal()).add(p); + } + + ProcessInfo processInfo = new ProcessInfo(); + processInfo.cmd = cmd; + processInfo.type = type; + processInfo.workDir = workDir; + processInfo.redisAddress = redisAddress; + processInfo.ip = ip; + processInfo.redirect = redirect; + processInfo.cleanup = cleanup; + processInfo.process = p; + runInfo.allProcesses.get(type.ordinal()).add(processInfo); + + return p; + } + + private static boolean killProcess(Process p) { + if (p.isAlive()) { + p.destroyForcibly(); + return true; + } else { + return false; + } + } + + // + // start a redis server + // + // @param ip the IP address of the local node + // @param port port to be opended for redis traffic + // @param numOfShards the number of redis shards to start + // @param redirect whether to redirect the output/err to the log files + // @param cleanup true if using ray in local mode. If cleanup is true, when + // all Redis processes started by this method will be killed by @cleanup + // when the worker exits + // @return primary redis shard address + // + private List startRedis(String workDir, String ip, int port, int numOfShards, + boolean redirect, boolean cleanup) { + ArrayList shards = new ArrayList<>(); + String addr; + for (int i = 0; i < numOfShards; i++) { + addr = startRedisInstance(workDir, ip, port + i, redirect, cleanup); + + if (addr.length() == 0) { + cleanup(cleanup); + shards.clear(); + return shards; + } else { + shards.add(addr); + } + } + + for (String shard : shards) { + // TODO: wait for redis server to start + } + + return shards; + } + + // + // @param ip local node ip, only used for logging purpose + // @param port given port for this redis instance, 0 for auto-selected port + // @return redis server address + // + private String startRedisInstance(String workDir, String ip, int port, + boolean redirect, boolean cleanup) { + String redisFilePath = paths.redis_server; + String redisModule = paths.redis_module; + + assert (new File(redisFilePath).exists()) : "file don't exsits : " + redisFilePath; + assert (new File(redisModule).exists()) : "file don't exsits : " + redisModule; + + + String cmd = redisFilePath + " --protected-mode no --port " + port + " --loglevel warning" + + " --loadmodule " + redisModule; + + Map env = null; + Process p = startProcess(cmd.split(" "), env, RunInfo.ProcessType.PT_REDIS_SERVER, + workDir + port, "", ip, redirect, cleanup); + + if (p == null || !p.isAlive()) { + return ""; + } + + try { + TimeUnit.MILLISECONDS.sleep(300); + } catch (InterruptedException e) { + } + + Jedis client = new Jedis(params.node_ip_address, port); + + // Configure Redis to only generate notifications for the export keys. + client.configSet("notify-keyspace-events", "Kl"); + + // Put a time stamp in Redis to indicate when it was started. + client.set("redis_start_time", LocalDateTime.now().toString()); + + client.close(); + return ip + ":" + port; + } + + private void startGlobalScheduler(String workDir, String redisAddress, String ip, + boolean redirect, boolean cleanup) { + String filePath = paths.global_scheduler; + String cmd = filePath + " -r " + redisAddress + " -h " + ip; + + Map env = null; + startProcess(cmd.split(" "), env, RunInfo.ProcessType.PT_GLOBAL_SCHEDULER, workDir, + redisAddress, + ip, redirect, cleanup); + } + + private Map retrieveEnv(String conf, Map env) { + String[] splits = conf.split(" "); + for (String item : splits) { + int idx = item.trim().indexOf('='); + if (idx == -1) { + continue; + } + String key = item.substring(0, idx); + String val = item.substring(idx + 1); + env.put(key, val); + } + return env; + } + + /* + * @param storeName The name of the plasma store socket to connect to + * + * @param storeManagerName The name of the plasma manager socket to connect + * to + * + * @param storeManagerAddress the address of the plasma manager to connect + * to + * + * @param workerPath The path of the script to use when the local scheduler + * starts up new workers + * + * @param numCpus The number of CPUs the local scheduler should be + * configured with + * + * @param numGpus The number of GPUs the local scheduler should be + * configured with + * + * @param numWorkers The number of workers that the local scheduler should + * start + */ + private void startLocalScheduler(int index, AddressInfo info, int numCpus, + int numGpus, int numWorkers, String workDir, + String redisAddress, String ip, boolean redirect, + boolean cleanup) { + //if (numCpus <= 0) + // numCpus = Runtime.getRuntime().availableProcessors(); + if (numGpus <= 0) { + numGpus = 0; + } + + String filePath = paths.local_scheduler; + int rpcPort = params.local_scheduler_rpc_port + index; + String name = "/tmp/scheduler" + rpcPort; + String rpcAddr = ""; + String cmd = filePath + " -s " + name + " -p " + info.storeName + " -h " + ip + " -n " + + numWorkers + " -c " + "CPU," + INT16_MAX +",GPU,0"; + + assert (info.managerName.length() > 0); + assert (info.storeName.length() > 0); + assert (redisAddress.length() > 0); + + cmd += " -m " + info.managerName; + + String workerCmd = null; + workerCmd = buildWorkerCommand(true, info.storeName, info.managerName, name, UniqueID.nil, + "", workDir + rpcPort, ip, redisAddress); + cmd += " -w \"" + workerCmd + "\""; + + if (redisAddress.length() > 0) { + cmd += " -r " + redisAddress; + } + if (info.managerPort > 0) { + cmd += " -a " + params.node_ip_address + ":" + info.managerPort; + } + + Map env = null; + String[] cmds = StringUtil.Split(cmd, " ", "\"", "\"").toArray(new String[0]); + Process p = startProcess(cmds, env, RunInfo.ProcessType.PT_LOCAL_SCHEDULER, + workDir + rpcPort, redisAddress, ip, redirect, cleanup); + + if (p != null && p.isAlive()) { + try { + TimeUnit.MILLISECONDS.sleep(100); + } catch (InterruptedException e) { + } + } + + if (p == null || !p.isAlive()) { + info.schedulerName = ""; + info.schedulerRpcAddr = ""; + throw new RuntimeException("Start local scheduler failed ..."); + } else { + info.schedulerName = name; + info.schedulerRpcAddr = rpcAddr; + } + } + + private String buildWorkerCommand(boolean isFromLocalScheduler, String storeName, + String storeManagerName, String localSchedulerName, + UniqueID actorId, String actorClass, String workDir, 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)) { + workerConfigs += ";ray.java.start.actor_id=" + actorId; + } + if (!actorClass.equals("")) { + workerConfigs += ";ray.java.start.driver_class=" + actorClass; + } + + String jvmArgs = ""; + jvmArgs += " -DlogOutput=" + params.logging_directory + "/workers/*pid_suffix*"; + + return buildJavaProcessCommand( + RunInfo.ProcessType.PT_WORKER, + "org.ray.runner.worker.DefaultWorker", + "", + workerConfigs, + jvmArgs, + workDir, + ip, + redisAddress, + null + ); + } + + private void startObjectStore(int index, AddressInfo info, String workDir, String redisAddress, + String ip, boolean redirect, boolean cleanup) { + int occupiedMemoryMB = params.object_store_occupied_memory_MB; + long memoryBytes = occupiedMemoryMB * 1000000; + String filePath = paths.store; + int rpcPort = params.object_store_rpc_port + index; + String name = "/tmp/plasma_store" + rpcPort; + String rpcAddr = ""; + String cmd = filePath + " -s " + name + " -m " + memoryBytes; + + Map env = null; + Process p = startProcess(cmd.split(" "), env, RunInfo.ProcessType.PT_PLASMA_STORE, + workDir + rpcPort, redisAddress, ip, redirect, cleanup); + + if (p != null && p.isAlive()) { + try { + TimeUnit.MILLISECONDS.sleep(100); + } catch (InterruptedException e) { + } + } + + if (p == null || !p.isAlive()) { + info.storeName = ""; + info.storeRpcAddr = ""; + throw new RuntimeException("Start object store failed ..."); + } else { + info.storeName = name; + info.storeRpcAddr = rpcAddr; + } + } + + private AddressInfo startObjectManager(int index, AddressInfo info, String workDir, + String redisAddress, String ip, boolean redirect, + boolean cleanup) { + String filePath = paths.store_manager; + int rpcPort = params.object_store_manager_rpc_port + index; + String name = "/tmp/plasma_manager" + rpcPort; + String rpcAddr = ""; + + String cmd = filePath + " -s " + info.storeName + " -m " + name + " -h " + ip + " -p " + + (params.object_store_manager_ray_listen_port + index) + + " -r " + redisAddress; + + Map env = null; + Process p = startProcess(cmd.split(" "), env, RunInfo.ProcessType.PT_PLASMA_MANAGER, + workDir + rpcPort, redisAddress, ip, redirect, cleanup); + + if (p != null && p.isAlive()) { + try { + TimeUnit.MILLISECONDS.sleep(100); + } catch (InterruptedException e) { + } + } + + if (p == null || !p.isAlive()) { + throw new RuntimeException("Start object manager failed ..."); + } else { + info.managerName = name; + info.managerPort = params.object_store_manager_ray_listen_port + index; + info.managerRpcAddr = rpcAddr; + return info; + } + } + + public void startWorker(String storeName, String storeManagerName, + String localSchedulerName, String workDir, String redisAddress, + String ip, UniqueID actorId, String actorClass, + boolean redirect, boolean cleanup) { + String cmd = buildWorkerCommand(false, storeName, storeManagerName, localSchedulerName, actorId, + actorClass, workDir, ip, redisAddress); + startProcess(cmd.split(" "), null, RunInfo.ProcessType.PT_WORKER, workDir, redisAddress, ip, + redirect, cleanup); + } +} diff --git a/java/runtime-native/src/main/java/org/ray/runner/worker/DefaultDriver.java b/java/runtime-native/src/main/java/org/ray/runner/worker/DefaultDriver.java new file mode 100644 index 000000000000..261998e55e68 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/runner/worker/DefaultDriver.java @@ -0,0 +1,31 @@ +package org.ray.runner.worker; + +import org.ray.core.RayRuntime; +import org.ray.core.model.WorkerMode; + +/** + * + */ +public class DefaultDriver { + + // + // " --node-ip-address=" + ip + // + " --redis-address=" + redisAddress + // + " --driver-class" + className + // + public static void main(String[] args) { + try { + RayRuntime.init(args); + assert RayRuntime.getParams().worker_mode == WorkerMode.DRIVER; + + String driverClass = RayRuntime.configReader + .getStringValue("ray.java.start", "driver_class", "", + "java class which main is served as the driver in a java worker"); + Class cls = Class.forName(driverClass); + cls.getMethod("main", String[].class).invoke(null, (Object) new String[]{}); + } catch (Throwable e) { + e.printStackTrace(); + System.exit(-1); + } + } +} diff --git a/java/runtime-native/src/main/java/org/ray/runner/worker/DefaultWorker.java b/java/runtime-native/src/main/java/org/ray/runner/worker/DefaultWorker.java new file mode 100644 index 000000000000..a14403087384 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/runner/worker/DefaultWorker.java @@ -0,0 +1,31 @@ +package org.ray.runner.worker; + +import org.ray.core.RayRuntime; +import org.ray.core.model.WorkerMode; + +/** + * default worker implementation + */ +public class DefaultWorker { + + // + // String workerCmd = "java" + " -jarls " + workerPath + " --node-ip-address=" + ip + // + " --object-store-name=" + storeName + // + " --object-store-manager-name=" + storeManagerName + // + " --local-scheduler-name=" + name + " --redis-address=" + redisAddress + // + public static void main(String[] args) { + try { + RayRuntime.init(args); + assert RayRuntime.getParams().worker_mode == WorkerMode.WORKER; + RayRuntime.getInstance().loop(); + throw new RuntimeException("Control flow should never reach here"); + + } catch (Throwable e) { + e.printStackTrace(); + System.err + .println("--config=ray.config.ini --overwrite=ray.java.start.worker_mode=WORKER;..."); + System.exit(-1); + } + } +} diff --git a/java/runtime-native/src/main/java/org/ray/spi/FileStoreLink.java b/java/runtime-native/src/main/java/org/ray/spi/FileStoreLink.java new file mode 100644 index 000000000000..13523a0d6f62 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/FileStoreLink.java @@ -0,0 +1,90 @@ +package org.ray.spi; + +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public interface FileStoreLink { + + /** + * + */ + boolean mkdirs(String f); + + /** + * Check if exists. + * + * @param f source file + */ + boolean exists(String f); + + /** + * True if the named path is a directory. + * + * @param f path to check + */ + boolean isDirectory(String f); + + /** + * True if the named path is a regular file. + * + * @param f path to check + */ + boolean isFile(String f); + + /** + * Delete a file. + * + * @param f the path to delete. + * @param recursive if path is a directory and set to true, the directory is deleted else throws + * an exception. In case of a file the recursive can be set to either true or false. + * @return true if delete is successful else false. + */ + boolean delete(String f, boolean recursive); + + /** + * The src file is on the local disk. Add it to FS at the given dst name and the source is kept + * intact afterwards + * + * @param src path + * @param dst path + */ + void copyFromLocalFile(String src, String dst); + + /** + * The src file is under FS, and the dst is on the local disk. Copy it from FS control to the + * local dst name. + * + * @param src path + * @param dst path + */ + void copyToLocalFile(String src, String dst); + + /** + * Create an FSDataOutputStream at the indicated Path. Files are overwritten by default. + * + * @param f the file to create + */ + DataOutputStream create(String f, boolean overwrite); + + /** + * Opens an FSDataInputStream at the indicated Path. + * + * @param f the file name to open + */ + DataInputStream open(String f); + + /** + * Append to an existing file (optional operation). + * + * @param f the existing file to be appended. + */ + DataOutputStream append(String f); + + /** + * get the file length which is located in the file store. + * + * @param f the existing file path. + */ + int fileLength(String f); + +} diff --git a/java/runtime-native/src/main/java/org/ray/spi/KeyValueStoreLink.java b/java/runtime-native/src/main/java/org/ray/spi/KeyValueStoreLink.java new file mode 100644 index 000000000000..3e58762e96e1 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/KeyValueStoreLink.java @@ -0,0 +1,125 @@ +package org.ray.spi; + +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * Ray K/V abstraction + */ +public interface KeyValueStoreLink { + + /** + * set address of kv store: format "ip:port" + */ + void SetAddr(String addr); + + /** + * check if the kvstore client connected + */ + void CheckConnected() throws Exception; + + /** + * Set Key-value into State Store, such as redis + * + * @param key the key to set + * @param value the value to set + * @param field the field is being set when the item is a hash If it is not hash field should be + * filled with null + * @return If the key(or field) already exists, and the StateStoreSet just produced an update of + * the value, 0 is returned, otherwise if a new key(or field) is created 1 is returned. + */ + Long Set(final String key, final String value, final String field); + + Long Set(final byte[] key, final byte[] value, final byte[] field); + + /** + * multi hash value set + * + * @param key the key in kvStore + * @param hash the multi hash value to be set + * @return Return OK or Exception if hash is empty + */ + String Hmset(final String key, final Map hash); + + String Hmset(final byte[] key, final Map hash); + + /** + * multi hash value get + * + * @param key the key in kvStore + * @param fields the fields to be get + * @return Multi Bulk Reply specifically a list of all the values associated with the specified + * fields, in the same order of the request. + */ + List Hmget(final String key, final String... fields); + + List Hmget(final byte[] key, final byte[]... fields); + + /** + * Get the value of the specified key from State Store + * + * @param key the key to get + * @param field the field is being got when the item is a hash If it is not hash field should be + * filled with null + * @return Bulk reply If the key does not exist null is returned. + */ + String Get(final String key, final String field); + + byte[] Get(final byte[] key, final byte[] field); + + /** + * Delete the key(or the specified field of the key) from State Store + * + * @param key the key to delete + * @param field the field is to delete when the item is a hash If it is not hash field should be + * filled with null + * @return Integer reply, specifically: an integer greater than 0 if the key(or the field) was + * removed 0 if none of the specified key existed + */ + Long Delete(final String key, final String field); + + Long Delete(final byte[] key, final byte[] field); + + /** + * get all keys which fit the pattern + */ + Set Keys(final byte[] pattern); + + /** + * get all keys which fit the pattern + */ + Set Keys(String pattern); + + /** + * get all hash of the key + */ + Map hgetAll(final byte[] key); + + /** + * Return the specified elements of the list stored at the specified key. + * + * @return Multi bulk reply, specifically a list of elements in the specified range. + */ + List Lrange(final String key, final long start, final long end); + + /** + * @return Integer reply, specifically, the number of elements inside the list after the push + * operation. + */ + Long Rpush(final String key, final String... strings); + + Long Rpush(final byte[] key, final byte[]... strings); + + /** + * + * @param channel To which channel the message will be published + * @param message What to publish + * @return the number of clients that received the message + */ + Long Publish(final String channel, final String message); + + Long Publish(byte[] channel, byte[] message); + + Object GetImpl(); +} diff --git a/java/runtime-native/src/main/java/org/ray/spi/StateStoreProxy.java b/java/runtime-native/src/main/java/org/ray/spi/StateStoreProxy.java new file mode 100644 index 000000000000..4d2c2fa33e8c --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/StateStoreProxy.java @@ -0,0 +1,32 @@ +package org.ray.spi; + +import java.util.List; +import java.util.Set; +import org.ray.spi.model.AddressInfo; + +/** + * Proxy client for state store, for instance redis + */ +public interface StateStoreProxy { + + /** + * @param rayKvStore the underlying kv store used to store states + */ + void setStore(KeyValueStoreLink rayKvStore); + + + /** + * initialize the store + */ + void initializeGlobalState() throws Exception; + + /** + * @param pattern filter which keys you are interested in. + */ + Set keys(final String pattern); + + /** + * @return list of address information + */ + List getAddressInfo(final String node_ip_address, int num_retries); +} diff --git a/java/runtime-native/src/main/java/org/ray/spi/impl/Arg.java b/java/runtime-native/src/main/java/org/ray/spi/impl/Arg.java new file mode 100644 index 000000000000..1b6c78c622f8 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/impl/Arg.java @@ -0,0 +1,58 @@ +package org.ray.spi.impl; + +// automatically generated by the FlatBuffers compiler, do not modify + +import java.nio.*; +import java.lang.*; +import java.util.*; +import com.google.flatbuffers.*; + +@SuppressWarnings("unused") +public final class Arg extends Table { + public static Arg getRootAsArg(ByteBuffer _bb) { return getRootAsArg(_bb, new Arg()); } + public static Arg getRootAsArg(ByteBuffer _bb, Arg obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } + public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } + public Arg __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } + + public String objectIds(int j) { int o = __offset(4); return o != 0 ? __string(__vector(o) + j * 4) : null; } + public int objectIdsLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; } + public String data() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer dataAsByteBuffer() { return __vector_as_bytebuffer(6, 1); } + + public static int createArg(FlatBufferBuilder builder, + int object_idsOffset, + int dataOffset) { + builder.startObject(2); + Arg.addData(builder, dataOffset); + Arg.addObjectIds(builder, object_idsOffset); + return Arg.endArg(builder); + } + + public static void startArg(FlatBufferBuilder builder) { builder.startObject(2); } + public static void addObjectIds(FlatBufferBuilder builder, int objectIdsOffset) { builder.addOffset(0, objectIdsOffset, 0); } + public static int createObjectIdsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); } + public static void startObjectIdsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); } + public static void addData(FlatBufferBuilder builder, int dataOffset) { builder.addOffset(1, dataOffset, 0); } + public static int endArg(FlatBufferBuilder builder) { + int o = builder.endObject(); + return o; + } + + //this is manually added to avoid encoding/decoding cost as our object id is a byte array instead of a string + public ByteBuffer objectIdAsByteBuffer(int j) { + int o = __offset(4); + if (o == 0) { + return null; + } + + int offset = __vector(o) + j * 4; + offset += bb.getInt(offset); + ByteBuffer src = bb.duplicate().order(ByteOrder.LITTLE_ENDIAN); + int length = src.getInt(offset); + src.position(offset + 4); + src.limit(offset + 4 + length); + return src; + } +} + + diff --git a/java/runtime-native/src/main/java/org/ray/spi/impl/DefaultLocalSchedulerClient.java b/java/runtime-native/src/main/java/org/ray/spi/impl/DefaultLocalSchedulerClient.java new file mode 100644 index 000000000000..d3f67649a413 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/impl/DefaultLocalSchedulerClient.java @@ -0,0 +1,226 @@ +package org.ray.spi.impl; + +import com.google.flatbuffers.FlatBufferBuilder; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.ArrayList; +import java.util.List; +import org.ray.api.UniqueID; +import org.ray.core.RayRuntime; +import org.ray.spi.LocalSchedulerLink; +import org.ray.spi.model.FunctionArg; +import org.ray.spi.model.TaskSpec; +import org.ray.util.logger.RayLog; + +/** + * JNI-based local scheduler link provider + */ +public class DefaultLocalSchedulerClient implements LocalSchedulerLink { + + public DefaultLocalSchedulerClient(String schedulerSockName, UniqueID clientId, UniqueID actorId, + boolean isWorker, long numGpus) { + _client = _init(schedulerSockName, clientId.getBytes(), actorId.getBytes(), isWorker, + numGpus); + } + + + @Override + public void submitTask(TaskSpec task) { + ByteBuffer info = TaskSpec2Info(task); + byte[] a = null; + if(!task.actorId.isNil()) { + a = task.cursorId.getBytes(); + } + _submitTask(_client, a, info, info.position(), info.remaining()); + } + + @Override + public TaskSpec getTaskTodo() { + byte[] bytes = _getTaskTodo(_client); + assert (null != bytes); + ByteBuffer bb = ByteBuffer.wrap(bytes); + return TaskInfo2Spec(bb); + } + + public void destroy() { + _destroy(_client); + } + + @Override + public void notifyUnblocked() { + _notify_unblocked(_client); + } + + @Override + public void reconstructObject(UniqueID objectId) { + _reconstruct_object(_client, objectId.getBytes()); + } + + @Override + public void markTaskPutDependency(UniqueID taskId, UniqueID objectId) { + _put_object(_client, taskId.getBytes(), objectId.getBytes()); + } + + private long _client = 0; + + private static ThreadLocal _taskBuffer = ThreadLocal.withInitial(() -> { + ByteBuffer bb = ByteBuffer + .allocateDirect(RayRuntime.getParams().max_submit_task_buffer_size_bytes); + bb.order(ByteOrder.LITTLE_ENDIAN); + return bb; + }); + + public static ByteBuffer TaskSpec2Info(TaskSpec task) { + ByteBuffer bb = _taskBuffer.get(); + bb.clear(); + + FlatBufferBuilder fbb = new FlatBufferBuilder(bb); + + int driver_idOffset = fbb.createString(task.driverId.ToByteBuffer()); + int task_idOffset = fbb.createString(task.taskId.ToByteBuffer()); + int parent_task_idOffset = fbb.createString(task.parentTaskId.ToByteBuffer()); + int parent_counter = task.parentCounter; + int actorCreate_idOffset = fbb.createString(task.createActorId.ToByteBuffer()); + int actorCreateDummy_idOffset = fbb.createString(UniqueID.nil.ToByteBuffer()); + int actor_idOffset = fbb.createString(task.actorId.ToByteBuffer()); + int actor_handle_idOffset = fbb.createString(task.actorHandleId.ToByteBuffer()); + int actor_counter = task.actorCounter; + int function_idOffset = fbb.createString(task.functionId.ToByteBuffer()); + + // serialize args + int[] argsOffsets = new int[task.args.length]; + for (int i = 0; i < argsOffsets.length; i++) { + + int object_idOffset = 0; + int dataOffset = 0; + if (task.args[i].ids != null) { + int id_count = task.args[i].ids.size(); + int[] idOffsets = new int[id_count]; + for (int k = 0; k < id_count; k++) { + idOffsets[k] = fbb.createString(task.args[i].ids.get(k).ToByteBuffer()); + } + object_idOffset = fbb.createVectorOfTables(idOffsets); + } + if (task.args[i].data != null) { + dataOffset = fbb.createString(ByteBuffer.wrap(task.args[i].data)); + } + + argsOffsets[i] = Arg.createArg(fbb, object_idOffset, dataOffset); + } + int argsOffset = fbb.createVectorOfTables(argsOffsets); + + // serialize returns + int return_count = task.returnIds.length; + int[] returnsOffsets = new int[return_count]; + for (int k = 0; k < return_count; k++) { + returnsOffsets[k] = fbb.createString(task.returnIds[k].ToByteBuffer()); + } + int returnsOffset = fbb.createVectorOfTables(returnsOffsets); + + // serialize required resources + // The required_resources vector indicates the quantities of the different + // resources required by this task. The index in this vector corresponds to + // the resource type defined in the ResourceIndex enum. For example, + + int[] required_resourcesOffsets = new int[1]; + for (int i = 0; i < required_resourcesOffsets.length; i++) { + int keyOffset = 0; + keyOffset = fbb.createString(ByteBuffer.wrap("CPU".getBytes())); + required_resourcesOffsets[i] = ResourcePair.createResourcePair(fbb,keyOffset,0.0); + } + int requiredResourcesOffset = fbb.createVectorOfTables(required_resourcesOffsets); + + int root = TaskInfo.createTaskInfo( + fbb, driver_idOffset, task_idOffset, + parent_task_idOffset, parent_counter, + actorCreate_idOffset, actorCreateDummy_idOffset, + actor_idOffset, actor_handle_idOffset, actor_counter, + false, function_idOffset, + argsOffset, returnsOffset, requiredResourcesOffset); + + fbb.finish(root); + ByteBuffer buffer = fbb.dataBuffer(); + + if (buffer.remaining() > RayRuntime.getParams().max_submit_task_buffer_size_bytes) { + RayLog.core.error( + "Allocated buffer is not enough to transfer the task specification: " + RayRuntime + .getParams().max_submit_task_buffer_size_bytes + " vs " + buffer.remaining()); + assert (false); + } + + return buffer; + } + + public static TaskSpec TaskInfo2Spec(ByteBuffer bb) { + bb.order(ByteOrder.LITTLE_ENDIAN); + TaskInfo info = TaskInfo.getRootAsTaskInfo(bb); + + TaskSpec spec = new TaskSpec(); + spec.driverId = new UniqueID(info.driverIdAsByteBuffer()); + spec.taskId = new UniqueID(info.taskIdAsByteBuffer()); + spec.parentTaskId = new UniqueID(info.parentTaskIdAsByteBuffer()); + spec.parentCounter = info.parentCounter(); + spec.actorId = new UniqueID(info.actorIdAsByteBuffer()); + spec.actorCounter = info.actorCounter(); + spec.createActorId = new UniqueID(info.actorCreationIdAsByteBuffer()); + + spec.functionId = new UniqueID(info.functionIdAsByteBuffer()); + + List args = new ArrayList<>(); + for (int i = 0; i < info.argsLength(); i++) { + FunctionArg darg = new FunctionArg(); + Arg sarg = info.args(i); + + int id_count = sarg.objectIdsLength(); + if (id_count > 0) { + darg.ids = new ArrayList<>(); + for (int j = 0; j < id_count; j++) { + ByteBuffer lbb = sarg.objectIdAsByteBuffer(j); + assert (lbb != null && lbb.remaining() > 0); + darg.ids.add(new UniqueID(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); + } + + args.add(darg); + } + spec.args = args.toArray(new FunctionArg[0]); + + List rids = new ArrayList<>(); + for (int i = 0; i < info.returnsLength(); i++) { + ByteBuffer lbb = info.returnsAsByteBuffer(i); + assert (lbb != null && lbb.remaining() > 0); + rids.add(new UniqueID(lbb)); + } + spec.returnIds = rids.toArray(new UniqueID[0]); + + return spec; + } + + native private static long _init(String localSchedulerSocket, byte[] workerId, byte[] actorId, + boolean isWorker, long numGpus); + + // task -> TaskInfo (with FlatBuffer) + native private static void _submitTask(long client, byte[] cursorId, /*Direct*/ByteBuffer task, int pos, int sz); + + // return TaskInfo (in FlatBuffer) + native private static byte[] _getTaskTodo(long client); + + native private static byte[] _computePutId(long client, byte[] taskId, int putIndex); + + native private static void _destroy(long client); + + native private static void _task_done(long client); + + native private static void _reconstruct_object(long client, byte[] objectId); + + native private static void _notify_unblocked(long client); + + native private static void _put_object(long client, byte[] taskId, byte[] objectId); +} diff --git a/java/runtime-native/src/main/java/org/ray/spi/impl/NativeRemoteFunctionManager.java b/java/runtime-native/src/main/java/org/ray/spi/impl/NativeRemoteFunctionManager.java new file mode 100644 index 000000000000..d11232e8e809 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/impl/NativeRemoteFunctionManager.java @@ -0,0 +1,135 @@ +package org.ray.spi.impl; + +import java.io.File; +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.core.RayRuntime; +import org.ray.hook.JarRewriter; +import org.ray.hook.runtime.JarLoader; +import org.ray.hook.runtime.LoadedFunctions; +import org.ray.spi.KeyValueStoreLink; +import org.ray.spi.RemoteFunctionManager; +import org.ray.util.FileUtil; +import org.ray.util.SystemUtil; +import org.ray.util.logger.RayLog; + +/** + * native implementation of remote function manager + */ +public class NativeRemoteFunctionManager implements RemoteFunctionManager { + + public NativeRemoteFunctionManager(KeyValueStoreLink kvStore) throws NoSuchAlgorithmException { + this.kvStore = kvStore; + md = MessageDigest.getInstance("SHA-1"); + File appDir = new File(this.appDir); + if (!appDir.exists()) { + appDir.mkdirs(); + } + + } + + @Override + public UniqueID registerResource(byte[] resourceZip) { + byte[] digest = md.digest(resourceZip); + assert (digest.length == UniqueID.LENGTH); + + UniqueID resourceId = new UniqueID(digest); + + // TODO: resources must be saved in persistent store + // instead of cache + //if (!Ray.exist(resourceId)) { + //Ray.put(resourceId, resourceZip); + kvStore.Set(resourceId.getBytes(), resourceZip, null); + //} + return resourceId; + } + + @Override + public byte[] getResource(UniqueID resourceId) { + return kvStore.Get(resourceId.getBytes(), null); + //return (byte[])Ray.get(resourceId); + } + + @Override + public void unregisterResource(UniqueID resourceId) { + kvStore.Delete(resourceId.getBytes(), null); + } + + @Override + public void registerApp(UniqueID driverId, UniqueID resourceId) { + //Ray.put(driverId, resourceId); + kvStore.Set("App2ResMap", resourceId.toString(), driverId.toString()); + } + + @Override + public UniqueID getAppResourceId(UniqueID driverId) { + return new UniqueID(kvStore.Get("App2ResMap", driverId.toString())); + } + + @Override + public void unregisterApp(UniqueID driverId) { + kvStore.Delete("App2ResMap", driverId.toString()); + } + + @Override + public LoadedFunctions loadFunctions(UniqueID driverId) { + LoadedFunctions rf = loadedApps.get(driverId); + if (rf == null) { + rf = initLoadedApps(driverId); + } + return rf; + } + + private synchronized LoadedFunctions initLoadedApps(UniqueID driverId) { + try { + RayLog.core.info("initLoadedApps" + driverId.toString()); + LoadedFunctions rf = loadedApps.get(driverId); + if (rf == null) { + UniqueID resId = new UniqueID(kvStore.Get("App2ResMap", driverId.toString())); + //UniqueID resId = Ray.get(driverId); + + byte[] res = getResource(resId); + if (res == null) { + throw new RuntimeException("get resource null, the resId " + resId.toString()); + } + RayLog.core.info("ger resource of " + resId.toString() + ", result len " + res.length); + String resPath = + appDir + "/" + driverId.toString() + "/" + String.valueOf(SystemUtil.pid()); + File dir = new File(resPath); + if (!dir.exists()) { + dir.mkdirs(); + } + String zipPath = resPath + ".zip"; + RayLog.rapp.info("unzip app file: zipPath " + zipPath + " resPath " + resPath); + FileUtil.bytesToFile(res, zipPath); + ZipFile zipFile = new ZipFile(zipPath); + zipFile.extractAll(resPath); + rf = JarRewriter + .load(resPath, RayRuntime.getInstance().getPaths().java_runtime_rewritten_jars_dir); + loadedApps.put(driverId, rf); + } + return rf; + } catch (Exception e) { + RayLog.rapp.error("load function for " + driverId + " failed, ex = " + e.getMessage(), e); + return null; + } + } + + @Override + public synchronized void unloadFunctions(UniqueID driverId) { + LoadedFunctions rf = loadedApps.get(driverId); + try { + JarLoader.unloadJars(rf.loader); + } catch (Exception e) { + RayLog.rapp.error("unload function for " + driverId + " failed, ex = " + e.getMessage(), e); + } + } + + private ConcurrentHashMap loadedApps = new ConcurrentHashMap<>(); + private MessageDigest md; + private String appDir = System.getProperty("user.dir") + "/apps"; + private KeyValueStoreLink kvStore; +} diff --git a/java/runtime-native/src/main/java/org/ray/spi/impl/PlasmaObjectExistsException.java b/java/runtime-native/src/main/java/org/ray/spi/impl/PlasmaObjectExistsException.java new file mode 100644 index 000000000000..9f2a38c05e35 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/impl/PlasmaObjectExistsException.java @@ -0,0 +1,35 @@ +package org.ray.spi.impl; + +/** + * This exception is raised if the object could not be created because there already is an object + * with the same ID in the plasma store. + */ +public class PlasmaObjectExistsException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 9128880292504270291L; + + public PlasmaObjectExistsException() { + super(); + } + + public PlasmaObjectExistsException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public PlasmaObjectExistsException(String message, Throwable cause) { + super(message, cause); + } + + public PlasmaObjectExistsException(String message) { + super(message); + } + + public PlasmaObjectExistsException(Throwable cause) { + super(cause); + } + +} diff --git a/java/runtime-native/src/main/java/org/ray/spi/impl/PlasmaOutOfMemoryException.java b/java/runtime-native/src/main/java/org/ray/spi/impl/PlasmaOutOfMemoryException.java new file mode 100644 index 000000000000..18ea8624d138 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/impl/PlasmaOutOfMemoryException.java @@ -0,0 +1,35 @@ +package org.ray.spi.impl; + +/** + * This exception is raised if the object could not be created because the plasma store is unable to + * evict enough objects to create room for it. + */ +public class PlasmaOutOfMemoryException extends Exception { + + /** + * + */ + private static final long serialVersionUID = -2786069077559520659L; + + public PlasmaOutOfMemoryException() { + super(); + } + + public PlasmaOutOfMemoryException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } + + public PlasmaOutOfMemoryException(String message, Throwable cause) { + super(message, cause); + } + + public PlasmaOutOfMemoryException(String message) { + super(message); + } + + public PlasmaOutOfMemoryException(Throwable cause) { + super(cause); + } + +} diff --git a/java/runtime-native/src/main/java/org/ray/spi/impl/RedisClient.java b/java/runtime-native/src/main/java/org/ray/spi/impl/RedisClient.java new file mode 100644 index 000000000000..a49549e9966e --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/impl/RedisClient.java @@ -0,0 +1,206 @@ +package org.ray.spi.impl; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.commons.lang3.StringUtils; +import org.ray.spi.KeyValueStoreLink; +import redis.clients.jedis.Jedis; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.JedisPoolConfig; + +public class RedisClient implements KeyValueStoreLink { + + private String redisAddress; + private JedisPool jedisPool; + + public RedisClient() { + } + + public RedisClient(String addr) { + SetAddr(addr); + } + + @Override + public synchronized void SetAddr(String addr) { + if (StringUtils.isEmpty(redisAddress)) { + redisAddress = addr; + String[] ipPort = addr.split(":"); + JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); + //TODO NUM maybe equels to the thread num + jedisPoolConfig.setMaxTotal(1); + jedisPool = new JedisPool(jedisPoolConfig, ipPort[0], Integer.parseInt(ipPort[1]), 30000); + } + } + + @Override + public void CheckConnected() throws Exception { + if (jedisPool == null) { + throw new Exception("the GlobalState API can't be used before ray init."); + } + } + + @Override + public Long Set(final String key, final String value, final String field) { + try (Jedis jedis = jedisPool.getResource()) { + if (field == null) { + jedis.set(key, value); + return (long) 1; + } else { + return jedis.hset(key, field, value); + } + } + + } + + @Override + public Long Set(byte[] key, byte[] value, byte[] field) { + try (Jedis jedis = jedisPool.getResource()) { + if (field == null) { + jedis.set(key, value); + return (long) 1; + } else { + return jedis.hset(key, field, value); + } + } + + } + + @Override + public String Get(final String key, final String field) { + try (Jedis jedis = jedisPool.getResource()) { + if (field == null) { + return jedis.get(key); + } else { + return jedis.hget(key, field); + } + } + + } + + @Override + public byte[] Get(byte[] key, byte[] field) { + try (Jedis jedis = jedisPool.getResource()) { + if (field == null) { + return jedis.get(key); + } else { + return jedis.hget(key, field); + } + } + + } + + @Override + public Long Delete(final String key, final String field) { + try (Jedis jedis = jedisPool.getResource()) { + if (field == null) { + return jedis.del(key); + } else { + return jedis.hdel(key, field); + } + } + + } + + @Override + public Long Delete(byte[] key, byte[] field) { + try (Jedis jedis = jedisPool.getResource()) { + if (field == null) { + return jedis.del(key); + } else { + return jedis.hdel(key, field); + } + } + + } + + @Override + public String Hmset(String key, Map hash) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.hmset(key, hash); + } + + } + + @Override + public String Hmset(byte[] key, Map hash) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.hmset(key, hash); + } + } + + @Override + public List Hmget(String key, String... fields) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.hmget(key, fields); + } + } + + @Override + public List Hmget(byte[] key, byte[]... fields) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.hmget(key, fields); + } + } + + @Override + public Set Keys(byte[] pattern) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.keys(pattern); + } + } + + @Override + public Set Keys(String pattern) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.keys(pattern); + } + } + + @Override + public Map hgetAll(byte[] key) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.hgetAll(key); + } + } + + @Override + public List Lrange(String key, long start, long end) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.lrange(key, start, end); + } + } + + @Override + public Long Rpush(String key, String... strings) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.rpush(key, strings); + } + } + + @Override + public Long Rpush(byte[] key, byte[]... strings) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.rpush(key, strings); + } + } + + @Override + public Long Publish(String channel, String message) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.publish(channel, message); + } + } + + @Override + public Long Publish(byte[] channel, byte[] message) { + try (Jedis jedis = jedisPool.getResource()) { + return jedis.publish(channel, message); + } + } + + @Override + public Object GetImpl() { + return jedisPool; + } +} diff --git a/java/runtime-native/src/main/java/org/ray/spi/impl/ResourcePair.java b/java/runtime-native/src/main/java/org/ray/spi/impl/ResourcePair.java new file mode 100644 index 000000000000..b002607a4ba0 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/impl/ResourcePair.java @@ -0,0 +1,38 @@ +package org.ray.spi.impl; + +// automatically generated by the FlatBuffers compiler, do not modify + +import java.nio.*; +import java.lang.*; +import java.util.*; +import com.google.flatbuffers.*; + +@SuppressWarnings("unused") +public final class ResourcePair extends Table { + public static ResourcePair getRootAsResourcePair(ByteBuffer _bb) { return getRootAsResourcePair(_bb, new ResourcePair()); } + public static ResourcePair getRootAsResourcePair(ByteBuffer _bb, ResourcePair obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } + public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } + public ResourcePair __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } + + public String key() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer keyAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } + public double value() { int o = __offset(6); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; } + + public static int createResourcePair(FlatBufferBuilder builder, + int keyOffset, + double value) { + builder.startObject(2); + ResourcePair.addValue(builder, value); + ResourcePair.addKey(builder, keyOffset); + return ResourcePair.endResourcePair(builder); + } + + public static void startResourcePair(FlatBufferBuilder builder) { builder.startObject(2); } + public static void addKey(FlatBufferBuilder builder, int keyOffset) { builder.addOffset(0, keyOffset, 0); } + public static void addValue(FlatBufferBuilder builder, double value) { builder.addDouble(1, value, 0.0); } + public static int endResourcePair(FlatBufferBuilder builder) { + int o = builder.endObject(); + return o; + } +} + diff --git a/java/runtime-native/src/main/java/org/ray/spi/impl/StateStoreProxyImpl.java b/java/runtime-native/src/main/java/org/ray/spi/impl/StateStoreProxyImpl.java new file mode 100644 index 000000000000..caad0efd9dd9 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/impl/StateStoreProxyImpl.java @@ -0,0 +1,197 @@ +package org.ray.spi.impl; + +import java.io.UnsupportedEncodingException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import org.ray.spi.KeyValueStoreLink; +import org.ray.spi.StateStoreProxy; +import org.ray.spi.model.AddressInfo; +import org.ray.util.logger.RayLog; + +/** + * A class used to interface with the Ray control state + */ +public class StateStoreProxyImpl implements StateStoreProxy { + + public KeyValueStoreLink rayKvStore; + public ArrayList shardStoreList = new ArrayList<>(); + + public StateStoreProxyImpl(KeyValueStoreLink rayKvStore) { + this.rayKvStore = rayKvStore; + } + + public void setStore(KeyValueStoreLink rayKvStore) { + this.rayKvStore = rayKvStore; + } + + public void checkConnected() throws Exception { + rayKvStore.CheckConnected(); + } + + public synchronized void initializeGlobalState() throws Exception { + + String es; + + checkConnected(); + + String s = rayKvStore.Get("NumRedisShards", null); + if (s == null) { + throw new Exception("NumRedisShards not found in redis."); + } + int numRedisShards = Integer.parseInt(s); + if (numRedisShards < 1) { + es = String.format("Expected at least one Redis shard, found %d", numRedisShards); + throw new Exception(es); + } + List ipAddressPorts = rayKvStore.Lrange("RedisShards", 0, -1); + if (ipAddressPorts.size() != numRedisShards) { + es = String.format("Expected %d Redis shard addresses, found %d.", numRedisShards, + ipAddressPorts.size()); + throw new Exception(es); + } + + shardStoreList.clear(); + for (String ipPort : ipAddressPorts) { + shardStoreList.add(new RedisClient(ipPort)); + } + + } + + public synchronized Set keys(final String pattern) { + Set allKeys = new HashSet<>(); + Set tmpKey; + for (KeyValueStoreLink a_shardStoreList : shardStoreList) { + tmpKey = a_shardStoreList.Keys(pattern); + allKeys.addAll(tmpKey); + } + + return allKeys; + } + + private byte[] CharsetEncode(String str, String Charset) throws UnsupportedEncodingException { + if (str != null) { + return str.getBytes(Charset); + } + return null; + } + + private String CharsetDecode(byte[] bs, String Charset) throws UnsupportedEncodingException { + return new String(bs, Charset); + } + + /* + * get address info of one node from primary redis + * @param: node ip address, usually local ip address + * @return: a list of SchedulerInfo which contains storeName, managerName, managerPort and schedulerName + * @note:Redis data key is "CL:*", redis data value is a hash. + * The hash contains the following: + * "deleted" : 0/1 + * "ray_client_id" + * "nodeIpAddress" + * "client_type" : plasma_manager/local_scheduler + * "store_socket_name"(op) + * "manager_socket_name"(op) + * "local_scheduler_socket_name"(op) + */ + public List getAddressInfoHelper(final String nodeIpAddress) throws Exception { + if (this.rayKvStore == null) { + throw new Exception("no redis client when use getAddressInfoHelper"); + } + List schedulerInfo = new ArrayList<>(); + + Set cks = rayKvStore.Keys("CL:*".getBytes()); + byte[] key; + List> plasmaManager = new ArrayList<>(); + List> localScheduler = new ArrayList<>(); + for (byte[] ck : cks) { + key = ck; + Map info = rayKvStore.hgetAll(key); + + String deleted = CharsetDecode(info.get("deleted".getBytes()), "US-ASCII"); + if (deleted != null) { + if (Boolean.getBoolean(deleted)) { + continue; + } + } + + if (!info.containsKey("ray_client_id".getBytes())) { + throw new Exception("no ray_client_id in any client"); + } else if (!info.containsKey("nodeIpAddress".getBytes())) { + throw new Exception("no nodeIpAddress in any client"); + } else if (!info.containsKey("client_type".getBytes())) { + throw new Exception("no client_type in any client"); + } + + if (CharsetDecode(info.get("nodeIpAddress".getBytes()), "US-ASCII") + .equals(nodeIpAddress)) { + String clientType = CharsetDecode(info.get("client_type".getBytes()), "US-ASCII"); + if (clientType.equals("plasmaManager")) { + plasmaManager.add(info); + } else if (clientType.equals("localScheduler")) { + localScheduler.add(info); + } + } + } + + if (plasmaManager.size() < 1 || localScheduler.size() < 1) { + throw new Exception("no plasmaManager or localScheduler"); + } else if (plasmaManager.size() != localScheduler.size()) { + throw new Exception("plasmaManager number not Equal localScheduler number"); + } + + for (int i = 0; i < plasmaManager.size(); i++) { + AddressInfo si = new AddressInfo(); + si.storeName = CharsetDecode(plasmaManager.get(i).get("store_socket_name".getBytes()), + "US-ASCII"); + si.managerName = CharsetDecode(plasmaManager.get(i).get("manager_socket_name".getBytes()), + "US-ASCII"); + + byte[] rpc = plasmaManager.get(i).get("manager_rpc_name".getBytes()); + if (rpc != null) { + si.managerRpcAddr = CharsetDecode(rpc, "US-ASCII"); + } + + rpc = plasmaManager.get(i).get("store_rpc_name".getBytes()); + if (rpc != null) { + si.storeRpcAddr = CharsetDecode(rpc, "US-ASCII"); + } + + String managerAddr = CharsetDecode(plasmaManager.get(i).get("manager_address".getBytes()), + "US-ASCII"); + si.managerPort = Integer.parseInt(managerAddr.split(":")[1]); + si.schedulerName = CharsetDecode( + localScheduler.get(i).get("local_scheduler_socket_name".getBytes()), "US-ASCII"); + + rpc = localScheduler.get(i).get("local_scheduler_rpc_name".getBytes()); + if (rpc != null) { + si.schedulerRpcAddr = CharsetDecode(rpc, "US-ASCII"); + } + + schedulerInfo.add(si); + } + + return schedulerInfo; + } + + public List getAddressInfo(final String node_ip_address, int numRetries) { + int count = 0; + while (count < numRetries) { + try { + return getAddressInfoHelper(node_ip_address); + } catch (Exception e) { + try { + TimeUnit.MILLISECONDS.sleep(1000); + } catch (InterruptedException ie) { + RayLog.core.error("error at StateStoreProxyImpl getAddressInfo", e); + throw new RuntimeException(e); + } + } + count++; + } + throw new RuntimeException("cannot get address info from state store"); + } +} diff --git a/java/runtime-native/src/main/java/org/ray/spi/impl/TaskInfo.java b/java/runtime-native/src/main/java/org/ray/spi/impl/TaskInfo.java new file mode 100644 index 000000000000..aacd585a4a27 --- /dev/null +++ b/java/runtime-native/src/main/java/org/ray/spi/impl/TaskInfo.java @@ -0,0 +1,119 @@ +package org.ray.spi.impl; +// automatically generated by the FlatBuffers compiler, do not modify + +import java.nio.*; +import java.lang.*; +import java.util.*; +import com.google.flatbuffers.*; + +@SuppressWarnings("unused") +public final class TaskInfo extends Table { + public static TaskInfo getRootAsTaskInfo(ByteBuffer _bb) { return getRootAsTaskInfo(_bb, new TaskInfo()); } + public static TaskInfo getRootAsTaskInfo(ByteBuffer _bb, TaskInfo obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); } + public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; } + public TaskInfo __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; } + + public String driverId() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer driverIdAsByteBuffer() { return __vector_as_bytebuffer(4, 1); } + public String taskId() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer taskIdAsByteBuffer() { return __vector_as_bytebuffer(6, 1); } + public String parentTaskId() { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer parentTaskIdAsByteBuffer() { return __vector_as_bytebuffer(8, 1); } + public int parentCounter() { int o = __offset(10); return o != 0 ? bb.getInt(o + bb_pos) : 0; } + public String actorCreationId() { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer actorCreationIdAsByteBuffer() { return __vector_as_bytebuffer(12, 1); } + public String actorCreationDummyObjectId() { int o = __offset(14); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer actorCreationDummyObjectIdAsByteBuffer() { return __vector_as_bytebuffer(14, 1); } + public String actorId() { int o = __offset(16); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer actorIdAsByteBuffer() { return __vector_as_bytebuffer(16, 1); } + public String actorHandleId() { int o = __offset(18); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer actorHandleIdAsByteBuffer() { return __vector_as_bytebuffer(18, 1); } + public int actorCounter() { int o = __offset(20); return o != 0 ? bb.getInt(o + bb_pos) : 0; } + public boolean isActorCheckpointMethod() { int o = __offset(22); return o != 0 ? 0!=bb.get(o + bb_pos) : false; } + public String functionId() { int o = __offset(24); return o != 0 ? __string(o + bb_pos) : null; } + public ByteBuffer functionIdAsByteBuffer() { return __vector_as_bytebuffer(24, 1); } + public Arg args(int j) { return args(new Arg(), j); } + public Arg args(Arg obj, int j) { int o = __offset(26); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; } + public int argsLength() { int o = __offset(26); return o != 0 ? __vector_len(o) : 0; } + public String returns(int j) { int o = __offset(28); return o != 0 ? __string(__vector(o) + j * 4) : null; } + public int returnsLength() { int o = __offset(28); return o != 0 ? __vector_len(o) : 0; } + public ResourcePair requiredResources(int j) { return requiredResources(new ResourcePair(), j); } + public ResourcePair requiredResources(ResourcePair obj, int j) { int o = __offset(30); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; } + public int requiredResourcesLength() { int o = __offset(30); return o != 0 ? __vector_len(o) : 0; } + + public static int createTaskInfo(FlatBufferBuilder builder, + int driver_idOffset, + int task_idOffset, + int parent_task_idOffset, + int parent_counter, + int actor_creation_idOffset, + int actor_creation_dummy_object_idOffset, + int actor_idOffset, + int actor_handle_idOffset, + int actor_counter, + boolean is_actor_checkpoint_method, + int function_idOffset, + int argsOffset, + int returnsOffset, + int required_resourcesOffset) { + builder.startObject(14); + TaskInfo.addRequiredResources(builder, required_resourcesOffset); + TaskInfo.addReturns(builder, returnsOffset); + TaskInfo.addArgs(builder, argsOffset); + TaskInfo.addFunctionId(builder, function_idOffset); + TaskInfo.addActorCounter(builder, actor_counter); + TaskInfo.addActorHandleId(builder, actor_handle_idOffset); + TaskInfo.addActorId(builder, actor_idOffset); + TaskInfo.addActorCreationDummyObjectId(builder, actor_creation_dummy_object_idOffset); + TaskInfo.addActorCreationId(builder, actor_creation_idOffset); + TaskInfo.addParentCounter(builder, parent_counter); + TaskInfo.addParentTaskId(builder, parent_task_idOffset); + TaskInfo.addTaskId(builder, task_idOffset); + TaskInfo.addDriverId(builder, driver_idOffset); + TaskInfo.addIsActorCheckpointMethod(builder, is_actor_checkpoint_method); + return TaskInfo.endTaskInfo(builder); + } + + public static void startTaskInfo(FlatBufferBuilder builder) { builder.startObject(14); } + public static void addDriverId(FlatBufferBuilder builder, int driverIdOffset) { builder.addOffset(0, driverIdOffset, 0); } + public static void addTaskId(FlatBufferBuilder builder, int taskIdOffset) { builder.addOffset(1, taskIdOffset, 0); } + public static void addParentTaskId(FlatBufferBuilder builder, int parentTaskIdOffset) { builder.addOffset(2, parentTaskIdOffset, 0); } + public static void addParentCounter(FlatBufferBuilder builder, int parentCounter) { builder.addInt(3, parentCounter, 0); } + public static void addActorCreationId(FlatBufferBuilder builder, int actorCreationIdOffset) { builder.addOffset(4, actorCreationIdOffset, 0); } + public static void addActorCreationDummyObjectId(FlatBufferBuilder builder, int actorCreationDummyObjectIdOffset) { builder.addOffset(5, actorCreationDummyObjectIdOffset, 0); } + public static void addActorId(FlatBufferBuilder builder, int actorIdOffset) { builder.addOffset(6, actorIdOffset, 0); } + public static void addActorHandleId(FlatBufferBuilder builder, int actorHandleIdOffset) { builder.addOffset(7, actorHandleIdOffset, 0); } + public static void addActorCounter(FlatBufferBuilder builder, int actorCounter) { builder.addInt(8, actorCounter, 0); } + public static void addIsActorCheckpointMethod(FlatBufferBuilder builder, boolean isActorCheckpointMethod) { builder.addBoolean(9, isActorCheckpointMethod, false); } + public static void addFunctionId(FlatBufferBuilder builder, int functionIdOffset) { builder.addOffset(10, functionIdOffset, 0); } + public static void addArgs(FlatBufferBuilder builder, int argsOffset) { builder.addOffset(11, argsOffset, 0); } + public static int createArgsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); } + public static void startArgsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); } + public static void addReturns(FlatBufferBuilder builder, int returnsOffset) { builder.addOffset(12, returnsOffset, 0); } + public static int createReturnsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); } + public static void startReturnsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); } + public static void addRequiredResources(FlatBufferBuilder builder, int requiredResourcesOffset) { builder.addOffset(13, requiredResourcesOffset, 0); } + public static int createRequiredResourcesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); } + public static void startRequiredResourcesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); } + public static int endTaskInfo(FlatBufferBuilder builder) { + int o = builder.endObject(); + return o; + } + + //this is manually added to avoid encoding/decoding cost as our object id is a byte array instead of a string + public ByteBuffer returnsAsByteBuffer(int j) { + int o = __offset(28); + if (o == 0) { + return null; + } + + int offset = __vector(o) + j * 4; + offset += bb.getInt(offset); + ByteBuffer src = bb.duplicate().order(ByteOrder.LITTLE_ENDIAN); + int length = src.getInt(offset); + src.position(offset + 4); + src.limit(offset + 4 + length); + return src; + } +} + diff --git a/java/test.sh b/java/test.sh new file mode 100755 index 000000000000..54674d251ef4 --- /dev/null +++ b/java/test.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +ROOT_DIR=$(cd "$(dirname "${BASH_SOURCE:-$0}")"; pwd) +$ROOT_DIR/../build.sh -l java + +pushd $ROOT_DIR/../thirdparty/build/arrow/java +mvn clean install -pl plasma -am -Dmaven.test.skip +popd +pushd $ROOT_DIR/../java +mvn clean install -Dmaven.test.skip +mvn test +popd \ No newline at end of file diff --git a/java/test/pom.xml b/java/test/pom.xml new file mode 100644 index 000000000000..03fc2141a7f8 --- /dev/null +++ b/java/test/pom.xml @@ -0,0 +1,128 @@ + + + + + org.ray.parent + ray-superpom + 1.0 + + 4.0.0 + + org.ray + ray-test + + java test cases for ray + java test cases for ray + + + jar + + + + org.ray + ray-api + 1.0 + + + + org.ray + ray-runtime-common + 1.0 + + + + org.ray + ray-runtime-native + 1.0 + + + + org.ray + ray-runtime-dev + 1.0 + + + + org.ray + ray-common + 1.0 + + + + org.ray + ray-hook + 1.0 + + + + junit + junit + 4.11 + + + + + + commons-collections + commons-collections + 3.2.2 + + + + com.google.guava + guava + 19.0 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.20.1 + + + + ${basedir}/../ray.config.ini + + -ea + -Djava.library.path=${basedir}/../../build/src/plasma:${basedir}/../../build/src/local_scheduler + -noverify + -DlogOutput=console + + ${basedir}/src/main/java/ + ${project.build.directory}/classes/ + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + package + + copy-dependencies + + + ${basedir}/lib + false + false + true + + + + + + + + + diff --git a/java/test/src/main/java/org/ray/api/benchmark/ActorPressTest.java b/java/test/src/main/java/org/ray/api/benchmark/ActorPressTest.java new file mode 100644 index 000000000000..c622698e1c58 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/benchmark/ActorPressTest.java @@ -0,0 +1,72 @@ +package org.ray.api.benchmark; + +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.test.MyRunner; + +@RunWith(MyRunner.class) +public class ActorPressTest extends RayBenchmarkTest { + + @Test + public void singleLatencyTest() { + int times = 10; + RayActor adder = Ray.create(ActorPressTest.Adder.class); + super.singleLatencyTest(times, adder); + } + + @Test + public void maxTest() { + int clientNum = 2; + int totalNum = 20; + RayActor adder = Ray.create(ActorPressTest.Adder.class); + PressureTestParameter pressureTestParameter = new PressureTestParameter(); + pressureTestParameter.setClientNum(clientNum); + pressureTestParameter.setTotalNum(totalNum); + pressureTestParameter.setRayBenchmarkTest(this); + pressureTestParameter.setRayActor(adder); + super.maxPressureTest(pressureTestParameter); + } + + @Test + public void rateLimiterTest() { + int clientNum = 2; + int totalQps = 2; + int duration = 3; + RayActor adder = Ray.create(ActorPressTest.Adder.class); + PressureTestParameter pressureTestParameter = new PressureTestParameter(); + pressureTestParameter.setClientNum(clientNum); + pressureTestParameter.setTotalQps(totalQps); + pressureTestParameter.setDuration(duration); + pressureTestParameter.setRayBenchmarkTest(this); + pressureTestParameter.setRayActor(adder); + super.rateLimiterPressureTest(pressureTestParameter); + } + + @RayRemote + public static class Adder { + + public RemoteResult add(Integer n) { + RemoteResult remoteResult = new RemoteResult<>(); + remoteResult.setResult(sum += n); + remoteResult.setFinishTime(System.nanoTime()); + return remoteResult; + } + + private Integer sum = 0; + } + + @Override + public RayObject> rayCall(RayActor rayActor) { + return Ray.call(Adder::add, (RayActor) rayActor, 10); + } + + @Override + public boolean checkResult(Object o) { + return true; + } + +} diff --git a/java/test/src/main/java/org/ray/api/benchmark/MaxPressureTest.java b/java/test/src/main/java/org/ray/api/benchmark/MaxPressureTest.java new file mode 100644 index 000000000000..b98ed54638f7 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/benchmark/MaxPressureTest.java @@ -0,0 +1,48 @@ +package org.ray.api.benchmark; + +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.test.MyRunner; + +@RunWith(MyRunner.class) +public class MaxPressureTest extends RayBenchmarkTest { + + private static final long serialVersionUID = -1684518885171395952L; + + public static final int clientNum = 2; + + public static final int totalNum = 10; + + @Test + public void Test() { + PressureTestParameter pressureTestParameter = new PressureTestParameter(); + pressureTestParameter.setClientNum(clientNum); + pressureTestParameter.setTotalNum(totalNum); + pressureTestParameter.setRayBenchmarkTest(this); + super.maxPressureTest(pressureTestParameter); + } + + @RayRemote + public static RemoteResult currentTime() { + RemoteResult remoteResult = new RemoteResult<>(); + remoteResult.setFinishTime(System.nanoTime()); + remoteResult.setResult(0); + return remoteResult; + } + + @Override + public boolean checkResult(Object o) { + return (int) o == 0; + } + + @Override + public RayObject> rayCall(RayActor rayActor) { + + return Ray.call(MaxPressureTest::currentTime); + } + +} diff --git a/java/test/src/main/java/org/ray/api/benchmark/PressureTestParameter.java b/java/test/src/main/java/org/ray/api/benchmark/PressureTestParameter.java new file mode 100644 index 000000000000..b5c533b307d5 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/benchmark/PressureTestParameter.java @@ -0,0 +1,79 @@ +package org.ray.api.benchmark; + +import java.io.Serializable; +import org.ray.api.RayActor; + +public class PressureTestParameter implements Serializable { + + private static final long serialVersionUID = -52054601722982473L; + + private Integer clientNum = 1; //number of test client + + private PressureTestType pressureTestType = PressureTestType.RATE_LIMITER; //pressure test type + + private Integer totalNum = 1; //total number of task under the mode of MAX + + private Integer totalQps = 1; //total qps of task under the mode of RATE_LIMITER + + private Integer duration = 1; //duration of the pressure test under the mode of RATE_LIMITER + + private RayBenchmarkTest rayBenchmarkTest; //reference of current test case instance + + private RayActor rayActor; // reference of the Actor, if only test remote funtion it could be null + + public Integer getClientNum() { + return clientNum; + } + + public void setClientNum(Integer clientNum) { + this.clientNum = clientNum; + } + + public PressureTestType getPressureTestType() { + return pressureTestType; + } + + public void setPressureTestType(PressureTestType pressureTestType) { + this.pressureTestType = pressureTestType; + } + + public Integer getTotalNum() { + return totalNum; + } + + public void setTotalNum(Integer totalNum) { + this.totalNum = totalNum; + } + + public Integer getTotalQps() { + return totalQps; + } + + public void setTotalQps(Integer totalQps) { + this.totalQps = totalQps; + } + + public Integer getDuration() { + return duration; + } + + public void setDuration(Integer duration) { + this.duration = duration; + } + + public RayBenchmarkTest getRayBenchmarkTest() { + return rayBenchmarkTest; + } + + public void setRayBenchmarkTest(RayBenchmarkTest rayBenchmarkTest) { + this.rayBenchmarkTest = rayBenchmarkTest; + } + + public RayActor getRayActor() { + return rayActor; + } + + public void setRayActor(RayActor rayActor) { + this.rayActor = rayActor; + } +} diff --git a/java/test/src/main/java/org/ray/api/benchmark/PressureTestType.java b/java/test/src/main/java/org/ray/api/benchmark/PressureTestType.java new file mode 100644 index 000000000000..91c2291b0348 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/benchmark/PressureTestType.java @@ -0,0 +1,8 @@ +package org.ray.api.benchmark; + +public enum PressureTestType { + + SINGLE_LATENCY, + RATE_LIMITER, + MAX +} diff --git a/java/test/src/main/java/org/ray/api/benchmark/RateLimiterPressureTest.java b/java/test/src/main/java/org/ray/api/benchmark/RateLimiterPressureTest.java new file mode 100644 index 000000000000..6dbb1bac77a3 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/benchmark/RateLimiterPressureTest.java @@ -0,0 +1,50 @@ +package org.ray.api.benchmark; + +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.test.MyRunner; + +@RunWith(MyRunner.class) +public class RateLimiterPressureTest extends RayBenchmarkTest { + + private static final long serialVersionUID = 6616958120966144235L; + + public static final int clientNum = 2; + + public static final int totalQps = 2; + + public static final int duration = 10; + + @Test + public void Test() { + PressureTestParameter pressureTestParameter = new PressureTestParameter(); + pressureTestParameter.setClientNum(clientNum); + pressureTestParameter.setTotalQps(totalQps); + pressureTestParameter.setDuration(duration); + pressureTestParameter.setRayBenchmarkTest(this); + super.rateLimiterPressureTest(pressureTestParameter); + } + + @RayRemote + public static RemoteResult currentTime() { + RemoteResult remoteResult = new RemoteResult<>(); + remoteResult.setFinishTime(System.nanoTime()); + remoteResult.setResult(0); + return remoteResult; + } + + @Override + public boolean checkResult(Object o) { + return (int) o == 0; + } + + @Override + public RayObject> rayCall(RayActor rayActor) { + + return Ray.call(RateLimiterPressureTest::currentTime); + } +} diff --git a/java/test/src/main/java/org/ray/api/benchmark/RayBenchmarkTest.java b/java/test/src/main/java/org/ray/api/benchmark/RayBenchmarkTest.java new file mode 100644 index 000000000000..c45e2786cb9c --- /dev/null +++ b/java/test/src/main/java/org/ray/api/benchmark/RayBenchmarkTest.java @@ -0,0 +1,152 @@ +package org.ray.api.benchmark; + +import com.google.common.util.concurrent.RateLimiter; +import java.io.Serializable; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +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.util.logger.RayLog; + +public abstract class RayBenchmarkTest implements Serializable { + + private static final long serialVersionUID = 416045641835782523L; + + //not thread safe ,but we only have one thread here + public static final DecimalFormat df = new DecimalFormat("00.00"); + + private static void printList(List list) { + int len = list.size(); + int middle = len / 2; + int almostHundred = (int) (len * 0.9999); + int ninetyNine = (int) (len * 0.99); + int ninetyFive = (int) (len * 0.95); + int ninety = (int) (len * 0.9); + int fifty = (int) (len * 0.5); + + RayLog.core.error("Final result of rt as below:"); + RayLog.core.error("max: " + list.get(len - 1) + "μs"); + RayLog.core.error("min: " + list.get(0) + "μs"); + RayLog.core.error("median: " + list.get(middle) + "μs"); + RayLog.core.error("99.99% data smaller than: " + list.get(almostHundred) + "μs"); + RayLog.core.error("99% data smaller than: " + list.get(ninetyNine) + "μs"); + RayLog.core.error("95% data smaller than: " + list.get(ninetyFive) + "μs"); + RayLog.core.error("90% data smaller than: " + list.get(ninety) + "μs"); + RayLog.core.error("50% data smaller than: " + list.get(fifty) + "μs"); + } + + public void singleLatencyTest(int times, RayActor rayActor) { + + List counterList = new ArrayList<>(); + for (int i = 0; i < times; i++) { + long startTime = System.nanoTime(); + RayObject> rayObject = rayCall(rayActor); + RemoteResult remoteResult = rayObject.get(); + T t = remoteResult.getResult(); + long endTime = System.nanoTime(); + long costTime = endTime - startTime; + counterList.add(costTime / 1000); + RayLog.core.warn("SINGLE_LATENCY_cost_time: " + costTime + " us"); + Assert.assertTrue(checkResult(t)); + } + Collections.sort(counterList); + printList(counterList); + } + + public void rateLimiterPressureTest(PressureTestParameter pressureTestParameter) { + + pressureTestParameter.setPressureTestType(PressureTestType.RATE_LIMITER); + notSinglePressTest(pressureTestParameter); + } + + public void maxPressureTest(PressureTestParameter pressureTestParameter) { + + pressureTestParameter.setPressureTestType(PressureTestType.MAX); + notSinglePressTest(pressureTestParameter); + } + + private void notSinglePressTest(PressureTestParameter pressureTestParameter) { + + List counterList = new ArrayList<>(); + int clientNum = pressureTestParameter.getClientNum(); + RayObject>[] rayObjects = new RayObject[clientNum]; + + for (int i = 0; i < clientNum; i++) { + rayObjects[i] = Ray.call(RayBenchmarkTest::singleClient, pressureTestParameter); + } + for (int i = 0; i < clientNum; i++) { + List subCounterList = rayObjects[i].get(); + Assert.assertNotNull(subCounterList); + counterList.addAll(subCounterList); + } + Collections.sort(counterList); + printList(counterList); + } + + @RayRemote + private static List singleClient(PressureTestParameter pressureTestParameter) { + + try { + List counterList = new ArrayList<>(); + PressureTestType pressureTestType = pressureTestParameter.getPressureTestType(); + RayBenchmarkTest rayBenchmarkTest = pressureTestParameter.getRayBenchmarkTest(); + int clientNum = pressureTestParameter.getClientNum(); + //SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + int len; + String logPrefix; + RateLimiter rateLimiter = null; + if (pressureTestType.equals(PressureTestType.MAX)) { + len = pressureTestParameter.getTotalNum() / clientNum; + logPrefix = "MAX"; + } else { + int totalQps = pressureTestParameter.getTotalQps(); + int duration = pressureTestParameter.getDuration(); + int qps = totalQps / clientNum; + rateLimiter = RateLimiter.create(qps); + len = qps * duration; + logPrefix = "RATE_LIMITER"; + } + RemoteResultWrapper[] remoteResultWrappers = new RemoteResultWrapper[len]; + int i = 0; + while (i < len) { + if (rateLimiter != null) { + rateLimiter.acquire(); + } +// Date currentTime = new Date(); +// String dateString = formatter.format(currentTime); +// RayLog.core.info(logPrefix + "_startTime: " + dateString); + + RemoteResultWrapper temp = new RemoteResultWrapper(); + temp.setStartTime(System.nanoTime()); + temp.setRayObject(rayBenchmarkTest.rayCall(pressureTestParameter.getRayActor())); + remoteResultWrappers[i++] = temp; + } + + int j = 0; + while (j < len) { + RemoteResultWrapper temp = remoteResultWrappers[j++]; + RemoteResult remoteResult = (RemoteResult) temp.getRayObject().get(); + long endTime = remoteResult.getFinishTime(); + long costTime = endTime - temp.getStartTime(); + counterList.add(costTime / 1000); + RayLog.core.warn(logPrefix + "_cost_time:" + costTime + "ns"); + Assert.assertTrue(rayBenchmarkTest.checkResult(remoteResult.getResult())); + } + return counterList; + } catch (Exception e) { + RayLog.core.error("singleClient", e); + return null; + + } + } + + abstract public RayObject> rayCall(RayActor rayActor); + + abstract public boolean checkResult(T t); + +} diff --git a/java/test/src/main/java/org/ray/api/benchmark/RemoteResult.java b/java/test/src/main/java/org/ray/api/benchmark/RemoteResult.java new file mode 100644 index 000000000000..3c319af65ced --- /dev/null +++ b/java/test/src/main/java/org/ray/api/benchmark/RemoteResult.java @@ -0,0 +1,28 @@ +package org.ray.api.benchmark; + +import java.io.Serializable; + +public class RemoteResult implements Serializable { + + private static final long serialVersionUID = -3825949468039358540L; + + private long finishTime; + + private T result; + + public long getFinishTime() { + return finishTime; + } + + public void setFinishTime(long finishTime) { + this.finishTime = finishTime; + } + + public T getResult() { + return result; + } + + public void setResult(T result) { + this.result = result; + } +} diff --git a/java/test/src/main/java/org/ray/api/benchmark/RemoteResultWrapper.java b/java/test/src/main/java/org/ray/api/benchmark/RemoteResultWrapper.java new file mode 100644 index 000000000000..bbd37c1c3eb1 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/benchmark/RemoteResultWrapper.java @@ -0,0 +1,26 @@ +package org.ray.api.benchmark; + +import org.ray.api.RayObject; + +public class RemoteResultWrapper { + + private long startTime; + + private RayObject> rayObject; + + public long getStartTime() { + return startTime; + } + + public void setStartTime(long startTime) { + this.startTime = startTime; + } + + public RayObject> getRayObject() { + return rayObject; + } + + public void setRayObject(RayObject> rayObject) { + this.rayObject = rayObject; + } +} diff --git a/java/test/src/main/java/org/ray/api/benchmark/SingleLatencyTest.java b/java/test/src/main/java/org/ray/api/benchmark/SingleLatencyTest.java new file mode 100644 index 000000000000..540d1877fa2d --- /dev/null +++ b/java/test/src/main/java/org/ray/api/benchmark/SingleLatencyTest.java @@ -0,0 +1,39 @@ +package org.ray.api.benchmark; + +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.test.MyRunner; + +@RunWith(MyRunner.class) +public class SingleLatencyTest extends RayBenchmarkTest { + + private static final long serialVersionUID = 3559601273941694468L; + + public static final int totalNum = 10; + + @Test + public void Test() { + super.singleLatencyTest(totalNum, null); + } + + @RayRemote + public static RemoteResult doFunc() { + RemoteResult remoteResult = new RemoteResult<>(); + remoteResult.setResult(1); + return remoteResult; + } + + @Override + public RayObject> rayCall(RayActor rayActor) { + return Ray.call(SingleLatencyTest::doFunc); + } + + @Override + public boolean checkResult(Object o) { + return (int) o == 1; + } +} diff --git a/java/test/src/main/java/org/ray/api/experiment/mr/MemoryMapReduce.java b/java/test/src/main/java/org/ray/api/experiment/mr/MemoryMapReduce.java new file mode 100644 index 000000000000..59d7f2985f7c --- /dev/null +++ b/java/test/src/main/java/org/ray/api/experiment/mr/MemoryMapReduce.java @@ -0,0 +1,179 @@ +package org.ray.api.experiment.mr; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.SortedMap; +import java.util.TreeMap; +import org.apache.commons.lang3.tuple.Pair; +import org.ray.api.Ray; +import org.ray.api.RayList; +import org.ray.api.RayObject; +import org.ray.api.RayRemote; + +/** + * mimic the MapReduce interface atop of Ray API (in memory version) + */ +public class MemoryMapReduce { + + public List> Map(TInput input) throws Exception { + throw new Exception("not implemented"); + } + + public TReduceValue Reduce(TMapKey k, List values) throws Exception { + throw new Exception("not implemented"); + } + + // + // main logic to execute this map-reduce with remote mappers and reducers + // + // @param inputs - given input file segments each containing List + // @return output file segments each containing SortedMap + // + public SortedMap Run(List> inputs, int mapperCount, + Integer reducerCount) { + // start all mappers + ArrayList>>> mappers = new ArrayList<>(); + + int inputCountPerMap = inputs.size() / mapperCount; + int index = 0; + for (int i = 0; i < mapperCount; i++) { + if (index >= inputs.size()) { + break; + } + + List> perMapInputs = new ArrayList<>(); + for (int j = 0; j < inputCountPerMap && index < inputs.size(); j++) { + perMapInputs.add(inputs.get(index++)); + } + + mappers.add(Ray.call_n(MemoryMapReduce::InternalMap, reducerCount, reducerCount, perMapInputs, + this.getClass().getName())); + } + + // BSP barrier for all mappers to be finished + // this is unnecessary as later on we call map.get() to wait for mappers to be completed + // Ray.wait(mappers.toArray(new RayObject[0]), mappers.size(), 0); + + // start all reducers + ArrayList>> reducers = new ArrayList<>(); + for (int i = 0; i < reducerCount; i++) { + // collect states from mappers for this reducer + RayList>> fromMappers = new RayList(); + for (int j = 0; j < mapperCount; j++) { + assert (mappers.get(j).size() == reducerCount); + fromMappers.add(mappers.get(j).Get(i)); + } + + // start this reducer with given input + reducers.add(Ray.call(MemoryMapReduce::InternalReduce, + (List>>) fromMappers, this.getClass().getName())); + } + + // BSP barrier for all reducers to be finished + // this is unnecessary coz we will call reducer.get() to wait for their completion + // Ray.wait(reducers.toArray(new RayObject[0]), reducers.size(), 0); + + // collect outputs + TreeMap outputs = new TreeMap<>(); + for (RayObject> r : reducers) { + r.get().forEach(outputs::put); + } + return outputs; + } + + // + // given a set of input files, output another set of files for reducers + // + // @param inputs - for each input file, it contains List + // @return %recuderCount% number of files for the reducers numbering from 0 to reducerCount - 1. + // for each output file, it contains SortedMap> + // + @RayRemote + public static List>> InternalMap( + Integer reducerCount, + List> inputs, + String mrClassName) { + MemoryMapReduce mr; + try { + mr = (MemoryMapReduce) Class + .forName(mrClassName).getConstructors()[0].newInstance(); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | SecurityException | ClassNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return null; + } + + ArrayList>> out = new ArrayList<>(); + for (int i = 0; i < reducerCount; i++) { + out.add(new TreeMap<>()); + } + + for (List inputSeg : inputs) { + for (TInput input : inputSeg) { + try { + List> result = mr.Map(input); + for (Pair pr : result) { + int reducerIndex = Math.abs(pr.getKey().hashCode()) % reducerCount; + out.get(reducerIndex).computeIfAbsent(pr.getKey(), k -> new ArrayList<>()); + out.get(reducerIndex).get(pr.getKey()).add(pr.getValue()); + } + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + return out; + } + + //public static class Helper { + // + // given a set of input sets from all mappers, performance merge sort and apply reducer function + // + // @param inputs each file contains SortedMap> + // @return an output file contains SortedMap + // + @RayRemote + public static SortedMap InternalReduce( + List>> inputs, + String mrClassName) { + MemoryMapReduce mr; + try { + mr = (MemoryMapReduce) Class + .forName(mrClassName).getConstructors()[0].newInstance(); + } catch (InstantiationException | IllegalAccessException | IllegalArgumentException + | InvocationTargetException | SecurityException | ClassNotFoundException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + return null; + } + + // merge inputs from many mappers + TreeMap> minputs = new TreeMap<>(); + for (SortedMap> input : inputs) { + for (Map.Entry> entry : input.entrySet()) { + if (!minputs.containsKey(entry.getKey())) { + minputs.put(entry.getKey(), new ArrayList<>()); + } + minputs.get(entry.getKey()).addAll(entry.getValue()); + } + } + + // reduce + TreeMap out = new TreeMap<>(); + for (Map.Entry> entry : minputs.entrySet()) { + try { + out.put(entry.getKey(), mr.Reduce(entry.getKey(), entry.getValue())); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return out; + } + // } +} diff --git a/java/test/src/main/java/org/ray/api/test/ActorTest.java b/java/test/src/main/java/org/ray/api/test/ActorTest.java new file mode 100644 index 000000000000..f46267a5c725 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/ActorTest.java @@ -0,0 +1,154 @@ +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; + +@RunWith(MyRunner.class) +public class ActorTest { + + @Test + public void Test() { + + RayActor adder = Ray.create(ActorTest.Adder.class); + Ray.call(Adder::set, adder, 10); + RayObject result = Ray.call(Adder::add, adder, 1); + Assert.assertEquals(11, (int) result.get()); + + RayActor secondAdder = Ray.create(Adder.class); + RayObject result2 = Ray.call(Adder::add, secondAdder, 1); + Assert.assertEquals(1, (int) result2.get()); + + RayObject result3 = Ray.call(Adder::add2, 1); + Assert.assertEquals(2, (int) result3.get()); + + RayObject result4 = Ray.call(ActorTest::sayWorld, 2, adder); + Assert.assertEquals(14, (int) result4.get()); + + RayActor adder2 = Ray.create(Adder2.class); + Ray.call(Adder2::setAdder, adder2, adder); + RayObject 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 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 result8 = Ray.call(Adder::testObjectList, adder); + Assert.assertEquals(11, (int) result8.get()); + } + + @RayRemote + public static class Adder { + + private List> objectList; + + public Integer set(Integer n) { + sum = n; + return sum; + } + + public Integer increase() { + return (++sum); + } + + public Integer add(Integer n) { + return (sum += n); + } + + public static Integer add2(Integer n) { + return n + 1; + } + + public Integer setObjectList(List> objectList) { + this.objectList = objectList; + return 1; + } + + public Integer testObjectList() { + return ((RayObject) objectList.get(0)).get(); + } + + private Integer sum = 0; + } + + @RayRemote + public static Integer sayWorld(Integer n, RayActor adder) { + RayObject result = Ray.call(ActorTest.Adder::add, adder, 1); + return result.get() + n; + } + + @RayRemote + public static class Adder2 { + + private RayActor adder; + + private List> adderList; + + private UniqueID id; + + public Integer set(Integer n) { + sum = n; + return sum; + } + + public Integer increase() { + RayObject result = Ray.call(Adder::increase, adder); + Assert.assertEquals(13, (int) result.get()); + return (++sum); + } + + public Integer testActorList() { + RayActor temp = adderList.get(0); + RayObject result = Ray.call(Adder::increase, temp); + return result.get(); + } + + public Integer add(Integer n) { + return (sum += n); + } + + public static Integer add2(Adder a, Integer n) { + return n + 1; + } + + public RayActor getAdder() { + return adder; + } + + public Integer setAdder(RayActor 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> adderList) { + this.adderList = adderList; + return 0; + } + + private Integer sum = 0; + } +} diff --git a/java/test/src/main/java/org/ray/api/test/EchoTest.java b/java/test/src/main/java/org/ray/api/test/EchoTest.java new file mode 100644 index 000000000000..ce56205c8ab7 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/EchoTest.java @@ -0,0 +1,46 @@ +package org.ray.api.test; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ray.api.Ray; +import org.ray.api.RayRemote; + +@RunWith(MyRunner.class) +public class EchoTest { + + @Test + public void test() { + long startTime, endTime; + for (int i = 0; i < 100; i++) { + startTime = System.nanoTime(); + String ret = echo("Ray++" + i); + endTime = System.nanoTime(); + System.out.println("echo: " + ret + " , total time is " + (endTime - startTime)); + } + } + + + public String echo(String who) { + + return Ray.call( + EchoTest::recho, + Ray.call(EchoTest::Hi), + Ray.call(EchoTest::Who, who) + ).get(); + } + + @RayRemote + public static String Hi() { + return "Hi"; + } + + @RayRemote + public static String Who(String who) { + return who; + } + + @RayRemote + public static String recho(String pre, String who) { + return pre + ", " + who + "!"; + } +} diff --git a/java/test/src/main/java/org/ray/api/test/HelloWorldTest.java b/java/test/src/main/java/org/ray/api/test/HelloWorldTest.java new file mode 100644 index 000000000000..eb88d945cefc --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/HelloWorldTest.java @@ -0,0 +1,51 @@ +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.RayObject; +import org.ray.api.RayRemote; +import org.ray.util.logger.RayLog; + +/** + * Hello world + */ +@RunWith(MyRunner.class) +public class HelloWorldTest { + + @Test + public void test() { + String helloWorld = sayHelloWorld(); + RayLog.rapp.info(helloWorld); + Assert.assertEquals("hello,world!", helloWorld); + Assert.assertTrue(Ray.call(TypesTest::sayBool).get()); + } + + public String sayHelloWorld() { + RayObject hello = Ray.call(HelloWorldTest::sayHello); + RayObject world = Ray.call(HelloWorldTest::sayWorld); + return Ray.call(HelloWorldTest::merge, hello, world).get(); + } + + @RayRemote + public static String sayHello() { + String ret = "he"; + ret += "llo"; + RayLog.rapp.info("real say hello"); + //throw new RuntimeException("+++++++++++++++++++++hello exception"); + return ret; + } + + @RayRemote + public static String sayWorld() { + String ret = "world"; + ret += "!"; + return ret; + } + + @RayRemote + public static String merge(String hello, String world) { + return hello + "," + world; + } +} diff --git a/java/test/src/main/java/org/ray/api/test/MemoryWordCountTest.java b/java/test/src/main/java/org/ray/api/test/MemoryWordCountTest.java new file mode 100644 index 000000000000..a95686d3b3c0 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/MemoryWordCountTest.java @@ -0,0 +1,71 @@ +package org.ray.api.test; + +import java.util.ArrayList; +import java.util.List; +import java.util.SortedMap; +import org.apache.commons.lang3.tuple.Pair; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ray.api.experiment.mr.MemoryMapReduce; + +/** + * test the MapReduce interface + */ +@RunWith(MyRunner.class) +public class MemoryWordCountTest { + + public static class MemoryWordCount extends MemoryMapReduce { + + public List> Map(String input) { + ArrayList> counts = new ArrayList<>(); + for (String s : input.split(" ")) { + counts.add(Pair.of(s, 1)); + } + return counts; + } + + public Integer Reduce(String k, List values) { + return values.size(); + } + } + + @Test + public void test() { + List> iinputs = new ArrayList<>(); + List inputs = new ArrayList<>(); + inputs.add("1 3 5 7 9"); + inputs.add("0 2 4 6 8"); + iinputs.add(inputs); + + inputs = new ArrayList<>(); + inputs.add("1 2 3 4 5 6 7 8 9 0"); + inputs.add("1 3 5 7 9"); + iinputs.add(inputs); + + inputs = new ArrayList<>(); + inputs.add("1 2 3 4 5 6 7 8 9 0"); + inputs.add("0 2 4 6 8"); + iinputs.add(inputs); + + inputs = new ArrayList<>(); + inputs.add("1 2 3 4 5 6 7 8 9 0"); + inputs.add("1 3 5 7 9"); + inputs.add("0 2 4 6 8"); + iinputs.add(inputs); + + MemoryWordCount wc = new MemoryWordCount(); + SortedMap result = wc.Run(iinputs, 2, 2); + + Assert.assertEquals(6, (int) result.get("0")); + Assert.assertEquals(6, (int) result.get("1")); + Assert.assertEquals(6, (int) result.get("2")); + Assert.assertEquals(6, (int) result.get("3")); + Assert.assertEquals(6, (int) result.get("4")); + Assert.assertEquals(6, (int) result.get("5")); + Assert.assertEquals(6, (int) result.get("6")); + Assert.assertEquals(6, (int) result.get("7")); + Assert.assertEquals(6, (int) result.get("8")); + Assert.assertEquals(6, (int) result.get("9")); + } +} diff --git a/java/test/src/main/java/org/ray/api/test/MyRunner.java b/java/test/src/main/java/org/ray/api/test/MyRunner.java new file mode 100644 index 000000000000..3c7b755f5bbb --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/MyRunner.java @@ -0,0 +1,19 @@ +package org.ray.api.test; + +import org.junit.runner.notification.RunNotifier; +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.InitializationError; + +public class MyRunner extends BlockJUnit4ClassRunner { + + public MyRunner(Class klass) throws InitializationError { + super(klass); + } + + @Override + public void run(RunNotifier notifier) { + notifier.addListener(new TestListener()); + notifier.fireTestRunStarted(getDescription()); + super.run(notifier); + } +} diff --git a/java/test/src/main/java/org/ray/api/test/RayMethodsTest.java b/java/test/src/main/java/org/ray/api/test/RayMethodsTest.java new file mode 100644 index 000000000000..39f4233264b6 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/RayMethodsTest.java @@ -0,0 +1,54 @@ +package org.ray.api.test; + +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.RayList; +import org.ray.api.RayObject; +import org.ray.api.WaitResult; +import org.ray.util.logger.RayLog; + +/** + * Integration test for Ray.* + */ +@RunWith(MyRunner.class) +public class RayMethodsTest { + + @Test + public void test() { + RayObject i1Id = Ray.put(1); + RayObject f1Id = Ray.put(3.14); + RayObject s1Id = Ray.put(String.valueOf("Hello ")); + RayObject s2Id = Ray.put(String.valueOf("World!")); + RayObject n1Id = Ray.put(null); + + RayList wIds = new RayList<>(); + wIds.add(s1Id); + wIds.add(s2Id); + WaitResult readys = Ray.wait(wIds, 2); + + List ss = readys.getReadyOnes().get(); + int i1 = i1Id.get(); + double f1 = f1Id.get(); + Object n1 = n1Id.get(); + + RayLog.rapp.info("Strings: " + ss.get(0) + ss.get(1) + + " int: " + i1 + + " double: " + f1 + + " null: " + n1); + Assert.assertEquals("Hello World!", ss.get(0) + ss.get(1)); + Assert.assertEquals(1, i1); + Assert.assertEquals(3.14, f1, Double.MIN_NORMAL); + Assert.assertNull(n1); + + // metadata test + RayObject vId = Ray.put(643, "test metadata"); + Integer v = vId.get(); + String m = vId.getMeta(); + + Assert.assertEquals(643L, v.longValue()); + Assert.assertEquals("test metadata", m); + } +} diff --git a/java/test/src/main/java/org/ray/api/test/RemoteLambdaTest.java b/java/test/src/main/java/org/ray/api/test/RemoteLambdaTest.java new file mode 100644 index 000000000000..09fa1eb7c446 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/RemoteLambdaTest.java @@ -0,0 +1,43 @@ +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 String RemoteToString(T o) { + return o.toString(); + } + + @Test + public void test() { + + RemoteFunction f0 = RemoteLambdaTest::RemoteToString; + byte[] bytes = SerializationUtils.serialize(f0); + //System.out.println(new String(bytes)); + //Object m = SerializationUtils.deserialize(bytes); + + RemoteFunction f = x -> + { + System.out.println("remote function " + x); + return x + 1; + }; + + RemoteFunction f2 = SerializationUtils.clone(f); + Assert.assertEquals(101, (int) f2.apply(100)); + + Integer y = 100; + RemoteFunction f3 = x -> + { + System.out.println("remote function " + x); + return x + y + 1; + }; + RemoteFunction f4 = SerializationUtils.clone(f3); + Assert.assertEquals(201, (int) f4.apply(100)); + Assert.assertEquals(201, (int) f4.apply(100)); + } +} diff --git a/java/test/src/main/java/org/ray/api/test/RewriteTest.java b/java/test/src/main/java/org/ray/api/test/RewriteTest.java new file mode 100644 index 000000000000..e79606f65e61 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/RewriteTest.java @@ -0,0 +1,13 @@ +package org.ray.api.test; + +import java.io.IOException; +import java.util.zip.DataFormatException; +import org.ray.hook.JarRewriter; + +public class RewriteTest { + + public static void main(String[] args) throws IOException, DataFormatException { + System.out.println(System.getProperty("user.dir")); + JarRewriter.rewrite("target", "target2"); + } +} diff --git a/java/test/src/main/java/org/ray/api/test/RpcTest.java b/java/test/src/main/java/org/ray/api/test/RpcTest.java new file mode 100644 index 000000000000..aca61e68ed75 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/RpcTest.java @@ -0,0 +1,39 @@ +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 { + + @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()); + } + + @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; + } +} diff --git a/java/test/src/main/java/org/ray/api/test/TestListener.java b/java/test/src/main/java/org/ray/api/test/TestListener.java new file mode 100644 index 000000000000..5af2dfb227ee --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/TestListener.java @@ -0,0 +1,20 @@ +package org.ray.api.test; + +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 { + + @Override + public void testRunStarted(Description description) { + Ray.init(); + } + + @Override + public void testRunFinished(Result result) { + RayRuntime.getInstance().cleanUp(); + } +} \ No newline at end of file diff --git a/java/test/src/main/java/org/ray/api/test/TwoClassTest.java b/java/test/src/main/java/org/ray/api/test/TwoClassTest.java new file mode 100644 index 000000000000..fa0083507926 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/TwoClassTest.java @@ -0,0 +1,20 @@ +package org.ray.api.test; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ray.api.Ray; + +/** + * local test in IDE, for class lazy load + */ +@RunWith(MyRunner.class) +public class TwoClassTest { + + @Test + public void testLocal() { + Assert.assertTrue( + Ray.call(TypesTest::sayBool).get());//call function in other class which may not be loaded + } + +} diff --git a/java/test/src/main/java/org/ray/api/test/TypesTest.java b/java/test/src/main/java/org/ray/api/test/TypesTest.java new file mode 100644 index 000000000000..9fad470d3793 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/TypesTest.java @@ -0,0 +1,202 @@ +package org.ray.api.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ray.api.Ray; +import org.ray.api.RayList; +import org.ray.api.RayMap; +import org.ray.api.RayObject; +import org.ray.api.RayRemote; +import org.ray.api.returns.MultipleReturns2; +import org.ray.api.returns.RayObjects2; + +/** + * types test + */ +@RunWith(MyRunner.class) +public class TypesTest { + + @Test + public void test() { + sayTypes(); + } + + public void sayTypes() { + + Assert.assertEquals(1, (int) Ray.call(TypesTest::sayInt).get()); + Assert.assertEquals(1, (byte) Ray.call(TypesTest::sayByte).get()); + Assert.assertEquals(1, (short) Ray.call(TypesTest::sayShort).get()); + Assert.assertEquals(1, (long) Ray.call(TypesTest::sayLong).get()); + Assert.assertEquals(1.0, Ray.call(TypesTest::sayDouble).get(), 0.0); + Assert.assertEquals(1.0f, Ray.call(TypesTest::sayFloat).get(), 0.0); + Assert.assertEquals(true, Ray.call(TypesTest::sayBool).get()); + Assert.assertEquals("object", Ray.call(TypesTest::sayReference).get()); + + RayObjects2 refs = Ray.call_2(TypesTest::sayReferences); + Assert.assertEquals(123, (int) refs.r0().get()); + Assert.assertEquals("123", refs.r1().get()); + + RayMap futureRs = Ray.call_n(TypesTest::sayReferencesN, + Arrays.asList(1, 2, 4, 3), "n_refs_", "_suffix"); + for (Entry> fne : futureRs.EntrySet()) { + Assert.assertEquals(fne.getValue().get(), "n_refs_" + fne.getKey() + "_suffix"); + } + + RayMap futureRs2 = Ray.call_n(TypesTest::sayReferencesN, + Arrays.asList(1), "n_refs_", "_suffix"); + for (Entry> fne : futureRs2.EntrySet()) { + Assert.assertEquals(fne.getValue().get(), "n_refs_" + fne.getKey() + "_suffix"); + } + + RayObject future = Ray.call(TypesTest::sayRayFuture); + Assert.assertEquals(123, (int) future.get()); + RayObjects2 futures = Ray.call_2(TypesTest::sayRayFutures); + Assert.assertEquals(123, (int) futures.r0().get()); + Assert.assertEquals("123", futures.r1().get()); + RayMap futureNs = Ray.call_n(TypesTest::sayRayFuturesN, + Arrays.asList(1, 2, 4, 3), "n_futures_"); + for (Entry> fne : futureNs.EntrySet()) { + Assert.assertEquals(fne.getValue().get(), "n_futures_" + fne.getKey()); + } + + RayList ns = Ray.call_n(TypesTest::sayArray, 10, 10); + for (int i = 0; i < 10; i++) { + Assert.assertEquals(i, (int) ns.Get(i).get()); + } + + RayList ns2 = Ray.call_n(TypesTest::sayArray, 1, 1); + Assert.assertEquals(0, (int) ns2.Get(0).get()); + + RayObject> ns3 = Ray.call(TypesTest::sayArray, 1); + Assert.assertEquals(0, (int) ns3.get().get(0)); + + RayList ints = new RayList<>(); + ints.add(Ray.call(TypesTest::sayInt)); + ints.add(Ray.call(TypesTest::sayInt)); + ints.add(Ray.call(TypesTest::sayInt)); + // TODO: when RayParameters.use_remote_lambda is on, we have to explicitly + // cast RayList and RayMap to List and Map explicitly, so that the parameter + // types of the lambdas can be correctly deducted. + RayObject collection = Ray.call(TypesTest::sayReadRayList, (List) ints); + Assert.assertEquals(3, (int) collection.get()); + + RayMap namedInts = new RayMap(); + namedInts.put("a", Ray.call(TypesTest::sayInt)); + namedInts.put("b", Ray.call(TypesTest::sayInt)); + namedInts.put("c", Ray.call(TypesTest::sayInt)); + RayObject collection2 = Ray + .call(TypesTest::sayReadRayMap, (Map) namedInts); + Assert.assertEquals(3, (int) collection2.get()); + } + + @RayRemote + public static int sayInt() { + return 1; + } + + @RayRemote + public static byte sayByte() { + return 1; + } + + @RayRemote + public static short sayShort() { + return 1; + } + + @RayRemote + public static long sayLong() { + return 1; + } + + @RayRemote + public static double sayDouble() { + return 1; + } + + @RayRemote + public static float sayFloat() { + return 1; + } + + @RayRemote + public static boolean sayBool() { + return true; + } + + @RayRemote + public static Object sayReference() { + return "object"; + } + + @RayRemote + public static MultipleReturns2 sayReferences() { + return new MultipleReturns2<>(123, "123"); + } + + @RayRemote + public static Map sayReferencesN(Collection userReturnIds, + String prefix, String suffix) { + Map ret = new HashMap<>(); + for (Integer returnid : userReturnIds) { + ret.put(returnid, prefix + returnid + suffix); + } + return ret; + } + + @RayRemote + public static List sayArray(Integer returnCount) { + ArrayList rets = new ArrayList<>(); + for (int i = 0; i < returnCount; i++) { + rets.add(i); + } + return rets; + } + + @RayRemote(externalIO = true) + public static Integer sayRayFuture() { + return 123; + } + + @RayRemote(externalIO = true) + public static MultipleReturns2 sayRayFutures() { + return new MultipleReturns2<>(123, "123"); + } + + @RayRemote(externalIO = true) + public static Map sayRayFuturesN( + Collection userReturnIds, + String prefix) { + Map ret = new HashMap<>(); + for (int id : userReturnIds) { + ret.put(id, prefix + id); + } + return ret; + } + + @RayRemote + public static int sayReadRayList(List ints) { + int sum = 0; + for (Integer i : ints) { + sum += i; + } + return sum; + } + + @RayRemote + public static int sayReadRayMap(Map ints) { + int sum = 0; + for (Integer i : ints.values()) { + sum += i; + } + return sum; + } +} diff --git a/java/test/src/main/java/org/ray/api/test/UniqueIDTest.java b/java/test/src/main/java/org/ray/api/test/UniqueIDTest.java new file mode 100644 index 000000000000..d28f9e7d900b --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/UniqueIDTest.java @@ -0,0 +1,38 @@ +package org.ray.api.test; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ray.api.RayObject; +import org.ray.api.RayRemote; +import org.ray.api.UniqueID; +import org.ray.api.funcs.RayFunc_1_1; +import org.ray.core.RayRuntime; +import org.ray.core.UniqueIdHelper; + +@RunWith(MyRunner.class) +public class UniqueIDTest { + + @Test + public void test() { + UniqueID tid = UniqueIdHelper.nextTaskId(0xdeadbeefL); + UniqueIdHelper.setTest(tid, true); + System.out.println("Tested task id = " + tid); + RayFunc_1_1 f = UniqueIDTest::hi; + RayObject result = new RayObject<>( + RayRuntime.getInstance().call( + tid, + RayFunc_1_1.class, + f, + 1, 1 + ).getObjs()[0].getId() + ); + System.out.println("Tested task return object id = " + result.getId()); + Assert.assertEquals("hi1", result.get()); + } + + @RayRemote + public static String hi(Integer i) { + return "hi" + i; + } +} diff --git a/java/test/src/main/java/org/ray/api/test/WordCountTest.java b/java/test/src/main/java/org/ray/api/test/WordCountTest.java new file mode 100644 index 000000000000..0e73bd2cb9f3 --- /dev/null +++ b/java/test/src/main/java/org/ray/api/test/WordCountTest.java @@ -0,0 +1,74 @@ +package org.ray.api.test; + +import java.io.FileNotFoundException; +import java.util.Arrays; +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.util.FileUtil; + +/** + * given a directory of document files on each "machine", we would like to count the appearance of + * some word + */ +public class WordCountTest { + + //@Test + public void test() { + int sum = mapReduce(); + Assert.assertEquals(sum, 143); + } + + public int mapReduce() { + RayObject> machines = Ray.call(WordCountTest::getMachineList); + RayObject total = null; + for (String machine : machines.get()) { + RayObject wordcount = Ray.call(WordCountTest::countWord, machine, "ray"); + if (total == null) { + total = wordcount; + } else { + total = Ray.call(WordCountTest::sum, total, wordcount); + } + } + return total.get(); + } + + @RayRemote + public static List getMachineList() { + return Arrays.asList("A", "B", "C"); + } + + @RayRemote + public static Integer countWord(String machine, String word) { + + String log; + try { + log = FileUtil.readResourceFile("mapreduce/" + machine + ".log"); + } catch (FileNotFoundException e) { + e.printStackTrace(); + log = ""; + } + log = log.toLowerCase(); + int start = 0; + int count = 0; + while (true) { + if (start >= log.length()) { + break; + } + int index = log.indexOf(word, start); + if (index == -1) { + break; + } + start = index + word.length(); + count++; + } + return count; + } + + @RayRemote + public static Integer sum(Integer a, Integer/*TODO modify int to Integer in ASM hook*/ b) { + return a + b; + } +} diff --git a/setup_thirdparty.sh b/setup_thirdparty.sh index 77014226c2f4..430e5d86d861 100755 --- a/setup_thirdparty.sh +++ b/setup_thirdparty.sh @@ -13,4 +13,15 @@ else fi echo "Using Python executable $PYTHON_EXECUTABLE." -$TP_DIR/thirdparty/scripts/setup.sh $PYTHON_EXECUTABLE +LANGUAGE="python" +if [[ -n "$2" ]]; then + LANGUAGE=$2 +fi + +$TP_DIR/thirdparty/scripts/setup.sh $PYTHON_EXECUTABLE $LANGUAGE + +if [[ "$LANGUAGE" == "java" ]]; then + pushd thirdparty/build/arrow/java + mvn clean install -pl plasma -am -Dmaven.test.skip + popd +fi diff --git a/thirdparty/scripts/build_arrow.sh b/thirdparty/scripts/build_arrow.sh index 402b4d65453a..7640a9ee1462 100755 --- a/thirdparty/scripts/build_arrow.sh +++ b/thirdparty/scripts/build_arrow.sh @@ -15,6 +15,12 @@ else fi echo "Using Python executable $PYTHON_EXECUTABLE." +LANGUAGE="python" +if [[ -n "$2" ]]; then + LANGUAGE=$2 +fi +echo "Build language is $LANGUAGE." + unamestr="$(uname)" if [[ "$unamestr" == "Linux" ]]; then @@ -44,10 +50,10 @@ if [[ ! -d $TP_DIR/../python/ray/pyarrow_files/pyarrow ]]; then pushd $TP_DIR/build/arrow git fetch origin master - # The PR for this commit is https://github.com/apache/arrow/pull/2073. We + # The PR for this commit is https://github.com/apache/arrow/pull/2065. We # include the link here to make it easier to find the right commit because # Arrow often rewrites git history and invalidates certain commits. - git checkout 1d9d8939efe54a640b46fcbe8e14e5b347c7a422 + git checkout ce23c06469de9cf0c3e38e35cdb8d135f341b964 cd cpp if [ ! -d "build" ]; then @@ -55,6 +61,11 @@ if [[ ! -d $TP_DIR/../python/ray/pyarrow_files/pyarrow ]]; then fi cd build + BUILD_ARROW_PLASMA_JAVA_CLIENT=off + if [[ "$LANGUAGE" == "java" ]]; then + BUILD_ARROW_PLASMA_JAVA_CLIENT=on + fi + ARROW_HOME=$TP_DIR/pkg/arrow/cpp/build/cpp-install BOOST_ROOT=$TP_DIR/pkg/boost \ FLATBUFFERS_HOME=$FLATBUFFERS_HOME \ @@ -74,6 +85,7 @@ if [[ ! -d $TP_DIR/../python/ray/pyarrow_files/pyarrow ]]; then -DARROW_WITH_LZ4=off \ -DARROW_WITH_ZLIB=off \ -DARROW_WITH_ZSTD=off \ + -DARROW_PLASMA_JAVA_CLIENT=$BUILD_ARROW_PLASMA_JAVA_CLIENT \ .. make VERBOSE=1 -j$PARALLEL make install diff --git a/thirdparty/scripts/setup.sh b/thirdparty/scripts/setup.sh index 633da0b6da2f..6dd8d93862d3 100755 --- a/thirdparty/scripts/setup.sh +++ b/thirdparty/scripts/setup.sh @@ -18,6 +18,12 @@ else fi echo "Using Python executable $PYTHON_EXECUTABLE." +LANGUAGE="python" +if [[ -n "$2" ]]; then + LANGUAGE=$2 +fi +echo "Build language is $LANGUAGE." + unamestr="$(uname)" ############################################## @@ -46,7 +52,7 @@ fi ############################################## # arrow ############################################## -bash "$TP_SCRIPT_DIR/build_arrow.sh" $PYTHON_EXECUTABLE +bash "$TP_SCRIPT_DIR/build_arrow.sh" $PYTHON_EXECUTABLE $LANGUAGE ############################################## # parquet (skipped as it is inlined in build_arrow.sh)