heatmap.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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: function () {
  21. return App.Cluster.find().objectAt(0);
  22. }.property(''),
  23. allMetrics: function () {
  24. var metrics = [
  25. Em.Object.create({
  26. label: Em.I18n.t('charts.heatmap.category.host'),
  27. category: 'host',
  28. items: [
  29. App.MainChartHeatmapDiskSpaceUsedMetric.create(),
  30. App.MainChartHeatmapMemoryUsedMetric.create(),
  31. App.MainChartHeatmapCpuWaitIOMetric.create()
  32. /*, App.MainChartHeatmapProcessRunMetric.create()*/
  33. ]
  34. }),
  35. Em.Object.create({
  36. label: Em.I18n.t('charts.heatmap.category.hdfs'),
  37. category: 'hdfs',
  38. items: [
  39. App.MainChartHeatmapDFSBytesReadMetric.create(),
  40. App.MainChartHeatmapDFSBytesWrittenMetric.create(),
  41. App.MainChartHeatmapDFSGCTimeMillisMetric.create(),
  42. App.MainChartHeatmapDFSMemHeapUsedMetric.create()
  43. ]
  44. })
  45. ];
  46. if (App.MapReduceService.find().get('length')) {
  47. metrics.push(
  48. Em.Object.create({
  49. label: Em.I18n.t('charts.heatmap.category.mapreduce'),
  50. category: 'mapreduce',
  51. items: [
  52. App.MainChartHeatmapMapreduceMapsRunningMetric.create(),
  53. App.MainChartHeatmapMapreduceReducesRunningMetric.create(),
  54. App.MainChartHeatmapMapreduceGCTimeMillisMetric.create(),
  55. App.MainChartHeatmapMapreduceMemHeapUsedMetric.create()
  56. ]
  57. })
  58. );
  59. }
  60. if (App.YARNService.find().get('length')) {
  61. metrics.push(
  62. Em.Object.create({
  63. label: Em.I18n.t('charts.heatmap.category.yarn'),
  64. category: 'yarn',
  65. items: [
  66. App.MainChartHeatmapYarnGCTimeMillisMetric.create(),
  67. App.MainChartHeatmapYarnMemHeapUsedMetric.create(),
  68. App.MainChartHeatmapYarnResourceUsedMetric.create()
  69. ]
  70. })
  71. );
  72. }
  73. if (App.HBaseService.find().get('length')) {
  74. metrics.push(
  75. Em.Object.create({
  76. label: Em.I18n.t('charts.heatmap.category.hbase'),
  77. category: 'hbase',
  78. items: [
  79. App.MainChartHeatmapHbaseReadReqCount.create(),
  80. App.MainChartHeatmapHbaseWriteReqCount.create(),
  81. App.MainChartHeatmapHbaseCompactionQueueSize.create(),
  82. App.MainChartHeatmapHbaseRegions.create(),
  83. App.MainChartHeatmapHbaseMemStoreSize.create()
  84. ]
  85. })
  86. );
  87. }
  88. return metrics;
  89. }.property(),
  90. selectedMetric: null,
  91. inputMaximum: '',
  92. validation: function () {
  93. if (this.get('selectedMetric')) {
  94. if (/^\d+$/.test(this.get('inputMaximum'))) {
  95. $('#inputMaximum').removeClass('error');
  96. this.set('selectedMetric.maximumValue', this.get('inputMaximum'));
  97. } else {
  98. $('#inputMaximum').addClass('error');
  99. }
  100. }
  101. }.observes('inputMaximum'),
  102. showHeatMapMetric: function (event) {
  103. var metricItem = event.context;
  104. if (metricItem) {
  105. this.set('selectedMetric', metricItem);
  106. }
  107. },
  108. hostToSlotMap: function () {
  109. return this.get('selectedMetric.hostToSlotMap');
  110. }.property('selectedMetric.hostToSlotMap'),
  111. loadMetrics: function () {
  112. var selectedMetric = this.get('selectedMetric');
  113. if (selectedMetric) {
  114. selectedMetric.refreshHostSlots();
  115. }
  116. this.set('inputMaximum', this.get('selectedMetric.maximumValue'));
  117. }.observes('selectedMetric'),
  118. /**
  119. * return class name for to be used for containing each rack.
  120. *
  121. * @this App.MainChartsHeatmapController
  122. */
  123. rackClass: function () {
  124. var rackCount = this.get('cluster.racks.length');
  125. if (rackCount < 2) {
  126. return "span12";
  127. } else if (rackCount == 2) {
  128. return "span6";
  129. } else {
  130. return "span4";
  131. }
  132. }.property('cluster')
  133. });