swuferhong commented on code in PR #2341:
URL: https://github.com/apache/fluss/pull/2341#discussion_r2684463426


##########
fluss-common/src/main/java/org/apache/fluss/utils/json/RebalancePlanForBucketJsonSerde.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.fluss.utils.json;
+
+import org.apache.fluss.cluster.rebalance.RebalancePlanForBucket;
+import org.apache.fluss.metadata.TableBucket;
+import 
org.apache.fluss.shaded.jackson2.com.fasterxml.jackson.core.JsonGenerator;
+import 
org.apache.fluss.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/** Json serializer and deserializer for {@link RebalancePlanForBucket}. */
+public class RebalancePlanForBucketJsonSerde

Review Comment:
   Revert the changes to `RebalancePlanForBucketJsonSerde` and 
`RebalanceTaskJspnSerde`, as we are not reusing it now.



##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/procedure/ListRebalanceProcessProcedure.java:
##########
@@ -60,33 +63,41 @@ public class ListRebalanceProcessProcedure extends 
ProcedureBase {
                         name = "rebalanceId",
                         type = @DataTypeHint("STRING"),
                         isOptional = true)
-            })
-    public String[] call(ProcedureContext context, @Nullable String 
rebalanceId) throws Exception {
+            },
+            output =
+                    @DataTypeHint(
+                            "ROW<rebalance_id STRING, rebalance_status STRING, 
rebalance_progress STRING, rebalance_plan STRING>"))
+    public Row[] call(ProcedureContext context, @Nullable String rebalanceId) 
throws Exception {
         Optional<RebalanceProgress> progressOpt = 
admin.listRebalanceProgress(rebalanceId).get();
 
         if (!progressOpt.isPresent()) {
-            return new String[] {"No rebalance progress found."};
+            return new Row[] {Row.of("No rebalance progress found.")};
         }
 
         return progressToString(progressOpt.get());
     }
 
-    private static String[] progressToString(RebalanceProgress progress) {
-        RebalanceStatus status = progress.status();
+    private static Row[] progressToString(RebalanceProgress progress) {
         double rebalanceProgress = progress.progress();
         Map<TableBucket, RebalanceResultForBucket> bucketMap = 
progress.progressForBucketMap();
 
-        // TODO format the result into a row type, and the detail progress for 
bucket show in json
-        // format. Trace by: https://github.com/apache/fluss/issues/2325
-        List<String> result = new ArrayList<>();
-        result.add("Rebalance id: " + progress.rebalanceId());
-        result.add("Reblance total status: " + status);
-        result.add("Rebalance progress: " + 
formatAsPercentage(rebalanceProgress));
-        result.add("Rebalance detail progress for bucket:");
+        StringJoiner planResult = new StringJoiner(", ");
+
         for (RebalanceResultForBucket resultForBucket : bucketMap.values()) {

Review Comment:
   You need to serialize the `Map<TableBucket, RebalanceResultForBucket> 
progressForBucketMap` as a whole, rather than serializing individual 
`RebalanceResultForBucket` objects. From my perspective, you don't need to 
reuse any existing classes right now—just define a dedicated serde class to 
handle serialization and deserialization of the `Map<TableBucket, 
RebalanceResultForBucket> progressForBucketMap`. This class can be named 
`RebalanceProgressForBucketsSerde` or other you think good name.



##########
fluss-server/src/test/java/org/apache/fluss/server/zk/data/RebalanceTaskJsonSerdeTest.java:
##########
@@ -89,13 +89,13 @@ protected String[] expectedJsons() {
         return new String[] {
             
"{\"version\":1,\"rebalance_id\":\"rebalance-task-21jd\",\"rebalance_status\":0,\"rebalance_plan\":"
                     + "[{\"table_id\":0,\"buckets\":"
-                    + 
"[{\"bucket_id\":1,\"original_leader\":1,\"new_leader\":1,\"origin_replicas\":[0,1,2],\"new_replicas\":[1,2,3]},"
-                    + 
"{\"bucket_id\":0,\"original_leader\":0,\"new_leader\":3,\"origin_replicas\":[0,1,2],\"new_replicas\":[3,4,5]}]},"
-                    + "{\"table_id\":1,\"partition_id\":0,\"buckets\":["
-                    + 
"{\"bucket_id\":0,\"original_leader\":0,\"new_leader\":3,\"origin_replicas\":[0,1,2],\"new_replicas\":[3,4,5]},"
-                    + 
"{\"bucket_id\":1,\"original_leader\":1,\"new_leader\":1,\"origin_replicas\":[0,1,2],\"new_replicas\":[1,2,3]}]},"
-                    + "{\"table_id\":1,\"partition_id\":1,\"buckets\":["

Review Comment:
   why you need to change the serde way of `RebalanceTaskJsoSerde`?



-- 
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]

Reply via email to