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

[Java] improve Java API module #2783

Merged
merged 17 commits into from
Sep 2, 2018
Prev Previous commit
Next Next commit
fix and document
  • Loading branch information
raulchen committed Aug 31, 2018
commit 536e39f42bed9dd1a425fe54bd052498d19ab09c
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import java.lang.annotation.Target;

/**
* Defines a remote function (when used on a method)
* or actor (when used on a class).
* Defines a remote function (when used on a method),
* or an actor (when used on a class).
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
Expand All @@ -20,5 +20,5 @@
* for this task or for the lifetime of the actor.
* @return an array of custom resource items.
*/
ResourceItem[] resources() default {@ResourceItem()};
ResourceItem[] resources() default {};
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Name of this resource, must not be null or empty.
*/
String name() default "";
String name();

/**
* Quantity of this resource.
Expand Down
7 changes: 1 addition & 6 deletions java/cli/src/main/java/org/ray/cli/RayCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,6 @@ private static void submit(CommandSubmit cmdSubmit, String configPath) throws Ex
cmdSubmit.packageZip.lastIndexOf('/') + 1,
cmdSubmit.packageZip.lastIndexOf('.'));

//final RemoteFunctionManager functionManager = AbstractRayRuntime
// .getInstance().getRemoteFunctionManager();

UniqueId resourceId = functionManager.registerResource(zip);

// Init RayLog before using it.
Expand All @@ -181,7 +178,7 @@ private static void submit(CommandSubmit cmdSubmit, String configPath) throws Ex
String appDir = "/tmp/" + cmdSubmit.className;
String extPath = appDir + "/" + packageName;
if (!FileUtil.createDir(extPath, false)) {
throw new RuntimeException("createActor dir " + extPath + " failed ");
throw new RuntimeException("create dir " + extPath + " failed ");
}

ZipFile zipFile = new ZipFile(cmdSubmit.packageZip);
Expand All @@ -206,8 +203,6 @@ private static void submit(CommandSubmit cmdSubmit, String configPath) throws Ex
RayLog.rapp.debug("Find app class path " + additionalClassPath);

// Start driver process.
//RunManager runManager = new RunManager(params, AbstractRayRuntime.getInstance().getPaths(),
// AbstractRayRuntime.configReader);
RunManager runManager = new RunManager(params, paths, config);
Process proc = runManager.startDriver(
DefaultDriver.class.getName(),
Expand Down
2 changes: 1 addition & 1 deletion java/common/src/main/java/org/ray/util/FileUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static byte[] fileToBytes(String name) throws IOException {
public static String getCanonicalDirectory(final String rawDir) throws IOException {
String dir = rawDir.length() == 0 ? "." : rawDir;

// createActor working dir if necessary
// create working dir if necessary
File dd = new File(dir);
if (!dd.exists()) {
dd.mkdirs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ private static Object createLocalActor(UniqueId actorId, String className) {
}

/**
* generate the return ids of a task.
* Generate the return ids of a task.
*/
private UniqueId[] genReturnIds(UniqueId taskId, int numReturns) {
UniqueId[] ret = new UniqueId[numReturns];
Expand All @@ -399,6 +399,15 @@ private UniqueId[] genReturnIds(UniqueId taskId, int numReturns) {
return ret;
}

/**
* Create the task specification.
* @param func The target remote function.
* @param actor The actor handle. If the task is not an actor task, actor id must be NIL.
* @param args The arguments for the remote function.
* @param actorClassForCreation If the task is a actor creation task, the argument should be
* the actor class. Otherwise, it should be null.
* @return A TaskSpec object.
*/
private TaskSpec createTaskSpec(RayFunc func, RayActorImpl actor, Object[] args,
Class actorClassForCreation) {
final TaskSpec current = WorkerContext.currentTask();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ RayMethod getTaskMethod(UniqueId methodId, String className) {
RayTaskMethods tasks = taskMethods.get(className);
if (tasks == null) {
tasks = RayTaskMethods.fromClass(className, classLoader);
RayLog.core.info("createActor RayTaskMethods:" + tasks);
RayLog.core.info("create RayTaskMethods:" + tasks);
taskMethods.put(className, tasks);
}
RayMethod m = tasks.functions.get(methodId);
Expand All @@ -113,7 +113,7 @@ private RayMethod getActorMethod(UniqueId methodId, String className, boolean is
RayActorMethods actor = actors.get(className);
if (actor == null) {
actor = RayActorMethods.fromClass(className, classLoader);
RayLog.core.info("createActor RayActorMethods:" + actor);
RayLog.core.info("create RayActorMethods:" + actor);
actors.put(className, actor);
}
return isStatic ? actor.staticFunctions.get(methodId) : actor.functions.get(methodId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
import org.ray.api.id.UniqueId;


//
// Helper methods for UniqueId. These are the same as the helper functions in src/ray/id.h.
//
/**
* Helper method for UniqueId.
* Note: any changes to these methods must be synced with C++ helper functions
* in src/ray/id.h
*/
public class UniqueIdHelper {
public static final int OBJECT_INDEX_POS = 0;
public static final int OBJECT_INDEX_LENGTH = 4;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public interface FileStoreLink {
/**
* Create an FSDataOutputStream at the indicated Path. Files are overwritten by default.
*
* @param f the file to createActor
* @param f the file to create
*/
DataOutputStream create(String f, boolean overwrite);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* This exception is raised if the object could not be created because the plasma store is unable to
* evict enough objects to createActor room for it.
* evict enough objects to create room for it.
*/
public class PlasmaOutOfMemoryException extends Exception {

Expand Down