loserwang1024 commented on code in PR #1443:
URL: https://github.com/apache/fluss/pull/1443#discussion_r2247030051
##########
fluss-client/src/main/java/com/alibaba/fluss/client/table/scanner/log/RemoteLogDownloader.java:
##########
@@ -140,44 +137,55 @@ void recycleRemoteLog(RemoteLogSegment segment) {
* to fetch.
*/
void fetchOnce() throws Exception {
- // wait until there is a remote fetch request
- RemoteLogDownloadRequest request = segmentsToFetch.poll(pollTimeout,
TimeUnit.MILLISECONDS);
- if (request == null) {
+ int availablePermits = prefetchSemaphore.availablePermits();
+ List<RemoteLogDownloadRequest> requests = new
ArrayList<>(availablePermits);
+ segmentsToFetch.drainTo(requests, availablePermits);
+ if (requests.size() <= 0) {
+ Thread.sleep(pollSleepTimeout);
return;
}
- // blocks until there is capacity (the fetched file is consumed)
- prefetchSemaphore.acquire();
+
+ prefetchSemaphore.acquire(requests.size());
Review Comment:
If the remoteLogDownloader is just a single thread, maybe a `Semaphore` is
no need? Maybe a simple `EMPTY` condition is enough.
What if availablePermits is 8 while segmentsToFetch is just 4?
--
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]