mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 21:38:18 +08:00
[JavaWorker] Java code lint check and binding to CI (#2225)
* add java code lint check and fix the java code lint error * add java doc lint check and fix the java doc lint error * add java code and doc lint to the CI
This commit is contained in:
committed by
Philipp Moritz
parent
5789a247f9
commit
3b5e700fd7
+43
-44
@@ -1,54 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-api</artifactId>
|
||||
<name>java api for ray</name>
|
||||
<description>java api for ray</description>
|
||||
<url></url>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-api</artifactId>
|
||||
<name>java api for ray</name>
|
||||
<description>java api for ray</description>
|
||||
<url></url>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-common</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-common</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.ruedigermoeller</groupId>
|
||||
<artifactId>fst</artifactId>
|
||||
<version>2.47</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.arrow</groupId>
|
||||
<artifactId>arrow-plasma</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/commons-cli/commons-cli -->
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.ruedigermoeller</groupId>
|
||||
<artifactId>fst</artifactId>
|
||||
<version>2.47</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.arrow</groupId>
|
||||
<artifactId>arrow-plasma</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -7,12 +7,14 @@ import org.ray.util.logger.DynamicLog;
|
||||
import org.ray.util.logger.RayLog;
|
||||
|
||||
/**
|
||||
* Ray API
|
||||
* Ray API.
|
||||
*/
|
||||
public final class Ray extends Rpc {
|
||||
|
||||
private static RayApi impl = null;
|
||||
|
||||
/**
|
||||
* initialize the current worker or the single-box cluster
|
||||
* initialize the current worker or the single-box cluster.
|
||||
*/
|
||||
public static void init() {
|
||||
if (impl == null) {
|
||||
@@ -21,44 +23,44 @@ public final class Ray extends Rpc {
|
||||
}
|
||||
|
||||
/**
|
||||
* Put obj into object store
|
||||
* Put obj into object store.
|
||||
*/
|
||||
public static <T> RayObject<T> put(T obj) {
|
||||
return impl.put(obj);
|
||||
}
|
||||
|
||||
public static <T, TM> RayObject<T> put(T obj, TM metadata) {
|
||||
public static <T, TMT> RayObject<T> put(T obj, TMT metadata) {
|
||||
return impl.put(obj, metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get obj(s) from object store
|
||||
* Get obj(s) from object store.
|
||||
*/
|
||||
static <T> T get(UniqueID objectId) throws TaskExecutionException {
|
||||
return impl.get(objectId);
|
||||
}
|
||||
|
||||
static <T> T getMeta(UniqueID objectId) throws TaskExecutionException {
|
||||
return impl.getMeta(objectId);
|
||||
}
|
||||
|
||||
static <T> List<T> get(List<UniqueID> objectIds) throws TaskExecutionException {
|
||||
return impl.get(objectIds);
|
||||
}
|
||||
|
||||
static <T> T getMeta(UniqueID objectId) throws TaskExecutionException {
|
||||
return impl.getMeta(objectId);
|
||||
}
|
||||
|
||||
static <T> List<T> getMeta(List<UniqueID> objectIds) throws TaskExecutionException {
|
||||
return impl.getMeta(objectIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* wait until timeout or enough RayObject are ready
|
||||
* wait until timeout or enough RayObject are ready.
|
||||
*
|
||||
* @param waitfor wait for who
|
||||
* @param numReturns how many of ready is enough
|
||||
* @param waitfor wait for who
|
||||
* @param numReturns how many of ready is enough
|
||||
* @param timeoutMilliseconds in millisecond
|
||||
*/
|
||||
public static <T> WaitResult<T> wait(RayList<T> waitfor, int numReturns,
|
||||
int timeoutMilliseconds) {
|
||||
int timeoutMilliseconds) {
|
||||
return impl.wait(waitfor, numReturns, timeoutMilliseconds);
|
||||
}
|
||||
|
||||
@@ -77,7 +79,7 @@ public final class Ray extends Rpc {
|
||||
}
|
||||
|
||||
/**
|
||||
* create actor object
|
||||
* create actor object.
|
||||
*/
|
||||
public static <T> RayActor<T> create(Class<T> cls) {
|
||||
try {
|
||||
@@ -95,23 +97,21 @@ public final class Ray extends Rpc {
|
||||
}
|
||||
|
||||
/**
|
||||
* get underlying runtime
|
||||
* get underlying runtime.
|
||||
*/
|
||||
static RayApi internal() {
|
||||
return impl;
|
||||
}
|
||||
|
||||
/**
|
||||
* whether to use remote lambda
|
||||
* whether to use remote lambda.
|
||||
*/
|
||||
public static boolean isRemoteLambda() {
|
||||
return impl.isRemoteLambda();
|
||||
}
|
||||
|
||||
private static RayApi impl = null;
|
||||
|
||||
/**
|
||||
* for ray's app's log
|
||||
* for ray's app's log.
|
||||
*/
|
||||
public static DynamicLog getRappLogger() {
|
||||
return RayLog.rapp;
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.io.ObjectOutput;
|
||||
import org.ray.util.Sha1Digestor;
|
||||
|
||||
/**
|
||||
* Ray actor abstraction
|
||||
* Ray actor abstraction.
|
||||
*/
|
||||
public class RayActor<T> extends RayObject<T> implements Externalizable {
|
||||
|
||||
@@ -40,7 +40,7 @@ public class RayActor<T> extends RayObject<T> implements Externalizable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter method for property <tt>taskCursor</tt>
|
||||
* Getter method for property <tt>taskCursor</tt>.
|
||||
*
|
||||
* @return property value of taskCursor
|
||||
*/
|
||||
@@ -49,7 +49,7 @@ public class RayActor<T> extends RayObject<T> implements Externalizable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for property <tt>taskCursor</tt>
|
||||
* Setter method for property <tt>taskCursor</tt>.
|
||||
*
|
||||
* @param taskCursor value to be assigned to property taskCursor
|
||||
*/
|
||||
@@ -57,11 +57,6 @@ public class RayActor<T> extends RayObject<T> implements Externalizable {
|
||||
this.taskCursor = taskCursor;
|
||||
}
|
||||
|
||||
public UniqueID computeNextActorHandleId() {
|
||||
byte[] bytes = Sha1Digestor.digest(actorHandleId.id, ++forksNum);
|
||||
return new UniqueID(bytes);
|
||||
}
|
||||
|
||||
public UniqueID getActorHandleId() {
|
||||
return actorHandleId;
|
||||
}
|
||||
@@ -77,6 +72,11 @@ public class RayActor<T> extends RayObject<T> implements Externalizable {
|
||||
out.writeObject(this.taskCursor);
|
||||
}
|
||||
|
||||
public UniqueID computeNextActorHandleId() {
|
||||
byte[] bytes = Sha1Digestor.digest(actorHandleId.id, ++forksNum);
|
||||
return new UniqueID(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
|
||||
|
||||
|
||||
@@ -7,95 +7,98 @@ import org.ray.api.internal.Callable;
|
||||
import org.ray.util.exception.TaskExecutionException;
|
||||
|
||||
/**
|
||||
* Ray runtime abstraction
|
||||
* Ray runtime abstraction.
|
||||
*/
|
||||
public interface RayApi {
|
||||
|
||||
/**
|
||||
* Put obj into object store
|
||||
* Put obj into object store.
|
||||
*
|
||||
* @return RayObject
|
||||
*/
|
||||
<T> RayObject<T> put(T obj);
|
||||
|
||||
<T, TM> RayObject<T> put(T obj, TM metadata);
|
||||
<T, TMT> RayObject<T> put(T obj, TMT metadata);
|
||||
|
||||
/**
|
||||
* Get real obj from object store
|
||||
* Get real obj from object store.
|
||||
*/
|
||||
<T> T get(UniqueID objectId) throws TaskExecutionException;
|
||||
|
||||
<T> T getMeta(UniqueID objectId) throws TaskExecutionException;
|
||||
|
||||
/**
|
||||
* Get real objects from object store
|
||||
* Get real objects from object store.
|
||||
*
|
||||
* @param objectIds list of ids of objects to get
|
||||
*/
|
||||
<T> List<T> get(List<UniqueID> objectIds) throws TaskExecutionException;
|
||||
|
||||
<T> T getMeta(UniqueID objectId) throws TaskExecutionException;
|
||||
|
||||
<T> List<T> getMeta(List<UniqueID> objectIds) throws TaskExecutionException;
|
||||
|
||||
/**
|
||||
* wait until timeout or enough RayObjects are ready
|
||||
* wait until timeout or enough RayObjects are ready.
|
||||
*
|
||||
* @param waitfor wait for who
|
||||
* @param waitfor wait for who
|
||||
* @param numReturns how many of ready is enough
|
||||
* @param timeout in millisecond
|
||||
* @param timeout in millisecond
|
||||
*/
|
||||
<T> WaitResult<T> wait(RayList<T> waitfor, int numReturns, int timeout);
|
||||
|
||||
/**
|
||||
* create remote actor
|
||||
* create remote actor.
|
||||
*/
|
||||
<T> RayActor<T> create(Class<T> cls);
|
||||
|
||||
/**
|
||||
* submit a new task by invoking a remote function
|
||||
* submit a new task by invoking a remote function.
|
||||
*
|
||||
* @param taskId nil
|
||||
* @param funcRun the target running function with @RayRemote
|
||||
* @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<original-type>
|
||||
* @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);
|
||||
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)
|
||||
* outputs with a set of labels (usually with Integer or String).
|
||||
*
|
||||
* @param taskId nil
|
||||
* @param funcRun the target running function with @RayRemote
|
||||
* @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<original-type>
|
||||
* @param args arguments to this funcRun, can be its original form or
|
||||
* RayObject<original-type>
|
||||
* @return a set of ray objects with their labels and return ids
|
||||
*/
|
||||
<R, RID> RayMap<RID, R> callWithReturnLabels(UniqueID taskId, Callable funcRun,
|
||||
Collection<RID> returnIds, Object... args);
|
||||
<R, RIDT> RayMap<RIDT, R> callWithReturnLabels(UniqueID taskId, Callable funcRun,
|
||||
Collection<RIDT> returnIds, Object... args);
|
||||
|
||||
<R, RID> RayMap<RID, R> callWithReturnLabels(UniqueID taskId, Class<?> funcCls,
|
||||
Serializable lambda, Collection<RID> returnids, Object... args);
|
||||
<R, RIDT> RayMap<RIDT, R> callWithReturnLabels(UniqueID taskId, Class<?> funcCls,
|
||||
Serializable lambda, Collection<RIDT> returnids,
|
||||
Object... args);
|
||||
|
||||
/**
|
||||
* a special case for the above RID-based labeling as <0...returnCount - 1>
|
||||
* 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 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<original-type>
|
||||
* @param args arguments to this funcRun, can be its original form or
|
||||
* RayObject<original-type>
|
||||
* @return an array of returned objects with their Unique ids
|
||||
*/
|
||||
<R> RayList<R> callWithReturnIndices(UniqueID taskId, Callable funcRun, Integer returnCount,
|
||||
Object... args);
|
||||
Object... args);
|
||||
|
||||
<R> RayList<R> callWithReturnIndices(UniqueID taskId, Class<?> funcCls, Serializable lambda,
|
||||
Integer returnCount, Object... args);
|
||||
Integer returnCount, Object... args);
|
||||
|
||||
boolean isRemoteLambda();
|
||||
}
|
||||
|
||||
@@ -38,15 +38,16 @@ public class RayList<E> extends ArrayList<E> {
|
||||
return ids.contains(o);
|
||||
}
|
||||
|
||||
@RayDisabled
|
||||
@Deprecated
|
||||
@Override
|
||||
public Iterator<E> iterator() {
|
||||
throw new UnsupportedOperationException();
|
||||
public int indexOf(Object o) {
|
||||
//throw new UnsupportedOperationException();
|
||||
return ids.indexOf(o);
|
||||
}
|
||||
|
||||
public Iterator<RayObject<E>> Iterator() {
|
||||
return ids.iterator();
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
//throw new UnsupportedOperationException();
|
||||
return ids.lastIndexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -61,6 +62,30 @@ public class RayList<E> extends ArrayList<E> {
|
||||
return ids.toArray(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
return ids.get(index).get();
|
||||
}
|
||||
|
||||
public List<E> get() {
|
||||
List<UniqueID> objectIds = new ArrayList<>();
|
||||
for (RayObject<E> id : ids) {
|
||||
objectIds.add(id.getId());
|
||||
}
|
||||
return Ray.get(objectIds);
|
||||
}
|
||||
|
||||
@RayDisabled
|
||||
@Deprecated
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public RayObject<E> set(int index, RayObject<E> element) {
|
||||
return ids.set(index, element);
|
||||
}
|
||||
|
||||
@RayDisabled
|
||||
@Deprecated
|
||||
@Override
|
||||
@@ -68,10 +93,28 @@ public class RayList<E> extends ArrayList<E> {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@RayDisabled
|
||||
@Deprecated
|
||||
@Override
|
||||
public void add(int index, E element) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public boolean add(RayObject<E> e) {
|
||||
return ids.add(e);
|
||||
}
|
||||
|
||||
public void add(int index, RayObject<E> element) {
|
||||
ids.add(index, element);
|
||||
}
|
||||
|
||||
@RayDisabled
|
||||
@Deprecated
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
//throw new UnsupportedOperationException();
|
||||
@@ -79,9 +122,9 @@ public class RayList<E> extends ArrayList<E> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
public void clear() {
|
||||
//throw new UnsupportedOperationException();
|
||||
return ids.containsAll(c);
|
||||
ids.clear();
|
||||
}
|
||||
|
||||
@RayDisabled
|
||||
@@ -110,86 +153,13 @@ public class RayList<E> extends ArrayList<E> {
|
||||
return ids.retainAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
//throw new UnsupportedOperationException();
|
||||
ids.clear();
|
||||
}
|
||||
|
||||
public List<E> get() {
|
||||
List<UniqueID> objectIds = new ArrayList<>();
|
||||
for (RayObject<E> id : ids) {
|
||||
objectIds.add(id.getId());
|
||||
}
|
||||
return Ray.get(objectIds);
|
||||
}
|
||||
|
||||
public <T> List<T> getMeta() {
|
||||
List<UniqueID> objectIds = new ArrayList<>();
|
||||
for (RayObject<E> id : ids) {
|
||||
objectIds.add(id.getId());
|
||||
}
|
||||
return Ray.getMeta(objectIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
return ids.get(index).get();
|
||||
}
|
||||
|
||||
public <TM> TM getMeta(int index) {
|
||||
return ids.get(index).getMeta();
|
||||
}
|
||||
|
||||
public RayObject<E> Get(int index) {
|
||||
return ids.get(index);
|
||||
}
|
||||
|
||||
@RayDisabled
|
||||
@Deprecated
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
public ListIterator<E> listIterator(int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public RayObject<E> set(int index, RayObject<E> 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<E> element) {
|
||||
ids.add(index, element);
|
||||
}
|
||||
|
||||
@RayDisabled
|
||||
@Deprecated
|
||||
@Override
|
||||
public E remove(int index) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public RayObject<E> 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
|
||||
@@ -200,7 +170,7 @@ public class RayList<E> extends ArrayList<E> {
|
||||
@RayDisabled
|
||||
@Deprecated
|
||||
@Override
|
||||
public ListIterator<E> listIterator(int index) {
|
||||
public Iterator<E> iterator() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -210,4 +180,34 @@ public class RayList<E> extends ArrayList<E> {
|
||||
public List<E> subList(int fromIndex, int toIndex) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Iterator<RayObject<E>> Iterator() {
|
||||
return ids.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
//throw new UnsupportedOperationException();
|
||||
return ids.containsAll(c);
|
||||
}
|
||||
|
||||
public <T> List<T> getMeta() {
|
||||
List<UniqueID> objectIds = new ArrayList<>();
|
||||
for (RayObject<E> id : ids) {
|
||||
objectIds.add(id.getId());
|
||||
}
|
||||
return Ray.getMeta(objectIds);
|
||||
}
|
||||
|
||||
public <TMT> TMT getMeta(int index) {
|
||||
return ids.get(index).getMeta();
|
||||
}
|
||||
|
||||
public RayObject<E> Get(int index) {
|
||||
return ids.get(index);
|
||||
}
|
||||
|
||||
public RayObject<E> Remove(int index) {
|
||||
return ids.remove(index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,15 +32,8 @@ public class RayMap<K, V> extends HashMap<K, V> {
|
||||
}
|
||||
|
||||
@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);
|
||||
public V get(Object key) {
|
||||
return ids.get(key).get();
|
||||
}
|
||||
|
||||
// TODO: try to use multiple get
|
||||
@@ -52,26 +45,10 @@ public class RayMap<K, V> extends HashMap<K, V> {
|
||||
return objs;
|
||||
}
|
||||
|
||||
public <TM> Map<K, TM> getMeta() {
|
||||
Map<K, TM> metas = new HashMap<>();
|
||||
for (Map.Entry<K, RayObject<V>> 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> TM getMeta(K key) {
|
||||
return ids.get(key).getMeta();
|
||||
}
|
||||
|
||||
public RayObject<V> Get(K key) {
|
||||
return ids.get(key);
|
||||
public boolean containsKey(Object key) {
|
||||
//throw new UnsupportedOperationException();
|
||||
return ids.containsKey(key);
|
||||
}
|
||||
|
||||
@RayDisabled
|
||||
@@ -88,18 +65,14 @@ public class RayMap<K, V> extends HashMap<K, V> {
|
||||
@RayDisabled
|
||||
@Deprecated
|
||||
@Override
|
||||
public V remove(Object key) {
|
||||
public void putAll(Map<? extends K, ? extends V> m) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public RayObject<V> Remove(K key) {
|
||||
return ids.remove(key);
|
||||
}
|
||||
|
||||
@RayDisabled
|
||||
@Deprecated
|
||||
@Override
|
||||
public void putAll(Map<? extends K, ? extends V> m) {
|
||||
public V remove(Object key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -109,6 +82,12 @@ public class RayMap<K, V> extends HashMap<K, V> {
|
||||
ids.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
//throw new UnsupportedOperationException();
|
||||
return ids.containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<K> keySet() {
|
||||
return ids.keySet();
|
||||
@@ -121,10 +100,6 @@ public class RayMap<K, V> extends HashMap<K, V> {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Collection<RayObject<V>> Values() {
|
||||
return ids.values();
|
||||
}
|
||||
|
||||
@RayDisabled
|
||||
@Deprecated
|
||||
@Override
|
||||
@@ -132,6 +107,31 @@ public class RayMap<K, V> extends HashMap<K, V> {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public <TMT> Map<K, TMT> getMeta() {
|
||||
Map<K, TMT> metas = new HashMap<>();
|
||||
for (Map.Entry<K, RayObject<V>> id : ids.entrySet()) {
|
||||
TMT meta = id.getValue().getMeta();
|
||||
metas.put(id.getKey(), meta);
|
||||
}
|
||||
return metas;
|
||||
}
|
||||
|
||||
public <TMT> TMT getMeta(K key) {
|
||||
return ids.get(key).getMeta();
|
||||
}
|
||||
|
||||
public RayObject<V> Get(K key) {
|
||||
return ids.get(key);
|
||||
}
|
||||
|
||||
public RayObject<V> Remove(K key) {
|
||||
return ids.remove(key);
|
||||
}
|
||||
|
||||
public Collection<RayObject<V>> Values() {
|
||||
return ids.values();
|
||||
}
|
||||
|
||||
public Set<java.util.Map.Entry<K, RayObject<V>>> EntrySet() {
|
||||
return ids.entrySet();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class RayObject<T> implements Serializable {
|
||||
return Ray.get(id);
|
||||
}
|
||||
|
||||
public <TM> TM getMeta() throws TaskExecutionException {
|
||||
public <TMT> TMT getMeta() throws TaskExecutionException {
|
||||
return Ray.getMeta(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.ray.api;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
/**
|
||||
* Real object or ray future proxy for multiple returns
|
||||
* Real object or ray future proxy for multiple returns.
|
||||
*/
|
||||
public class RayObjects {
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* a ray remote function or class (as an actor)
|
||||
* 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
|
||||
* whether to use external I/O pool to execute the function.
|
||||
*/
|
||||
boolean externalIO() default false;
|
||||
boolean externalIo() default false;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package org.ray.api;
|
||||
|
||||
/**
|
||||
* a RPC service that represent the data processing services implemented in Ray
|
||||
*
|
||||
* 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 {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.ray.api;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
@@ -12,10 +11,9 @@ import java.util.Random;
|
||||
*/
|
||||
public class UniqueID implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8588849129675565761L;
|
||||
|
||||
public static final int LENGTH = 20;
|
||||
|
||||
public static final UniqueID nil = genNil();
|
||||
private static final long serialVersionUID = 8588849129675565761L;
|
||||
byte[] id;
|
||||
|
||||
public UniqueID(byte[] id) {
|
||||
@@ -42,23 +40,26 @@ public class UniqueID implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
public static UniqueID genNil() {
|
||||
byte[] b = new byte[LENGTH];
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
b[i] = (byte) 0xFF;
|
||||
}
|
||||
return s;
|
||||
|
||||
return new UniqueID(b);
|
||||
}
|
||||
|
||||
public static UniqueID randomId() {
|
||||
byte[] b = new byte[LENGTH];
|
||||
new Random().nextBytes(b);
|
||||
return new UniqueID(b);
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ByteBuffer ToByteBuffer() {
|
||||
public ByteBuffer toByteBuffer() {
|
||||
return ByteBuffer.wrap(id);
|
||||
}
|
||||
|
||||
@@ -91,6 +92,18 @@ public class UniqueID implements Serializable {
|
||||
return Arrays.equals(id, r.id);
|
||||
}
|
||||
|
||||
@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 boolean isNil() {
|
||||
for (byte b : id) {
|
||||
if (b != (byte) 0xFF) {
|
||||
@@ -99,21 +112,4 @@ public class UniqueID implements Serializable {
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_0_1<R0> extends RayFunc {
|
||||
|
||||
R0 apply() throws Throwable;
|
||||
|
||||
static <R0> R0 execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_0_1.class.getName()));
|
||||
@@ -16,4 +14,6 @@ public interface RayFunc_0_1<R0> extends RayFunc {
|
||||
return f.apply();
|
||||
}
|
||||
|
||||
R0 apply() throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns2;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_0_2<R0, R1> extends RayFunc {
|
||||
|
||||
MultipleReturns2<R0, R1> apply() throws Throwable;
|
||||
|
||||
static <R0, R1> MultipleReturns2<R0, R1> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_0_2.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_0_2<R0, R1> extends RayFunc {
|
||||
return f.apply();
|
||||
}
|
||||
|
||||
MultipleReturns2<R0, R1> apply() throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns3;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_0_3<R0, R1, R2> extends RayFunc {
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply() throws Throwable;
|
||||
|
||||
static <R0, R1, R2> MultipleReturns3<R0, R1, R2> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_0_3.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_0_3<R0, R1, R2> extends RayFunc {
|
||||
return f.apply();
|
||||
}
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply() throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns4;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_0_4<R0, R1, R2, R3> extends RayFunc {
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply() throws Throwable;
|
||||
|
||||
static <R0, R1, R2, R3> MultipleReturns4<R0, R1, R2, R3> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_0_4.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_0_4<R0, R1, R2, R3> extends RayFunc {
|
||||
return f.apply();
|
||||
}
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply() throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.ray.api.internal.RayFunc;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_0_n<R, RID> extends RayFunc {
|
||||
public interface RayFunc_0_n<R, RIDT> extends RayFunc {
|
||||
|
||||
Map<RID, R> apply(Collection<RID> returnids) throws Throwable;
|
||||
|
||||
static <R, RID> Map<RID, R> execute(Object[] args) throws Throwable {
|
||||
static <R, RIDT> Map<RIDT, R> 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<R, RID> f = SerializationUtils.deserialize(funcBytes);
|
||||
return f.apply((Collection<RID>) args[0]);
|
||||
RayFunc_0_n<R, RIDT> f = SerializationUtils.deserialize(funcBytes);
|
||||
return f.apply((Collection<RIDT>) args[0]);
|
||||
}
|
||||
|
||||
Map<RIDT, R> apply(Collection<RIDT> returnids) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_0_n_list<R> extends RayFunc {
|
||||
|
||||
List<R> apply() throws Throwable;
|
||||
|
||||
static <R> List<R> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_0_n_list.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_0_n_list<R> extends RayFunc {
|
||||
return f.apply();
|
||||
}
|
||||
|
||||
List<R> apply() throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_1_1<T0, R0> extends RayFunc {
|
||||
|
||||
R0 apply(T0 t0) throws Throwable;
|
||||
|
||||
static <T0, R0> R0 execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_1_1.class.getName()));
|
||||
@@ -16,4 +14,6 @@ public interface RayFunc_1_1<T0, R0> extends RayFunc {
|
||||
return f.apply((T0) args[0]);
|
||||
}
|
||||
|
||||
R0 apply(T0 t0) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns2;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_1_2<T0, R0, R1> extends RayFunc {
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0) throws Throwable;
|
||||
|
||||
static <T0, R0, R1> MultipleReturns2<R0, R1> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_1_2.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_1_2<T0, R0, R1> extends RayFunc {
|
||||
return f.apply((T0) args[0]);
|
||||
}
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns3;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_1_3<T0, R0, R1, R2> extends RayFunc {
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0) throws Throwable;
|
||||
|
||||
static <T0, R0, R1, R2> MultipleReturns3<R0, R1, R2> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_1_3.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_1_3<T0, R0, R1, R2> extends RayFunc {
|
||||
return f.apply((T0) args[0]);
|
||||
}
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns4;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_1_4<T0, R0, R1, R2, R3> extends RayFunc {
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0) throws Throwable;
|
||||
|
||||
static <T0, R0, R1, R2, R3> MultipleReturns4<R0, R1, R2, R3> execute(Object[] args)
|
||||
throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -18,4 +16,6 @@ public interface RayFunc_1_4<T0, R0, R1, R2, R3> extends RayFunc {
|
||||
return f.apply((T0) args[0]);
|
||||
}
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.ray.api.internal.RayFunc;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_1_n<T0, R, RID> extends RayFunc {
|
||||
public interface RayFunc_1_n<T0, R, RIDT> extends RayFunc {
|
||||
|
||||
Map<RID, R> apply(Collection<RID> returnids, T0 t0) throws Throwable;
|
||||
|
||||
static <T0, R, RID> Map<RID, R> execute(Object[] args) throws Throwable {
|
||||
static <T0, R, RIDT> Map<RIDT, R> 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<T0, R, RID> f = SerializationUtils.deserialize(funcBytes);
|
||||
return f.apply((Collection<RID>) args[0], (T0) args[1]);
|
||||
RayFunc_1_n<T0, R, RIDT> f = SerializationUtils.deserialize(funcBytes);
|
||||
return f.apply((Collection<RIDT>) args[0], (T0) args[1]);
|
||||
}
|
||||
|
||||
Map<RIDT, R> apply(Collection<RIDT> returnids, T0 t0) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_1_n_list<T0, R> extends RayFunc {
|
||||
|
||||
List<R> apply(T0 t0) throws Throwable;
|
||||
|
||||
static <T0, R> List<R> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_1_n_list.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_1_n_list<T0, R> extends RayFunc {
|
||||
return f.apply((T0) args[0]);
|
||||
}
|
||||
|
||||
List<R> apply(T0 t0) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_2_1<T0, T1, R0> extends RayFunc {
|
||||
|
||||
R0 apply(T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
static <T0, T1, R0> R0 execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_2_1.class.getName()));
|
||||
@@ -16,4 +14,6 @@ public interface RayFunc_2_1<T0, T1, R0> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1]);
|
||||
}
|
||||
|
||||
R0 apply(T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns2;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_2_2<T0, T1, R0, R1> extends RayFunc {
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
static <T0, T1, R0, R1> MultipleReturns2<R0, R1> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_2_2.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_2_2<T0, T1, R0, R1> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1]);
|
||||
}
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns3;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_2_3<T0, T1, R0, R1, R2> extends RayFunc {
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
static <T0, T1, R0, R1, R2> MultipleReturns3<R0, R1, R2> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_2_3.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_2_3<T0, T1, R0, R1, R2> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1]);
|
||||
}
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns4;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_2_4<T0, T1, R0, R1, R2, R3> extends RayFunc {
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
static <T0, T1, R0, R1, R2, R3> MultipleReturns4<R0, R1, R2, R3> execute(Object[] args)
|
||||
throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -18,4 +16,6 @@ public interface RayFunc_2_4<T0, T1, R0, R1, R2, R3> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1]);
|
||||
}
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.ray.api.internal.RayFunc;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_2_n<T0, T1, R, RID> extends RayFunc {
|
||||
public interface RayFunc_2_n<T0, T1, R, RIDT> extends RayFunc {
|
||||
|
||||
Map<RID, R> apply(Collection<RID> returnids, T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
static <T0, T1, R, RID> Map<RID, R> execute(Object[] args) throws Throwable {
|
||||
static <T0, T1, R, RIDT> Map<RIDT, R> 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<T0, T1, R, RID> f = SerializationUtils.deserialize(funcBytes);
|
||||
return f.apply((Collection<RID>) args[0], (T0) args[1], (T1) args[2]);
|
||||
RayFunc_2_n<T0, T1, R, RIDT> f = SerializationUtils.deserialize(funcBytes);
|
||||
return f.apply((Collection<RIDT>) args[0], (T0) args[1], (T1) args[2]);
|
||||
}
|
||||
|
||||
Map<RIDT, R> apply(Collection<RIDT> returnids, T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_2_n_list<T0, T1, R> extends RayFunc {
|
||||
|
||||
List<R> apply(T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
static <T0, T1, R> List<R> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_2_n_list.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_2_n_list<T0, T1, R> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1]);
|
||||
}
|
||||
|
||||
List<R> apply(T0 t0, T1 t1) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_3_1<T0, T1, T2, R0> extends RayFunc {
|
||||
|
||||
R0 apply(T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, R0> R0 execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_3_1.class.getName()));
|
||||
@@ -16,4 +14,6 @@ public interface RayFunc_3_1<T0, T1, T2, R0> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2]);
|
||||
}
|
||||
|
||||
R0 apply(T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns2;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_3_2<T0, T1, T2, R0, R1> extends RayFunc {
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, R0, R1> MultipleReturns2<R0, R1> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_3_2.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_3_2<T0, T1, T2, R0, R1> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2]);
|
||||
}
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns3;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_3_3<T0, T1, T2, R0, R1, R2> extends RayFunc {
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, R0, R1, R2> MultipleReturns3<R0, R1, R2> execute(Object[] args)
|
||||
throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -18,4 +16,6 @@ public interface RayFunc_3_3<T0, T1, T2, R0, R1, R2> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2]);
|
||||
}
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns4;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_3_4<T0, T1, T2, R0, R1, R2, R3> extends RayFunc {
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, R0, R1, R2, R3> MultipleReturns4<R0, R1, R2, R3> execute(Object[] args)
|
||||
throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -18,4 +16,6 @@ public interface RayFunc_3_4<T0, T1, T2, R0, R1, R2, R3> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2]);
|
||||
}
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,16 +6,16 @@ import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.ray.api.internal.RayFunc;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_3_n<T0, T1, T2, R, RID> extends RayFunc {
|
||||
public interface RayFunc_3_n<T0, T1, T2, R, RIDT> extends RayFunc {
|
||||
|
||||
Map<RID, R> apply(Collection<RID> returnids, T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, R, RID> Map<RID, R> execute(Object[] args) throws Throwable {
|
||||
static <T0, T1, T2, R, RIDT> Map<RIDT, R> 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<T0, T1, T2, R, RID> f = SerializationUtils.deserialize(funcBytes);
|
||||
return f.apply((Collection<RID>) args[0], (T0) args[1], (T1) args[2], (T2) args[3]);
|
||||
RayFunc_3_n<T0, T1, T2, R, RIDT> f = SerializationUtils.deserialize(funcBytes);
|
||||
return f.apply((Collection<RIDT>) args[0], (T0) args[1], (T1) args[2], (T2) args[3]);
|
||||
}
|
||||
|
||||
Map<RIDT, R> apply(Collection<RIDT> returnids, T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_3_n_list<T0, T1, T2, R> extends RayFunc {
|
||||
|
||||
List<R> apply(T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, R> List<R> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_3_n_list.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_3_n_list<T0, T1, T2, R> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2]);
|
||||
}
|
||||
|
||||
List<R> apply(T0 t0, T1 t1, T2 t2) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_4_1<T0, T1, T2, T3, R0> extends RayFunc {
|
||||
|
||||
R0 apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, R0> R0 execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_4_1.class.getName()));
|
||||
@@ -16,4 +14,6 @@ public interface RayFunc_4_1<T0, T1, T2, T3, R0> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]);
|
||||
}
|
||||
|
||||
R0 apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns2;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_4_2<T0, T1, T2, T3, R0, R1> extends RayFunc {
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, R0, R1> MultipleReturns2<R0, R1> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_4_2.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_4_2<T0, T1, T2, T3, R0, R1> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]);
|
||||
}
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns3;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_4_3<T0, T1, T2, T3, R0, R1, R2> extends RayFunc {
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, R0, R1, R2> MultipleReturns3<R0, R1, R2> execute(Object[] args)
|
||||
throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -18,4 +16,6 @@ public interface RayFunc_4_3<T0, T1, T2, T3, R0, R1, R2> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]);
|
||||
}
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns4;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_4_4<T0, T1, T2, T3, R0, R1, R2, R3> extends RayFunc {
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, R0, R1, R2, R3> MultipleReturns4<R0, R1, R2, R3> execute(Object[] args)
|
||||
throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -18,4 +16,6 @@ public interface RayFunc_4_4<T0, T1, T2, T3, R0, R1, R2, R3> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]);
|
||||
}
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,17 +6,17 @@ import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.ray.api.internal.RayFunc;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_4_n<T0, T1, T2, T3, R, RID> extends RayFunc {
|
||||
public interface RayFunc_4_n<T0, T1, T2, T3, R, RIDT> extends RayFunc {
|
||||
|
||||
Map<RID, R> apply(Collection<RID> returnids, T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, R, RID> Map<RID, R> execute(Object[] args) throws Throwable {
|
||||
static <T0, T1, T2, T3, R, RIDT> Map<RIDT, R> 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<T0, T1, T2, T3, R, RID> f = SerializationUtils.deserialize(funcBytes);
|
||||
RayFunc_4_n<T0, T1, T2, T3, R, RIDT> f = SerializationUtils.deserialize(funcBytes);
|
||||
return f
|
||||
.apply((Collection<RID>) args[0], (T0) args[1], (T1) args[2], (T2) args[3], (T3) args[4]);
|
||||
.apply((Collection<RIDT>) args[0], (T0) args[1], (T1) args[2], (T2) args[3], (T3) args[4]);
|
||||
}
|
||||
|
||||
Map<RIDT, R> apply(Collection<RIDT> returnids, T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_4_n_list<T0, T1, T2, T3, R> extends RayFunc {
|
||||
|
||||
List<R> apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, R> List<R> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_4_n_list.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_4_n_list<T0, T1, T2, T3, R> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3]);
|
||||
}
|
||||
|
||||
List<R> apply(T0 t0, T1 t1, T2 t2, T3 t3) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_5_1<T0, T1, T2, T3, T4, R0> extends RayFunc {
|
||||
|
||||
R0 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, R0> R0 execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_5_1.class.getName()));
|
||||
@@ -16,4 +14,6 @@ public interface RayFunc_5_1<T0, T1, T2, T3, T4, R0> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4]);
|
||||
}
|
||||
|
||||
R0 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns2;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_5_2<T0, T1, T2, T3, T4, R0, R1> extends RayFunc {
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, R0, R1> MultipleReturns2<R0, R1> execute(Object[] args)
|
||||
throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -18,4 +16,6 @@ public interface RayFunc_5_2<T0, T1, T2, T3, T4, R0, R1> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4]);
|
||||
}
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns3;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_5_3<T0, T1, T2, T3, T4, R0, R1, R2> extends RayFunc {
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, R0, R1, R2> MultipleReturns3<R0, R1, R2> execute(Object[] args)
|
||||
throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -18,4 +16,6 @@ public interface RayFunc_5_3<T0, T1, T2, T3, T4, R0, R1, R2> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4]);
|
||||
}
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns4;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_5_4<T0, T1, T2, T3, T4, R0, R1, R2, R3> extends RayFunc {
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, R0, R1, R2, R3> MultipleReturns4<R0, R1, R2, R3> execute(
|
||||
Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -18,4 +16,6 @@ public interface RayFunc_5_4<T0, T1, T2, T3, T4, R0, R1, R2, R3> extends RayFunc
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4]);
|
||||
}
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,18 +6,19 @@ import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.ray.api.internal.RayFunc;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_5_n<T0, T1, T2, T3, T4, R, RID> extends RayFunc {
|
||||
public interface RayFunc_5_n<T0, T1, T2, T3, T4, R, RIDT> extends RayFunc {
|
||||
|
||||
Map<RID, R> apply(Collection<RID> returnids, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, R, RID> Map<RID, R> execute(Object[] args) throws Throwable {
|
||||
static <T0, T1, T2, T3, T4, R, RIDT> Map<RIDT, R> 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<T0, T1, T2, T3, T4, R, RID> f = SerializationUtils.deserialize(funcBytes);
|
||||
RayFunc_5_n<T0, T1, T2, T3, T4, R, RIDT> f = SerializationUtils.deserialize(funcBytes);
|
||||
return f
|
||||
.apply((Collection<RID>) args[0], (T0) args[1], (T1) args[2], (T2) args[3], (T3) args[4],
|
||||
.apply((Collection<RIDT>) args[0], (T0) args[1], (T1) args[2], (T2) args[3], (T3) args[4],
|
||||
(T4) args[5]);
|
||||
}
|
||||
|
||||
Map<RIDT, R> apply(Collection<RIDT> returnids, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4)
|
||||
throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_5_n_list<T0, T1, T2, T3, T4, R> extends RayFunc {
|
||||
|
||||
List<R> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, R> List<R> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_5_n_list.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_5_n_list<T0, T1, T2, T3, T4, R> extends RayFunc {
|
||||
return f.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4]);
|
||||
}
|
||||
|
||||
List<R> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_6_1<T0, T1, T2, T3, T4, T5, R0> extends RayFunc {
|
||||
|
||||
R0 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, T5, R0> R0 execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_6_1.class.getName()));
|
||||
@@ -17,4 +15,6 @@ public interface RayFunc_6_1<T0, T1, T2, T3, T4, T5, R0> extends RayFunc {
|
||||
.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5]);
|
||||
}
|
||||
|
||||
R0 apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns2;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_6_2<T0, T1, T2, T3, T4, T5, R0, R1> extends RayFunc {
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, T5, R0, R1> MultipleReturns2<R0, R1> execute(Object[] args)
|
||||
throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -19,4 +17,6 @@ public interface RayFunc_6_2<T0, T1, T2, T3, T4, T5, R0, R1> extends RayFunc {
|
||||
.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5]);
|
||||
}
|
||||
|
||||
MultipleReturns2<R0, R1> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns3;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_6_3<T0, T1, T2, T3, T4, T5, R0, R1, R2> extends RayFunc {
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, T5, R0, R1, R2> MultipleReturns3<R0, R1, R2> execute(Object[] args)
|
||||
throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -19,4 +17,6 @@ public interface RayFunc_6_3<T0, T1, T2, T3, T4, T5, R0, R1, R2> extends RayFunc
|
||||
.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5]);
|
||||
}
|
||||
|
||||
MultipleReturns3<R0, R1, R2> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.returns.MultipleReturns4;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_6_4<T0, T1, T2, T3, T4, T5, R0, R1, R2, R3> extends RayFunc {
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, T5, R0, R1, R2, R3> MultipleReturns4<R0, R1, R2, R3> execute(
|
||||
Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
@@ -20,4 +18,6 @@ public interface RayFunc_6_4<T0, T1, T2, T3, T4, T5, R0, R1, R2, R3> extends Ray
|
||||
.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5]);
|
||||
}
|
||||
|
||||
MultipleReturns4<R0, R1, R2, R3> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -6,19 +6,19 @@ import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.ray.api.internal.RayFunc;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_6_n<T0, T1, T2, T3, T4, T5, R, RID> extends RayFunc {
|
||||
public interface RayFunc_6_n<T0, T1, T2, T3, T4, T5, R, RIDT> extends RayFunc {
|
||||
|
||||
Map<RID, R> apply(Collection<RID> returnids, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
|
||||
throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, T5, R, RID> Map<RID, R> execute(Object[] args) throws Throwable {
|
||||
static <T0, T1, T2, T3, T4, T5, R, RIDT> Map<RIDT, R> 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<T0, T1, T2, T3, T4, T5, R, RID> f = SerializationUtils.deserialize(funcBytes);
|
||||
RayFunc_6_n<T0, T1, T2, T3, T4, T5, R, RIDT> f = SerializationUtils.deserialize(funcBytes);
|
||||
return f
|
||||
.apply((Collection<RID>) args[0], (T0) args[1], (T1) args[2], (T2) args[3], (T3) args[4],
|
||||
.apply((Collection<RIDT>) args[0], (T0) args[1], (T1) args[2], (T2) args[3], (T3) args[4],
|
||||
(T4) args[5], (T5) args[6]);
|
||||
}
|
||||
|
||||
Map<RIDT, R> apply(Collection<RIDT> returnids, T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
|
||||
throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import org.ray.api.internal.RayFunc;
|
||||
@FunctionalInterface
|
||||
public interface RayFunc_6_n_list<T0, T1, T2, T3, T4, T5, R> extends RayFunc {
|
||||
|
||||
List<R> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable;
|
||||
|
||||
static <T0, T1, T2, T3, T4, T5, R> List<R> execute(Object[] args) throws Throwable {
|
||||
String name = (String) args[args.length - 2];
|
||||
assert (name.equals(RayFunc_6_n_list.class.getName()));
|
||||
@@ -18,4 +16,6 @@ public interface RayFunc_6_n_list<T0, T1, T2, T3, T4, T5, R> extends RayFunc {
|
||||
.apply((T0) args[0], (T1) args[1], (T2) args[2], (T3) args[3], (T4) args[4], (T5) args[5]);
|
||||
}
|
||||
|
||||
List<R> apply(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5) throws Throwable;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.ray.api.internal;
|
||||
|
||||
/**
|
||||
* hold the remote call
|
||||
* hold the remote call.
|
||||
*/
|
||||
public interface Callable {
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.ray.api.internal;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Base of the ray remote function
|
||||
* Base of the ray remote function.
|
||||
*/
|
||||
public interface RayFunc extends Serializable {
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package org.ray.api.returns;
|
||||
|
||||
/**
|
||||
* Multiple return objects for user's method
|
||||
* Multiple return objects for user's method.
|
||||
*/
|
||||
public class MultipleReturns {
|
||||
|
||||
protected final Object[] values;
|
||||
|
||||
public MultipleReturns(Object values[]) {
|
||||
public MultipleReturns(Object[] values) {
|
||||
this.values = values;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package org.ray.api.returns;
|
||||
public class MultipleReturns2<R0, R1> extends MultipleReturns {
|
||||
|
||||
public MultipleReturns2(R0 r0, R1 r1) {
|
||||
super(new Object[]{r0, r1});
|
||||
super(new Object[] {r0, r1});
|
||||
}
|
||||
|
||||
public R0 get0() {
|
||||
|
||||
@@ -4,7 +4,7 @@ package org.ray.api.returns;
|
||||
public class MultipleReturns3<R0, R1, R2> extends MultipleReturns {
|
||||
|
||||
public MultipleReturns3(R0 r0, R1 r1, R2 r2) {
|
||||
super(new Object[]{r0, r1, r2});
|
||||
super(new Object[] {r0, r1, r2});
|
||||
}
|
||||
|
||||
public R0 get0() {
|
||||
|
||||
@@ -4,7 +4,7 @@ package org.ray.api.returns;
|
||||
public class MultipleReturns4<R0, R1, R2, R3> extends MultipleReturns {
|
||||
|
||||
public MultipleReturns4(R0 r0, R1 r1, R2 r2, R3 r3) {
|
||||
super(new Object[]{r0, r1, r2, r3});
|
||||
super(new Object[] {r0, r1, r2, r3});
|
||||
}
|
||||
|
||||
public R0 get0() {
|
||||
|
||||
@@ -11,7 +11,7 @@ public class RayObjects2<R0, R1> extends RayObjects {
|
||||
super(ids);
|
||||
}
|
||||
|
||||
public RayObjects2(RayObject objs[]) {
|
||||
public RayObjects2(RayObject[] objs) {
|
||||
super(objs);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public class RayObjects3<R0, R1, R2> extends RayObjects {
|
||||
super(ids);
|
||||
}
|
||||
|
||||
public RayObjects3(RayObject objs[]) {
|
||||
public RayObjects3(RayObject[] objs) {
|
||||
super(objs);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public class RayObjects4<R0, R1, R2, R3> extends RayObjects {
|
||||
super(ids);
|
||||
}
|
||||
|
||||
public RayObjects4(RayObject objs[]) {
|
||||
public RayObjects4(RayObject[] objs) {
|
||||
super(objs);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<!DOCTYPE suppressions PUBLIC
|
||||
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
|
||||
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
|
||||
|
||||
<suppressions>
|
||||
<suppress checks="ParameterNameCheck" files="Arg.java"/>
|
||||
<suppress checks="MethodNameCheck" files="Arg.java"/>
|
||||
<suppress checks="MethodNameCheck" files="DefaultLocalSchedulerClient.java"/>
|
||||
<suppress checks="MemberNameCheck" files="PathConfig.java"/>
|
||||
<suppress checks="MemberNameCheck" files="RayParameters.java"/>
|
||||
<suppress checks="AbbreviationAsWordInNameCheck" files="RayParameters.java"/>
|
||||
<suppress checks="MethodNameCheck" files="ResourcePair.java"/>
|
||||
<suppress checks="ParameterNameCheck" files="ResourcePair.java"/>
|
||||
<suppress checks="ParameterNameCheck" files="TaskInfo.java"/>
|
||||
<suppress checks="MethodNameCheck" files="TaskInfo.java"/>
|
||||
<suppress checks="MethodNameCheck" files="RayMap.java"/>
|
||||
<suppress checks="MethodNameCheck" files="RayList.java"/>
|
||||
<suppress checks="OverloadMethodsDeclarationOrderCheck" files="Rpc.java"/>
|
||||
<suppress checks="MethodTypeParameterNameCheck" files="Rpc.java"/>
|
||||
<suppress checks="AbbreviationAsWordInNameCheck" files="UniqueID.java"/>
|
||||
<suppress checks="TypeNameCheck" files="RayFunc_[0-9]_.+\.java"/>
|
||||
</suppressions>
|
||||
@@ -0,0 +1,240 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
|
||||
|
||||
<!--
|
||||
Checkstyle configuration that checks the Google coding conventions from Google Java Style
|
||||
that can be found at https://google.github.io/styleguide/javaguide.html.
|
||||
|
||||
Checkstyle is very configurable. Be sure to read the documentation at
|
||||
http://checkstyle.sf.net (or in your downloaded distribution).
|
||||
|
||||
To completely disable a check, just comment it out or delete it from the file.
|
||||
|
||||
Authors: Max Vetrenko, Ruslan Diachenko, Roman Ivanov.
|
||||
-->
|
||||
|
||||
<module name="Checker">
|
||||
<property name="charset" value="UTF-8"/>
|
||||
|
||||
<property name="severity" value="warning"/>
|
||||
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
<!-- Checks for whitespace -->
|
||||
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="IllegalTokenText">
|
||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||
<property name="format"
|
||||
value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||
<property name="message"
|
||||
value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
|
||||
</module>
|
||||
<module name="AvoidEscapedUnicodeCharacters">
|
||||
<property name="allowEscapesForControlCharacters" value="true"/>
|
||||
<property name="allowByTailComment" value="true"/>
|
||||
<property name="allowNonPrintableEscapes" value="true"/>
|
||||
</module>
|
||||
<module name="LineLength">
|
||||
<property name="max" value="100"/>
|
||||
<property name="ignorePattern"
|
||||
value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||
</module>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="OneTopLevelClass"/>
|
||||
<module name="NoLineWrap"/>
|
||||
<module name="EmptyBlock">
|
||||
<property name="option" value="TEXT"/>
|
||||
<property name="tokens"
|
||||
value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
|
||||
</module>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly">
|
||||
<property name="id" value="RightCurlySame"/>
|
||||
<property name="tokens"
|
||||
value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE,
|
||||
LITERAL_DO"/>
|
||||
</module>
|
||||
<module name="RightCurly">
|
||||
<property name="id" value="RightCurlyAlone"/>
|
||||
<property name="option" value="alone"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, STATIC_INIT,
|
||||
INSTANCE_INIT"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="allowEmptyConstructors" value="true"/>
|
||||
<property name="allowEmptyMethods" value="true"/>
|
||||
<property name="allowEmptyTypes" value="true"/>
|
||||
<property name="allowEmptyLoops" value="true"/>
|
||||
<message key="ws.notFollowed"
|
||||
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
|
||||
<message key="ws.notPreceded"
|
||||
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
||||
</module>
|
||||
<module name="OneStatementPerLine"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="FallThrough"/>
|
||||
<module name="UpperEll"/>
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="id" value="SeparatorWrapDot"/>
|
||||
<property name="tokens" value="DOT"/>
|
||||
<property name="option" value="nl"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="id" value="SeparatorWrapComma"/>
|
||||
<property name="tokens" value="COMMA"/>
|
||||
<property name="option" value="EOL"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<!-- ARRAY_DECLARATOR is EOL until https://github.com/google/styleguide/issues/259 -->
|
||||
<property name="id" value="SeparatorWrapArrayDeclarator"/>
|
||||
<property name="tokens" value="ARRAY_DECLARATOR"/>
|
||||
<property name="option" value="EOL"/>
|
||||
</module>
|
||||
<module name="PackageName">
|
||||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Package name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="TypeName">
|
||||
<message key="name.invalidPattern"
|
||||
value="Type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ParameterName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="CatchParameterName">
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Catch parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LocalVariableName">
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ClassTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MethodTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="InterfaceTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="NoFinalizer"/>
|
||||
<module name="GenericWhitespace">
|
||||
<message key="ws.followed"
|
||||
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
|
||||
<message key="ws.preceded"
|
||||
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
|
||||
<message key="ws.illegalFollow"
|
||||
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
|
||||
<message key="ws.notPreceded"
|
||||
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||
</module>
|
||||
<module name="Indentation">
|
||||
<property name="basicOffset" value="2"/>
|
||||
<property name="braceAdjustment" value="0"/>
|
||||
<property name="caseIndent" value="2"/>
|
||||
<property name="throwsIndent" value="4"/>
|
||||
<property name="lineWrappingIndentation" value="4"/>
|
||||
<property name="arrayInitIndent" value="2"/>
|
||||
</module>
|
||||
<module name="AbbreviationAsWordInName">
|
||||
<property name="ignoreFinal" value="false"/>
|
||||
<property name="allowedAbbreviationLength" value="1"/>
|
||||
</module>
|
||||
<module name="OverloadMethodsDeclarationOrder"/>
|
||||
<module name="CustomImportOrder">
|
||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||
<property name="separateLineBetweenGroups" value="true"/>
|
||||
<property name="customImportOrderRules" value="STATIC###THIRD_PARTY_PACKAGE"/>
|
||||
</module>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="NoWhitespaceBefore">
|
||||
<property name="tokens"
|
||||
value="COMMA, SEMI, POST_INC, POST_DEC, DOT"/>
|
||||
<property name="allowLineBreaks" value="true"/>
|
||||
</module>
|
||||
<module name="ParenPad"/>
|
||||
<module name="OperatorWrap">
|
||||
<property name="option" value="NL"/>
|
||||
<property name="tokens"
|
||||
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR,
|
||||
LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="id" value="AnnotationLocationMostCases"/>
|
||||
<property name="tokens"
|
||||
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="id" value="AnnotationLocationVariables"/>
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
||||
</module>
|
||||
<module name="NonEmptyAtclauseDescription"/>
|
||||
<module name="JavadocTagContinuationIndentation"/>
|
||||
<module name="SummaryJavadoc">
|
||||
<property name="forbiddenSummaryFragments"
|
||||
value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
|
||||
</module>
|
||||
<module name="JavadocParagraph"/>
|
||||
<module name="AtclauseOrder">
|
||||
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
|
||||
<property name="target"
|
||||
value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
|
||||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<property name="scope" value="public"/>
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingThrowsTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
<property name="allowMissingJavadoc" value="true"/>
|
||||
<property name="minLineCount" value="2"/>
|
||||
<property name="allowedAnnotations" value="Override, Test"/>
|
||||
<property name="allowThrowsTagsForSubclasses" value="true"/>
|
||||
</module>
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||
<message key="name.invalidPattern"
|
||||
value="Method name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="SingleLineJavadoc">
|
||||
<property name="ignoreInlineTags" value="false"/>
|
||||
</module>
|
||||
<module name="EmptyCatchBlock">
|
||||
<property name="exceptionVariableName" value="expected"/>
|
||||
</module>
|
||||
<module name="CommentsIndentation"/>
|
||||
</module>
|
||||
</module>
|
||||
+32
-32
@@ -1,40 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-common</artifactId>
|
||||
<name>java common and util for ray</name>
|
||||
<description>java common and util for ray</description>
|
||||
<url></url>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-common</artifactId>
|
||||
<name>java common and util for ray</name>
|
||||
<description>java common and util for ray</description>
|
||||
<url></url>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>quartz</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>1.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ini4j</groupId>
|
||||
<artifactId>ini4j</artifactId>
|
||||
<version>0.5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>quartz</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>1.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ini4j</groupId>
|
||||
<artifactId>ini4j</artifactId>
|
||||
<version>0.5.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
|
||||
@@ -3,14 +3,14 @@ package org.ray.util;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Common utilities
|
||||
* Common utilities.
|
||||
*/
|
||||
public class CommonUtil {
|
||||
|
||||
private static final Random seed = new Random();
|
||||
|
||||
/**
|
||||
* Get random number between 0 and (max-1)
|
||||
* Get random number between 0 and (max-1).
|
||||
*/
|
||||
public static int getRandom(int max) {
|
||||
return Math.abs(seed.nextInt() % max);
|
||||
|
||||
@@ -53,10 +53,8 @@ public class NetworkUtil {
|
||||
ds.setReuseAddress(true);
|
||||
return true;
|
||||
} catch (IOException ignored) {
|
||||
/* should not be thrown */
|
||||
return false;
|
||||
}
|
||||
|
||||
/* should not be thrown */
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ public class ObjectUtil {
|
||||
public static <T> T newObject(Class<T> cls) {
|
||||
try {
|
||||
return cls.getConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException
|
||||
| InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -6,29 +6,15 @@ 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
|
||||
* split.
|
||||
* @param s input string
|
||||
* @param splitters common splitters
|
||||
* @param open open braces
|
||||
* @param close close braces
|
||||
* @param open open braces
|
||||
* @param close close braces
|
||||
* @return output array list
|
||||
*/
|
||||
public static Vector<String> Split(String s, String splitters, String open, String close) {
|
||||
public static Vector<String> split(String s, String splitters, String open, String close) {
|
||||
// The splits.
|
||||
Vector<String> split = new Vector<>();
|
||||
// The stack.
|
||||
@@ -130,5 +116,20 @@ public class StringUtil {
|
||||
}
|
||||
return objs.length == 0 ? "" : sb.substring(0, sb.length() - concatenator.length());
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,13 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.ray.util.logger.RayLog;
|
||||
|
||||
/**
|
||||
* some utilities for system process
|
||||
* some utilities for system process.
|
||||
*/
|
||||
public class SystemUtil {
|
||||
|
||||
static final ReentrantLock pidlock = new ReentrantLock();
|
||||
static Integer pid;
|
||||
|
||||
public static String userHome() {
|
||||
return System.getProperty("user.home");
|
||||
}
|
||||
@@ -36,9 +39,6 @@ public class SystemUtil {
|
||||
}
|
||||
}
|
||||
|
||||
static Integer pid;
|
||||
static final ReentrantLock pidlock = new ReentrantLock();
|
||||
|
||||
public static int pid() {
|
||||
if (pid == null) {
|
||||
pidlock.lock();
|
||||
|
||||
@@ -13,24 +13,24 @@ import java.lang.annotation.Target;
|
||||
public @interface AConfig {
|
||||
|
||||
/**
|
||||
* comments for this configuration field
|
||||
* 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
|
||||
* as possible splits.
|
||||
*/
|
||||
String splitters() default ", \t";
|
||||
|
||||
/**
|
||||
* indirect with value as the new section name, the field name remains the same
|
||||
* 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
|
||||
* indirectSectionName in that function.
|
||||
*/
|
||||
String defaultArrayIndirectSectionName() default "";
|
||||
}
|
||||
|
||||
@@ -43,10 +43,6 @@ public class ConfigReader {
|
||||
|
||||
}
|
||||
|
||||
public String filePath() {
|
||||
return file;
|
||||
}
|
||||
|
||||
private void loadConfigFile(String filePath) throws Exception {
|
||||
|
||||
this.currentUseConfig.filePath = filePath;
|
||||
@@ -106,46 +102,16 @@ public class ConfigReader {
|
||||
}
|
||||
}
|
||||
|
||||
public String filePath() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public CurrentUseConfig getCurrentUseConfig() {
|
||||
return currentUseConfig;
|
||||
}
|
||||
|
||||
private synchronized <T> 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 <T> void updateConfigSection(ConfigSection configSection, String configKey,
|
||||
T defaultValue, String deptr, String oriValue) {
|
||||
ConfigItem<T> 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 dsptr) {
|
||||
String value = getOriValue(sectionKey, configKey, defaultValue, dsptr);
|
||||
if (value != null) {
|
||||
return value;
|
||||
@@ -155,7 +121,7 @@ public class ConfigReader {
|
||||
}
|
||||
|
||||
public boolean getBooleanValue(String sectionKey, String configKey, boolean defaultValue,
|
||||
String dsptr) {
|
||||
String dsptr) {
|
||||
String value = getOriValue(sectionKey, configKey, defaultValue, dsptr);
|
||||
if (value != null) {
|
||||
if (value.length() == 0) {
|
||||
@@ -181,6 +147,39 @@ public class ConfigReader {
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized <T> 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 <T> void updateConfigSection(ConfigSection configSection, String configKey,
|
||||
T defaultValue, String deptr, String oriValue) {
|
||||
ConfigItem<T> configItem = new ConfigItem<>();
|
||||
configItem.defaultValue = defaultValue;
|
||||
configItem.key = configKey;
|
||||
configItem.oriValue = oriValue;
|
||||
configItem.desc = deptr;
|
||||
configSection.itemMap.put(configKey, configItem);
|
||||
}
|
||||
|
||||
public long getLongValue(String sectionKey, String configKey, long defaultValue, String dsptr) {
|
||||
String value = getOriValue(sectionKey, configKey, defaultValue, dsptr);
|
||||
if (value != null) {
|
||||
@@ -195,7 +194,7 @@ public class ConfigReader {
|
||||
}
|
||||
|
||||
public double getDoubleValue(String sectionKey, String configKey, double defaultValue,
|
||||
String dsptr) {
|
||||
String dsptr) {
|
||||
String value = getOriValue(sectionKey, configKey, defaultValue, dsptr);
|
||||
if (value != null) {
|
||||
if (value.length() == 0) {
|
||||
@@ -210,7 +209,7 @@ public class ConfigReader {
|
||||
|
||||
|
||||
public int[] getIntegerArray(String sectionKey, String configKey, int[] defaultValue,
|
||||
String dsptr) {
|
||||
String dsptr) {
|
||||
String value = getOriValue(sectionKey, configKey, defaultValue, dsptr);
|
||||
int[] array = defaultValue;
|
||||
if (value != null) {
|
||||
@@ -226,24 +225,22 @@ public class ConfigReader {
|
||||
/**
|
||||
* 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 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 indirectSectionName, String dsptr) {
|
||||
String s = getStringValue(sectionKey, configKey, indirectSectionName, dsptr);
|
||||
Profile.Section section = ini.get(s);
|
||||
if (section == null) {
|
||||
return new String[]{};
|
||||
return new String[] {};
|
||||
} else {
|
||||
return section.keySet().toArray(new String[]{});
|
||||
return section.keySet().toArray(new String[] {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,8 +323,9 @@ public class ConfigReader {
|
||||
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) {
|
||||
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());
|
||||
@@ -340,7 +338,7 @@ public class ConfigReader {
|
||||
if (null == ss) {
|
||||
fld.set(obj, defaultFldValue);
|
||||
} else {
|
||||
Vector<String> ls = StringUtil.Split(ss, splitters, "", "");
|
||||
Vector<String> ls = StringUtil.split(ss, splitters, "", "");
|
||||
if (ccls.equals(boolean.class)) {
|
||||
boolean[] v = ObjectUtil
|
||||
.toBooleanArray(ls.stream().map(Boolean::parseBoolean).toArray());
|
||||
@@ -357,7 +355,7 @@ public class ConfigReader {
|
||||
} else if (ccls.equals(String.class)) {
|
||||
String[] v;
|
||||
if (StringUtil.isNullOrEmpty(defaultArrayIndirectSectionName)) {
|
||||
v = ls.toArray(new String[]{});
|
||||
v = ls.toArray(new String[] {});
|
||||
} else {
|
||||
v = this
|
||||
.getIndirectStringArray(section, fld.getName(),
|
||||
|
||||
@@ -8,7 +8,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*/
|
||||
public class ConfigSection {
|
||||
|
||||
public String sectionKey;
|
||||
|
||||
public final Map<String, ConfigItem<?>> itemMap = new ConcurrentHashMap<>();
|
||||
public String sectionKey;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*/
|
||||
public class CurrentUseConfig {
|
||||
|
||||
public final Map<String, ConfigSection> sectionMap = new ConcurrentHashMap<>();
|
||||
public String filePath;
|
||||
|
||||
public final Map<String, ConfigSection> sectionMap = new ConcurrentHashMap<>();
|
||||
|
||||
}
|
||||
|
||||
@@ -9,20 +9,8 @@ import java.util.List;
|
||||
*/
|
||||
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<TR> calculate(int maxT, int maxR) {
|
||||
List<TR> ret = new ArrayList<>();
|
||||
public static List<Tr> calculate(int maxT, int maxR) {
|
||||
List<Tr> ret = new ArrayList<>();
|
||||
for (int t = 0; t <= maxT; t++) {
|
||||
|
||||
// <= 0 for dynamic return count
|
||||
@@ -30,9 +18,21 @@ public class Composition {
|
||||
// -1 for call_n returns RayObject<>[N]
|
||||
|
||||
for (int r = -1; r <= maxR; r++) {
|
||||
ret.add(new TR(t, r));
|
||||
ret.add(new Tr(t, r));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static class Tr {
|
||||
|
||||
public final int tcount;
|
||||
public final int rcount;
|
||||
|
||||
public Tr(int tcount, int rcount) {
|
||||
super();
|
||||
this.tcount = tcount;
|
||||
this.rcount = rcount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.ray.util.generator;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.ray.util.FileUtil;
|
||||
import org.ray.util.generator.Composition.TR;
|
||||
import org.ray.util.generator.Composition.Tr;
|
||||
|
||||
/**
|
||||
* Generate all classes in org.ray.api.funcs
|
||||
@@ -16,10 +16,10 @@ public class FuncsGenerator {
|
||||
}
|
||||
|
||||
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";
|
||||
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);
|
||||
}
|
||||
@@ -34,20 +34,21 @@ public class FuncsGenerator {
|
||||
*
|
||||
* public static <R0> 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<R0> f = (RayFunc_0_1<R0>)SerializationUtils.deserialize(funcBytes);
|
||||
* funcBytes = (byte[])args[args.length - 1]; RayFunc_0_1<R0> f = (RayFunc_0_1<R0>)
|
||||
* SerializationUtils.deserialize(funcBytes);
|
||||
* return f.apply(); } }
|
||||
*/
|
||||
private static String build(int Tcount, int Rcount) {
|
||||
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) + ">";
|
||||
"Ray" + "Func_" + tcount + "_" + (rcount <= 0 ? (rcount == 0 ? "n" : "n_list") : rcount);
|
||||
final String gname = tname + "<" + Share.buildClassDeclare(tcount, rcount) + ">";
|
||||
|
||||
sb.append("package org.ray.api.funcs;").append("\n");
|
||||
if (Rcount > 1) {
|
||||
if (rcount > 1) {
|
||||
sb.append("import org.ray.api.returns.*;").append("\n");
|
||||
}
|
||||
if (Rcount <= 0) {
|
||||
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");
|
||||
@@ -60,14 +61,14 @@ public class FuncsGenerator {
|
||||
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<RID> returnids" + (Tcount > 0 ? ", " : "")) : "")
|
||||
.append(Share.buildParameter(Tcount, "T", null)).append(") throws Throwable;")
|
||||
sb.append("\t").append(Share.buildFuncReturn(rcount)).append(" apply(")
|
||||
.append(rcount == 0 ? ("Collection<RID> 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))
|
||||
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");
|
||||
@@ -75,8 +76,8 @@ public class FuncsGenerator {
|
||||
sb.append("\t\t").append(gname).append(" f = SerializationUtils.deserialize(funcBytes);")
|
||||
.append("\n");
|
||||
sb.append("\t\treturn f.apply(")
|
||||
.append(Rcount == 0 ? ("(Collection<RID>)args[0]" + (Tcount > 0 ? ", " : "")) : "")
|
||||
.append(Share.buildParameterUse2(Tcount, Rcount == 0 ? 1 : 0, "T", "args[", "]"))
|
||||
.append(rcount == 0 ? ("(Collection<RID>)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");
|
||||
|
||||
@@ -20,35 +20,25 @@ public class MultipleReturnGenerator {
|
||||
}
|
||||
|
||||
/**
|
||||
* package org.ray.api.returns;
|
||||
*
|
||||
* public class MultipleReturns2<R0, R1> 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]; }
|
||||
*
|
||||
* }
|
||||
* package org.ray.api.returns.
|
||||
*/
|
||||
private static String build(int Rcount) {
|
||||
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 {")
|
||||
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(") {")
|
||||
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"))
|
||||
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++) {
|
||||
for (int k = 0; k < rcount; k++) {
|
||||
sb.append(buildGetter(k));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,23 +35,23 @@ public class RayObjectsGenerator {
|
||||
*
|
||||
* public RayObject<R1> r1() { return objs[1]; } }
|
||||
*/
|
||||
private static String build(int Rcount) {
|
||||
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 {")
|
||||
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("\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("\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++) {
|
||||
for (int k = 0; k < rcount; k++) {
|
||||
sb.append(buildGetter(k));
|
||||
}
|
||||
|
||||
@@ -59,9 +59,6 @@ public class RayObjectsGenerator {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* public RayObject<R0> r0() { return objs[0]; }
|
||||
*/
|
||||
private static String buildGetter(int index) {
|
||||
return "\tpublic RayObject<R" + index + "> r" + index + "() {\n"
|
||||
+ "\t\treturn objs[" + index + "];\n"
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.ray.util.FileUtil;
|
||||
import org.ray.util.generator.Composition.TR;
|
||||
import org.ray.util.generator.Composition.Tr;
|
||||
|
||||
/**
|
||||
* Generate Rpc.java
|
||||
@@ -29,90 +29,75 @@ public class RpcGenerator {
|
||||
|
||||
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);
|
||||
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<Integer> whichTisFuture : whichTisFutureComposition(Tcount)) {
|
||||
sb.append(buildCall(Tcount, Rcount, whichTisFuture));
|
||||
private static void buildCall(StringBuilder sb, int tcount, int rcount) {
|
||||
for (Set<Integer> whichTisFuture : whichTisFutureComposition(tcount)) {
|
||||
sb.append(buildCall(tcount, rcount, whichTisFuture));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* public static <T0, R0> RayObject<R0> call(RayFunc_1_1<T0, R0> f, RayObject<T0> arg) { return
|
||||
* Ray.runtime().rpc(() -> f.apply(null), arg).objs[0]; }
|
||||
*/
|
||||
private static String buildCall(int Tcount, int Rcount, Set<Integer> whichTisFuture) {
|
||||
private static String buildCall(int tcount, int rcount, Set<Integer> 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<RID> returnids" : ", Integer returnCount")
|
||||
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<RID> returnids" : ", Integer returnCount")
|
||||
: "").append(parameter).append(") {\n");
|
||||
|
||||
/*
|
||||
* public static <R0> RayObject<R0> call(RayFunc_0_1<R0> 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")));
|
||||
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)
|
||||
+ tcount + "_" + (rcount <= 0 ? (rcount == 0 ? "n" : "n_list") : rcount)
|
||||
+ ".class, f";
|
||||
|
||||
sb.append("\t\tif (Ray.Parameters().remoteLambda()) {\n");
|
||||
if (Rcount == 1) {
|
||||
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) {
|
||||
} 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) {
|
||||
} 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)
|
||||
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) {
|
||||
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) {
|
||||
} 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) {
|
||||
} 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)
|
||||
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(rcount).append(parameterUse).append(").objs);")
|
||||
.append("\n");
|
||||
}
|
||||
sb.append("\t\t}\n");
|
||||
@@ -120,34 +105,34 @@ public class RpcGenerator {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static Set<Set<Integer>> whichTisFutureComposition(int Tcount) {
|
||||
private static Set<Set<Integer>> whichTisFutureComposition(int tcount) {
|
||||
Set<Set<Integer>> ret = new HashSet<>();
|
||||
Set<Integer> N = new HashSet<>();
|
||||
for (int k = 0; k < Tcount; k++) {
|
||||
N.add(k);
|
||||
Set<Integer> 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));
|
||||
for (int k = 0; k <= tcount; k++) {
|
||||
ret.addAll(cnn(n, k));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
//pick n numbers in N
|
||||
private static Set<Set<Integer>> CNn(Set<Integer> N, int n) {
|
||||
private static Set<Set<Integer>> cnn(Set<Integer> bigN, int n) {
|
||||
C c = new C();
|
||||
for (int k = 0; k < n; k++) {
|
||||
c.mul(N);
|
||||
c.mul(bigN);
|
||||
}
|
||||
return c.v;
|
||||
return c.vc;
|
||||
}
|
||||
|
||||
static class C {
|
||||
|
||||
Set<Set<Integer>> v;
|
||||
Set<Set<Integer>> vc;
|
||||
|
||||
public C() {
|
||||
v = new HashSet<>();
|
||||
v.add(new HashSet<>());
|
||||
vc = new HashSet<>();
|
||||
vc.add(new HashSet<>());
|
||||
}
|
||||
|
||||
void mul(Set<Integer> ns) {
|
||||
@@ -155,12 +140,12 @@ public class RpcGenerator {
|
||||
for (int n : ns) {
|
||||
ret.addAll(mul(n));
|
||||
}
|
||||
this.v = ret;
|
||||
this.vc = ret;
|
||||
}
|
||||
|
||||
Set<Set<Integer>> mul(int n) {
|
||||
Set<Set<Integer>> ret = new HashSet<>();
|
||||
for (Set<Integer> s : v) {
|
||||
for (Set<Integer> s : vc) {
|
||||
if (s.contains(n)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.ray.util.generator;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Share util for generators
|
||||
* Share util for generators.
|
||||
*/
|
||||
public class Share {
|
||||
|
||||
@@ -11,20 +11,20 @@ public class Share {
|
||||
public static final int MAX_R = 4;
|
||||
|
||||
/**
|
||||
* T0, T1, T2, T3, R
|
||||
* T0, T1, T2, T3, R.
|
||||
*/
|
||||
public static String buildClassDeclare(int Tcount, int Rcount) {
|
||||
public static String buildClassDeclare(int tcount, int rcount) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int k = 0; k < Tcount; k++) {
|
||||
for (int k = 0; k < tcount; k++) {
|
||||
sb.append("T").append(k).append(", ");
|
||||
}
|
||||
if (Rcount == 0) {
|
||||
if (rcount == 0) {
|
||||
sb.append("R, RID");
|
||||
} else if (Rcount < 0) {
|
||||
assert (Rcount == -1);
|
||||
} else if (rcount < 0) {
|
||||
assert (rcount == -1);
|
||||
sb.append("R");
|
||||
} else {
|
||||
for (int k = 0; k < Rcount; k++) {
|
||||
for (int k = 0; k < rcount; k++) {
|
||||
sb.append("R").append(k).append(", ");
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
@@ -34,16 +34,16 @@ public class Share {
|
||||
}
|
||||
|
||||
/**
|
||||
* T0 t0, T1 t1, T2 t2, T3 t3
|
||||
* T0 t0, T1 t1, T2 t2, T3 t3.
|
||||
*/
|
||||
public static String buildParameter(int Tcount, String TR, Set<Integer> whichTisFuture) {
|
||||
public static String buildParameter(int tcount, String tr, Set<Integer> whichTisFuture) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int k = 0; k < Tcount; k++) {
|
||||
for (int k = 0; k < tcount; k++) {
|
||||
sb.append(whichTisFuture != null && whichTisFuture.contains(k)
|
||||
? "RayObject<" + (TR + k) + ">" : (TR + k)).append(" ").append(TR.toLowerCase())
|
||||
? "RayObject<" + (tr + k) + ">" : (tr + k)).append(" ").append(tr.toLowerCase())
|
||||
.append(k).append(", ");
|
||||
}
|
||||
if (Tcount > 0) {
|
||||
if (tcount > 0) {
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
}
|
||||
@@ -51,77 +51,72 @@ public class Share {
|
||||
}
|
||||
|
||||
/**
|
||||
* t0, t1, t2
|
||||
* t0, t1, t2.
|
||||
*/
|
||||
public static String buildParameterUse(int Tcount, String TR) {
|
||||
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(", ");
|
||||
for (int k = 0; k < tcount; k++) {
|
||||
sb.append(tr.toLowerCase()).append(k).append(", ");
|
||||
}
|
||||
if (Tcount > 0) {
|
||||
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) {
|
||||
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)
|
||||
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) {
|
||||
if (tcount > 0) {
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* MultipleReturns2<R0, R1> apply(); R0
|
||||
*/
|
||||
public static String buildFuncReturn(int Rcount) {
|
||||
if (Rcount == 0) {
|
||||
public static String buildFuncReturn(int rcount) {
|
||||
if (rcount == 0) {
|
||||
return "Map<RID, R>";
|
||||
} else if (Rcount < 0) {
|
||||
assert (-1 == Rcount);
|
||||
} else if (rcount < 0) {
|
||||
assert (-1 == rcount);
|
||||
return "List<R>";
|
||||
}
|
||||
if (Rcount == 1) {
|
||||
if (rcount == 1) {
|
||||
return "R0";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int k = 0; k < Rcount; k++) {
|
||||
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() + ">";
|
||||
return "MultipleReturns" + rcount + "<" + sb.toString() + ">";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public static String buildRpcReturn(int Rcount) {
|
||||
if (Rcount == 0) {
|
||||
public static String buildRpcReturn(int rcount) {
|
||||
if (rcount == 0) {
|
||||
return "RayMap<RID, R>";
|
||||
} else if (Rcount < 0) {
|
||||
assert (Rcount == -1);
|
||||
} else if (rcount < 0) {
|
||||
assert (rcount == -1);
|
||||
return "RayList<R>";
|
||||
}
|
||||
|
||||
if (Rcount == 1) {
|
||||
if (rcount == 1) {
|
||||
return "RayObject<R0>";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int k = 0; k < Rcount; k++) {
|
||||
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() + ">";
|
||||
return "RayObjects" + rcount + "<" + sb.toString() + ">";
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.ray.util.logger;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* A logger which prints output to console
|
||||
* A logger which prints output to console.
|
||||
*/
|
||||
public class ConsoleLogger extends Logger {
|
||||
|
||||
@@ -14,21 +14,6 @@ public class ConsoleLogger extends Logger {
|
||||
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);
|
||||
@@ -43,4 +28,19 @@ public class ConsoleLogger extends Logger {
|
||||
public void error(Object log, Throwable e) {
|
||||
realLogger.error("(" + this.getName() + ") " + log, e);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.apache.log4j.Logger;
|
||||
import org.ray.util.CommonUtil;
|
||||
|
||||
/**
|
||||
* Dynamic logger without properties configuration file
|
||||
* Dynamic logger without properties configuration file.
|
||||
*/
|
||||
public class DynamicLog {
|
||||
|
||||
@@ -16,12 +16,11 @@ public class DynamicLog {
|
||||
private static LogLevel logLevel = LogLevel.DEBUG;
|
||||
|
||||
private static Boolean logLevelSetFlag = false;
|
||||
private static Map<String/*Samplekey*/, SampleStatis> sampleStatis = new ConcurrentHashMap<>();
|
||||
private final String key;
|
||||
|
||||
/**
|
||||
* set the context prefix for all logs
|
||||
*/
|
||||
public static void setContextPrefix(String prefix) {
|
||||
PREFIX.set(prefix);
|
||||
private DynamicLog(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public static String getContextPrefix() {
|
||||
@@ -29,7 +28,14 @@ public class DynamicLog {
|
||||
}
|
||||
|
||||
/**
|
||||
* set the level for all logs
|
||||
* set the context prefix for all logs.
|
||||
*/
|
||||
public static void setContextPrefix(String prefix) {
|
||||
PREFIX.set(prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* set the level for all logs.
|
||||
*/
|
||||
public static void setLogLevel(String level) {
|
||||
if (logLevelSetFlag) { /* one shot, avoid the risk of multithreading */
|
||||
@@ -39,13 +45,17 @@ public class DynamicLog {
|
||||
logLevel = LogLevel.of(level);
|
||||
}
|
||||
|
||||
private static LogLevel getenumLogLevel() {
|
||||
return logLevel;
|
||||
public static DynamicLog registerName(String name) {
|
||||
return DynamicLogNameRegister.registerName(name);
|
||||
}
|
||||
|
||||
public static Collection<DynamicLog> values() {
|
||||
return DynamicLogNameRegister.names.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getKey();
|
||||
public int hashCode() {
|
||||
return this.toString().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,12 +64,31 @@ public class DynamicLog {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.toString().hashCode();
|
||||
public String toString() {
|
||||
return this.getKey();
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private static LogLevel getenumLogLevel() {
|
||||
return logLevel;
|
||||
}
|
||||
|
||||
private String wrap(String level, String log) {
|
||||
StackTraceElement stes[] = Thread.currentThread().getStackTrace();
|
||||
StackTraceElement[] stes = Thread.currentThread().getStackTrace();
|
||||
String ret = "[" + level + "]" + "[" + stes[3].getFileName() + ":" + stes[3].getLineNumber()
|
||||
+ "] - " + (log == null ? "" : log);
|
||||
String prefix = PREFIX.get();
|
||||
@@ -69,23 +98,12 @@ public class DynamicLog {
|
||||
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);
|
||||
Logger[] loggers = DynamicLogManager.getLogs(this);
|
||||
for (Logger logger : loggers) {
|
||||
logger.info(log);
|
||||
}
|
||||
@@ -96,7 +114,7 @@ public class DynamicLog {
|
||||
return;
|
||||
}
|
||||
log = wrap("warn", log);
|
||||
Logger loggers[] = DynamicLogManager.getLogs(this);
|
||||
Logger[] loggers = DynamicLogManager.getLogs(this);
|
||||
for (Logger logger : loggers) {
|
||||
logger.warn(log);
|
||||
}
|
||||
@@ -107,23 +125,12 @@ public class DynamicLog {
|
||||
return;
|
||||
}
|
||||
log = wrap("warn", log);
|
||||
Logger loggers[] = DynamicLogManager.getLogs(this);
|
||||
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;
|
||||
@@ -134,12 +141,23 @@ public class DynamicLog {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger loggers[] = DynamicLogManager.getLogs(this);
|
||||
Logger[] loggers = DynamicLogManager.getLogs(this);
|
||||
for (Logger logger : loggers) {
|
||||
logger.error(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(Throwable e) {
|
||||
if (!getenumLogLevel().needLog(LogLevel.ERROR)) {
|
||||
return;
|
||||
@@ -149,12 +167,43 @@ public class DynamicLog {
|
||||
error(log);
|
||||
return;
|
||||
}
|
||||
Logger loggers[] = DynamicLogManager.getLogs(this);
|
||||
Logger[] loggers = DynamicLogManager.getLogs(this);
|
||||
for (Logger logger : loggers) {
|
||||
logger.error(log, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getDefaultLogFileName() {
|
||||
return this.key + ".log";
|
||||
}
|
||||
|
||||
//statistic for sampling
|
||||
private static class SampleStatis {
|
||||
|
||||
@@ -185,57 +234,6 @@ public class DynamicLog {
|
||||
}
|
||||
}
|
||||
|
||||
private static Map<String/*Samplekey*/, SampleStatis> 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<DynamicLog> values() {
|
||||
return DynamicLogNameRegister.names.values();
|
||||
}
|
||||
|
||||
public static class DynamicLogNameRegister {
|
||||
|
||||
static final Map<String, DynamicLog> names = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -11,27 +11,26 @@ import org.apache.log4j.RollingFileAppender;
|
||||
import org.ray.util.SystemUtil;
|
||||
|
||||
/**
|
||||
* Manager for dynamic loggers
|
||||
* Manager for dynamic loggers.
|
||||
*/
|
||||
public class DynamicLogManager {
|
||||
|
||||
protected static final String DAY_DATE_PATTERN = "'.'yyyy-MM-dd";
|
||||
private static final int LOG_CACHE_SIZE = 32 * 1024;
|
||||
// private final static String HOUR_DATE_PATTERN = "'
|
||||
// .'yyyy-MM-dd_HH";
|
||||
// private final static String GBK = "GBK";
|
||||
private static final String DAILY_APPENDER_NAME = "_DAILY_APPENDER_NAME";
|
||||
// private final static String CONSOLE_APPENDER_NAME =
|
||||
// "_CONSOLE_APPENDER_NAME";
|
||||
private static final String LAYOUT_PATTERN = "%d [%t]%m%n";
|
||||
private static final ConcurrentHashMap<DynamicLog, Logger> loggers = new ConcurrentHashMap<>();
|
||||
//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<DynamicLog, Logger> loggers = new ConcurrentHashMap<>();
|
||||
|
||||
private static int MAX_FILE_NUM = 10;
|
||||
|
||||
private static String MAX_FILE_SIZE = "500MB";
|
||||
@@ -98,13 +97,13 @@ public class DynamicLogManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Logger[]{logger};
|
||||
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);
|
||||
final ConsoleLogger logger = new ConsoleLogger(dynLog.getKey(), reallogger);
|
||||
PatternLayout layout = new PatternLayout(LAYOUT_PATTERN);
|
||||
ConsoleAppender appender = new ConsoleAppender(layout, ConsoleAppender.SYSTEM_OUT);
|
||||
reallogger.removeAllAppenders();
|
||||
@@ -122,7 +121,7 @@ public class DynamicLogManager {
|
||||
}
|
||||
|
||||
protected static Logger makeLogger(String loggerName, String filename) {
|
||||
Logger logger = Logger.getLogger(loggerName);
|
||||
final Logger logger = Logger.getLogger(loggerName);
|
||||
PatternLayout layout = new PatternLayout(LAYOUT_PATTERN);
|
||||
File dir = new File(logsDir);
|
||||
if (!dir.exists()) {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package org.ray.util.logger;
|
||||
|
||||
/**
|
||||
* Dynamic loggers in Ray
|
||||
* Dynamic loggers in Ray.
|
||||
*/
|
||||
public class RayLog {
|
||||
|
||||
/**
|
||||
* for ray itself
|
||||
* for ray itself.
|
||||
*/
|
||||
public static final DynamicLog core = DynamicLog.registerName("core");
|
||||
|
||||
/**
|
||||
* for ray's app's log
|
||||
* for ray's app's log.
|
||||
*/
|
||||
public static DynamicLog rapp = core; //DynamicLog.registerName("rapp");
|
||||
}
|
||||
|
||||
+6
-6
@@ -7,11 +7,15 @@ import org.apache.log4j.Layout;
|
||||
import org.apache.log4j.RollingFileAppender;
|
||||
|
||||
/**
|
||||
* Normal log appender
|
||||
* Normal log appender.
|
||||
*/
|
||||
public class TimedFlushDailyRollingFileAppender extends RollingFileAppender {
|
||||
|
||||
private final static Set<TimedFlushDailyRollingFileAppender> all = new HashSet<>();
|
||||
private static final Set<TimedFlushDailyRollingFileAppender> all = new HashSet<>();
|
||||
|
||||
static {
|
||||
new TimedFlushLogThread().start();
|
||||
}
|
||||
|
||||
public TimedFlushDailyRollingFileAppender() {
|
||||
super();
|
||||
@@ -27,10 +31,6 @@ public class TimedFlushDailyRollingFileAppender extends RollingFileAppender {
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
new TimedFlushLogThread().start();
|
||||
}
|
||||
|
||||
private void flush() {
|
||||
try {
|
||||
if (!checkEntryConditions()) {
|
||||
|
||||
+87
-87
@@ -1,102 +1,102 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-example</artifactId>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-example</artifactId>
|
||||
|
||||
<name>java example for ray</name>
|
||||
<description>java example for ray</description>
|
||||
<url></url>
|
||||
<name>java example for ray</name>
|
||||
<description>java example for ray</description>
|
||||
<url></url>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-common</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-common</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-native</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-native</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-dev</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-dev</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-common</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-common</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-hook</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.20.1</version>
|
||||
<configuration>
|
||||
<environmentVariables>
|
||||
<RAY_CONFIG>${basedir}/../ray.config.ini</RAY_CONFIG>
|
||||
</environmentVariables>
|
||||
<argLine>-ea
|
||||
-Djava.library.path=${basedir}/../../build/src/plasma:${basedir}/../../build/src/local_scheduler
|
||||
-noverify
|
||||
-DlogOutput=console
|
||||
</argLine>
|
||||
<testSourceDirectory>${basedir}/src/main/java/</testSourceDirectory>
|
||||
<testClassesDirectory>${project.build.directory}/classes/</testClassesDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-hook</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.20.1</version>
|
||||
<configuration>
|
||||
<environmentVariables>
|
||||
<RAY_CONFIG>${basedir}/../ray.config.ini</RAY_CONFIG>
|
||||
</environmentVariables>
|
||||
<argLine>-ea
|
||||
-Djava.library.path=${basedir}/../../build/src/plasma:${basedir}/../../build/src/local_scheduler
|
||||
-noverify
|
||||
-DlogOutput=console
|
||||
</argLine>
|
||||
<testSourceDirectory>${basedir}/src/main/java/</testSourceDirectory>
|
||||
<testClassesDirectory>${project.build.directory}/classes/</testClassesDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/lib</outputDirectory>
|
||||
<overWriteReleases>false</overWriteReleases>
|
||||
<overWriteSnapshots>false</overWriteSnapshots>
|
||||
<overWriteIfNewer>true</overWriteIfNewer>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${basedir}/lib</outputDirectory>
|
||||
<overWriteReleases>false</overWriteReleases>
|
||||
<overWriteSnapshots>false</overWriteSnapshots>
|
||||
<overWriteIfNewer>true</overWriteIfNewer>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
package org.ray.example;
|
||||
|
||||
import java.io.Serializable;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayObject;
|
||||
import org.ray.api.RayRemote;
|
||||
import org.ray.core.RayRuntime;
|
||||
import org.ray.util.logger.RayLog;
|
||||
|
||||
import java.io.Serializable;
|
||||
public class HelloWorld implements Serializable {
|
||||
|
||||
public class HelloWorld implements Serializable{
|
||||
|
||||
|
||||
public static String sayHelloWorld() {
|
||||
RayObject<String> hello = Ray.call(HelloWorld::sayHello);
|
||||
RayObject<String> world = Ray.call(HelloWorld::sayWorld);
|
||||
return Ray.call(HelloWorld::merge, hello, world).get();
|
||||
}
|
||||
|
||||
@RayRemote
|
||||
public static String sayHello() {
|
||||
@@ -39,18 +32,22 @@ public class HelloWorld implements Serializable{
|
||||
|
||||
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) {
|
||||
Ray.init();
|
||||
String helloWorld = HelloWorld.sayHelloWorld();
|
||||
RayLog.rapp.info(helloWorld);
|
||||
assert helloWorld.equals("hello,world!");
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
RayRuntime.getInstance().cleanUp();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static String sayHelloWorld() {
|
||||
RayObject<String> hello = Ray.call(HelloWorld::sayHello);
|
||||
RayObject<String> world = Ray.call(HelloWorld::sayWorld);
|
||||
return Ray.call(HelloWorld::merge, hello, world).get();
|
||||
}
|
||||
}
|
||||
|
||||
+75
-75
@@ -1,88 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-hook</artifactId>
|
||||
<name>java api hook for ray</name>
|
||||
<description>java api hook for ray</description>
|
||||
<url></url>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-hook</artifactId>
|
||||
<name>java api hook for ray</name>
|
||||
<description>java api hook for ray</description>
|
||||
<url></url>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependencies>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.ow2.asm/asm -->
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
<version>6.0</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.ow2.asm/asm -->
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
<version>6.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-common</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-common</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Premain-Class>org.ray.hook.Agent</Premain-Class>
|
||||
<Can-Retransform-Classes>true</Can-Retransform-Classes>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Premain-Class>org.ray.hook.Agent</Premain-Class>
|
||||
<Can-Retransform-Classes>true</Can-Retransform-Classes>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.objectweb.asm</pattern>
|
||||
<shadedPattern>agent.org.objectweb.asm</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.objectweb.asm</pattern>
|
||||
<shadedPattern>agent.org.objectweb.asm</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -6,21 +6,10 @@ import org.objectweb.asm.ClassWriter;
|
||||
|
||||
public class ClassAdapter {
|
||||
|
||||
public static class Result {
|
||||
|
||||
public byte[] classBuffer;
|
||||
public Set<MethodId> 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);
|
||||
@@ -46,4 +35,10 @@ public class ClassAdapter {
|
||||
rr.classBuffer = result;
|
||||
return rr;
|
||||
}
|
||||
|
||||
public static class Result {
|
||||
|
||||
public byte[] classBuffer;
|
||||
public Set<MethodId> changedMethods;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,20 +11,16 @@ import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
|
||||
/**
|
||||
* rewrite phase 1
|
||||
* rewrite phase 1.
|
||||
*/
|
||||
public class ClassDetectVisitor extends ClassVisitor {
|
||||
|
||||
static int count = 0;
|
||||
final String className;
|
||||
final Set<MethodId> rayMethods = new HashSet<>();
|
||||
boolean isActor = false;
|
||||
static int count = 0;
|
||||
int actorCalls = 0;
|
||||
final ClassLoader loader;
|
||||
|
||||
public int actorCalls() {
|
||||
return actorCalls;
|
||||
}
|
||||
boolean isActor = false;
|
||||
int actorCalls = 0;
|
||||
|
||||
public ClassDetectVisitor(ClassLoader loader, ClassVisitor origin, String className) {
|
||||
super(Opcodes.ASM6, origin);
|
||||
@@ -32,15 +28,12 @@ public class ClassDetectVisitor extends ClassVisitor {
|
||||
this.loader = loader;
|
||||
}
|
||||
|
||||
public Set<MethodId> detectedMethods() {
|
||||
return rayMethods;
|
||||
public int actorCalls() {
|
||||
return actorCalls;
|
||||
}
|
||||
|
||||
@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);
|
||||
public Set<MethodId> detectedMethods() {
|
||||
return rayMethods;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,20 +44,16 @@ public class ClassDetectVisitor extends ClassVisitor {
|
||||
return super.visitAnnotation(desc, visible);
|
||||
}
|
||||
|
||||
private void visitRayMethod(int access, String name, String mdesc) {
|
||||
if (name.equals("<init>")) {
|
||||
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 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 MethodVisitor visitMethod(int access, String name, String mdesc, String signature,
|
||||
String[] exceptions) {
|
||||
String[] exceptions) {
|
||||
//System.out.println("Visit " + className + "." + name);
|
||||
if (isActor && (access & Opcodes.ACC_PUBLIC) != 0) {
|
||||
visitRayMethod(access, name, mdesc);
|
||||
@@ -81,41 +70,9 @@ public class ClassDetectVisitor extends ClassVisitor {
|
||||
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) {
|
||||
Object... bsmArgs) {
|
||||
|
||||
// fix all actor calls from InvokeVirtual to InvokeStatic
|
||||
if (desc.contains("org/ray/api/funcs/RayFunc_")) {
|
||||
@@ -151,7 +108,8 @@ public class ClassDetectVisitor extends ClassVisitor {
|
||||
dsptr,
|
||||
h.isInterface());
|
||||
bsmArgs[i] = newh;
|
||||
//System.err.println("Change ray.call from " + h + " -> " + newh + ", isInterface = " + h.isInterface());
|
||||
//System.err.println("Change ray.call from " + h + " -> " + newh + ", isInterface
|
||||
// = " + h.isInterface());
|
||||
++actorCalls;
|
||||
}
|
||||
}
|
||||
@@ -159,6 +117,49 @@ public class ClassDetectVisitor extends ClassVisitor {
|
||||
}
|
||||
super.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void visitRayMethod(int access, String name, String mdesc) {
|
||||
if (name.equals("<init>")) {
|
||||
return;
|
||||
}
|
||||
|
||||
MethodId m = new MethodId(className, name, mdesc, (access & Opcodes.ACC_STATIC) != 0, loader);
|
||||
rayMethods.add(m);
|
||||
//System.err.println("Visit " + m.toString());
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,75 +7,33 @@ import org.objectweb.asm.MethodVisitor;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
|
||||
/**
|
||||
* rewrite phase 2
|
||||
* rewrite phase 2.
|
||||
*/
|
||||
public class ClassOverrideVisitor extends ClassVisitor {
|
||||
|
||||
final String className;
|
||||
final Set<MethodId> rayRemoteMethods;
|
||||
MethodVisitor ClinitVisitor;
|
||||
|
||||
// init the static added field in <clinit>
|
||||
// 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 <clinit>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
MethodVisitor clinitVisitor;
|
||||
|
||||
public ClassOverrideVisitor(ClassVisitor origin, String className,
|
||||
Set<MethodId> rayRemoteMethods) {
|
||||
Set<MethodId> rayRemoteMethods) {
|
||||
super(Opcodes.ASM6, origin);
|
||||
this.className = className;
|
||||
this.rayRemoteMethods = rayRemoteMethods;
|
||||
this.ClinitVisitor = null;
|
||||
this.clinitVisitor = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MethodVisitor visitMethod(int access, String name, String desc, String signature,
|
||||
String[] exceptions) {
|
||||
if ("<clinit>".equals(name) && ClinitVisitor == null) {
|
||||
String[] exceptions) {
|
||||
if ("<clinit>".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
|
||||
clinitVisitor = new StaticBlockVisitor(mv);
|
||||
return clinitVisitor;// dispatch the ASM modifications (assign values to the preComputedxxx
|
||||
// static field) to the clinitVisitor
|
||||
}
|
||||
|
||||
ClassVisitor this_ = this;
|
||||
ClassVisitor current = this;
|
||||
MethodId m = new MethodId(className, name, desc, (access & Opcodes.ACC_STATIC) != 0, null);
|
||||
if (rayRemoteMethods.contains(m)) {
|
||||
if (m.isStaticMethod()) {
|
||||
@@ -86,10 +44,11 @@ public class ClassOverrideVisitor extends ClassVisitor {
|
||||
// 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",
|
||||
current.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
|
||||
// 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",
|
||||
@@ -103,10 +62,7 @@ public class ClassOverrideVisitor extends ClassVisitor {
|
||||
mv.visitCode();// real work
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// non-static
|
||||
else {
|
||||
} else { // non-static
|
||||
return super.visitMethod(access, name, desc, signature, exceptions);
|
||||
}
|
||||
} else {
|
||||
@@ -116,7 +72,7 @@ public class ClassOverrideVisitor extends ClassVisitor {
|
||||
|
||||
@Override
|
||||
public void visitEnd() {
|
||||
if (ClinitVisitor == null) { // works fine
|
||||
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
|
||||
@@ -163,14 +119,6 @@ public class ClassOverrideVisitor extends ClassVisitor {
|
||||
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();
|
||||
}
|
||||
@@ -220,4 +168,47 @@ public class ClassOverrideVisitor extends ClassVisitor {
|
||||
return str.substring(left);
|
||||
}
|
||||
|
||||
// init the static added field in <clinit>
|
||||
// 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 <clinit>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ 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;
|
||||
@@ -26,7 +25,7 @@ import org.ray.hook.runtime.LoadedFunctions;
|
||||
import org.ray.util.logger.RayLog;
|
||||
|
||||
/**
|
||||
* rewrite jars to new jars with methods marked using Ray annotations
|
||||
* rewrite jars to new jars with methods marked using Ray annotations.
|
||||
*/
|
||||
public class JarRewriter {
|
||||
|
||||
@@ -51,10 +50,32 @@ public class JarRewriter {
|
||||
rewrite(args[0], args[1]);
|
||||
}
|
||||
|
||||
public static LoadedFunctions load(String dir, String baseDir)
|
||||
throws FileNotFoundException, SecurityException {
|
||||
List<String> 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<String> baseFunctions = JarRewriter.getRewrittenFunctions(baseDir);
|
||||
for (String func : baseFunctions) {
|
||||
MethodId mid = new MethodId(func, efuncs.loader);
|
||||
efuncs.functions.add(mid);
|
||||
}
|
||||
}
|
||||
|
||||
return efuncs;
|
||||
}
|
||||
|
||||
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);
|
||||
final File toDirFile = new File(toDir);
|
||||
|
||||
File[] topFiles = fromDirFile.listFiles();
|
||||
if (topFiles.length != 1 || !topFiles[0].isDirectory()) {
|
||||
@@ -103,57 +124,6 @@ public class JarRewriter {
|
||||
FileUtils.moveDirectory(toDirFileTmp, toDirFile);
|
||||
}
|
||||
|
||||
public static LoadedFunctions load(String dir, String baseDir)
|
||||
throws FileNotFoundException, SecurityException {
|
||||
List<String> 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<String> 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<String> 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<String> getRewrittenFunctions(String rewrittenDir)
|
||||
throws FileNotFoundException {
|
||||
ArrayList<String> 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<ClassLoader, MethodId> consumer)
|
||||
throws IOException {
|
||||
|
||||
@@ -170,7 +140,8 @@ public class JarRewriter {
|
||||
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);
|
||||
//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 "
|
||||
@@ -198,4 +169,33 @@ public class JarRewriter {
|
||||
ojStream.close();
|
||||
ofStream.close();
|
||||
}
|
||||
|
||||
public static List<String> getRewrittenFunctions(String rewrittenDir)
|
||||
throws FileNotFoundException {
|
||||
ArrayList<String> 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 LoadedFunctions loadBase(String baseDir)
|
||||
throws FileNotFoundException, SecurityException {
|
||||
List<String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,27 +11,26 @@ import org.objectweb.asm.Type;
|
||||
import org.ray.util.logger.RayLog;
|
||||
|
||||
/**
|
||||
* Represent a Method in a Class
|
||||
* Represent a Method in a Class.
|
||||
*/
|
||||
public class MethodId {
|
||||
|
||||
static final String getFunctionIdPostfix = "_function_id";
|
||||
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_) {
|
||||
public MethodId(String cls, String method, String mdesc, boolean isstatic, ClassLoader loader) {
|
||||
className = cls;
|
||||
methodName = method;
|
||||
methodDesc = mdesc;
|
||||
isStatic = isstatic;
|
||||
loader = loader_;
|
||||
this.loader = loader;
|
||||
}
|
||||
|
||||
public MethodId(String encodedString, ClassLoader loader_) {
|
||||
public MethodId(String encodedString, ClassLoader loader) {
|
||||
// className + "." + methodName + "::" + methodDesc + "&&" + isStatic;
|
||||
int lastPos3 = encodedString.lastIndexOf("&&");
|
||||
int lastPos2 = encodedString.lastIndexOf("::");
|
||||
@@ -45,7 +44,24 @@ public class MethodId {
|
||||
methodName = encodedString.substring(lastPos1 + ".".length(), lastPos2);
|
||||
methodDesc = encodedString.substring(lastPos2 + "::".length(), lastPos3);
|
||||
isStatic = Boolean.parseBoolean(encodedString.substring(lastPos3 + "&&".length()));
|
||||
loader = loader_;
|
||||
this.loader = loader;
|
||||
}
|
||||
|
||||
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 String getClassName() {
|
||||
@@ -76,23 +92,6 @@ public class MethodId {
|
||||
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;
|
||||
@@ -153,7 +152,8 @@ public class MethodId {
|
||||
: "<nil>") + " vs id-hash: " + toHexHashString());
|
||||
}
|
||||
}
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
|
||||
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException
|
||||
| IllegalAccessException e) {
|
||||
RayLog.core.error("load method hash field failed for " + toString(), e);
|
||||
}
|
||||
return m;
|
||||
|
||||
@@ -17,13 +17,13 @@ import org.apache.commons.io.filefilter.RegexFileFilter;
|
||||
import org.ray.util.logger.RayLog;
|
||||
|
||||
/**
|
||||
* load and unload jars from a dir
|
||||
* load and unload jars from a dir.
|
||||
*/
|
||||
public class JarLoader {
|
||||
|
||||
private static Method AddUrl = InitAddUrl();
|
||||
private static Method AddUrl = initAddUrl();
|
||||
|
||||
private static Method InitAddUrl() {
|
||||
private static Method initAddUrl() {
|
||||
try {
|
||||
Method m = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
|
||||
m.setAccessible(true);
|
||||
@@ -59,10 +59,6 @@ public class JarLoader {
|
||||
return loadJar(jars, explicitLoadForHook);
|
||||
}
|
||||
|
||||
public static void unloadJars(ClassLoader loader) {
|
||||
// TODO:
|
||||
}
|
||||
|
||||
private static URLClassLoader loadJar(Collection<File> appJars, boolean explicitLoadForHook) {
|
||||
List<JarFile> jars = new ArrayList<>();
|
||||
List<URL> urls = new ArrayList<>();
|
||||
@@ -128,4 +124,8 @@ public class JarLoader {
|
||||
|
||||
jars.addAll(files);
|
||||
}
|
||||
|
||||
public static void unloadJars(ClassLoader loader) {
|
||||
// TODO:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ import org.ray.hook.MethodId;
|
||||
|
||||
public class LoadedFunctions {
|
||||
|
||||
public ClassLoader loader = null;
|
||||
public final Set<MethodId> functions = Collections.synchronizedSet(new HashSet<>());
|
||||
public ClassLoader loader = null;
|
||||
}
|
||||
|
||||
@@ -10,15 +10,15 @@ public class MethodHash {
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
public byte[] getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(getHash());
|
||||
}
|
||||
|
||||
public byte[] getHash() {
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.ray.hook.runtime;
|
||||
|
||||
/**
|
||||
* method mode switch at runtime
|
||||
* method mode switch at runtime.
|
||||
*/
|
||||
public class MethodSwitcher {
|
||||
|
||||
|
||||
+144
-110
@@ -1,122 +1,156 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
<modules>
|
||||
<module>api</module>
|
||||
<module>common</module>
|
||||
<module>hook</module>
|
||||
<module>runtime-common</module>
|
||||
<module>runtime-native</module>
|
||||
<module>runtime-dev</module>
|
||||
<module>test</module>
|
||||
<module>example</module>
|
||||
</modules>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
<modules>
|
||||
<module>api</module>
|
||||
<module>common</module>
|
||||
<module>hook</module>
|
||||
<module>runtime-common</module>
|
||||
<module>runtime-native</module>
|
||||
<module>runtime-dev</module>
|
||||
<module>test</module>
|
||||
<module>example</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.arrow</groupId>
|
||||
<artifactId>arrow-plasma</artifactId>
|
||||
<version>0.10.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.arrow</groupId>
|
||||
<artifactId>arrow-plasma</artifactId>
|
||||
<version>0.10.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
<compilerArgument>-parameters</compilerArgument>
|
||||
<testCompilerArgument>-parameters</testCompilerArgument>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
<compilerArgument>-parameters</compilerArgument>
|
||||
<testCompilerArgument>-parameters</testCompilerArgument>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.10</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>2.10</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>maven-jetty-plugin</artifactId>
|
||||
<version>6.1.26</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>maven-jetty-plugin</artifactId>
|
||||
<version>6.1.26</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>deploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>deploy</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.8.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>deploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>deploy</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>2.17</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.puppycrawl.tools</groupId>
|
||||
<artifactId>checkstyle</artifactId>
|
||||
<version>6.19</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>validate</id>
|
||||
<phase>validate</phase>
|
||||
<goals>
|
||||
<goal>check</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<configLocation>checkstyle.xml</configLocation>
|
||||
<suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
|
||||
<encoding>UTF-8</encoding>
|
||||
<consoleOutput>true</consoleOutput>
|
||||
<failsOnError>false</failsOnError>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
<violationSeverity>warning</violationSeverity>
|
||||
<format>xml</format>
|
||||
<format>html</format>
|
||||
<outputFile>${project.build.directory}/test/checkstyle-errors.xml</outputFile>
|
||||
<linkXRef>false</linkXRef>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
+4
-4
@@ -117,7 +117,7 @@ driver_class =
|
||||
|
||||
[ray.java.path.jni.package]
|
||||
%CONFIG_FILE_DIR%/../build/src/plasma =
|
||||
%CONFIG_FILE_DIR%/../build/src/local_scheduler =
|
||||
%CONFIG_FILE_DIR%/../build/src/local_scheduler =
|
||||
|
||||
[ray.java.path.jni.deploy]
|
||||
%CONFIG_FILE_DIR%/native/lib =
|
||||
@@ -130,7 +130,7 @@ 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_runtime_rewritten_jars_dir =
|
||||
java_class_paths = ray.java.path.classes.source
|
||||
java_jnilib_paths = ray.java.path.jni.package
|
||||
|
||||
@@ -142,7 +142,7 @@ 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_runtime_rewritten_jars_dir =
|
||||
java_class_paths = ray.java.path.classes.package
|
||||
java_jnilib_paths = ray.java.path.jni.package
|
||||
|
||||
@@ -154,7 +154,7 @@ 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_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
|
||||
|
||||
|
||||
+48
-48
@@ -1,58 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-common</artifactId>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-common</artifactId>
|
||||
|
||||
<name>runtime common</name>
|
||||
<description>runtime common</description>
|
||||
<url></url>
|
||||
<name>runtime common</name>
|
||||
<description>runtime common</description>
|
||||
<url></url>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-hook</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.ruedigermoeller</groupId>
|
||||
<artifactId>fst</artifactId>
|
||||
<version>2.47</version>
|
||||
</dependency>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-api</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-hook</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.ruedigermoeller</groupId>
|
||||
<artifactId>fst</artifactId>
|
||||
<version>2.47</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.github.davidmoten/flatbuffers-java -->
|
||||
<dependency>
|
||||
<groupId>com.github.davidmoten</groupId>
|
||||
<artifactId>flatbuffers-java</artifactId>
|
||||
<version>1.7.0.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.davidmoten/flatbuffers-java -->
|
||||
<dependency>
|
||||
<groupId>com.github.davidmoten</groupId>
|
||||
<artifactId>flatbuffers-java</artifactId>
|
||||
<version>1.7.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.arrow</groupId>
|
||||
<artifactId>arrow-plasma</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/redis.clients/jedis -->
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.arrow</groupId>
|
||||
<artifactId>arrow-plasma</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user