summaryrefslogtreecommitdiff
path: root/ambari-web
diff options
context:
space:
mode:
authorYusaku Sako <yusaku@apache.org>2012-12-09 14:23:41 +0000
committerYusaku Sako <yusaku@apache.org>2012-12-09 14:23:41 +0000
commit59100605114056bb819e6e568af24dd20b4a350d (patch)
tree408201d0baa55c0056b98e3093dea4f4bab86770 /ambari-web
parent0eabc1a3c69955d8cf324d4a8d2460da63d74db8 (diff)
AMBARI-1032. Host hover in cluster heatmap showing mock data. (Srimanth Gunturi via yusaku)
git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1418971 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'ambari-web')
-rw-r--r--ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_processrun.js12
-rw-r--r--ambari-web/app/mappers/hosts_mapper.js80
-rw-r--r--ambari-web/app/templates/main/charts/heatmap/heatmap_host_detail.hbs3
-rw-r--r--ambari-web/app/views/main/charts/heatmap/heatmap_host_detail.js5
4 files changed, 60 insertions, 40 deletions
diff --git a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_processrun.js b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_processrun.js
index cb216f485e..31afe5d0f3 100644
--- a/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_processrun.js
+++ b/ambari-web/app/controllers/main/charts/heatmap_metrics/heatmap_metric_processrun.js
@@ -33,5 +33,13 @@ App.MainChartHeatmapProcessRunMetric = App.MainChartHeatmapMetric.extend({
name: 'Total Running Processes',
maximumValue: 1,
defaultMetric: 'metrics.process.proc_run',
- units: 'Processes'
-}) \ No newline at end of file
+ units: 'Processes',
+ metricMapper: function (json) {
+ var map = this._super(json);
+ for ( var host in map) {
+ var val = map[host];
+ map[host] = val.toFixed(1);
+ }
+ return map;
+ }
+}); \ No newline at end of file
diff --git a/ambari-web/app/mappers/hosts_mapper.js b/ambari-web/app/mappers/hosts_mapper.js
index d25f7be499..742a383f1b 100644
--- a/ambari-web/app/mappers/hosts_mapper.js
+++ b/ambari-web/app/mappers/hosts_mapper.js
@@ -1,32 +1,30 @@
/**
- * 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
- *
+ * 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.
+ * 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.
*/
-
App.hostsMapper = App.QuickDataMapper.create({
- model : App.Host,
- config : {
- id : 'Hosts.host_name',
- host_name : 'Hosts.host_name',
- cluster_id: 'Hosts.cluster_name',//1
+ model: App.Host,
+ config: {
+ id: 'Hosts.host_name',
+ host_name: 'Hosts.host_name',
+ cluster_id: 'Hosts.cluster_name',// 1
components_key: 'host_components',
components_type: 'array',
components: {
- item : 'HostRoles.component_name'
+ item: 'HostRoles.component_name'
},
rack: 'Hosts.rack_info',
host_components_key: 'host_components',
@@ -34,22 +32,22 @@ App.hostsMapper = App.QuickDataMapper.create({
host_components: {
item: 'id'
},
- cpu : 'Hosts.cpu_count',
- memory : 'Hosts.total_mem',
+ cpu: 'Hosts.cpu_count',
+ memory: 'Hosts.total_mem',
disk_info: 'Hosts.disk_info',
- $disk_usage: '-',
+ disk_usage: 'disk_usage',
health_status: 'Hosts.host_status',
load_one: 'Hosts.load.load_one',
load_five: 'Hosts.load.load_five',
load_fifteen: 'Hosts.load.load_fifteen',
- $cpu_usage: 33,
- $memory_usage: 26,
+ cpu_usage: 'cpu_usage',
+ memory_usage: 'memory_usage',
$network_usage: 36,
$io_usage: 39,
- last_heart_beat_time : "Hosts.last_heartbeat_time",
- os_arch : 'Hosts.os_arch',
- os_type : 'Hosts.os_type',
- ip : 'Hosts.ip'
+ last_heart_beat_time: "Hosts.last_heartbeat_time",
+ os_arch: 'Hosts.os_arch',
+ os_type: 'Hosts.os_type',
+ ip: 'Hosts.ip'
},
map: function (json) {
if (!this.get('model')) {
@@ -57,15 +55,31 @@ App.hostsMapper = App.QuickDataMapper.create({
}
if (json.items) {
var result = [];
-
json.items.forEach(function (item) {
- item.host_components.forEach(function(host_component){
+ // Disk Usage
+ if (item.metrics && item.metrics.disk && item.metrics.disk.disk_total && item.metrics.disk.disk_free) {
+ var diskUsed = item.metrics.disk.disk_total - item.metrics.disk.disk_free;
+ var diskUsedPercent = (100 * diskUsed) / item.metrics.disk.disk_total;
+ item.disk_usage = diskUsedPercent.toFixed(1);
+ }
+ // CPU Usage
+ if (item.metrics && item.metrics.cpu && item.metrics.cpu.cpu_system && item.metrics.cpu.cpu_user) {
+ var cpuUsedPercent = item.metrics.cpu.cpu_system + item.metrics.cpu.cpu_user;
+ item.cpu_usage = cpuUsedPercent.toFixed(1);
+ }
+ // Memory Usage
+ if (item.metrics && item.metrics.memory && item.metrics.memory.mem_free && item.metrics.memory.mem_total) {
+ var memUsed = item.metrics.memory.mem_total - item.metrics.memory.mem_free;
+ var memUsedPercent = (100 * memUsed) / item.metrics.memory.mem_total;
+ item.memory_usage = memUsedPercent.toFixed(1);
+ }
+ item.host_components.forEach(function (host_component) {
host_component.id = host_component.HostRoles.component_name + "_" + host_component.HostRoles.host_name;
}, this);
result.push(this.parseIt(item, this.config));
}, this);
- //console.log(this.get('model'), result);
+ // console.log(this.get('model'), result);
App.store.loadMany(this.get('model'), result);
}
}
diff --git a/ambari-web/app/templates/main/charts/heatmap/heatmap_host_detail.hbs b/ambari-web/app/templates/main/charts/heatmap/heatmap_host_detail.hbs
index 76300821bc..dc3a05a8fe 100644
--- a/ambari-web/app/templates/main/charts/heatmap/heatmap_host_detail.hbs
+++ b/ambari-web/app/templates/main/charts/heatmap/heatmap_host_detail.hbs
@@ -22,7 +22,6 @@ IP: {{view.details.ip}}<br/>
{{#if view.details.metricName}}
{{view.details.metricName}}: {{view.details.metricValue}}<br/>
{{/if}}
+Disk: {{view.details.diskUsage}}% <br/>
CPU: {{view.details.cpuUsage}}%<br/>
Memory: {{view.details.memoryUsage}}%<br/>
-Network: {{view.details.networkUsage}}%<br/>
-I/O: {{view.details.ioUsage}}% \ No newline at end of file
diff --git a/ambari-web/app/views/main/charts/heatmap/heatmap_host_detail.js b/ambari-web/app/views/main/charts/heatmap/heatmap_host_detail.js
index 4337eeb929..d90f1d92b8 100644
--- a/ambari-web/app/views/main/charts/heatmap/heatmap_host_detail.js
+++ b/ambari-web/app/views/main/charts/heatmap/heatmap_host_detail.js
@@ -28,9 +28,8 @@ App.MainChartsHeatmapHostDetailView = Em.View.extend({
ip: '192.168.0.0',
metricName: 'metric-name',
metricValue: 'metric-value',
+ diskUsage: '10',
cpuUsage: '10',
- memoryUsage: '10',
- networkUsage: '30',
- ioUsage: '40'
+ memoryUsage: '10'
}
}); \ No newline at end of file