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


##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/procedure/ListRebalanceProcessProcedure.java:
##########
@@ -60,33 +56,28 @@ 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.")};

Review Comment:
   Violates the schema convention; simply return an empty array.
   
   



##########
fluss-common/src/main/java/org/apache/fluss/cluster/rebalance/RebalanceResultForBucket.java:
##########
@@ -70,4 +71,22 @@ public String toString() {
                 + rebalanceStatus
                 + '}';
     }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+        RebalanceResultForBucket that = (RebalanceResultForBucket) o;
+        return Objects.equals(rebalancePlanForBucket, 
that.rebalancePlanForBucket)
+                && rebalanceStatus == that.rebalanceStatus;
+    }
+
+    @Override
+    public int hashCode() {

Review Comment:
   ditto



##########
fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/procedure/RebalanceProgressForBucketJsonSerdeTest.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.flink.procedure;
+
+import org.apache.fluss.cluster.rebalance.RebalancePlanForBucket;
+import org.apache.fluss.cluster.rebalance.RebalanceResultForBucket;
+import org.apache.fluss.cluster.rebalance.RebalanceStatus;
+import org.apache.fluss.metadata.TableBucket;
+import org.apache.fluss.utils.json.JsonSerdeTestBase;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+/** Test for {@link RebalanceProgressForBucketJsonSerde}. */
+public class RebalanceProgressForBucketJsonSerdeTest

Review Comment:
   Remove it.



##########
fluss-common/src/main/java/org/apache/fluss/cluster/rebalance/RebalanceResultForBucket.java:
##########
@@ -70,4 +71,22 @@ public String toString() {
                 + rebalanceStatus
                 + '}';
     }
+
+    @Override
+    public boolean equals(Object o) {

Review Comment:
   From the current code references, RebalanceResultForBucket is not used as a 
key in a Map or as an element in a Set. Why are these extra functions needed at 
present?
   
   



##########
fluss-common/src/main/java/org/apache/fluss/utils/json/RebalancePlanForBucketJsonUtils.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * 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;
+
+/**
+ * Extract the common parts of the code from `RebalanceTaskJsonSerde` and
+ * `RebalanceProgressForBucketJsonSerde`.
+ */
+public class RebalancePlanForBucketJsonUtils {

Review Comment:
   Remove it.



##########
fluss-flink/fluss-flink-common/src/test/java/org/apache/fluss/flink/procedure/FlinkProcedureITCase.java:
##########
@@ -767,17 +768,11 @@ void testListRebalanceProgress() throws Exception {
                                                     "Call 
%s.sys.list_rebalance('%s')",
                                                     CATALOG_NAME, 
progress.rebalanceId()))
                                     .collect()) {
-                        List<String> listProgressResult =
-                                CollectionUtil.iteratorToList(rows).stream()
-                                        .map(Row::toString)
-                                        .collect(Collectors.toList());
-                        
assertThat(listProgressResult.get(0)).startsWith("+I[Rebalance id:");
-                        assertThat(listProgressResult.get(1))
-                                .isEqualTo("+I[Reblance total status: 
COMPLETED]");
-                        assertThat(listProgressResult.get(2))
-                                .isEqualTo("+I[Rebalance progress: 100%]");
-                        assertThat(listProgressResult.get(3))
-                                .isEqualTo("+I[Rebalance detail progress for 
bucket:]");
+                        List<Row> listProgressResult = 
CollectionUtil.iteratorToList(rows);
+                        Row row = listProgressResult.get(0);
+                        assertThat(row.getArity()).isEqualTo(4);
+                        
assertThat(row.getField(1)).isEqualTo(RebalanceStatus.COMPLETED);
+                        assertThat((String) row.getField(2)).endsWith("%");

Review Comment:
   Missing assertion for column `resource_plan`.



##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/procedure/RebalanceProgressForBucketJsonSerde.java:
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.flink.procedure;
+
+import org.apache.fluss.cluster.rebalance.RebalancePlanForBucket;
+import org.apache.fluss.cluster.rebalance.RebalanceProgress;
+import org.apache.fluss.cluster.rebalance.RebalanceResultForBucket;
+import org.apache.fluss.cluster.rebalance.RebalanceStatus;
+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 org.apache.fluss.utils.json.JsonDeserializer;
+import org.apache.fluss.utils.json.JsonSerializer;
+import org.apache.fluss.utils.json.RebalancePlanForBucketJsonUtils;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/** Json serializer and deserializer for {@link 
RebalanceProgress#progressForBucketMap()}. */
+public class RebalanceProgressForBucketJsonSerde

Review Comment:
   Remove it.



##########
fluss-flink/fluss-flink-common/src/main/java/org/apache/fluss/flink/procedure/ListRebalanceProcessProcedure.java:
##########


Review Comment:
   Update procedures.md



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