Github user siyuanh commented on a diff in the pull request:
https://github.com/apache/incubator-apex-malhar/pull/118#discussion_r46729161
--- Diff:
contrib/src/main/java/com/datatorrent/contrib/kafka/AbstractKafkaInputOperator.java
---
@@ -363,18 +361,26 @@ public void emitTuples()
if (maxTuplesPerWindow > 0) {
count = Math.min(count, maxTuplesPerWindow - emitCount);
}
- for (int i = 0; i < count; i++) {
- KafkaConsumer.KafkaMessage message = consumer.pollMessage();
- // Ignore the duplicate messages
- if(offsetStats.containsKey(message.kafkaPart) && message.offSet <=
offsetStats.get(message.kafkaPart))
- continue;
- emitTuple(message.msg);
- offsetStats.put(message.kafkaPart, message.offSet);
- MutablePair<Long, Integer> offsetAndCount =
currentWindowRecoveryState.get(message.kafkaPart);
- if(offsetAndCount == null) {
- currentWindowRecoveryState.put(message.kafkaPart, new
MutablePair<Long, Integer>(message.offSet, 1));
- } else {
- offsetAndCount.setRight(offsetAndCount.right+1);
+ if (count > 0) {
+ for (int i = 0; i < count; i++) {
+ KafkaConsumer.KafkaMessage message = consumer.pollMessage();
+ // Ignore the duplicate messages
+ if (offsetStats.containsKey(message.kafkaPart) && message.offSet
<= offsetStats.get(message.kafkaPart))
+ continue;
+ emitTuple(message.msg);
+ offsetStats.put(message.kafkaPart, message.offSet);
+ MutablePair<Long, Integer> offsetAndCount =
currentWindowRecoveryState.get(message.kafkaPart);
+ if (offsetAndCount == null) {
+ currentWindowRecoveryState.put(message.kafkaPart, new
MutablePair<Long, Integer>(message.offSet, 1));
+ } else {
+ offsetAndCount.setRight(offsetAndCount.right + 1);
+ }
+ }
+ } else {
+ try {
+ Thread.sleep(spinMillis);
--- End diff --
@PramodSSImmaneni my understanding is in the InputNode, it already sleep
spinmillis if counter of the emitTuples() is 0, do we need to double sleep here?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---