[Java] Enable direct call by default. (#7408)

* WIP

* Address comments.

* Linting

* Fix

* Fix

* Fix test

* Fix

* Fix single process ci

* Fix ut

* Update java/test/src/main/java/org/ray/api/test/PlasmaFreeTest.java

* Address comments

* Fix linting

* Minor update comments.

* Fix streaming CI
This commit is contained in:
Qing Wang
2020-03-13 12:25:30 +08:00
committed by GitHub
parent 6993a471f1
commit f4656d8cc3
20 changed files with 34 additions and 161 deletions
@@ -18,8 +18,8 @@ public class ActorCreationOptions extends BaseTaskOptions {
public final int maxConcurrency;
private ActorCreationOptions(Map<String, Double> resources, int maxReconstructions,
boolean useDirectCall, String jvmOptions, int maxConcurrency) {
super(resources, useDirectCall);
String jvmOptions, int maxConcurrency) {
super(resources);
this.maxReconstructions = maxReconstructions;
this.jvmOptions = jvmOptions;
this.maxConcurrency = maxConcurrency;
@@ -32,7 +32,6 @@ public class ActorCreationOptions extends BaseTaskOptions {
private Map<String, Double> resources = new HashMap<>();
private int maxReconstructions = NO_RECONSTRUCTION;
private boolean useDirectCall = DEFAULT_USE_DIRECT_CALL;
private String jvmOptions = null;
private int maxConcurrency = 1;
@@ -46,14 +45,6 @@ public class ActorCreationOptions extends BaseTaskOptions {
return this;
}
// Since direct call is not fully supported yet (see issue #5559),
// users are not allowed to set the option to true.
// TODO (kfstorm): uncomment when direct call is ready.
// public Builder setUseDirectCall(boolean useDirectCall) {
// this.useDirectCall = useDirectCall;
// return this;
// }
public Builder setJvmOptions(String jvmOptions) {
this.jvmOptions = jvmOptions;
return this;
@@ -61,9 +52,8 @@ public class ActorCreationOptions extends BaseTaskOptions {
// The max number of concurrent calls to allow for this actor.
//
// This only works with direct actor calls. The max concurrency defaults to 1
// for threaded execution. Note that the execution order is not guaranteed
// when max_concurrency > 1.
// The max concurrency defaults to 1 for threaded execution.
// Note that the execution order is not guaranteed when max_concurrency > 1.
public Builder setMaxConcurrency(int maxConcurrency) {
if (maxConcurrency <= 0) {
throw new IllegalArgumentException("maxConcurrency must be greater than 0.");
@@ -75,7 +65,7 @@ public class ActorCreationOptions extends BaseTaskOptions {
public ActorCreationOptions createActorCreationOptions() {
return new ActorCreationOptions(
resources, maxReconstructions, useDirectCall, jvmOptions, maxConcurrency);
resources, maxReconstructions, jvmOptions, maxConcurrency);
}
}
@@ -7,21 +7,14 @@ import java.util.Map;
* The options class for RayCall or ActorCreation.
*/
public abstract class BaseTaskOptions {
// DO NOT set this environment variable. It's only used for test purposes.
// Please use `setUseDirectCall` instead.
public static final boolean DEFAULT_USE_DIRECT_CALL = "1"
.equals(System.getenv("DEFAULT_USE_DIRECT_CALL"));
public final Map<String, Double> resources;
public final boolean useDirectCall;
public BaseTaskOptions() {
resources = new HashMap<>();
useDirectCall = DEFAULT_USE_DIRECT_CALL;
}
public BaseTaskOptions(Map<String, Double> resources, boolean useDirectCall) {
public BaseTaskOptions(Map<String, Double> resources) {
for (Map.Entry<String, Double> entry : resources.entrySet()) {
if (entry.getValue().compareTo(0.0) <= 0) {
throw new IllegalArgumentException(String.format("Resource capacity should be " +
@@ -29,7 +22,6 @@ public abstract class BaseTaskOptions {
}
}
this.resources = resources;
this.useDirectCall = useDirectCall;
}
}
@@ -8,8 +8,8 @@ import java.util.Map;
*/
public class CallOptions extends BaseTaskOptions {
private CallOptions(Map<String, Double> resources, boolean useDirectCall) {
super(resources, useDirectCall);
private CallOptions(Map<String, Double> resources) {
super(resources);
}
/**
@@ -18,23 +18,14 @@ public class CallOptions extends BaseTaskOptions {
public static class Builder {
private Map<String, Double> resources = new HashMap<>();
private boolean useDirectCall = DEFAULT_USE_DIRECT_CALL;
public Builder setResources(Map<String, Double> resources) {
this.resources = resources;
return this;
}
// Since direct call is not fully supported yet (see issue #5559),
// users are not allowed to set the option to true.
// TODO (kfstorm): uncomment when direct call is ready.
// public Builder setUseDirectCall(boolean useDirectCall) {
// this.useDirectCall = useDirectCall;
// return this;
// }
public CallOptions createCallOptions() {
return new CallOptions(resources, useDirectCall);
return new CallOptions(resources);
}
}
}