vldpyatkov commented on code in PR #1871:
URL: https://github.com/apache/ignite-3/pull/1871#discussion_r1156947610


##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/LeaseUpdater.java:
##########
@@ -146,18 +172,53 @@ public void deactivate() {
 
             updaterTread = null;
         }
+
+        leaseTracker.unsubscribeLeaseAdded();
+
+        leaseConciliator = null;
     }
 
     /**
      * Finds a node that can be the leaseholder.
      *
+     * @param groupId Replication group id.
      * @param assignments Replication group assignment.
      * @return Cluster node, or {@code null} if no node in assignments can be 
the leaseholder.
      */
-    private ClusterNode nextLeaseHolder(Set<Assignment> assignments) {
+    private ClusterNode nextLeaseHolder(ReplicationGroupId groupId, 
Set<Assignment> assignments) {
         //TODO: IGNITE-18879 Implement more intellectual algorithm to choose a 
node.
+        LeaseAgreement agreement = leaseConciliator.conciliated(groupId);
+
+        if (agreement.getRedirectTo() != null) {
+            boolean hasInAssignments = false;
+
+            for (Assignment assignment : assignments) {
+                if 
(agreement.getRedirectTo().equals(assignment.consistentId())) {
+                    hasInAssignments = true;
+
+                    break;
+                }
+            }
+
+            if (hasInAssignments) {
+                ClusterNode candidate = 
topologyTracker.nodeByConsistentId(agreement.getRedirectTo());
+
+                if (candidate != null) {
+                    return candidate;
+                }
+            }
+        }

Review Comment:
   Without the logic, I cannot write a test. If it is now, it does not mean 
that it cannot be rewritten in the future.



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