mapreduce.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. var date = require('utils/date');
  19. var numberUtils = require('utils/number_utils');
  20. App.MainDashboardServiceMapreduceView = App.MainDashboardServiceView.extend({
  21. templateName: require('templates/main/dashboard/service/mapreduce'),
  22. serviceName: 'MAPREDUCE',
  23. jobTrackerWebUrl: function () {
  24. return "http://" + (App.singleNodeInstall ? App.singleNodeAlias : this.get('service').get('jobTracker').get('publicHostName')) + ":50030";
  25. }.property('service.jobTracker'),
  26. Chart: App.ChartLinearView.extend({
  27. data: function () {
  28. return this.get('_parentView.data.chart');
  29. }.property('_parentView.data.chart')
  30. }),
  31. jobTrackerUptime: function () {
  32. var uptime = this.get('service').get('jobTrackerStartTime');
  33. if (uptime && uptime > 0){
  34. var diff = (new Date()).getTime() - uptime;
  35. if (diff < 0) {
  36. diff = 0;
  37. }
  38. var formatted = date.timingFormat(diff);
  39. return this.t('dashboard.services.uptime').format(formatted);
  40. }
  41. return this.t('services.service.summary.notRunning');
  42. }.property("service.jobTrackerStartTime"),
  43. summaryHeader: function () {
  44. var svc = this.get('service');
  45. var liveCount = svc.get('aliveTrackers').get('length');
  46. var allCount = svc.get('taskTrackers').get('length');
  47. var runningCount = svc.get('jobsRunning');
  48. if (runningCount === null) {
  49. runningCount = 'n/a';
  50. }
  51. var template = this.t('dashboard.services.mapreduce.summary');
  52. return template.format(liveCount, allCount, runningCount);
  53. }.property('service.aliveTrackers', 'service.taskTrackers', 'service.jobsRunning'),
  54. trackersText: function () {
  55. if(this.get('service').get('taskTrackers').get('length') > 1){
  56. return Em.I18n.t('services.service.summary.viewHosts');
  57. }else{
  58. return Em.I18n.t('services.service.summary.viewHost');
  59. }
  60. }.property("service.taskTrackers.length"),
  61. trackersSummary: function () {
  62. var svc = this.get('service');
  63. var liveCount = App.HostComponent.find().filterProperty('componentName', 'TASKTRACKER').filterProperty("workStatus","STARTED").length;
  64. var totalCount = svc.get('taskTrackers').get('length');
  65. var template = this.t('dashboard.services.mapreduce.trackersSummary');
  66. return template.format(liveCount, totalCount);
  67. }.property('service.aliveTrackers.length', 'service.taskTrackers.length'),
  68. trackersLiveTextView: App.ComponentLiveTextView.extend({
  69. liveComponents: function() {
  70. return App.HostComponent.find().filterProperty('componentName', 'TASKTRACKER').filterProperty("workStatus","STARTED").get("length");
  71. }.property("service.hostComponents.@each", "service.aliveTrackers.length"),
  72. totalComponents: function() {
  73. return this.get("service.taskTrackers.length");
  74. }.property('service.taskTrackers.length')
  75. }),
  76. trackersHeapSummary: function () {
  77. var heapUsed = this.get('service').get('jobTrackerHeapUsed');
  78. var heapMax = this.get('service').get('jobTrackerHeapMax');
  79. var percent = heapMax > 0 ? 100 * heapUsed / heapMax : 0;
  80. return this.t('dashboard.services.mapreduce.jobTrackerHeapSummary').format(numberUtils.bytesToSize(heapUsed, 1, "parseFloat"), numberUtils.bytesToSize(heapMax, 1, "parseFloat"), percent.toFixed(1));
  81. }.property('service.jobTrackerHeapUsed', 'service.jobTrackerHeapMax'),
  82. jobsSummary: function () {
  83. var svc = this.get('service');
  84. var template = this.t('dashboard.services.mapreduce.jobsSummary');
  85. return template.format(this.formatUnavailable(svc.get('jobsSubmitted')), this.formatUnavailable(svc.get('jobsCompleted')));
  86. }.property('service.jobsSubmitted', 'service.jobsCompleted'),
  87. mapSlotsSummary: function () {
  88. var svc = this.get('service');
  89. var template = this.t('dashboard.services.mapreduce.mapSlotsSummary');
  90. return template.format(this.formatUnavailable(svc.get('mapSlotsOccupied')), this.formatUnavailable(svc.get('mapSlotsReserved')));
  91. }.property('service.mapSlotsOccupied', 'service.mapSlotsReserved'),
  92. reduceSlotsSummary: function () {
  93. var svc = this.get('service');
  94. var template = this.t('dashboard.services.mapreduce.reduceSlotsSummary');
  95. return template.format(this.formatUnavailable(svc.get('reduceSlotsOccupied')), this.formatUnavailable(svc.get('reduceSlotsReserved')));
  96. }.property('service.reduceSlotsOccupied', 'service.reduceSlotsReserved'),
  97. mapTasksSummary: function () {
  98. var svc = this.get('service');
  99. var template = this.t('dashboard.services.mapreduce.tasksSummary');
  100. return template.format(this.formatUnavailable(svc.get('mapsRunning')), this.formatUnavailable(svc.get('mapsWaiting')));
  101. }.property('service.mapsRunning', 'service.mapsWaiting'),
  102. reduceTasksSummary: function () {
  103. var svc = this.get('service');
  104. var template = this.t('dashboard.services.mapreduce.tasksSummary');
  105. return template.format(this.formatUnavailable(svc.get('reducesRunning')), this.formatUnavailable(svc.get('reducesWaiting')));
  106. }.property('service.reducesRunning', 'service.reducesWaiting'),
  107. slotsCapacitySummary: function () {
  108. var mapSlots = this.get('service').get('mapSlots');
  109. var reduceSlots = this.get('service').get('reduceSlots');
  110. var liveNodeCount = this.get('service').get('aliveTrackers').get('length');
  111. if(liveNodeCount != 0){
  112. var avg = (mapSlots + reduceSlots) / liveNodeCount;
  113. }else{
  114. avg = Em.I18n.t('services.service.summary.notAvailable') + " ";
  115. }
  116. return this.t('dashboard.services.mapreduce.slotCapacitySummary').format(mapSlots, reduceSlots, avg);
  117. }.property('service.mapSlots', 'service.reduceSlots', 'service.aliveTrackers'),
  118. taskTrackerComponent: function () {
  119. return App.HostComponent.find().findProperty('componentName', 'TASKTRACKER');
  120. }.property()
  121. });