run.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. /**
  34. * Jobs in the current run
  35. */
  36. jobs: function() {
  37. return App.Job.find().filterProperty('run.id', this.get('id'));
  38. }.property('loadAllJobs'),
  39. /**
  40. * Run duration
  41. */
  42. duration: function() {
  43. var d = this.get('elapsedTime') / 1000 || 0;
  44. return date.dateFormatInterval(parseInt(d));
  45. }.property('elapsedTime'),
  46. /**
  47. * Status of running jobs
  48. */
  49. isRunning: function () {
  50. return !this.get('numJobsTotal') == this.get('numJobsCompleted');
  51. }.property('numJobsTotal', 'numJobsCompleted'),
  52. /**
  53. * Sum of input bandwidth for all jobs with appropriate measure
  54. */
  55. inputFormatted: function () {
  56. var input = this.get('input');
  57. input = misc.formatBandwidth(input);
  58. return input;
  59. }.property('input'),
  60. /**
  61. * Sum of output bandwidth for all jobs with appropriate measure
  62. */
  63. outputFormatted: function () {
  64. var output = this.get('output');
  65. output = misc.formatBandwidth(output);
  66. return output;
  67. }.property('output'),
  68. /**
  69. *
  70. */
  71. lastUpdateTime: function() {
  72. return parseInt(this.get('startTime')) + parseInt(this.get('elapsedTime'));
  73. }.property('elapsedTime', 'startTime'),
  74. /**
  75. *
  76. */
  77. lastUpdateTimeFormatted: function() {
  78. return date.dateFormat(this.get('lastUpdateTime'));
  79. }.property('lastUpdateTime'),
  80. /**
  81. * Type value based on first part of id
  82. */
  83. type: function() {
  84. if (this.get('id').indexOf('pig_') === 0) {
  85. return 'Pig';
  86. }
  87. if (this.get('id').indexOf('hive_') === 0) {
  88. return 'Hive';
  89. }
  90. if (this.get('id').indexOf('mr_') === 0) {
  91. return 'mapReduce';
  92. }
  93. }.property('id')
  94. });
  95. App.Run.FIXTURES = [];