mapreduce.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.MainDashboardServiceMapreduceView = App.MainDashboardServiceView.extend({
  19. templateName: require('templates/main/dashboard/service/mapreduce'),
  20. serviceName: 'MAPREDUCE',
  21. jobTrackerWebUrl: function () {
  22. return "http://" + this.get('service').get('jobTracker').get('publicHostName') + ":50030";
  23. }.property('service.nameNode'),
  24. Chart: App.ChartLinearView.extend({
  25. data: function () {
  26. return this.get('_parentView.data.chart');
  27. }.property('_parentView.data.chart')
  28. }),
  29. jobTrackerUptime: function () {
  30. var uptime = this.get('service').get('jobTrackerStartTime');
  31. var formatted = (new Date().getTime() - uptime).toDaysHoursMinutes();
  32. return this.t('dashboard.services.uptime').format(formatted.d, formatted.h, formatted.m);
  33. }.property("service.jobTrackerStartTime"),
  34. summaryHeader: function () {
  35. var svc = this.get('service');
  36. var liveCount = svc.get('aliveTrackers').get('length');
  37. var allCount = svc.get('taskTrackers').get('length');
  38. var runningCount = svc.get('mapsRunning') + svc.get('reducesRunning');
  39. var waitingCount = svc.get('mapsWaiting') + svc.get('reducesWaiting');
  40. var template = this.t('dashboard.services.mapreduce.summary');
  41. return template.format(liveCount, allCount, runningCount, waitingCount);
  42. }.property('service.aliveTrackers', 'service.taskTrackers','service.mapsRunning', 'service.mapsWaiting', 'service.reducesRunning', 'service.reducesWaiting'),
  43. trackersSummary: function () {
  44. var svc = this.get('service');
  45. var liveCount = svc.get('aliveTrackers').get('length');
  46. var totalCount = svc.get('taskTrackers').get('length');
  47. var template = this.t('dashboard.services.mapreduce.trackersSummary');
  48. return template.format(liveCount, totalCount);
  49. }.property('service.aliveTrackers', 'service.taskTrackers'),
  50. trackersHeapSummary: function () {
  51. var heapUsed = this.get('service').get('jobTrackerHeapUsed') || 90;
  52. var heapMax = this.get('service').get('jobTrackerHeapMax') || 90;
  53. var percent = heapMax > 0 ? 100 * heapUsed / heapMax : 0;
  54. return this.t('dashboard.services.mapreduce.jobTrackerHeapSummary').format(heapUsed.bytesToSize(1, "parseFloat"), heapMax.bytesToSize(1, "parseFloat"), percent.toFixed(1));
  55. }.property('service.jobTrackerHeapUsed', 'service.jobTrackerHeapMax'),
  56. jobsSummary: function () {
  57. var svc = this.get('service');
  58. var template = this.t('dashboard.services.mapreduce.jobsSummary');
  59. return template.format(svc.get('jobsSubmitted'), svc.get('jobsCompleted'));
  60. }.property('service.jobsSubmitted', 'service.jobsCompleted'),
  61. mapSlotsSummary: function () {
  62. var svc = this.get('service');
  63. var template = this.t('dashboard.services.mapreduce.mapSlotsSummary');
  64. return template.format(svc.get('mapSlotsOccupied'), svc.get('mapSlotsReserved'));
  65. }.property('service.mapSlotsOccupied', 'service.mapSlotsReserved'),
  66. reduceSlotsSummary: function () {
  67. var svc = this.get('service');
  68. var template = this.t('dashboard.services.mapreduce.reduceSlotsSummary');
  69. return template.format(svc.get('reduceSlotsOccupied'), svc.get('reduceSlotsReserved'));
  70. }.property('service.reduceSlotsOccupied', 'service.reduceSlotsReserved'),
  71. mapTasksSummary: function () {
  72. var svc = this.get('service');
  73. var template = this.t('dashboard.services.mapreduce.tasksSummary');
  74. return template.format(svc.get('mapsRunning'), svc.get('mapsWaiting'));
  75. }.property('service.mapsRunning', 'service.mapsWaiting'),
  76. reduceTasksSummary: function () {
  77. var svc = this.get('service');
  78. var template = this.t('dashboard.services.mapreduce.tasksSummary');
  79. return template.format(svc.get('reducesRunning'), svc.get('reducesWaiting'));
  80. }.property('service.reducesRunning', 'service.reducesWaiting'),
  81. slotsCapacitySummary: function () {
  82. var mapSlots = this.get('service').get('mapSlots');
  83. var reduceSlots = this.get('service').get('reduceSlots');
  84. var liveNodeCount = this.get('service').get('aliveTrackers').get('length');
  85. if(liveNodeCount != 0){
  86. var avg = (mapSlots + reduceSlots) / liveNodeCount;
  87. }else{
  88. avg = "n/a ";
  89. }
  90. return this.t('dashboard.services.mapreduce.slotCapacitySummary').format(mapSlots, reduceSlots, avg);
  91. }.property('service.mapSlots', 'service.reduceSlots', 'service.aliveTrackers'),
  92. taskTrackerComponent: function () {
  93. return App.Component.find().findProperty('componentName', 'TASKTRACKER');
  94. }.property('components'),
  95. toggleInfoView: function() {
  96. $('#mapreduce-info').toggle('blind', 200);
  97. }
  98. });