Browse Source

AMBARI-4100 - Chart not showing complete hour

tbeerbower 11 years ago
parent
commit
43002933c6

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java

@@ -493,7 +493,7 @@ public abstract class GangliaPropertyProvider extends AbstractPropertyProvider {
 
           while(! val.equals("[~EOM]")) {
             if (val.startsWith("[~r]")) {
-              Integer repeat = Integer.valueOf(val.substring(4));
+              Integer repeat = Integer.valueOf(val.substring(4)) - 1;
               for (int i = 0; i < repeat; ++i) {
                 if (! lastVal.equals("[~n]")) {
                   GangliaMetric.TemporalMetric tm = new GangliaMetric.TemporalMetric(lastVal, time);

+ 10 - 0
ambari-server/src/test/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProviderTest.java

@@ -193,7 +193,17 @@ public class GangliaPropertyProviderTest {
 
 
     Assert.assertEquals(6, PropertyHelper.getProperties(resource).size());
+
     Assert.assertNotNull(resource.getPropertyValue(shuffle_exceptions_caught));
+
+    Number[][] dataPoints = (Number[][]) resource.getPropertyValue(shuffle_exceptions_caught);
+
+    Assert.assertEquals(106, dataPoints.length);
+    for (int i = 0; i < dataPoints.length; ++i) {
+      Assert.assertEquals(i >=10 && i < 20 ? 7 : 0.0, dataPoints[i][0]);
+      Assert.assertEquals(360 * i + 1358434800, dataPoints[i][1]);
+    }
+
     Assert.assertNotNull(resource.getPropertyValue(shuffle_failed_outputs));
     Assert.assertNotNull(resource.getPropertyValue(shuffle_output_bytes));
     Assert.assertNotNull(resource.getPropertyValue(shuffle_success_outputs));

+ 5 - 1
ambari-server/src/test/resources/temporal_ganglia_data.txt

@@ -6,7 +6,11 @@ mapred.shuffleOutput.shuffle_exceptions_caught
 1358434800
 360
 0.0
-[~r]106
+[~r]10
+7.0
+[~r]10
+0.0
+[~r]86
 [~EOM]
 sum
 HDPSlaves