vldpyatkov commented on code in PR #1726:
URL: https://github.com/apache/ignite-3/pull/1726#discussion_r1127756025
##########
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());
+
+ if (lease.leaseholder == null && holder != null
+ || lease.leaseholder != null &&
lease.leaseholder.equals(holder)
+ || holder != null && (lease.stopLeas ==
null || now.getPhysical() > lease.stopLeas.getPhysical())) {
Review Comment:
We may not waiting to lease expiration in case whrn the leaseholder in not
changed, but if the leaseholder is changed the thread will wait to lease
expiration.
--
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]