run_class.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. var date = require('utils/date');
  20. var misc = require('utils/misc');
  21. App.Run2 = Ember.Object.extend({
  22. id: null, //string
  23. appName: null, //string
  24. userName: null, //string
  25. numJobsTotal: 0, //number
  26. numJobsCompleted: 0, //number
  27. startTime: 0, //number
  28. elapsedTime: 0, //number
  29. workflowContext: null, //string
  30. input: 0, //number
  31. output: 0, //number
  32. /**
  33. * Will set to true when we load all jobs related to this run
  34. */
  35. loadAllJobs : false,
  36. /**
  37. * runId short part
  38. */
  39. idFormatted: function() {
  40. return this.get('id').substr(0, 20);
  41. }.property('id'),
  42. /**
  43. * Run duration
  44. */
  45. duration: function() {
  46. return date.timingFormat(this.get('elapsedTime'));
  47. }.property('elapsedTime'),
  48. /**
  49. * Status of running jobs
  50. */
  51. isRunning: function () {
  52. return !this.get('numJobsTotal') == this.get('numJobsCompleted');
  53. }.property('numJobsTotal', 'numJobsCompleted'),
  54. /**
  55. * Sum of input bandwidth for all jobs with appropriate measure
  56. */
  57. inputFormatted: function () {
  58. return misc.formatBandwidth(this.get('input'));
  59. }.property('input'),
  60. /**
  61. * Sum of output bandwidth for all jobs with appropriate measure
  62. */
  63. outputFormatted: function () {
  64. return misc.formatBandwidth(this.get('output'));
  65. }.property('output'),
  66. lastUpdateTime: function() {
  67. return this.get('startTime') + this.get('elapsedTime');
  68. }.property('elapsedTime', 'startTime'),
  69. lastUpdateTimeFormatted: function() {
  70. return date.dateFormat(this.get('lastUpdateTime'));
  71. }.property('lastUpdateTime'),
  72. lastUpdateTimeFormattedShort: function(){
  73. return date.dateFormatShort(this.get('lastUpdateTime'));
  74. }.property('lastUpdateTime'),
  75. /**
  76. * Type value based on first part of id
  77. */
  78. type: function() {
  79. if (this.get('id').indexOf('pig_') === 0) {
  80. return 'Pig';
  81. }
  82. if (this.get('id').indexOf('hive_') === 0) {
  83. return 'Hive';
  84. }
  85. if (this.get('id').indexOf('mr_') === 0) {
  86. return 'MapReduce';
  87. }
  88. return 'Undefined';
  89. }.property('id')
  90. });