[Java] improve Java API module (#2783)

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

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

(Apologize for posting such a large PR. Java worker code has been lack of maintenance for a while. There're a lot of code quality issues that need to be fixed. We plan to use a couple of large PRs to address them. After that, future changes will come in small PRs.)
This commit is contained in:
Hao Chen
2018-09-03 02:51:16 +08:00
committed by Robert Nishihara
parent 2691b3a11a
commit 3b0a2c4197
98 changed files with 2232 additions and 2158 deletions
@@ -6,7 +6,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import net.lingala.zip4j.core.ZipFile;
import org.ray.api.UniqueID;
import org.ray.api.id.UniqueId;
import org.ray.core.model.RayParameters;
import org.ray.core.model.RunMode;
import org.ray.runner.RunManager;
@@ -162,10 +162,7 @@ public class RayCli {
cmdSubmit.packageZip.lastIndexOf('/') + 1,
cmdSubmit.packageZip.lastIndexOf('.'));
//final RemoteFunctionManager functionManager = RayRuntime
// .getInstance().getRemoteFunctionManager();
UniqueID resourceId = functionManager.registerResource(zip);
UniqueId resourceId = functionManager.registerResource(zip);
// Init RayLog before using it.
RayLog.init(params.log_dir);
@@ -173,7 +170,7 @@ public class RayCli {
RayLog.rapp.debug(
"registerResource " + resourceId + " for package " + packageName + " done");
UniqueID appId = params.driver_id;
UniqueId appId = params.driver_id;
functionManager.registerApp(appId, resourceId);
RayLog.rapp.debug("registerApp " + appId + " for resouorce " + resourceId + " done");
@@ -206,8 +203,6 @@ public class RayCli {
RayLog.rapp.debug("Find app class path " + additionalClassPath);
// Start driver process.
//RunManager runManager = new RunManager(params, RayRuntime.getInstance().getPaths(),
// RayRuntime.configReader);
RunManager runManager = new RunManager(params, paths, config);
Process proc = runManager.startDriver(
DefaultDriver.class.getName(),