gavinchou commented on code in PR #46221:
URL: https://github.com/apache/doris/pull/46221#discussion_r1900423307
##########
fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java:
##########
@@ -1158,4 +1158,44 @@ public String getInstanceId(String cloudUniqueId) throws
IOException {
throw new IOException("Failed to get instance info");
}
}
+
+ public void renameComputeGroup(String originalName, String newGroupName)
throws UserException {
+ String cloudInstanceId = ((CloudEnv)
Env.getCurrentEnv()).getCloudInstanceId();
+ if (Strings.isNullOrEmpty(cloudInstanceId)) {
+ throw new DdlException("unable to rename compute group due to
empty cloud_instance_id");
+ }
+ String originalComputeGroupId = ((CloudSystemInfoService)
Env.getCurrentSystemInfo())
+ .getCloudClusterIdByName(originalName);
+ if (Strings.isNullOrEmpty(originalComputeGroupId)) {
+ throw new DdlException("unable to rename compute group, "
Review Comment:
should we also check the existence of target name (newGroupName) before
sending rpc to meta service?
BTW we need to cover these situations in regression tests.
##########
fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java:
##########
@@ -1158,4 +1158,44 @@ public String getInstanceId(String cloudUniqueId) throws
IOException {
throw new IOException("Failed to get instance info");
}
}
+
+ public void renameComputeGroup(String originalName, String newGroupName)
throws UserException {
+ String cloudInstanceId = ((CloudEnv)
Env.getCurrentEnv()).getCloudInstanceId();
+ if (Strings.isNullOrEmpty(cloudInstanceId)) {
+ throw new DdlException("unable to rename compute group due to
empty cloud_instance_id");
+ }
+ String originalComputeGroupId = ((CloudSystemInfoService)
Env.getCurrentSystemInfo())
+ .getCloudClusterIdByName(originalName);
+ if (Strings.isNullOrEmpty(originalComputeGroupId)) {
+ throw new DdlException("unable to rename compute group, "
+ + "cant get compute group id by compute name " +
originalName);
+ }
+
+ Cloud.ClusterPB clusterPB = Cloud.ClusterPB.newBuilder()
+ .setClusterId(originalComputeGroupId)
+ .setClusterName(newGroupName)
+ .setType(Cloud.ClusterPB.Type.COMPUTE)
+ .build();
+
+ Cloud.AlterClusterRequest request =
Cloud.AlterClusterRequest.newBuilder()
+ .setInstanceId(((CloudEnv)
Env.getCurrentEnv()).getCloudInstanceId())
+ .setOp(Cloud.AlterClusterRequest.Operation.RENAME_CLUSTER)
+ .setDropEmptyCluster(true)
+ .setCluster(clusterPB)
+ .build();
+
+
+ Cloud.AlterClusterResponse response;
+ try {
+ response = MetaServiceProxy.getInstance().alterCluster(request);
+ LOG.info("alter rename compute group, request: {}, response: {}",
request, response);
+ if (response.getStatus().getCode() != Cloud.MetaServiceCode.OK) {
+ LOG.warn("alter rename compute group not ok, response: {}",
response);
+ throw new UserException("failed to rename compute group
errorCode: " + response.getStatus().getCode()
Review Comment:
this code is not informative to user, translate it to a message with which
user can proceed to resolve the error. e.g. "the new group name {} is already
occupied"
##########
fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java:
##########
@@ -1158,4 +1158,44 @@ public String getInstanceId(String cloudUniqueId) throws
IOException {
throw new IOException("Failed to get instance info");
}
}
+
+ public void renameComputeGroup(String originalName, String newGroupName)
throws UserException {
+ String cloudInstanceId = ((CloudEnv)
Env.getCurrentEnv()).getCloudInstanceId();
+ if (Strings.isNullOrEmpty(cloudInstanceId)) {
+ throw new DdlException("unable to rename compute group due to
empty cloud_instance_id");
+ }
+ String originalComputeGroupId = ((CloudSystemInfoService)
Env.getCurrentSystemInfo())
+ .getCloudClusterIdByName(originalName);
+ if (Strings.isNullOrEmpty(originalComputeGroupId)) {
+ throw new DdlException("unable to rename compute group, "
+ + "cant get compute group id by compute name " +
originalName);
+ }
+
+ Cloud.ClusterPB clusterPB = Cloud.ClusterPB.newBuilder()
+ .setClusterId(originalComputeGroupId)
+ .setClusterName(newGroupName)
+ .setType(Cloud.ClusterPB.Type.COMPUTE)
+ .build();
+
+ Cloud.AlterClusterRequest request =
Cloud.AlterClusterRequest.newBuilder()
+ .setInstanceId(((CloudEnv)
Env.getCurrentEnv()).getCloudInstanceId())
+ .setOp(Cloud.AlterClusterRequest.Operation.RENAME_CLUSTER)
+ .setDropEmptyCluster(true)
+ .setCluster(clusterPB)
+ .build();
+
+
+ Cloud.AlterClusterResponse response;
+ try {
+ response = MetaServiceProxy.getInstance().alterCluster(request);
Review Comment:
LOG request before sending request
##########
fe/fe-core/src/main/java/org/apache/doris/cloud/system/CloudSystemInfoService.java:
##########
@@ -1158,4 +1158,44 @@ public String getInstanceId(String cloudUniqueId) throws
IOException {
throw new IOException("Failed to get instance info");
}
}
+
+ public void renameComputeGroup(String originalName, String newGroupName)
throws UserException {
+ String cloudInstanceId = ((CloudEnv)
Env.getCurrentEnv()).getCloudInstanceId();
+ if (Strings.isNullOrEmpty(cloudInstanceId)) {
+ throw new DdlException("unable to rename compute group due to
empty cloud_instance_id");
+ }
+ String originalComputeGroupId = ((CloudSystemInfoService)
Env.getCurrentSystemInfo())
+ .getCloudClusterIdByName(originalName);
+ if (Strings.isNullOrEmpty(originalComputeGroupId)) {
+ throw new DdlException("unable to rename compute group, "
+ + "cant get compute group id by compute name " +
originalName);
+ }
+
+ Cloud.ClusterPB clusterPB = Cloud.ClusterPB.newBuilder()
+ .setClusterId(originalComputeGroupId)
+ .setClusterName(newGroupName)
+ .setType(Cloud.ClusterPB.Type.COMPUTE)
+ .build();
+
+ Cloud.AlterClusterRequest request =
Cloud.AlterClusterRequest.newBuilder()
+ .setInstanceId(((CloudEnv)
Env.getCurrentEnv()).getCloudInstanceId())
+ .setOp(Cloud.AlterClusterRequest.Operation.RENAME_CLUSTER)
+ .setDropEmptyCluster(true)
+ .setCluster(clusterPB)
+ .build();
+
+
+ Cloud.AlterClusterResponse response;
+ try {
+ response = MetaServiceProxy.getInstance().alterCluster(request);
+ LOG.info("alter rename compute group, request: {}, response: {}",
request, response);
+ if (response.getStatus().getCode() != Cloud.MetaServiceCode.OK) {
+ LOG.warn("alter rename compute group not ok, response: {}",
response);
+ throw new UserException("failed to rename compute group
errorCode: " + response.getStatus().getCode()
+ + " msg: " + response.getStatus().getMsg());
+ }
+ } catch (RpcException e) {
+ throw new UserException("failed to alter rename compute group", e);
Review Comment:
LOG here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]