run.js 3.1 KB

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