run.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.Run = DS.Model.extend({
  22. appName: DS.attr('string'),
  23. type: DS.attr('string'),
  24. userName:DS.attr('string'),
  25. numJobsTotal: DS.attr('number'),
  26. numJobsCompleted: DS.attr('number'),
  27. startTime:DS.attr('string'),
  28. elapsedTime:DS.attr('string'),
  29. workflowContext:DS.attr('string'),
  30. input: DS.attr('number'),
  31. output: DS.attr('number'),
  32. loadAllJobs : false,
  33. isStared: false,
  34. isFiltered: false,
  35. /**
  36. * runId short part
  37. */
  38. idFormatted: function() {
  39. return this.get('id').substr(0, 20);
  40. }.property('id'),
  41. /**
  42. * Jobs in the current run
  43. */
  44. jobs: function() {
  45. return App.Job.find().filterProperty('run.id', this.get('id'));
  46. }.property('loadAllJobs'),
  47. /**
  48. * Run duration
  49. */
  50. duration: function() {
  51. return date.timingFormat(parseInt(this.get('elapsedTime')));
  52. }.property('elapsedTime'),
  53. /**
  54. * Status of running jobs
  55. */
  56. isRunning: function () {
  57. return !this.get('numJobsTotal') == this.get('numJobsCompleted');
  58. }.property('numJobsTotal', 'numJobsCompleted'),
  59. /**
  60. * Sum of input bandwidth for all jobs with appropriate measure
  61. */
  62. inputFormatted: function () {
  63. var input = this.get('input');
  64. input = misc.formatBandwidth(input);
  65. return input;
  66. }.property('input'),
  67. /**
  68. * Sum of output bandwidth for all jobs with appropriate measure
  69. */
  70. outputFormatted: function () {
  71. var output = this.get('output');
  72. output = misc.formatBandwidth(output);
  73. return output;
  74. }.property('output'),
  75. /**
  76. *
  77. */
  78. lastUpdateTime: function() {
  79. return parseInt(this.get('startTime')) + parseInt(this.get('elapsedTime'));
  80. }.property('elapsedTime', 'startTime'),
  81. /**
  82. *
  83. */
  84. lastUpdateTimeFormatted: function() {
  85. return date.dateFormat(this.get('lastUpdateTime'));
  86. }.property('lastUpdateTime'),
  87. lastUpdateTimeFormattedShort: function(){
  88. return date.dateFormatShort(this.get('lastUpdateTime'));
  89. }.property('lastUpdateTime'),
  90. /**
  91. * Type value based on first part of id
  92. */
  93. type: function() {
  94. if (this.get('id').indexOf('pig_') === 0) {
  95. return 'Pig';
  96. }
  97. if (this.get('id').indexOf('hive_') === 0) {
  98. return 'Hive';
  99. }
  100. if (this.get('id').indexOf('mr_') === 0) {
  101. return 'MapReduce';
  102. }
  103. }.property('id')
  104. });
  105. App.Run.FIXTURES = [];