mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 21:38:18 +08:00
[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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user