forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Serve] Make Java Replica Extendable (ray-project#19463)
- Loading branch information
1 parent
81f036d
commit efca009
Showing
34 changed files
with
1,198 additions
and
664 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
java/serve/src/main/java/io/ray/serve/DeploymentConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package io.ray.serve; | ||
|
||
import com.google.common.base.Preconditions; | ||
import java.io.Serializable; | ||
|
||
public class DeploymentConfig implements Serializable { | ||
|
||
private static final long serialVersionUID = 4037621960087621036L; | ||
|
||
private int numReplicas = 1; | ||
|
||
private int maxConcurrentQueries = 100; | ||
|
||
private Object userConfig; | ||
|
||
private double gracefulShutdownWaitLoopS = 2; | ||
|
||
private double gracefulShutdownTimeoutS = 20; | ||
|
||
private boolean isCrossLanguage; | ||
|
||
private int deploymentLanguage = 1; | ||
|
||
public int getNumReplicas() { | ||
return numReplicas; | ||
} | ||
|
||
public DeploymentConfig setNumReplicas(int numReplicas) { | ||
this.numReplicas = numReplicas; | ||
return this; | ||
} | ||
|
||
public int getMaxConcurrentQueries() { | ||
return maxConcurrentQueries; | ||
} | ||
|
||
public DeploymentConfig setMaxConcurrentQueries(int maxConcurrentQueries) { | ||
Preconditions.checkArgument(maxConcurrentQueries >= 0, "max_concurrent_queries must be >= 0"); | ||
this.maxConcurrentQueries = maxConcurrentQueries; | ||
return this; | ||
} | ||
|
||
public Object getUserConfig() { | ||
return userConfig; | ||
} | ||
|
||
public DeploymentConfig setUserConfig(Object userConfig) { | ||
this.userConfig = userConfig; | ||
return this; | ||
} | ||
|
||
public double getGracefulShutdownWaitLoopS() { | ||
return gracefulShutdownWaitLoopS; | ||
} | ||
|
||
public DeploymentConfig setGracefulShutdownWaitLoopS(double gracefulShutdownWaitLoopS) { | ||
this.gracefulShutdownWaitLoopS = gracefulShutdownWaitLoopS; | ||
return this; | ||
} | ||
|
||
public double getGracefulShutdownTimeoutS() { | ||
return gracefulShutdownTimeoutS; | ||
} | ||
|
||
public DeploymentConfig setGracefulShutdownTimeoutS(double gracefulShutdownTimeoutS) { | ||
this.gracefulShutdownTimeoutS = gracefulShutdownTimeoutS; | ||
return this; | ||
} | ||
|
||
public boolean isCrossLanguage() { | ||
return isCrossLanguage; | ||
} | ||
|
||
public DeploymentConfig setCrossLanguage(boolean isCrossLanguage) { | ||
this.isCrossLanguage = isCrossLanguage; | ||
return this; | ||
} | ||
|
||
public int getDeploymentLanguage() { | ||
return deploymentLanguage; | ||
} | ||
|
||
public DeploymentConfig setDeploymentLanguage(int deploymentLanguage) { | ||
this.deploymentLanguage = deploymentLanguage; | ||
return this; | ||
} | ||
} |
65 changes: 51 additions & 14 deletions
65
java/serve/src/main/java/io/ray/serve/DeploymentInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,75 @@ | ||
package io.ray.serve; | ||
|
||
import java.io.Serializable; | ||
import java.util.Map; | ||
|
||
public class DeploymentInfo implements Serializable { | ||
|
||
private static final long serialVersionUID = -4198364411759931955L; | ||
private static final long serialVersionUID = -7132135316463505391L; | ||
|
||
private byte[] deploymentConfig; | ||
private String name; | ||
|
||
private ReplicaConfig replicaConfig; | ||
private String deploymentDef; | ||
|
||
private byte[] deploymentVersion; | ||
private Object[] initArgs; | ||
|
||
public byte[] getDeploymentConfig() { | ||
return deploymentConfig; | ||
private DeploymentConfig deploymentConfig; | ||
|
||
private DeploymentVersion deploymentVersion; | ||
|
||
private Map<String, String> config; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setDeploymentConfig(byte[] deploymentConfig) { | ||
this.deploymentConfig = deploymentConfig; | ||
public DeploymentInfo setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public ReplicaConfig getReplicaConfig() { | ||
return replicaConfig; | ||
public String getDeploymentDef() { | ||
return deploymentDef; | ||
} | ||
|
||
public void setReplicaConfig(ReplicaConfig replicaConfig) { | ||
this.replicaConfig = replicaConfig; | ||
public DeploymentInfo setDeploymentDef(String deploymentDef) { | ||
this.deploymentDef = deploymentDef; | ||
return this; | ||
} | ||
|
||
public byte[] getDeploymentVersion() { | ||
public Object[] getInitArgs() { | ||
return initArgs; | ||
} | ||
|
||
public DeploymentInfo setInitArgs(Object[] initArgs) { | ||
this.initArgs = initArgs; | ||
return this; | ||
} | ||
|
||
public DeploymentConfig getDeploymentConfig() { | ||
return deploymentConfig; | ||
} | ||
|
||
public DeploymentInfo setDeploymentConfig(DeploymentConfig deploymentConfig) { | ||
this.deploymentConfig = deploymentConfig; | ||
return this; | ||
} | ||
|
||
public DeploymentVersion getDeploymentVersion() { | ||
return deploymentVersion; | ||
} | ||
|
||
public void setDeploymentVersion(byte[] deploymentVersion) { | ||
public DeploymentInfo setDeploymentVersion(DeploymentVersion deploymentVersion) { | ||
this.deploymentVersion = deploymentVersion; | ||
return this; | ||
} | ||
|
||
public Map<String, String> getConfig() { | ||
return config; | ||
} | ||
|
||
public DeploymentInfo setConfig(Map<String, String> config) { | ||
this.config = config; | ||
return this; | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
java/serve/src/main/java/io/ray/serve/DeploymentVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.ray.serve; | ||
|
||
import java.io.Serializable; | ||
import org.apache.commons.lang3.RandomStringUtils; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
public class DeploymentVersion implements Serializable { | ||
|
||
private static final long serialVersionUID = 3400261981775851058L; | ||
|
||
private String codeVersion; | ||
|
||
private Object userConfig; | ||
|
||
private boolean unversioned; | ||
|
||
public DeploymentVersion() { | ||
this(null, null); | ||
} | ||
|
||
public DeploymentVersion(String codeVersion) { | ||
this(codeVersion, null); | ||
} | ||
|
||
public DeploymentVersion(String codeVersion, Object userConfig) { | ||
if (StringUtils.isBlank(codeVersion)) { | ||
this.unversioned = true; | ||
this.codeVersion = RandomStringUtils.randomAlphabetic(6); | ||
} else { | ||
this.codeVersion = codeVersion; | ||
} | ||
this.userConfig = userConfig; | ||
} | ||
|
||
public String getCodeVersion() { | ||
return codeVersion; | ||
} | ||
|
||
public Object getUserConfig() { | ||
return userConfig; | ||
} | ||
|
||
public boolean isUnversioned() { | ||
return unversioned; | ||
} | ||
} |
12 changes: 0 additions & 12 deletions
12
java/serve/src/main/java/io/ray/serve/DummyBackendReplica.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.ray.serve; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
public class DummyReplica { | ||
|
||
private AtomicInteger counter = new AtomicInteger(); | ||
|
||
public String call() { | ||
return String.valueOf(counter.incrementAndGet()); | ||
} | ||
|
||
public void reconfigure(Object userConfig) { | ||
counter.set(0); | ||
} | ||
|
||
public void reconfigure(Map<String, String> userConfig) { | ||
counter.set(Integer.valueOf(userConfig.get("value"))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,35 @@ | ||
package io.ray.serve; | ||
|
||
public class RayServeConfig { | ||
import java.io.Serializable; | ||
import java.util.Map; | ||
|
||
public class RayServeConfig implements Serializable { | ||
|
||
private static final long serialVersionUID = 5367425336296141588L; | ||
|
||
public static final String PROXY_CLASS = "ray.serve.proxy.class"; | ||
|
||
public static final String METRICS_ENABLED = "ray.serve.metrics.enabled"; | ||
|
||
private String name; | ||
|
||
private Map<String, String> config; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public RayServeConfig setName(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public Map<String, String> getConfig() { | ||
return config; | ||
} | ||
|
||
public RayServeConfig setConfig(Map<String, String> config) { | ||
this.config = config; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.