swuferhong commented on code in PR #1452:
URL: https://github.com/apache/fluss/pull/1452#discussion_r2664476654
##########
fluss-client/src/main/java/org/apache/fluss/client/utils/ClientRpcMessageUtils.java:
##########
@@ -370,6 +382,68 @@ public static AlterTableRequest makeAlterTableRequest(
return request;
}
+ public static RebalancePlan toRebalancePlan(RebalanceResponse response) {
+ Map<TableBucket, RebalancePlanForBucket> rebalancePlan = new
HashMap<>();
+ for (PbRebalancePlanForTable pbTable : response.getTablePlansList()) {
+ long tableId = pbTable.getTableId();
+ for (PbRebalancePlanForBucket pbBucket :
pbTable.getBucketsPlansList()) {
+ RebalancePlanForBucket planForBucket =
toRebalancePlanForBucket(tableId, pbBucket);
+ rebalancePlan.put(planForBucket.getTableBucket(),
planForBucket);
+ }
+ }
+ return new RebalancePlan(response.getRebalanceId(), rebalancePlan);
+ }
+
+ public static RebalanceProgress
toRebalanceProgress(ListRebalanceProgressResponse response) {
+ RebalanceStatus totalRebalanceStatus =
RebalanceStatus.of(response.getRebalanceStatus());
+ int totalTask = 0;
+ int finishedTask = 0;
+ Map<TableBucket, RebalanceResultForBucket> rebalanceProgress = new
HashMap<>();
+ for (PbRebalanceProgressForTable pbTable :
response.getTableProgressesList()) {
+ long tableId = pbTable.getTableId();
+ for (PbRebalanceProgressForBucket pbBucket :
pbTable.getBucketsProgressesList()) {
+ RebalanceStatus bucketStatus =
RebalanceStatus.of(pbBucket.getRebalanceStatus());
+ RebalancePlanForBucket planForBucket =
+ toRebalancePlanForBucket(tableId,
pbBucket.getRebalancePlan());
+ rebalanceProgress.put(
+ planForBucket.getTableBucket(),
+ new RebalanceResultForBucket(planForBucket,
bucketStatus));
+ if (FINAL_STATUSES.contains(bucketStatus)) {
+ finishedTask++;
+ }
+ totalTask++;
+ }
+ }
+
+ double progress = -1d;
Review Comment:
If the process is a negitive value, it means there are no bucket level
rebalance tasks. I will add some comments
--
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]