denis-chudov commented on code in PR #6198: URL: https://github.com/apache/ignite-3/pull/6198#discussion_r2192003686
########## modules/placement-driver/src/main/java/org/apache/ignite/internal/placementdriver/leases/LeaseTracker.java: ########## @@ -255,63 +256,77 @@ private void enqueuePrimaryReplicaEvents( } } - private void awaitPrimaryReplica( - ReplicationGroupId groupId, - HybridTimestamp timestamp, - CompletableFuture<ReplicaMeta> resultFuture - ) { - inBusyLockAsync(busyLock, () -> getOrCreatePrimaryReplicaWaiter(groupId).waitFor(timestamp) - .thenAccept(replicaMeta -> { - ClusterNode leaseholderNode = clusterNodeResolver.getById(replicaMeta.getLeaseholderId()); - - if (leaseholderNode == null && !resultFuture.isDone()) { - awaitPrimaryReplica( - groupId, - replicaMeta.getExpirationTime().tick(), - resultFuture - ); - } else { - resultFuture.complete(replicaMeta); - } - }) - ); - } - @Override public CompletableFuture<ReplicaMeta> awaitPrimaryReplica( ReplicationGroupId groupId, HybridTimestamp timestamp, long timeout, TimeUnit unit ) { - if (!busyLock.enterBusy()) { - throw new IgniteInternalException(NODE_STOPPING_ERR, new NodeStoppingException()); - } - try { + return inBusyLockAsync(busyLock, () -> { ReplicaMeta currentMeta = getCurrentPrimaryReplica(groupId, timestamp); - if (currentMeta != null && clusterNodeResolver.getById(currentMeta.getLeaseholderId()) != null) { + if (isValidReplicaMeta(currentMeta)) { return completedFuture(currentMeta); } - } finally { - busyLock.leaveBusy(); - } - - CompletableFuture<ReplicaMeta> future = new CompletableFuture<>(); - awaitPrimaryReplica(groupId, timestamp, future); + return awaitPrimaryReplicaImpl(groupId, timestamp, timeout, unit); + }); + } - return future - .orTimeout(timeout, unit) + private CompletableFuture<ReplicaMeta> awaitPrimaryReplicaImpl( + ReplicationGroupId groupId, + HybridTimestamp timestamp, + long timeout, + TimeUnit unit + ) { + return awaitPrimaryReplicaImpl(groupId, timestamp, System.nanoTime(), unit.toNanos(timeout)) Review Comment: why `nanoTime`? looks like overkill here, we don't need this precision -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org