[Java] Support concurrent actor calls API. (#7022)

* WIP

Temp change

Attach native thread to jvm

* Fix run mode

* Address comments.
This commit is contained in:
Qing Wang
2020-02-14 13:02:39 +08:00
committed by GitHub
parent 0d3687a10d
commit f3703bafa3
13 changed files with 139 additions and 21 deletions
@@ -21,12 +21,15 @@ public class ActorCreationOptions extends BaseTaskOptions {
public final String jvmOptions;
public final int maxConcurrency;
private ActorCreationOptions(Map<String, Double> resources, int maxReconstructions,
boolean useDirectCall, String jvmOptions) {
boolean useDirectCall, String jvmOptions, int maxConcurrency) {
super(resources);
this.maxReconstructions = maxReconstructions;
this.useDirectCall = useDirectCall;
this.jvmOptions = jvmOptions;
this.maxConcurrency = maxConcurrency;
}
/**
@@ -38,6 +41,7 @@ public class ActorCreationOptions extends BaseTaskOptions {
private int maxReconstructions = NO_RECONSTRUCTION;
private boolean useDirectCall = DEFAULT_USE_DIRECT_CALL;
private String jvmOptions = null;
private int maxConcurrency = 1;
public Builder setResources(Map<String, Double> resources) {
this.resources = resources;
@@ -62,8 +66,23 @@ public class ActorCreationOptions extends BaseTaskOptions {
return this;
}
// 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.
public Builder setMaxConcurrency(int maxConcurrency) {
if (maxConcurrency <= 0) {
throw new IllegalArgumentException("maxConcurrency must be greater than 0.");
}
this.maxConcurrency = maxConcurrency;
return this;
}
public ActorCreationOptions createActorCreationOptions() {
return new ActorCreationOptions(resources, maxReconstructions, useDirectCall, jvmOptions);
return new ActorCreationOptions(
resources, maxReconstructions, useDirectCall, jvmOptions, maxConcurrency);
}
}