On Tue, Sep 2, 2014 at 6:39 PM, John Sanda <jsanda@redhat.com> wrote:
Are you saying that the graph should dip at T1, but it does not? Not sure I completely understand.

What I observe is the graph dips at T1, but that's not the correct result in my opinion.

   T0    T1
------------------
S1  6    4
S2  6    4
S3  x    4
A1  6    4
A2  4    4

RHQ is returning results at A1, I would expect A2 to be the result. This but here's a sketch of a way to fix:

diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Buckets.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Buckets.java
index 80fa577..95470d3 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Buckets.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/Buckets.java
@@ -38,7 +38,7 @@
         // end time is exclusive
         private long endTime;
 
-        private ArithmeticMeanCalculator mean;
+        private double total;
         private double max;
         private double min;
         private int count;
@@ -46,7 +46,6 @@
         public Bucket(long startTime, long endTime) {
             this.startTime = startTime;
             this.endTime = endTime;
-            this.mean = new ArithmeticMeanCalculator();
         }
 
         public long getStartTime() {
@@ -58,7 +57,7 @@ public long getEndTime() {
         }
 
         public Bucket insert(double value, double min, double max) {
-            mean.add(value);
+            total += value;
             if (count == 0) {
                 this.min = min;
                 this.max = max;
@@ -74,11 +73,11 @@ public Bucket insert(double value, double min, double max) {
             return this;
         }
 
-        public double getAvg() {
+        public double getAvg(int count) {
             if (count == 0) {
                 return Double.NaN;
             }
-            return mean.getArithmeticMean();
+            return total / count;
         }
 
         public double getMax() {

You would pass the number of schedules to 'getAvg' (or possibly the the constructor of 'Buckets') because this should be constant across the graph.

The other thing that might make sense would be to return a total rather than an average. The main problem with my idea is I'm not sure what to do about cases where no data appears, like if data wasn't being collected or was turned off.

Anyway I hope you can see how this is a potential problem.