You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apex.apache.org by PramodSSImmaneni <gi...@git.apache.org> on 2015/12/04 21:13:39 UTC

[GitHub] incubator-apex-malhar pull request: Avoid busy wait when maximum n...

GitHub user PramodSSImmaneni opened a pull request:

    https://github.com/apache/incubator-apex-malhar/pull/118

    Avoid busy wait when maximum number of tuples emitted in a window are reached

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/PramodSSImmaneni/incubator-apex-malhar APEX-280

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-apex-malhar/pull/118.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #118
    
----
commit 3902715ee2ec907a5140268560211e0e53c111cf
Author: Pramod Immaneni <pr...@datatorrent.com>
Date:   2015-12-04T20:10:45Z

    If the max number of emitted tuples is reached and there is nothing to send sleep for a little bit of time, APEX-280 #comment

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: Avoid busy wait when maximum n...

Posted by PramodSSImmaneni <gi...@git.apache.org>.
Github user PramodSSImmaneni closed the pull request at:

    https://github.com/apache/incubator-apex-malhar/pull/118


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-apex-malhar pull request: Avoid busy wait when maximum n...

Posted by siyuanh <gi...@git.apache.org>.
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---