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


##########
modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/leases/LeaseTracker.java:
##########
@@ -152,4 +195,46 @@ public CompletableFuture<Void> onUpdate(WatchEvent event) {
         public void onError(Throwable e) {
         }
     }
+
+    @Override
+    public CompletableFuture<LeaseMeta> awaitPrimaryReplica(ReplicationGroupId 
groupId, HybridTimestamp timestamp) {
+        if (!busyLock.enterBusy()) {
+            return failedFuture(new NodeStoppingException("Component is 
stopping."));
+        }
+        try {
+            return primaryReplicaWaiters.computeIfAbsent(groupId, id -> new 
PendingIndependentComparableValuesTracker<>(MIN_VALUE))
+                    .waitFor(timestamp);
+        } finally {
+            busyLock.leaveBusy();
+        }
+    }
+
+    @Override
+    public CompletableFuture<LeaseMeta> getPrimaryReplica(ReplicationGroupId 
replicationGroupId, HybridTimestamp timestamp) {
+        if (!busyLock.enterBusy()) {
+            return failedFuture(new NodeStoppingException("Component is 
stopping."));
+        }
+        try {
+            // There's no sense in awaiting previously detected primary 
replica more than lease interval.
+            return awaitPrimaryReplica(replicationGroupId, 
timestamp).orTimeout(longLeaseInterval, TimeUnit.MILLISECONDS);

Review Comment:
   I disagree that we can use long lease interval to limited waiting time. 
Timeout transaction is possible to use here, if I correctly understand how it 
is used in production, but the limitation is imposed externally.
   Here, safe time is only possible to use. If it is not possible for now, you 
will be able to write TODO.



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