incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject svn commit: r1418936 [3/3] - in /incubator/ambari/branches/AMBARI-666: ./ ambari-web/app/assets/data/cluster_metrics/ ambari-web/app/views/main/dashboard/cluster_metrics/
Date Sun, 09 Dec 2012 13:17:40 GMT
Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/cpu.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/cpu.js?rev=1418936&r1=1418935&r2=1418936&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/cpu.js
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/cpu.js
Sun Dec  9 13:17:38 2012
@@ -28,25 +28,39 @@ var App = require('app');
  */
 App.ChartClusterMetricsCPU = App.ChartLinearTimeView.extend({
   id: "cluster-metrics-cpu",
-  url: "/data/cluster_metrics/cpu_1hr.json",
+  url: function () {
+    return App.formatUrl("/api/clusters/{clusterName}?fields=metrics/cpu[{fromSeconds},{toSeconds},{stepSeconds}]",
{
+      clusterName: App.router.get('clusterController.clusterName')
+    }, "/data/cluster_metrics/cpu_1hr.json");
+  }.property('App.router.clusterController.clusterName'),
+
   title: "CPU Usage",
   yAxisFormatter: App.ChartLinearTimeView.PercentageFormatter,
   
   transformToSeries: function (jsonData) {
     var seriesArray = [];
-    if (jsonData instanceof Array) {
-      jsonData.forEach(function (data) {
-        var series = {};
-        series.name = data.metric_name.replace(/\\g/, '');
-        series.data = [];
-        for ( var index = 0; index < data.datapoints.length; index++) {
-          series.data.push({
-            x: data.datapoints[index][1],
-            y: data.datapoints[index][0]
-          });
+    if (jsonData && jsonData.metrics && jsonData.metrics.cpu) {
+      for ( var name in jsonData.metrics.cpu) {
+        var displayName = name;
+        var seriesData = jsonData.metrics.cpu[name];
+        if (seriesData) {
+          // Is it a string?
+          if ("string" == typeof seriesData) {
+            seriesData = JSON.parse(seriesData);
+          }
+          // We have valid data
+          var series = {};
+          series.name = displayName;
+          series.data = [];
+          for ( var index = 0; index < seriesData.length; index++) {
+            series.data.push({
+              x: seriesData[index][1],
+              y: seriesData[index][0]
+            });
+          }
+          seriesArray.push(series);
         }
-        seriesArray.push(series);
-      });
+      }
     }
     return seriesArray;
   },

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/load.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/load.js?rev=1418936&r1=1418935&r2=1418936&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/load.js
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/load.js
Sun Dec  9 13:17:38 2012
@@ -30,23 +30,38 @@ var App = require('app');
 App.ChartClusterMetricsLoad = App.ChartLinearTimeView.extend({
   id: "cluster-metrics-load",
   url: "/data/cluster_metrics/load_1hr.json",
+  url: function () {
+    return App.formatUrl("/api/clusters/{clusterName}?fields=metrics/load[{fromSeconds},{toSeconds},{stepSeconds}]",
{
+      clusterName: App.router.get('clusterController.clusterName')
+    }, "/data/cluster_metrics/load_1hr.json");
+  }.property('App.router.clusterController.clusterName'),
+  
   title: "Cluster Load",
   
   transformToSeries: function(jsonData){
     var seriesArray = [];
-    if(jsonData instanceof Array){
-      jsonData.forEach(function(data){
-        var series = {};
-        series.name = data.metric_name;
-        series.data = [];
-        for(var index=0; index<data.datapoints.length; index++){
-          series.data.push({
-            x: data.datapoints[index][1],
-            y: data.datapoints[index][0]
-          });
+    if (jsonData && jsonData.metrics && jsonData.metrics.load) {
+      for ( var name in jsonData.metrics.load) {
+        var displayName = name;
+        var seriesData = jsonData.metrics.load[name];
+        if (seriesData) {
+          // Is it a string?
+          if ("string" == typeof seriesData) {
+            seriesData = JSON.parse(seriesData);
+          }
+          // We have valid data
+          var series = {};
+          series.name = displayName;
+          series.data = [];
+          for ( var index = 0; index < seriesData.length; index++) {
+            series.data.push({
+              x: seriesData[index][1],
+              y: seriesData[index][0]
+            });
+          }
+          seriesArray.push(series);
         }
-        seriesArray.push(series);
-      });
+      }
     }
     return seriesArray;
   }

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/memory.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/memory.js?rev=1418936&r1=1418935&r2=1418936&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/memory.js
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/memory.js
Sun Dec  9 13:17:38 2012
@@ -28,25 +28,38 @@ var App = require('app');
  */
 App.ChartClusterMetricsMemory = App.ChartLinearTimeView.extend({
   id: "cluster-metrics-memory",
-  url: "/data/cluster_metrics/memory_1hr.json",
+  url: function () {
+    return App.formatUrl("/api/clusters/{clusterName}?fields=metrics/memory[{fromSeconds},{toSeconds},{stepSeconds}]",
{
+      clusterName: App.router.get('clusterController.clusterName')
+    }, "/data/cluster_metrics/memory_1hr.json");
+  }.property('App.router.clusterController.clusterName'),
   title: "Memory Usage",
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,
   
   transformToSeries: function (jsonData) {
     var seriesArray = [];
-    if (jsonData instanceof Array) {
-      jsonData.forEach(function (data) {
-        var series = {};
-        series.name = data.metric_name.replace(/\\g/, '');
-        series.data = [];
-        for ( var index = 0; index < data.datapoints.length; index++) {
-          series.data.push({
-            x: data.datapoints[index][1],
-            y: data.datapoints[index][0]
-          });
+    if (jsonData && jsonData.metrics && jsonData.metrics.memory) {
+      for ( var name in jsonData.metrics.memory) {
+        var displayName = name;
+        var seriesData = jsonData.metrics.memory[name];
+        if (seriesData) {
+          // Is it a string?
+          if ("string" == typeof seriesData) {
+            seriesData = JSON.parse(seriesData);
+          }
+          // We have valid data
+          var series = {};
+          series.name = displayName;
+          series.data = [];
+          for ( var index = 0; index < seriesData.length; index++) {
+            series.data.push({
+              x: seriesData[index][1],
+              y: seriesData[index][0]
+            });
+          }
+          seriesArray.push(series);
         }
-        seriesArray.push(series);
-      });
+      }
     }
     return seriesArray;
   },

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/network.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/network.js?rev=1418936&r1=1418935&r2=1418936&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/network.js
(original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/views/main/dashboard/cluster_metrics/network.js
Sun Dec  9 13:17:38 2012
@@ -29,25 +29,38 @@ var App = require('app');
  */
 App.ChartClusterMetricsNetwork = App.ChartLinearTimeView.extend({
   id: "cluster-metrics-network",
-  url : "/data/cluster_metrics/network_1hr.json",
+  url: function () {
+    return App.formatUrl("/api/clusters/{clusterName}?fields=metrics/network[{fromSeconds},{toSeconds},{stepSeconds}]",
{
+      clusterName: App.router.get('clusterController.clusterName')
+    }, "/data/cluster_metrics/network_1hr.json");
+  }.property('App.router.clusterController.clusterName'),
   title: "Network Usage",
   yAxisFormatter: App.ChartLinearTimeView.BytesFormatter,
   
   transformToSeries : function (jsonData) {
     var seriesArray = [];
-    if (jsonData instanceof Array) {
-      jsonData.forEach(function (data) {
-        var series = {};
-        series.name = data.metric_name;
-        series.data = [];
-        for ( var index = 0; index < data.datapoints.length; index++) {
-          series.data.push({
-            x : data.datapoints[index][1],
-            y : data.datapoints[index][0]
-          });
+    if (jsonData && jsonData.metrics && jsonData.metrics.network) {
+      for ( var name in jsonData.metrics.network) {
+        var displayName = name;
+        var seriesData = jsonData.metrics.network[name];
+        if (seriesData) {
+          // Is it a string?
+          if ("string" == typeof seriesData) {
+            seriesData = JSON.parse(seriesData);
+          }
+          // We have valid data
+          var series = {};
+          series.name = displayName;
+          series.data = [];
+          for ( var index = 0; index < seriesData.length; index++) {
+            series.data.push({
+              x: seriesData[index][1],
+              y: seriesData[index][0]
+            });
+          }
+          seriesArray.push(series);
         }
-        seriesArray.push(series);
-      });
+      }
     }
     return seriesArray;
   }



Mime
View raw message