Updated Branches: refs/heads/trunk 842125aa9 -> 3bc7d8336
AMBARI-2831. YARN specific heatmaps need to be provided. (onechiporenko via yusaku) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/3bc7d833 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/3bc7d833 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/3bc7d833 Branch: refs/heads/trunk Commit: 3bc7d8336ce8afd0a6bdd7bf0d2d4141fac70990 Parents: 842125a Author: Yusaku Sako <[email protected]> Authored: Wed Aug 7 09:52:34 2013 -0700 Committer: Yusaku Sako <[email protected]> Committed: Wed Aug 7 09:52:34 2013 -0700 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 3 +- ambari-web/app/controllers.js | 1 + .../app/controllers/main/charts/heatmap.js | 3 +- .../heatmap_metric_yarn_ResourceUsed.js | 52 ++++++++ ambari-web/app/messages.js | 1 + .../heatmap_metric_yarn_ResourceUsed_test.js | 130 +++++++++++++++++++ 6 files changed, 188 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/3bc7d833/ambari-web/app/assets/test/tests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index 16b466a..aa1e6f2 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/ambari-web/app/assets/test/tests.js @@ -26,6 +26,7 @@ require('test/controllers/main/admin/security/add/step3_test'); require('test/controllers/main/admin/security/add/step4_test'); require('test/controllers/main/charts/heatmap_test'); require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_test'); +require('test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed_test'); require('test/controllers/main/service/reassign_controller_test'); require('test/controllers/main/dashboard_test'); require('test/controllers/main/host_test'); @@ -64,4 +65,4 @@ require('test/views/common/chart/linear_time_test'); require('test/views/common/filter_view_test'); require('test/views/common/configs/services_config_test'); require('test/models/host_test'); -require('test/models/rack_test'); +require('test/models/rack_test'); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/3bc7d833/ambari-web/app/controllers.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers.js b/ambari-web/app/controllers.js index baa11f4..7ef651e 100644 --- a/ambari-web/app/controllers.js +++ b/ambari-web/app/controllers.js @@ -81,6 +81,7 @@ require('controllers/main/charts/heatmap_metrics/heatmap_metric_mapreduce_memHea require('controllers/main/charts/heatmap_metrics/heatmap_metric_yarn'); require('controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_gctime'); require('controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_memHeapUsed'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed'); require('controllers/main/charts/heatmap_metrics/heatmap_metric_hbase'); require('controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_readrequest'); require('controllers/main/charts/heatmap_metrics/heatmap_metric_hbase_writerequest'); http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/3bc7d833/ambari-web/app/controllers/main/charts/heatmap.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/charts/heatmap.js b/ambari-web/app/controllers/main/charts/heatmap.js index 771aa66..dbe8843 100644 --- a/ambari-web/app/controllers/main/charts/heatmap.js +++ b/ambari-web/app/controllers/main/charts/heatmap.js @@ -68,7 +68,8 @@ App.MainChartsHeatmapController = Em.Controller.extend({ category: 'yarn', items: [ App.MainChartHeatmapYarnGCTimeMillisMetric.create(), - App.MainChartHeatmapYarnMemHeapUsedMetric.create() + App.MainChartHeatmapYarnMemHeapUsedMetric.create(), + App.MainChartHeatmapYarnResourceUsedMetric.create() ] }) ); http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/3bc7d833/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed.js b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed.js new file mode 100644 index 0000000..e40282a --- /dev/null +++ b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed.js @@ -0,0 +1,52 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +var App = require('app'); + +/** + * + */ +App.MainChartHeatmapYarnResourceUsedMetric = App.MainChartHeatmapYarnMetrics.extend({ + metricUrlTemplate: '/clusters/{clusterName}/services/YARN/components/RESOURCEMANAGER?fields=ServiceComponentInfo/rm_metrics', + name: Em.I18n.t('charts.heatmap.metrics.YarnResourceUsed'), + maximumValue: 100, + defaultMetric: 'ServiceComponentInfo.rm_metrics.cluster.nodeManagers', + units: ' %', + slotDefinitionLabelSuffix: ' %', + metricMapper: function (json) { + var hostToValueMap = {}; + var metricName = this.get('defaultMetric'); + var props = metricName.split('.'); + var value = json; + props.forEach(function (prop) { + if (value != null && prop in value) { + value = value[prop]; + } else { + value = null; + } + }); + if (value != null) { + value = JSON.parse(value); + if (value instanceof Array) { + value.forEach(function(host) { + hostToValueMap[host.HostName] = (host.UsedMemoryMB / host.AvailableMemoryMB * 100).toFixed(1); + }); + } + } + return hostToValueMap; + } +}); http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/3bc7d833/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 9dc0604..363b810 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -1141,6 +1141,7 @@ Em.I18n.translations = { 'charts.heatmap.metrics.reducesRunning' :'MapReduce Reduces Running', 'charts.heatmap.metrics.memoryUsed' :'Host Memory Used %', 'charts.heatmap.metrics.processRun' :'Total Running Processes', + 'charts.heatmap.metrics.YarnResourceUsed' :'YARN Resource used %', 'charts.heatmap.metrics.cpuWaitIO':'Host CPU Wait I/O %', 'charts.heatmap.metrics.HbaseRegionServerReadCount': 'HBase Read Request Count', 'charts.heatmap.metrics.HbaseRegionServerWriteCount': 'HBase Write Request Count', http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/3bc7d833/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed_test.js b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed_test.js new file mode 100644 index 0000000..26207c0 --- /dev/null +++ b/ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed_test.js @@ -0,0 +1,130 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +var App = require('app'); +require('messages'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_yarn'); +require('controllers/main/charts/heatmap_metrics/heatmap_metric_yarn_ResourceUsed'); + +describe('App.MainChartHeatmapYarnResourceUsedMetric', function () { + + var mainChartHeatmapYarnResourceUsedMetric = App.MainChartHeatmapYarnResourceUsedMetric.create({}); + + describe('#metricMapper', function () { + var tests = [ + { + m: 'Correct JSON #1', + i: { + "ServiceComponentInfo" : { + "rm_metrics" : { + "cluster" : { + "nodeManagers" : "[{\"HostName\":\"dev01.hortonworks.com\",\"Rack\":\"/default-rack\",\"State\":\"RUNNING\",\"NodeId\":\"dev01.hortonworks.com:45454\",\"NodeHTTPAddress\":\"dev01.hortonworks.com:8042\",\"LastHealthUpdate\":1375869232870,\"HealthReport\":\"\",\"NumContainers\":0,\"UsedMemoryMB\":10,\"AvailableMemoryMB\":100}]" + } + } + } + }, + e: { + length: 1, + val: '10.0', + host: 'dev01.hortonworks.com' + } + }, + { + m: 'Correct JSON #2', + i: { + "ServiceComponentInfo" : { + "rm_metrics" : { + "cluster" : { + "nodeManagers" : "[{\"HostName\":\"dev01.hortonworks.com\",\"Rack\":\"/default-rack\",\"State\":\"RUNNING\",\"NodeId\":\"dev01.hortonworks.com:45454\",\"NodeHTTPAddress\":\"dev01.hortonworks.com:8042\",\"LastHealthUpdate\":1375869232870,\"HealthReport\":\"\",\"NumContainers\":0,\"UsedMemoryMB\":0,\"AvailableMemoryMB\":100}]" + } + } + } + }, + e: { + length: 1, + val: '0.0', + host: 'dev01.hortonworks.com' + } + }, + { + m: 'JSON without "cluster"', + i: { + "ServiceComponentInfo" : { + "rm_metrics" : { + } + } + }, + e: { + length: 0, + val: null, + host: null + } + }, + { + m: 'JSON without "nodeManagers"', + i: { + "ServiceComponentInfo" : { + "rm_metrics" : { + "cluster" : { + } + } + } + }, + e: { + length: 0, + val: null, + host: null + } + }, + { + m: 'Correct JSON #3 (with two nodeManagers)', + i: { + "ServiceComponentInfo" : { + "rm_metrics" : { + "cluster" : { + "nodeManagers" : "[{\"HostName\":\"dev01.hortonworks.com\",\"Rack\":\"/default-rack\",\"State\":\"RUNNING\",\"NodeId\":\"dev01.hortonworks.com:45454\",\"NodeHTTPAddress\":\"dev01.hortonworks.com:8042\",\"LastHealthUpdate\":1375869232870,\"HealthReport\":\"\",\"NumContainers\":0,\"UsedMemoryMB\":0,\"AvailableMemoryMB\":100}, {\"HostName\":\"dev02.hortonworks.com\",\"Rack\":\"/default-rack\",\"State\":\"RUNNING\",\"NodeId\":\"dev02.hortonworks.com:45454\",\"NodeHTTPAddress\":\"dev01.hortonworks.com:8042\",\"LastHealthUpdate\":1375869232870,\"HealthReport\":\"\",\"NumContainers\":0,\"UsedMemoryMB\":100,\"AvailableMemoryMB\":100}]" + } + } + } + }, + e: { + length: 2, + val: '100.0', + host: 'dev02.hortonworks.com' + } + } + ]; + tests.forEach(function(test) { + it(test.m, function () { + var result = mainChartHeatmapYarnResourceUsedMetric.metricMapper(test.i); + var length = 0; + for(var p in result) { + if (result.hasOwnProperty(p)) { + length++; + } + } + expect(length).to.equal(test.e.length); + if (test.e.host) { + expect(result.hasOwnProperty(test.e.host)).to.equal(true); + expect(result[test.e.host]).to.equal(test.e.val); + } + }); + }); + }); + +});
