STREAMS-197 | Avg time now will count for providers and does not include errors 
in calculations


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-streams/commit/f40ce9b0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-streams/tree/f40ce9b0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-streams/diff/f40ce9b0

Branch: refs/heads/master
Commit: f40ce9b0db7bc082ce98722529f69881d85f3c8f
Parents: bfffc5f
Author: Ryan Ebanks <[email protected]>
Authored: Mon Oct 20 16:00:26 2014 -0500
Committer: Ryan Ebanks <[email protected]>
Committed: Mon Oct 20 16:00:26 2014 -0500

----------------------------------------------------------------------
 .../apache/streams/local/counters/StreamsTaskCounter.java   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/f40ce9b0/streams-runtimes/streams-runtime-local/src/main/java/org/apache/streams/local/counters/StreamsTaskCounter.java
----------------------------------------------------------------------
diff --git 
a/streams-runtimes/streams-runtime-local/src/main/java/org/apache/streams/local/counters/StreamsTaskCounter.java
 
b/streams-runtimes/streams-runtime-local/src/main/java/org/apache/streams/local/counters/StreamsTaskCounter.java
index c93cae9..8801df2 100644
--- 
a/streams-runtimes/streams-runtime-local/src/main/java/org/apache/streams/local/counters/StreamsTaskCounter.java
+++ 
b/streams-runtimes/streams-runtime-local/src/main/java/org/apache/streams/local/counters/StreamsTaskCounter.java
@@ -145,10 +145,15 @@ public class StreamsTaskCounter implements 
StreamsTaskCounterMXBean{
 
     @Override
     public double getAvgTime() {
-        if(this.received.get() == 0) {
+        long rec = this.received.get();
+        long emit = this.emitted.get();
+        if(rec == 0 && emit == 0 ) {
             return 0.0;
+        } else if( rec == 0) { //provider instance
+            return this.totalTime.get() / (double) emit;
+        } else {
+            return this.totalTime.get() / ((double) this.received.get() - 
this.errors.get());
         }
-        return this.totalTime.get() / (double) this.received.get();
     }
 
     @Override

Reply via email to