hive_job_details_view.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. var dateUtils = require('utils/date');
  21. App.MainHiveJobDetailsView = Em.View.extend({
  22. templateName : require('templates/main/jobs/hive_job_details'),
  23. selectedVertex : null,
  24. content : null,
  25. summaryMetricType: 'input',
  26. summaryMetricTypesDisplay : [ Em.I18n.t('jobs.hive.tez.metric.input'), Em.I18n.t('jobs.hive.tez.metric.output'), Em.I18n.t('jobs.hive.tez.metric.recordsRead'),
  27. Em.I18n.t('jobs.hive.tez.metric.recordsWrite'), Em.I18n.t('jobs.hive.tez.metric.tezTasks') ],
  28. summaryMetricTypeDisplay: function(){
  29. return Em.I18n.t('jobs.hive.tez.metric.'+this.get('summaryMetricType'));
  30. }.property('summaryMetricType'),
  31. sortedVertices : function() {
  32. var vertices = this.get('content.tezDag.vertices');
  33. if (vertices != null) {
  34. vertices = vertices.toArray();
  35. return vertices.sort(function(v1, v2) {
  36. return Ember.compare(v1.get('name'), v2.get('name'));
  37. });
  38. }
  39. return vertices;
  40. }.property('content.tezDag.vertices'),
  41. initialDataLoaded : function() {
  42. var loaded = this.get('controller.loaded');
  43. if (loaded) {
  44. this.set('content', this.get('controller.content'));
  45. }
  46. }.observes('controller.loaded'),
  47. jobObserver : function() {
  48. var content = this.get('content');
  49. var selectedVertex = this.get('selectedVertex');
  50. if (selectedVertex == null && content != null) {
  51. var vertices = content.get('tezDag.vertices');
  52. if (vertices) {
  53. vertices.setEach('isSelected', false);
  54. this.doSelectVertex({
  55. context : vertices.objectAt(0)
  56. });
  57. }
  58. }
  59. }.observes('selectedVertex', 'content.tezDag.vertices.@each.id'),
  60. doSelectVertex : function(event) {
  61. var newVertex = event.context;
  62. var currentVertex = this.get('selectedVertex');
  63. if (currentVertex != null) {
  64. currentVertex.set('isSelected', false);
  65. }
  66. newVertex.set('isSelected', true);
  67. this.set('selectedVertex', newVertex);
  68. },
  69. doSelectSummaryMetricType: function(event) {
  70. var summaryType = event.context;
  71. switch (summaryType) {
  72. case Em.I18n.t('jobs.hive.tez.metric.input'):
  73. summaryType = 'input';
  74. break;
  75. case Em.I18n.t('jobs.hive.tez.metric.output'):
  76. summaryType = 'output';
  77. break;
  78. case Em.I18n.t('jobs.hive.tez.metric.recordsRead'):
  79. summaryType = 'recordsRead';
  80. break;
  81. case Em.I18n.t('jobs.hive.tez.metric.recordsWrite'):
  82. summaryType = 'recordsWrite';
  83. break;
  84. case Em.I18n.t('jobs.hive.tez.metric.tezTasks'):
  85. summaryType = 'tezTasks';
  86. break;
  87. default:
  88. break;
  89. }
  90. this.set('summaryMetricType', summaryType);
  91. },
  92. /**
  93. * Provides display information for vertex I/O.
  94. *
  95. * {
  96. * 'file': {
  97. * 'read': {
  98. * 'ops': '100 reads',
  99. * 'bytes': '10 MB'
  100. * }
  101. * 'write: {
  102. * 'ops': '200 writes',
  103. * 'bytes': '20 MB'
  104. * }
  105. * },
  106. * 'hdfs': {
  107. * 'read': {
  108. * 'ops': '100 reads',
  109. * 'bytes': '10 MB'
  110. * }
  111. * 'write: {
  112. * 'ops': '200 writes',
  113. * 'bytes': '20 MB'
  114. * }
  115. * },
  116. * 'records': {
  117. * 'read': '100 records',
  118. * 'write': '123 records'
  119. * },
  120. * 'started': 'Feb 12, 2014 10:30am',
  121. * 'ended': 'Feb 12, 2014 10:35am'
  122. * }
  123. */
  124. selectedVertexIODisplay : function() {
  125. var v = this.get('selectedVertex');
  126. return {
  127. file : {
  128. read : {
  129. ops : Em.I18n.t('jobs.hive.tez.reads').format(v.get('fileReadOps')),
  130. bytes : numberUtils.bytesToSize(v.get('fileReadBytes'))
  131. },
  132. write : {
  133. ops : Em.I18n.t('jobs.hive.tez.writes').format(v.get('fileWriteOps')),
  134. bytes : numberUtils.bytesToSize(v.get('fileWriteBytes'))
  135. }
  136. },
  137. hdfs : {
  138. read : {
  139. ops : Em.I18n.t('jobs.hive.tez.reads').format(v.get('hdfsReadOps')),
  140. bytes : numberUtils.bytesToSize(v.get('hdfsReadBytes'))
  141. },
  142. write : {
  143. ops : Em.I18n.t('jobs.hive.tez.writes').format(v.get('hdfsWriteOps')),
  144. bytes : numberUtils.bytesToSize(v.get('hdfsWriteBytes'))
  145. }
  146. },
  147. records : {
  148. read : Em.I18n.t('jobs.hive.tez.records.count').format(v.get('recordReadCount')),
  149. write : Em.I18n.t('jobs.hive.tez.records.count').format(v.get('recordWriteCount')),
  150. },
  151. started: v.get('startTime') ? dateUtils.dateFormat(v.get('startTime')) : '',
  152. ended: v.get('endTime') ? dateUtils.dateFormat(v.get('endTime')) : ''
  153. };
  154. }.property('selectedVertex.fileReadOps', 'selectedVertex.fileWriteOps', 'selectedVertex.hdfsReadOps', 'selectedVertex.hdfdWriteOps',
  155. 'selectedVertex.fileReadBytes', 'selectedVertex.fileWriteBytes', 'selectedVertex.hdfsReadBytes', 'selectedVertex.hdfdWriteBytes',
  156. 'selectedVertex.recordReadCount', 'selectedVertes.recordWriteCount')
  157. });