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


##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/PlacementDriverManager.java:
##########
@@ -187,10 +335,264 @@ private void takeOverActiveActor() {
      */
     private void stepDownActiveActor() {
         isActiveActor = false;
+
+        stopUpdater();
     }
 
     @TestOnly
     boolean isActiveActor() {
         return isActiveActor;
     }
+
+    /**
+     * Starts a dedicated thread to renew or assign leases.
+     */
+    private void startUpdater() {
+        //TODO: IGNITE-18879 Implement lease maintenance.
+        updater = new 
Thread(NamedThreadFactory.threadPrefix(clusterService.topologyService().localMember().name(),
 "lease-updater")) {
+            @Override
+            public void run() {
+                while (isActiveActor) {
+                    for (Map.Entry<ReplicationGroupId, Set<Assignment>> entry 
: groupAssignments.entrySet()) {
+                        ReplicationGroupId grpId = entry.getKey();
+
+                        ReplicationGroupLease lease = 
replicationGroups.getOrDefault(grpId, new ReplicationGroupLease());
+
+                        HybridTimestamp now = clock.now();
+
+                        if (lease.stopLeas == null || now.getPhysical() > 
(lease.stopLeas.getPhysical() - LEASE_PERIOD / 2)) {
+                            var leaseKey = 
ByteArray.fromString(PLACEMENTDRIVER_PREFIX + grpId);
+
+                            var newTs = new HybridTimestamp(now.getPhysical() 
+ LEASE_PERIOD, 0);
+
+                            ClusterNode holder = 
nextLeaseHolder(entry.getValue());

Review Comment:
   It can be needed, but make the selection more reasonable is a task of the 
maintenance ticket.



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