jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r1759268 - /jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java
Date Mon, 05 Sep 2016 13:37:28 GMT
Author: mreutegg
Date: Mon Sep  5 13:37:28 2016
New Revision: 1759268

URL: http://svn.apache.org/viewvc?rev=1759268&view=rev
Log:
JCR-4013: Calculate eventConsumerTimeRatio for entire time series

Modified:
    jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java

Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java?rev=1759268&r1=1759267&r2=1759268&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/observation/ListenerTracker.java
Mon Sep  5 13:37:28 2016
@@ -295,8 +295,8 @@ public class ListenerTracker {
             }
             @Override
             public double getEventConsumerTimeRatio() {
-                double consumerTime = sum(eventConsumerTime.getValuePerSecond());
-                double producerTime = sum(eventProducerTime.getValuePerSecond());
+                double consumerTime = sum(eventConsumerTime);
+                double producerTime = sum(eventProducerTime);
                 return consumerTime / Math.max(consumerTime + producerTime, 1);
             }
             @Override
@@ -390,10 +390,22 @@ public class ListenerTracker {
         }
     }
 
-    private static long sum(long[] values) {
+    private static long sum(TimeSeriesRecorder timeSeries) {
+        long missingValue = timeSeries.getMissingValue();
+        long sum = 0;
+        sum += sum(timeSeries.getValuePerSecond(), missingValue);
+        sum += sum(timeSeries.getValuePerMinute(), missingValue);
+        sum += sum(timeSeries.getValuePerHour(), missingValue);
+        sum += sum(timeSeries.getValuePerWeek(), missingValue);
+        return sum;
+    }
+
+    private static long sum(long[] values, long missing) {
         long sum = 0;
         for (long v : values) {
-            sum += v;
+            if (v != missing) {
+                sum += v;
+            }
         }
         return sum;
     }



Mime
View raw message