Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JavaWorker] Java code lint check and binding to CI #2225

Merged
merged 3 commits into from Jun 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
99 changes: 49 additions & 50 deletions java/api/pom.xml
@@ -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>

<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>

<dependencies>

<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>

<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>

<packaging>jar</packaging>

<dependencies>

<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>

</project>
38 changes: 19 additions & 19 deletions java/api/src/main/java/org/ray/api/Ray.java
Expand Up @@ -7,12 +7,14 @@
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) {
Expand All @@ -21,44 +23,44 @@ public static void init() {
}

/**
* 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);
}

Expand All @@ -77,7 +79,7 @@ public static <T> WaitResult<T> wait(RayObject<T> waitfor, int timeoutMillisecon
}

/**
* create actor object
* create actor object.
*/
public static <T> RayActor<T> create(Class<T> cls) {
try {
Expand All @@ -95,23 +97,21 @@ public static <T> RayActor<T> create(Class<T> cls) {
}

/**
* 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;
Expand Down
16 changes: 8 additions & 8 deletions java/api/src/main/java/org/ray/api/RayActor.java
Expand Up @@ -7,7 +7,7 @@
import org.ray.util.Sha1Digestor;

/**
* Ray actor abstraction
* Ray actor abstraction.
*/
public class RayActor<T> extends RayObject<T> implements Externalizable {

Expand Down Expand Up @@ -40,7 +40,7 @@ public int increaseTaskCounter() {
}

/**
* Getter method for property <tt>taskCursor</tt>
* Getter method for property <tt>taskCursor</tt>.
*
* @return property value of taskCursor
*/
Expand All @@ -49,19 +49,14 @@ public UniqueID getTaskCursor() {
}

/**
* Setter method for property <tt>taskCursor</tt>
* Setter method for property <tt>taskCursor</tt>.
*
* @param taskCursor value to be assigned to property taskCursor
*/
public void setTaskCursor(UniqueID taskCursor) {
this.taskCursor = taskCursor;
}

public UniqueID computeNextActorHandleId() {
byte[] bytes = Sha1Digestor.digest(actorHandleId.id, ++forksNum);
return new UniqueID(bytes);
}

public UniqueID getActorHandleId() {
return actorHandleId;
}
Expand All @@ -77,6 +72,11 @@ public void writeExternal(ObjectOutput out) throws IOException {
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 {

Expand Down
63 changes: 33 additions & 30 deletions java/api/src/main/java/org/ray/api/RayApi.java
Expand Up @@ -7,95 +7,98 @@
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();
}