ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject [5/5] git commit: AMBARI-4100 - Chart not showing complete hour
Date Wed, 18 Dec 2013 09:59:43 GMT
AMBARI-4100 - Chart not showing complete hour


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7f726aec
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7f726aec
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7f726aec

Branch: refs/heads/trunk
Commit: 7f726aec97273a2b80780de5b914d69ce01a5b05
Parents: 59d292a
Author: tbeerbower <tbeerbower@hortonworks.com>
Authored: Tue Dec 17 21:21:36 2013 -0500
Committer: tbeerbower <tbeerbower@hortonworks.com>
Committed: Wed Dec 18 04:59:12 2013 -0500

----------------------------------------------------------------------
 .../puppet/modules/hdp-ganglia/files/rrd.py     |    35 +-
 .../ganglia/GangliaPropertyProvider.java        |    30 +-
 .../1.3._/services/GANGLIA/package/files/rrd.py |    33 +-
 .../2.0._/services/GANGLIA/package/files/rrd.py |    33 +-
 .../src/test/resources/flume_ganglia_data.txt   |  7008 +++---
 .../test/resources/journalnode_ganglia_data.txt |   242 +-
 .../test/resources/temporal_ganglia_data.txt    |   408 +-
 .../temporal_ganglia_data_yarn_queues.txt       | 20153 +++++------------
 .../src/test/resources/yarn_ganglia_data.txt    |    22 +-
 9 files changed, 9164 insertions(+), 18800 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7f726aec/ambari-agent/src/main/puppet/modules/hdp-ganglia/files/rrd.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/puppet/modules/hdp-ganglia/files/rrd.py b/ambari-agent/src/main/puppet/modules/hdp-ganglia/files/rrd.py
index c9b490e..d29a944 100755
--- a/ambari-agent/src/main/puppet/modules/hdp-ganglia/files/rrd.py
+++ b/ambari-agent/src/main/puppet/modules/hdp-ganglia/files/rrd.py
@@ -65,10 +65,29 @@ def printMetric(clusterName, hostName, metricName, file, cf, start, end,
resolut
   sys.stdout.write("\n")
 
   if not pointInTime:
+    valueCount = 0
+    lastValue = None
+
     for tuple in rrdMetric[2]:
-      if tuple[0] is not None:
-        sys.stdout.write(str(tuple[0]))
-        sys.stdout.write("\n")
+
+      thisValue = tuple[0]
+
+      if valueCount > 0 and thisValue == lastValue:
+        valueCount += 1
+      else:
+        if valueCount > 1:
+          sys.stdout.write("[~r]")
+          sys.stdout.write(str(valueCount))
+          sys.stdout.write("\n")
+
+        if thisValue is None:
+          sys.stdout.write("[~n]\n")
+        else:
+          sys.stdout.write(str(thisValue))
+          sys.stdout.write("\n")
+
+        valueCount = 1
+        lastValue = thisValue
   else:
     value = None
     idx   = -1
@@ -83,7 +102,7 @@ def printMetric(clusterName, hostName, metricName, file, cf, start, end,
resolut
       sys.stdout.write(str(value))
       sys.stdout.write("\n")
 
-  sys.stdout.write("[AMBARI_DP_END]\n")
+  sys.stdout.write("[~EOM]\n")
   return
 
 def stripList(l):
@@ -147,9 +166,9 @@ if "pt" in queryString:
   pointInTime = True
 else:
   pointInTime = False
-  
+
 def _walk(*args, **kwargs):
- 
+
   for root,dirs,files in os.walk(*args, **kwargs):
     for dir in dirs:
       qualified_dir = os.path.join(root,dir)
@@ -157,7 +176,7 @@ def _walk(*args, **kwargs):
         for x in os.walk(qualified_dir, **kwargs):
           yield x
     yield (root, dirs, files)
-    
+
 
 for cluster in clusterParts:
   for path, dirs, files in _walk(rrdPath + cluster):
@@ -180,7 +199,7 @@ for cluster in clusterParts:
             printMetric(pathParts[-2], pathParts[-1], matchedFile[:-4], os.path.join(path,
matchedFile), cf, start, end, resolution, pointInTime)
 
 
-sys.stdout.write("[AMBARI_END]\n")
+sys.stdout.write("[~EOF]\n")
 # write end time
 sys.stdout.write(str(time.mktime(time.gmtime())))
 sys.stdout.write("\n")

http://git-wip-us.apache.org/repos/asf/ambari/blob/7f726aec/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
index 1130c6e..f0c6d3d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/ganglia/GangliaPropertyProvider.java
@@ -450,7 +450,7 @@ public abstract class GangliaPropertyProvider extends AbstractPropertyProvider
{
           LOG.info("Ganglia host is not live");
           return Collections.emptySet();
         }
-        
+
         //Check if Ganglia server component is live
         if (!hostProvider.isGangliaCollectorComponentLive(clusterName)) {
           LOG.info("Ganglia server component is not live");
@@ -475,7 +475,7 @@ public abstract class GangliaPropertyProvider extends AbstractPropertyProvider
{
           return Collections.emptySet();
         }
 
-        while(!dsName.equals("[AMBARI_END]")) {
+        while(!dsName.equals("[~EOF]")) {
           GangliaMetric metric = new GangliaMetric();
           List<GangliaMetric.TemporalMetric> listTemporalMetrics =
               new ArrayList<GangliaMetric.TemporalMetric>();
@@ -488,11 +488,27 @@ public abstract class GangliaPropertyProvider extends AbstractPropertyProvider
{
           int time = convertToNumber(reader.readLine()).intValue();
           int step = convertToNumber(reader.readLine()).intValue();
 
-          String val = reader.readLine();
-          while(! val.equals("[AMBARI_DP_END]")) {
-            GangliaMetric.TemporalMetric tm = new GangliaMetric.TemporalMetric(val, time);
-            if (tm.isValid()) listTemporalMetrics.add(tm);
-            time += step;
+          String val     = reader.readLine();
+          String lastVal = null;
+
+          while(! val.equals("[~EOM]")) {
+            if (val.startsWith("[~r]")) {
+              Integer repeat = Integer.valueOf(val.substring(4));
+              for (int i = 0; i < repeat; ++i) {
+                if (! lastVal.equals("[~n]")) {
+                  GangliaMetric.TemporalMetric tm = new GangliaMetric.TemporalMetric(lastVal,
time);
+                  if (tm.isValid()) listTemporalMetrics.add(tm);
+                }
+                time += step;
+              }
+            } else {
+              if (! val.equals("[~n]")) {
+                GangliaMetric.TemporalMetric tm = new GangliaMetric.TemporalMetric(val, time);
+                if (tm.isValid()) listTemporalMetrics.add(tm);
+              }
+              time += step;
+            }
+            lastVal = val;
             val = reader.readLine();
           }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/7f726aec/ambari-server/src/main/resources/stacks/HDP/1.3._/services/GANGLIA/package/files/rrd.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/1.3._/services/GANGLIA/package/files/rrd.py
b/ambari-server/src/main/resources/stacks/HDP/1.3._/services/GANGLIA/package/files/rrd.py
index 4b52487..3fe6901 100644
--- a/ambari-server/src/main/resources/stacks/HDP/1.3._/services/GANGLIA/package/files/rrd.py
+++ b/ambari-server/src/main/resources/stacks/HDP/1.3._/services/GANGLIA/package/files/rrd.py
@@ -66,10 +66,29 @@ def printMetric(clusterName, hostName, metricName, file, cf, start, end,
   sys.stdout.write("\n")
 
   if not pointInTime:
+    valueCount = 0
+    lastValue = None
+
     for tuple in rrdMetric[2]:
-      if tuple[0] is not None:
-        sys.stdout.write(str(tuple[0]))
-        sys.stdout.write("\n")
+
+      thisValue = tuple[0]
+
+      if valueCount > 0 and thisValue == lastValue:
+        valueCount += 1
+      else:
+        if valueCount > 1:
+          sys.stdout.write("[~r]")
+          sys.stdout.write(str(valueCount))
+          sys.stdout.write("\n")
+
+        if thisValue is None:
+          sys.stdout.write("[~n]\n")
+        else:
+          sys.stdout.write(str(thisValue))
+          sys.stdout.write("\n")
+
+        valueCount = 1
+        lastValue = thisValue
   else:
     value = None
     idx = -1
@@ -84,7 +103,7 @@ def printMetric(clusterName, hostName, metricName, file, cf, start, end,
       sys.stdout.write(str(value))
       sys.stdout.write("\n")
 
-  sys.stdout.write("[AMBARI_DP_END]\n")
+  sys.stdout.write("[~EOM]\n")
   return
 
 
@@ -101,8 +120,8 @@ sys.stdout.write("\n")
 requestMethod = os.environ['REQUEST_METHOD']
 
 if requestMethod == 'POST':
-  postData = sys.stdin.read()
-  queryString = urlparse.parse_qs(postData)
+  postData = sys.stdin.readline()
+  queryString = cgi.parse_qs(postData)
   queryString = dict((k, v[0]) for k, v in queryString.items())
 elif requestMethod == 'GET':
   queryString = dict(cgi.parse_qsl(os.environ['QUERY_STRING']));
@@ -186,7 +205,7 @@ for cluster in clusterParts:
                         os.path.join(path, matchedFile), cf, start, end,
                         resolution, pointInTime)
 
-sys.stdout.write("[AMBARI_END]\n")
+sys.stdout.write("[~EOF]\n")
 # write end time
 sys.stdout.write(str(time.mktime(time.gmtime())))
 sys.stdout.write("\n")

http://git-wip-us.apache.org/repos/asf/ambari/blob/7f726aec/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/files/rrd.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/files/rrd.py
b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/files/rrd.py
index 4b52487..3fe6901 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/files/rrd.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/GANGLIA/package/files/rrd.py
@@ -66,10 +66,29 @@ def printMetric(clusterName, hostName, metricName, file, cf, start, end,
   sys.stdout.write("\n")
 
   if not pointInTime:
+    valueCount = 0
+    lastValue = None
+
     for tuple in rrdMetric[2]:
-      if tuple[0] is not None:
-        sys.stdout.write(str(tuple[0]))
-        sys.stdout.write("\n")
+
+      thisValue = tuple[0]
+
+      if valueCount > 0 and thisValue == lastValue:
+        valueCount += 1
+      else:
+        if valueCount > 1:
+          sys.stdout.write("[~r]")
+          sys.stdout.write(str(valueCount))
+          sys.stdout.write("\n")
+
+        if thisValue is None:
+          sys.stdout.write("[~n]\n")
+        else:
+          sys.stdout.write(str(thisValue))
+          sys.stdout.write("\n")
+
+        valueCount = 1
+        lastValue = thisValue
   else:
     value = None
     idx = -1
@@ -84,7 +103,7 @@ def printMetric(clusterName, hostName, metricName, file, cf, start, end,
       sys.stdout.write(str(value))
       sys.stdout.write("\n")
 
-  sys.stdout.write("[AMBARI_DP_END]\n")
+  sys.stdout.write("[~EOM]\n")
   return
 
 
@@ -101,8 +120,8 @@ sys.stdout.write("\n")
 requestMethod = os.environ['REQUEST_METHOD']
 
 if requestMethod == 'POST':
-  postData = sys.stdin.read()
-  queryString = urlparse.parse_qs(postData)
+  postData = sys.stdin.readline()
+  queryString = cgi.parse_qs(postData)
   queryString = dict((k, v[0]) for k, v in queryString.items())
 elif requestMethod == 'GET':
   queryString = dict(cgi.parse_qsl(os.environ['QUERY_STRING']));
@@ -186,7 +205,7 @@ for cluster in clusterParts:
                         os.path.join(path, matchedFile), cf, start, end,
                         resolution, pointInTime)
 
-sys.stdout.write("[AMBARI_END]\n")
+sys.stdout.write("[~EOF]\n")
 # write end time
 sys.stdout.write(str(time.mktime(time.gmtime())))
 sys.stdout.write("\n")


Mime
View raw message