wuchong commented on code in PR #2052:
URL: https://github.com/apache/fluss/pull/2052#discussion_r2573491018
##########
fluss-client/src/main/java/org/apache/fluss/client/lookup/LookupSender.java:
##########
@@ -126,13 +126,21 @@ private void runOnce(boolean drainAll) throws Exception {
sendLookups(lookups);
}
- private void sendLookups(List<AbstractLookupQuery<?>> lookups) {
+ private void sendLookups(List<AbstractLookupQuery<?>> lookups) throws
Exception {
if (lookups.isEmpty()) {
return;
}
// group by <leader, lookup type> to lookup batches
Map<Tuple2<Integer, LookupType>, List<AbstractLookupQuery<?>>>
lookupBatches =
groupByLeaderAndType(lookups);
+
+ // if no lookup batches, sleep a bit to avoid busy loop. This case
will happen when there is
+ // no leader for all the lookup request in queue.
+ if (lookupBatches.isEmpty()) {
Review Comment:
We should only sleep when the lookup queue is also emtpy, because currently
we have a very small batch size.
```java
if (lookupBatches.isEmpty() && !lookupQueue.hasUnDrained()) {
```
##########
fluss-client/src/main/java/org/apache/fluss/client/lookup/LookupSender.java:
##########
@@ -126,13 +126,21 @@ private void runOnce(boolean drainAll) throws Exception {
sendLookups(lookups);
}
- private void sendLookups(List<AbstractLookupQuery<?>> lookups) {
+ private void sendLookups(List<AbstractLookupQuery<?>> lookups) throws
Exception {
if (lookups.isEmpty()) {
return;
}
// group by <leader, lookup type> to lookup batches
Map<Tuple2<Integer, LookupType>, List<AbstractLookupQuery<?>>>
lookupBatches =
groupByLeaderAndType(lookups);
+
+ // if no lookup batches, sleep a bit to avoid busy loop. This case
will happen when there is
+ // no leader for all the lookup request in queue.
+ if (lookupBatches.isEmpty()) {
+ // TODO Hard code sleep time.
Review Comment:
improve the TODO comment. TODO comment is used to describe what need to do,
not what is the current status.
```java
// TODO: may use wait/notify mechanism to avoid active sleep, and use a
dynamic sleep
// time based on the request waited time.
```
--
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]