summary.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. App.MainServiceInfoSummaryView = Em.View.extend({
  20. templateName: require('templates/main/service/info/summary'),
  21. attributes: null,
  22. serviceStatus: {
  23. hdfs: false,
  24. mapreduce: false,
  25. hbase: false
  26. },
  27. alerts: function(){
  28. var serviceId = this.get('service.id');
  29. if(serviceId) {
  30. return App.Alert.find({'service_id':serviceId });
  31. }
  32. return [];
  33. // return App.router.get('mainServiceInfoSummaryController.content.alerts');
  34. }.property('App.router.mainServiceInfoSummaryController.content.alerts'),
  35. controller: function(){
  36. return App.router.get('mainServiceInfoSummaryController');
  37. }.property(),
  38. service: function(){
  39. return this.get('controller.content');
  40. }.property('controller.content'),
  41. isHide: true,
  42. moreStatsView: Em.View.extend({
  43. tagName: "a",
  44. template: Ember.Handlebars.compile('{{t services.service.summary.moreStats}}'),
  45. attributeBindings: ['href'],
  46. classNames: ['more-stats'],
  47. click: function(event) {
  48. this._parentView._parentView.set('isHide', false);
  49. this.remove();
  50. },
  51. href: 'javascript:void(null)'
  52. }),
  53. serviceName: function() {
  54. return App.router.mainServiceInfoSummaryController.get('content.serviceName');
  55. }.property('App.router.mainServiceInfoSummaryController.content'),
  56. init: function() {
  57. this._super();
  58. if (this.get('serviceName'))
  59. this.loadServiceSummary(this.get('serviceName'));
  60. },
  61. loadServiceSummary: function(serviceName) {
  62. var summaryView = this;
  63. var serviceStatus = summaryView.get('serviceStatus');
  64. $.each(serviceStatus, function(key, value) {
  65. if (key == serviceName) {
  66. summaryView.set('serviceStatus.' + key, true);
  67. } else {
  68. summaryView.set('serviceStatus.' + key, false);
  69. }
  70. });
  71. jQuery.getJSON('data/services/summary/' + serviceName + '.json',
  72. function (data) {
  73. if (data[serviceName]) {
  74. var summary = data[serviceName];
  75. if(serviceName == 'hdfs') {
  76. summary['start_time'] = summary['start_time'].toDaysHoursMinutes();
  77. summary['memory_heap_percent_used'] = summary['memory_heap_used'].countPercentageRatio(summary['memory_heap_max']);
  78. summary['memory_heap_used'] = summary['memory_heap_used'].bytesToSize(2, 'parseFloat');
  79. summary['memory_heap_max'] = summary['memory_heap_max'].bytesToSize(2, 'parseFloat');
  80. summary['dfs_percent_disk_used'] = parseFloat((100 - summary['dfs_percent_remaining']).toFixed(2)) + "%";
  81. summary['used_bytes'] = (summary['dfs_used_bytes'] + summary['nondfs_used_bytes']).bytesToSize(2, 'parseFloat');
  82. summary['dfs_total_bytes'] = summary['dfs_total_bytes'].bytesToSize(2, 'parseFloat');
  83. summary['metricGraphViews'] = [App.ChartServiceMetricsHDFS_JVMThreads.extend(),
  84. App.ChartServiceMetricsHDFS_JVMHeap.extend(),
  85. App.ChartServiceMetricsHDFS_IO.extend(),
  86. App.ChartServiceMetricsHDFS_RPC.extend(),
  87. App.ChartServiceMetricsHDFS_FileOperations.extend(),
  88. App.ChartServiceMetricsHDFS_GC.extend()];
  89. } else if (serviceName == 'mapreduce') {
  90. summary['start_time'] = summary['start_time'].toDaysHoursMinutes();
  91. summary['memory_heap_percent_used'] = summary['memory_heap_used'].countPercentageRatio(summary['memory_heap_max']);
  92. summary['memory_heap_used'] = summary['memory_heap_used'].bytesToSize(2, 'parseFloat');
  93. summary['memory_heap_max'] = summary['memory_heap_max'].bytesToSize(2, 'parseFloat');
  94. summary['metricGraphViews'] = [App.ChartServiceMetricsMapReduce_JobsStatus.extend(),
  95. App.ChartServiceMetricsMapReduce_JobsRunningWaiting.extend(),
  96. App.ChartServiceMetricsMapReduce_MapSlots.extend(),
  97. App.ChartServiceMetricsMapReduce_ReduceSlots.extend(),
  98. App.ChartServiceMetricsMapReduce_JVMHeap.extend(),
  99. App.ChartServiceMetricsMapReduce_JVMThreads.extend(),
  100. App.ChartServiceMetricsMapReduce_GC.extend(),
  101. App.ChartServiceMetricsMapReduce_RPC.extend()];
  102. } else if (serviceName == 'hbase') {
  103. summary['memory_heap_percent_used'] = summary['memory_heap_used'].countPercentageRatio(summary['memory_heap_max']);
  104. summary['memory_heap_used'] = summary['memory_heap_used'].bytesToSize(2, 'parseFloat');
  105. summary['memory_heap_max'] = summary['memory_heap_max'].bytesToSize(2, 'parseFloat');
  106. summary['start_time'] = summary['start_time'].toDaysHoursMinutes();
  107. summary['active_time'] = summary['active_time'].toDaysHoursMinutes();
  108. }
  109. summaryView.set('attributes', summary);
  110. }
  111. }
  112. )
  113. }
  114. });