heatmap.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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.HBaseService.find().get('length')) {
  61. metrics.push(
  62. Em.Object.create({
  63. label: Em.I18n.t('charts.heatmap.category.hbase'),
  64. category: 'hbase',
  65. items: [
  66. App.MainChartHeatmapHbaseReadReqCount.create(),
  67. App.MainChartHeatmapHbaseWriteReqCount.create(),
  68. App.MainChartHeatmapHbaseCompactionQueueSize.create(),
  69. App.MainChartHeatmapHbaseRegions.create(),
  70. App.MainChartHeatmapHbaseMemStoreSize.create()
  71. ]
  72. })
  73. );
  74. }
  75. return metrics;
  76. }.property(),
  77. selectedMetric: null,
  78. /**
  79. * route on host detail page
  80. * @param event
  81. */
  82. routeHostDetail: function (event) {
  83. App.router.transitionTo('main.hosts.hostDetails.summary', event.context)
  84. },
  85. showHeatMapMetric: function (event) {
  86. var metricItem = event.context;
  87. if (metricItem) {
  88. this.set('selectedMetric', metricItem);
  89. }
  90. },
  91. hostToSlotMap: function () {
  92. return this.get('selectedMetric.hostToSlotMap');
  93. }.property('selectedMetric.hostToSlotMap'),
  94. loadMetrics: function () {
  95. var selectedMetric = this.get('selectedMetric');
  96. if (selectedMetric) {
  97. selectedMetric.refreshHostSlots();
  98. }
  99. }.observes('selectedMetric'),
  100. /**
  101. * return class name for to be used for containing each rack.
  102. *
  103. * @this App.MainChartsHeatmapController
  104. */
  105. rackClass: function () {
  106. var rackCount = this.get('cluster.racks.length');
  107. if (rackCount < 2) {
  108. return "span12";
  109. } else if (rackCount == 2) {
  110. return "span6";
  111. } else {
  112. return "span4";
  113. }
  114. }.property('cluster')
  115. });