123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- var App = require('app');
- var date = require('utils/date');
- var misc = require('utils/misc');
- App.Run = DS.Model.extend({
- runId:DS.attr('string'),
- parentRunId:DS.attr('string'),
- workflowId:DS.attr('string'),
- userName:DS.attr('string'),
- startTime:DS.attr('string'),
- elapsedTime:DS.attr('string'),
- appId:DS.attr('string'),
- /**
- *
- */
- /*workflowContext:function() {
- var r = '{dag: {';
- console.log('entries', this.get('entries'));
- this.get('entries').forEach(function(item) {
- r += '"' + item.source + '": [';
- item.targets.forEach(function(target) {
- r += '"' + target + '",';
- });
- r += '],';
- });
- r += '}}';
- console.log('dag', r);
- return r;
- }.property('entries'),*/
- workflowContext:DS.attr('string'),
- /**
- * Jobs in the current run
- */
- jobs: function() {
- var self = this;
- var r = Array();
- App.Job.find().forEach(function(job) {
- if (job.get('workflowId') == self.get('workflowId')) {
- r.push(job);
- }
- });
- return r;
- }.property('workflowId'),
- /**
- * Number of comleted jobs.
- * Field calculates dynamically using <code>jobs</code> property
- */
- numJobsCompleted: function() {
- return this.get('jobs').filterProperty('status', 'RUNNING').length;
- }.property('jobs.@each.status'),
- /**
- * Sum of the child jobs duration
- */
- duration: function() {
- var d = 0;
- this.get('jobs').forEach(function(job) {
- d += job.get('elapsedTime') / 1000 || 0;
- });
- return date.dateFormatInterval(parseInt(d));
- }.property('lastUpdateTime', 'startTime'),
- /**
- * Status of running jobs
- * Field calculates dynamically using <code>jobs</code> property
- */
- isRunning: function () {
- if (!this.get('isLoaded')) {
- return false;
- }
- return this.get('jobs').someProperty('status', 'RUNNING');
- }.property('jobs.@each.status'),
- /**
- * Sum of input bandwidth for all jobs
- * Field calculates dynamically using <code>jobs</code> property
- */
- input: function () {
- var sum = 0;
- this.get('jobs').forEach(
- function(item) {
- sum += item.get('input') || 0;
- });
- return sum;
- }.property('jobs.@each.input'),
- /**
- * Sum of input bandwidth for all jobs with appropriate measure
- * Field calculates dynamically using <code>jobs</code> property
- */
- inputFormatted: function () {
- var input = this.get('input');
- input = misc.formatBandwidth(input);
- return input;
- }.property('input'),
- /**
- * Sum of output bandwidth for all jobs
- * Field calculates dynamically using <code>jobs</code> property
- */
- output: function () {
- var sum = 0;
- this.get('jobs').forEach(
- function(item){
- sum += item.get('output') || 0;
- });
- return sum;
- }.property('jobs.@each.output'),
- /**
- * Sum of output bandwidth for all jobs with appropriate measure
- * Field calculates dynamically using <code>jobs</code> property
- */
- outputFormatted: function () {
- var output = this.get('output');
- output = misc.formatBandwidth(output);
- return output;
- }.property('output'),
- /**
- * Number of jobs on this run
- * Field calculates dynamically using <code>jobs</code> property
- */
- numJobsTotal: function() {
- return this.get('jobs').length;
- }.property('jobs'),
- /**
- *
- */
- lastUpdateTime: function() {
- return parseInt(this.get('startTime')) + parseInt(this.get('elapsedTime'));
- }.property('elapsedTime', 'startTime'),
- /**
- *
- */
- lastUpdateTimeFormatted: function() {
- return date.dateFormat(this.get('lastUpdateTime'));
- }.property('lastUpdateTime')
- });
- App.Run.FIXTURES = [
- /*{
- id:1,
- run_id:'pig_1',
- parent_run_id:null,
- workflow_context:'{dag: {"1":["2","3"],"2":["3","4"],"4":["2","5"]}}',
- user_name:'user3',
- start_time:1347539541501,
- last_update_time:'1347639541501',
- app_id:1,
- jobs:[1, 2, 3, 4, 5]
- },
- {
- id:2,
- run_id:'pig_3',
- parent_run_id:null,
- workflow_context:'{dag:{"4":["5","1"],"3":["6"],"6":["4"],"1":["5"]}}',
- user_name:'user1',
- start_time:1347339951502,
- last_update_time:'1347439951502',
- app_id:4,
- jobs:[4, 5, 1, 3, 6]
- },
- {
- id:3,
- run_id:'pig_5',
- parent_run_id:null,
- workflow_context:'{dag:{"6":["7","8"],"9":["8"],"10":["6"],"9":["7"]}}',
- user_name:'user2',
- start_time:1341539841503,
- last_update_time:'1341639841503',
- app_id:1,
- jobs:[6, 7, 8, 9, 10]
- },
- {
- id:4,
- run_id:'pig_5',
- parent_run_id:null,
- workflow_context:'{dag:{"8":["9","10"],"9":["10"]}}',
- user_name:'user1',
- start_time:1347539591504,
- last_update_time:'1347639591504',
- num_jobs_completed:0,
- app_id:2,
- jobs:[8, 9, 10]
- },
- {
- id:5,
- run_id:'pig_5',
- parent_run_id:null,
- workflow_context:'{dag:{"8":["9","10"],"8":["10","9"]}}',
- user_name:'user5',
- start_time:1347531541505,
- last_update_time:'1347631541505',
- app_id:2,
- jobs:[8, 9, 10]
- },
- {
- id:6,
- run_id:'pig_5',
- parent_run_id:null,
- workflow_context:'{dag:{"8":["9","10"],"9":["10","8"]}}',
- user_name:'user1',
- start_time:1342439541506,
- last_update_time:'1342639541506',
- app_id:2,
- jobs:[8, 9, 10]
- },
- {
- id:7,
- run_id:'pig_5',
- parent_run_id:null,
- workflow_context:'{dag:{"1":["3","5"],"5":["7"],"3":["1"]}}',
- user_name:'jsmith',
- start_time:1347539541507,
- last_update_time:'1347639541507',
- app_id:4,
- jobs:[1, 3, 5, 7]
- },
- {
- id:8,
- run_id:'pig_5',
- parent_run_id:null,
- workflow_context:'{dag:{"1":["3","5"],"5":["7"],"3":["1"]}}',
- user_name:'jsmith',
- start_time:1347539541508,
- last_update_time:'1347639541508',
- app_id:3,
- jobs:[1, 3, 5, 7]
- },
- {
- id:9,
- run_id:'pig_5',
- parent_run_id:null,
- workflow_context:'{dag:{"1":["3","5"],"5":["7"],"3":["1"]}}',
- user_name:'user1',
- start_time:1347539541509,
- last_update_time:'1347639541509',
- app_id:3,
- jobs:[1, 3, 5, 7]
- },
- {
- id:10,
- run_id:'pig_5',
- parent_run_id:null,
- workflow_context:'{dag:{"1":["3","5"],"5":["7"],"3":["1"]}}',
- user_name:'user1',
- start_time:1347539541510,
- last_update_time:'1347639541510',
- app_id:3,
- jobs:[1, 3, 5, 7]
- },
- {
- id:11,
- run_id:'pig_5',
- parent_run_id:null,
- workflow_context:'{dag:{"1":["3","5"],"5":["7"],"3":["1"]}}',
- user_name:'user1',
- start_time:1347539541511,
- last_update_time:'1347639541511',
- app_id:3,
- jobs:[1, 3, 5, 7]
- }*/
- ];
|