swuferhong commented on code in PR #2179:
URL: https://github.com/apache/fluss/pull/2179#discussion_r2703007776
##########
fluss-client/src/main/java/org/apache/fluss/client/admin/Admin.java:
##########
@@ -412,6 +415,56 @@ CompletableFuture<Void> dropPartition(
CompletableFuture<KvSnapshotMetadata> getKvSnapshotMetadata(
TableBucket bucket, long snapshotId);
+ /**
+ * Acquires a lease for specific KV snapshots of the given tableBuckets
asynchronously.
+ *
+ * <p>Once acquired, the specified KV snapshots will be protected from
garbage collection for
+ * the duration of the {@code leaseDuration}. The client must call {@link
+ * #releaseKvSnapshotLease} to release the lock early when reading is
finished.
+ *
+ * <p>If the lease expires (no renew received within duration), the server
is free to delete the
+ * snapshot files.
+ *
+ * <p>The following exceptions can be anticipated when calling {@code
get()} on returned future:
+ *
+ * <ul>
+ * <li>{@link TableNotExistException} if the table does not exist.
+ * <li>{@link PartitionNotExistException} if the partition does not
exist.
+ * </ul>
+ *
+ * @param leaseId The unique ID for this lease session (usually a UUID
generated by client).
+ * @param snapshotIds The snapshots to lease, a map from TableBucket to
kvSnapshotId.
+ * @param leaseDuration The duration (in milliseconds) for which the
snapshots should be kept.
+ * @return The result of the acquire operation, containing any buckets
that failed to be locked.
+ */
+ CompletableFuture<AcquireKvSnapshotLeaseResult> acquireKvSnapshotLease(
+ String leaseId, Map<TableBucket, Long> snapshotIds, long
leaseDuration);
+
+ /**
+ * Releases the lease for specific tableBuckets asynchronously.
+ *
+ * <p>This is typically called when a client finishes reading a specific
bucket (or a batch of
+ * buckets) but is still reading others under the same leaseId.
+ *
+ * <p>If {@code bucketsToRelease} contains all buckets under this leaseId,
the lease itself will
+ * be removed.
+ *
+ * @param leaseId The lease id.
+ * @param bucketsToRelease The specific tableBuckets to release.
+ */
+ CompletableFuture<Void> releaseKvSnapshotLease(
+ String leaseId, Set<TableBucket> bucketsToRelease);
+
+ /**
+ * Releases the entire lease asynchronously.
+ *
+ * <p>All snapshots locked under this {@code leaseId} will be released
immediately. This is
+ * equivalent to calling {@link #releaseKvSnapshotLease} with all held
buckets.
+ *
+ * @param leaseId The lease id to release.
+ */
+ CompletableFuture<Void> dropKvSnapshotLease(String leaseId);
Review Comment:
Ok, I will also remove
`DropKvSnapshotLeaseRequest/DropKvSnapshotLeaseResponse`. Instead the
`releaseAllKvSnapshotLeases()` and `releaseKvSnapshotLease` will use
`ReleaseKvSnapshotLeaseRequest/ReleaseKvSnapshotLeaseResponse` together.
--
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]