wuchong commented on code in PR #1159:
URL: https://github.com/apache/fluss/pull/1159#discussion_r2362997785


##########
fluss-server/src/main/java/org/apache/fluss/server/coordinator/statemachine/ReplicaLeaderElectionAlgorithms.java:
##########
@@ -17,21 +17,100 @@
 
 package org.apache.fluss.server.coordinator.statemachine;
 
+import 
org.apache.fluss.server.coordinator.statemachine.TableBucketStateMachine.ElectionResult;
+import org.apache.fluss.server.zk.data.LeaderAndIsr;
+
+import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /** The algorithms to elect the replica leader. */
 public class ReplicaLeaderElectionAlgorithms {
-    public static Optional<Integer> defaultReplicaLeaderElection(
-            List<Integer> assignments, List<Integer> aliveReplicas, 
List<Integer> isr) {
+
+    /**
+     * Init replica leader election when the bucket is new created.
+     *
+     * @param assignments the assignments
+     * @param aliveReplicas the alive replicas
+     * @param coordinatorEpoch the coordinator epoch
+     * @return the election result
+     */
+    public static Optional<ElectionResult> initReplicaLeaderElection(
+            List<Integer> assignments, List<Integer> aliveReplicas, int 
coordinatorEpoch) {
+        // currently, we always use the first replica in assignment, which 
also in aliveReplicas and
+        // isr as the leader replica.
+        for (int assignment : assignments) {
+            if (aliveReplicas.contains(assignment) && 
aliveReplicas.contains(assignment)) {

Review Comment:
   duplicated condition?



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