egor-ryashin commented on a change in pull request #7038: Fix and document
concurrency of EventReceiverFirehose and TimedShutoffFirehose; Refine
concurrency specification of Firehose
URL: https://github.com/apache/incubator-druid/pull/7038#discussion_r255260125
##########
File path:
server/src/main/java/org/apache/druid/segment/realtime/firehose/EventReceiverFirehoseFactory.java
##########
@@ -274,67 +359,59 @@ public Response addAll(
}
catch (InterruptedException e) {
Thread.currentThread().interrupt();
- throw Throwables.propagate(e);
- }
- catch (JsonProcessingException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
@Override
public boolean hasMore()
{
- synchronized (readLock) {
- try {
- while (nextRow == null) {
- nextRow = buffer.poll(500, TimeUnit.MILLISECONDS);
- if (closed) {
- break;
- }
- }
- }
- catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw Throwables.propagate(e);
- }
-
- return nextRow != null;
+ if (rowsRunOut) {
+ return false;
}
+ if (nextRow != null) {
+ return true;
+ }
+ Object next;
+ try {
+ next = buffer.take();
Review comment:
Why choosing a poison pill approach here instead of using a `volatile` flag
field `closed` and checking it if `next == null`? Like:
```next = buffer.poll(timeout)
if (next == null && closed)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]