heatmap.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with this
  4. * work for additional information regarding copyright ownership. The ASF
  5. * licenses this file to you under the Apache License, Version 2.0 (the
  6. * "License"); you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. var App = require('app');
  18. App.MainChartsHeatmapController = Em.Controller.extend({
  19. name: 'mainChartsHeatmapController',
  20. cluster: App.Cluster.find(1),
  21. allMetrics: [
  22. Em.Object.create({
  23. label: Em.I18n.t('charts.heatmap.category.host'),
  24. category: 'host',
  25. items: [ App.MainChartHeatmapDiskSpaceUsedMetric.create(),
  26. App.MainChartHeatmapMemoryUsedMetric.create()
  27. /*, App.MainChartHeatmapProcessRunMetric.create()*/ ]
  28. }),
  29. Em.Object.create({
  30. label: Em.I18n.t('charts.heatmap.category.hdfs'),
  31. category: 'hdfs',
  32. items: [ App.MainChartHeatmapDFSBytesReadMetric.create(),
  33. App.MainChartHeatmapDFSBytesWrittenMetric.create(),
  34. App.MainChartHeatmapDFSGCTimeMillisMetric.create(),
  35. App.MainChartHeatmapDFSMemHeapUsedMetric.create() ]
  36. }),
  37. Em.Object.create({
  38. label: Em.I18n.t('charts.heatmap.category.mapreduce'),
  39. category: 'mapreduce',
  40. items: [ App.MainChartHeatmapMapreduceMapsRunningMetric.create(),
  41. App.MainChartHeatmapMapreduceReducesRunningMetric.create(),
  42. App.MainChartHeatmapMapreduceGCTimeMillisMetric.create(),
  43. App.MainChartHeatmapMapreduceMemHeapUsedMetric.create() ]
  44. })
  45. ],
  46. selectedMetric: null,
  47. /**
  48. * route on host detail page
  49. * @param event
  50. */
  51. routeHostDetail: function(event){
  52. App.router.transitionTo('main.hosts.hostDetails.summary', event.context)
  53. },
  54. showHeatMapMetric: function (event) {
  55. var metricItem = event.context;
  56. if (metricItem) {
  57. this.set('selectedMetric', metricItem);
  58. }
  59. },
  60. hostToSlotMap: function () {
  61. return this.get('selectedMetric.hostToSlotMap');
  62. }.property('selectedMetric.hostToSlotMap'),
  63. loadMetrics: function () {
  64. var selectedMetric = this.get('selectedMetric');
  65. if (selectedMetric) {
  66. selectedMetric.refreshHostSlots();
  67. }
  68. }.observes('selectedMetric'),
  69. /**
  70. * return class name for to be used for containing each rack.
  71. *
  72. * @this App.MainChartsHeatmapController
  73. */
  74. rackClass: function () {
  75. var rackCount = this.get('cluster.racks.length');
  76. if (rackCount < 2) {
  77. return "span12";
  78. } else if (rackCount == 2) {
  79. return "span6";
  80. } else {
  81. return "span4";
  82. }
  83. }.property('cluster')
  84. });