Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[serve] Rename BackendConfig -> DeploymentConfig #19923

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions java/serve/src/main/java/io/ray/serve/DeploymentInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ public class DeploymentInfo implements Serializable {

private static final long serialVersionUID = -4198364411759931955L;

private byte[] backendConfig;
private byte[] deploymentConfig;

private ReplicaConfig replicaConfig;

private byte[] deploymentVersion;

public byte[] getBackendConfig() {
return backendConfig;
public byte[] getDeploymentConfig() {
return deploymentConfig;
}

public void setBackendConfig(byte[] backendConfig) {
this.backendConfig = backendConfig;
public void setDeploymentConfig(byte[] deploymentConfig) {
this.deploymentConfig = deploymentConfig;
}

public ReplicaConfig getReplicaConfig() {
Expand Down
14 changes: 7 additions & 7 deletions java/serve/src/main/java/io/ray/serve/RayServeReplica.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.ray.runtime.metric.Metrics;
import io.ray.runtime.serializer.MessagePackSerializer;
import io.ray.serve.api.Serve;
import io.ray.serve.generated.BackendConfig;
import io.ray.serve.generated.DeploymentConfig;
import io.ray.serve.generated.DeploymentVersion;
import io.ray.serve.generated.RequestWrapper;
import io.ray.serve.poll.KeyListener;
Expand All @@ -34,7 +34,7 @@ public class RayServeReplica {

private String replicaTag;

private BackendConfig config;
private DeploymentConfig config;

private AtomicInteger numOngoingRequests = new AtomicInteger();

Expand All @@ -58,19 +58,19 @@ public class RayServeReplica {

public RayServeReplica(
Object callable,
BackendConfig backendConfig,
DeploymentConfig deploymentConfig,
DeploymentVersion version,
BaseActorHandle actorHandle) {
this.backendTag = Serve.getReplicaContext().getBackendTag();
this.replicaTag = Serve.getReplicaContext().getReplicaTag();
this.callable = callable;
this.config = backendConfig;
this.config = deploymentConfig;
this.version = version;

Map<KeyType, KeyListener> keyListeners = new HashMap<>();
keyListeners.put(
new KeyType(LongPollNamespace.BACKEND_CONFIGS, backendTag),
newConfig -> updateBackendConfigs(newConfig));
newConfig -> updateDeploymentConfigs(newConfig));
this.longPollClient = new LongPollClient(actorHandle, keyListeners);
this.longPollClient.start();
registerMetrics();
Expand Down Expand Up @@ -319,8 +319,8 @@ public DeploymentVersion reconfigure(Object userConfig) {
*
* @param newConfig the new configuration of backend
*/
private void updateBackendConfigs(Object newConfig) {
config = (BackendConfig) newConfig;
private void updateDeploymentConfigs(Object newConfig) {
config = (DeploymentConfig) newConfig;
}

public DeploymentVersion getVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import io.ray.api.Ray;
import io.ray.runtime.serializer.MessagePackSerializer;
import io.ray.serve.api.Serve;
import io.ray.serve.generated.BackendConfig;
import io.ray.serve.generated.DeploymentConfig;
import io.ray.serve.generated.DeploymentVersion;
import io.ray.serve.generated.RequestMetadata;
import io.ray.serve.util.ReflectUtil;
Expand All @@ -27,17 +27,17 @@ public RayServeWrappedReplica(
String replicaTag,
String backendDef,
byte[] initArgsbytes,
byte[] backendConfigBytes,
byte[] deploymentConfigBytes,
byte[] deploymentVersionBytes,
String controllerName)
throws ClassNotFoundException, NoSuchMethodException, InstantiationException,
IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException {

// Parse BackendConfig.
BackendConfig backendConfig = ServeProtoUtil.parseBackendConfig(backendConfigBytes);
// Parse DeploymentConfig.
DeploymentConfig deploymentConfig = ServeProtoUtil.parseDeploymentConfig(deploymentConfigBytes);

// Parse init args.
Object[] initArgs = parseInitArgs(initArgsbytes, backendConfig);
Object[] initArgs = parseInitArgs(initArgsbytes, deploymentConfig);

// Instantiate the object defined by backendDef.
Class backendClass = Class.forName(backendDef);
Expand All @@ -57,7 +57,7 @@ public RayServeWrappedReplica(
backend =
new RayServeReplica(
callable,
backendConfig,
deploymentConfig,
ServeProtoUtil.parseDeploymentVersion(deploymentVersionBytes),
optional.get());
}
Expand All @@ -71,19 +71,19 @@ public RayServeWrappedReplica(
replicaTag,
deploymentInfo.getReplicaConfig().getBackendDef(),
deploymentInfo.getReplicaConfig().getInitArgs(),
deploymentInfo.getBackendConfig(),
deploymentInfo.getDeploymentConfig(),
deploymentInfo.getDeploymentVersion(),
controllerName);
}

private Object[] parseInitArgs(byte[] initArgsbytes, BackendConfig backendConfig)
private Object[] parseInitArgs(byte[] initArgsbytes, DeploymentConfig deploymentConfig)
throws IOException {

if (initArgsbytes == null || initArgsbytes.length == 0) {
return new Object[0];
}

if (!backendConfig.getIsCrossLanguage()) {
if (!deploymentConfig.getIsCrossLanguage()) {
// If the construction request is from Java API, deserialize initArgsbytes to Object[]
// directly.
return MessagePackSerializer.decode(initArgsbytes, Object[].class);
Expand Down
6 changes: 3 additions & 3 deletions java/serve/src/main/java/io/ray/serve/ReplicaSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.ray.runtime.metric.Metrics;
import io.ray.runtime.metric.TagKey;
import io.ray.serve.generated.ActorSet;
import io.ray.serve.generated.BackendConfig;
import io.ray.serve.generated.DeploymentConfig;
import io.ray.serve.util.CollectionUtil;
import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -48,8 +48,8 @@ public ReplicaSet(String backendTag) {
.register());
}

public void setMaxConcurrentQueries(Object backendConfig) {
int newValue = ((BackendConfig) backendConfig).getMaxConcurrentQueries();
public void setMaxConcurrentQueries(Object deploymentConfig) {
int newValue = ((DeploymentConfig) deploymentConfig).getMaxConcurrentQueries();
if (newValue != this.maxConcurrentQueries) {
this.maxConcurrentQueries = newValue;
LOGGER.info("ReplicaSet: changing max_concurrent_queries to {}", newValue);
Expand Down
2 changes: 1 addition & 1 deletion java/serve/src/main/java/io/ray/serve/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public Router(BaseActorHandle controllerHandle, String backendTag) {
Map<KeyType, KeyListener> keyListeners = new HashMap<>();
keyListeners.put(
new KeyType(LongPollNamespace.BACKEND_CONFIGS, backendTag),
backendConfig -> replicaSet.setMaxConcurrentQueries(backendConfig)); // cross language
deploymentConfig -> replicaSet.setMaxConcurrentQueries(deploymentConfig)); // cross language
keyListeners.put(
new KeyType(LongPollNamespace.REPLICA_HANDLES, backendTag),
workerReplicas -> replicaSet.updateWorkerReplicas(workerReplicas)); // cross language
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class LongPollClient {

static {
DESERIALIZERS.put(
LongPollNamespace.BACKEND_CONFIGS, body -> ServeProtoUtil.parseBackendConfig(body));
LongPollNamespace.BACKEND_CONFIGS, body -> ServeProtoUtil.parseDeploymentConfig(body));
DESERIALIZERS.put(
LongPollNamespace.REPLICA_HANDLES, body -> ServeProtoUtil.parseEndpointSet(body));
DESERIALIZERS.put(
Expand Down
39 changes: 20 additions & 19 deletions java/serve/src/main/java/io/ray/serve/util/ServeProtoUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import io.ray.runtime.serializer.MessagePackSerializer;
import io.ray.serve.Constants;
import io.ray.serve.RayServeException;
import io.ray.serve.generated.BackendConfig;
import io.ray.serve.generated.BackendLanguage;
import io.ray.serve.generated.DeploymentConfig;
import io.ray.serve.generated.DeploymentLanguage;
import io.ray.serve.generated.DeploymentVersion;
import io.ray.serve.generated.EndpointInfo;
import io.ray.serve.generated.EndpointSet;
Expand All @@ -25,23 +25,23 @@ public class ServeProtoUtil {

private static final Gson GSON = new Gson();

public static BackendConfig parseBackendConfig(byte[] backendConfigBytes) {
public static DeploymentConfig parseDeploymentConfig(byte[] deploymentConfigBytes) {

// Get a builder from BackendConfig(bytes) or create a new one.
BackendConfig.Builder builder = null;
if (backendConfigBytes == null) {
builder = BackendConfig.newBuilder();
// Get a builder from DeploymentConfig(bytes) or create a new one.
DeploymentConfig.Builder builder = null;
if (deploymentConfigBytes == null) {
builder = DeploymentConfig.newBuilder();
} else {
BackendConfig backendConfig = null;
DeploymentConfig deploymentConfig = null;
try {
backendConfig = BackendConfig.parseFrom(backendConfigBytes);
deploymentConfig = DeploymentConfig.parseFrom(deploymentConfigBytes);
} catch (InvalidProtocolBufferException e) {
throw new RayServeException("Failed to parse BackendConfig from protobuf bytes.", e);
throw new RayServeException("Failed to parse DeploymentConfig from protobuf bytes.", e);
}
if (backendConfig == null) {
builder = BackendConfig.newBuilder();
if (deploymentConfig == null) {
builder = DeploymentConfig.newBuilder();
} else {
builder = BackendConfig.newBuilder(backendConfig);
builder = DeploymentConfig.newBuilder(deploymentConfig);
}
}

Expand All @@ -64,22 +64,23 @@ public static BackendConfig parseBackendConfig(byte[] backendConfigBytes) {
builder.setGracefulShutdownTimeoutS(20);
}

if (builder.getBackendLanguage() == BackendLanguage.UNRECOGNIZED) {
if (builder.getDeploymentLanguage() == DeploymentLanguage.UNRECOGNIZED) {
throw new RayServeException(
LogUtil.format(
"Unrecognized backend language {}. Backend language must be in {}.",
builder.getBackendLanguageValue(),
Lists.newArrayList(BackendLanguage.values())));
builder.getDeploymentLanguageValue(),
Lists.newArrayList(DeploymentLanguage.values())));
}

return builder.build();
}

public static Object parseUserConfig(BackendConfig backendConfig) {
if (backendConfig.getUserConfig() == null || backendConfig.getUserConfig().size() == 0) {
public static Object parseUserConfig(DeploymentConfig deploymentConfig) {
if (deploymentConfig.getUserConfig() == null || deploymentConfig.getUserConfig().size() == 0) {
return null;
}
return MessagePackSerializer.decode(backendConfig.getUserConfig().toByteArray(), Object.class);
return MessagePackSerializer.decode(
deploymentConfig.getUserConfig().toByteArray(), Object.class);
}

public static RequestMetadata parseRequestMetadata(byte[] requestMetadataBytes)
Expand Down
4 changes: 2 additions & 2 deletions java/serve/src/test/java/io/ray/serve/ProxyActorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io.ray.runtime.serializer.MessagePackSerializer;
import io.ray.serve.api.Serve;
import io.ray.serve.generated.ActorSet;
import io.ray.serve.generated.BackendConfig;
import io.ray.serve.generated.DeploymentConfig;
import io.ray.serve.generated.DeploymentVersion;
import io.ray.serve.generated.EndpointInfo;
import io.ray.serve.util.CommonUtil;
Expand Down Expand Up @@ -51,7 +51,7 @@ public void test() throws IOException {

// Replica
DeploymentInfo deploymentInfo = new DeploymentInfo();
deploymentInfo.setBackendConfig(BackendConfig.newBuilder().build().toByteArray());
deploymentInfo.setDeploymentConfig(DeploymentConfig.newBuilder().build().toByteArray());
deploymentInfo.setDeploymentVersion(
DeploymentVersion.newBuilder().setCodeVersion(version).build().toByteArray());
deploymentInfo.setReplicaConfig(
Expand Down
12 changes: 6 additions & 6 deletions java/serve/src/test/java/io/ray/serve/RayServeHandleTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import io.ray.api.Ray;
import io.ray.runtime.serializer.MessagePackSerializer;
import io.ray.serve.generated.ActorSet;
import io.ray.serve.generated.BackendConfig;
import io.ray.serve.generated.BackendLanguage;
import io.ray.serve.generated.DeploymentConfig;
import io.ray.serve.generated.DeploymentLanguage;
import io.ray.serve.generated.DeploymentVersion;
import java.util.HashMap;
import org.testng.Assert;
Expand All @@ -31,15 +31,15 @@ public void test() {
Ray.actor(DummyServeController::new).setName(controllerName).remote();

// Replica
BackendConfig.Builder backendConfigBuilder = BackendConfig.newBuilder();
backendConfigBuilder.setBackendLanguage(BackendLanguage.JAVA);
byte[] backendConfigBytes = backendConfigBuilder.build().toByteArray();
DeploymentConfig.Builder deploymentConfigBuilder = DeploymentConfig.newBuilder();
deploymentConfigBuilder.setDeploymentLanguage(DeploymentLanguage.JAVA);
byte[] deploymentConfigBytes = deploymentConfigBuilder.build().toByteArray();

Object[] initArgs = new Object[] {backendTag, replicaTag, controllerName, new Object()};
byte[] initArgsBytes = MessagePackSerializer.encode(initArgs).getLeft();

DeploymentInfo deploymentInfo = new DeploymentInfo();
deploymentInfo.setBackendConfig(backendConfigBytes);
deploymentInfo.setDeploymentConfig(deploymentConfigBytes);
deploymentInfo.setDeploymentVersion(
DeploymentVersion.newBuilder().setCodeVersion(version).build().toByteArray());
deploymentInfo.setReplicaConfig(
Expand Down
12 changes: 6 additions & 6 deletions java/serve/src/test/java/io/ray/serve/RayServeReplicaTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import io.ray.api.ObjectRef;
import io.ray.api.Ray;
import io.ray.runtime.serializer.MessagePackSerializer;
import io.ray.serve.generated.BackendConfig;
import io.ray.serve.generated.BackendLanguage;
import io.ray.serve.generated.DeploymentConfig;
import io.ray.serve.generated.DeploymentLanguage;
import io.ray.serve.generated.DeploymentVersion;
import io.ray.serve.generated.RequestMetadata;
import io.ray.serve.generated.RequestWrapper;
Expand All @@ -32,14 +32,14 @@ public void test() throws IOException {
ActorHandle<DummyServeController> controllerHandle =
Ray.actor(DummyServeController::new).setName(controllerName).remote();

BackendConfig.Builder backendConfigBuilder = BackendConfig.newBuilder();
backendConfigBuilder.setBackendLanguage(BackendLanguage.JAVA);
byte[] backendConfigBytes = backendConfigBuilder.build().toByteArray();
DeploymentConfig.Builder deploymentConfigBuilder = DeploymentConfig.newBuilder();
deploymentConfigBuilder.setDeploymentLanguage(DeploymentLanguage.JAVA);
byte[] deploymentConfigBytes = deploymentConfigBuilder.build().toByteArray();
Object[] initArgs = new Object[] {backendTag, replicaTag, controllerName, new Object()};
byte[] initArgsBytes = MessagePackSerializer.encode(initArgs).getLeft();

DeploymentInfo deploymentInfo = new DeploymentInfo();
deploymentInfo.setBackendConfig(backendConfigBytes);
deploymentInfo.setDeploymentConfig(deploymentConfigBytes);
deploymentInfo.setDeploymentVersion(
DeploymentVersion.newBuilder().setCodeVersion(version).build().toByteArray());
deploymentInfo.setReplicaConfig(
Expand Down
14 changes: 7 additions & 7 deletions java/serve/src/test/java/io/ray/serve/ReplicaSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import io.ray.api.Ray;
import io.ray.runtime.serializer.MessagePackSerializer;
import io.ray.serve.generated.ActorSet;
import io.ray.serve.generated.BackendConfig;
import io.ray.serve.generated.BackendLanguage;
import io.ray.serve.generated.DeploymentConfig;
import io.ray.serve.generated.DeploymentLanguage;
import io.ray.serve.generated.DeploymentVersion;
import io.ray.serve.generated.RequestMetadata;
import java.util.HashMap;
Expand All @@ -23,7 +23,7 @@ public class ReplicaSetTest {
@Test
public void setMaxConcurrentQueriesTest() {
ReplicaSet replicaSet = new ReplicaSet(backendTag);
BackendConfig.Builder builder = BackendConfig.newBuilder();
DeploymentConfig.Builder builder = DeploymentConfig.newBuilder();
builder.setMaxConcurrentQueries(200);

replicaSet.setMaxConcurrentQueries(builder.build());
Expand Down Expand Up @@ -58,15 +58,15 @@ public void assignReplicaTest() {
Ray.actor(DummyServeController::new).setName(controllerName).remote();

// Replica
BackendConfig.Builder backendConfigBuilder = BackendConfig.newBuilder();
backendConfigBuilder.setBackendLanguage(BackendLanguage.JAVA);
byte[] backendConfigBytes = backendConfigBuilder.build().toByteArray();
DeploymentConfig.Builder deploymentConfigBuilder = DeploymentConfig.newBuilder();
deploymentConfigBuilder.setDeploymentLanguage(DeploymentLanguage.JAVA);
byte[] deploymentConfigBytes = deploymentConfigBuilder.build().toByteArray();

Object[] initArgs = new Object[] {backendTag, replicaTag, controllerName, new Object()};
byte[] initArgsBytes = MessagePackSerializer.encode(initArgs).getLeft();

DeploymentInfo deploymentInfo = new DeploymentInfo();
deploymentInfo.setBackendConfig(backendConfigBytes);
deploymentInfo.setDeploymentConfig(deploymentConfigBytes);
deploymentInfo.setDeploymentVersion(
DeploymentVersion.newBuilder().setCodeVersion(version).build().toByteArray());
deploymentInfo.setReplicaConfig(
Expand Down
Loading