2017-12-15 21:39:18 +00:00
|
|
|
import { computed } from '@ember/object';
|
2017-09-19 14:47:10 +00:00
|
|
|
import Fragment from 'ember-data-model-fragments/fragment';
|
|
|
|
import attr from 'ember-data/attr';
|
2020-06-17 07:16:12 +00:00
|
|
|
import { fragmentOwner, fragmentArray, fragment } from 'ember-data-model-fragments/attributes';
|
2017-09-19 14:47:10 +00:00
|
|
|
import sumAggregation from '../utils/properties/sum-aggregation';
|
2020-06-10 13:49:16 +00:00
|
|
|
import classic from 'ember-classic-decorator';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2018-02-08 23:02:48 +00:00
|
|
|
const maybe = arr => arr || [];
|
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@classic
|
|
|
|
export default class TaskGroup extends Fragment {
|
|
|
|
@fragmentOwner() job;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@attr('string') name;
|
|
|
|
@attr('number') count;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@fragmentArray('task') tasks;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@fragmentArray('service') services;
|
2019-09-04 14:39:56 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@fragmentArray('volume-definition') volumes;
|
2020-02-11 00:19:28 +00:00
|
|
|
|
2020-06-17 07:16:12 +00:00
|
|
|
@fragment('group-scaling') scaling;
|
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('tasks.@each.driver')
|
|
|
|
get drivers() {
|
2019-09-04 14:39:56 +00:00
|
|
|
return this.tasks.mapBy('driver').uniq();
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-05-10 00:04:45 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('job.allocations.@each.taskGroup')
|
|
|
|
get allocations() {
|
2019-03-26 07:46:44 +00:00
|
|
|
return maybe(this.get('job.allocations')).filterBy('taskGroupName', this.name);
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@sumAggregation('tasks', 'reservedCPU') reservedCPU;
|
|
|
|
@sumAggregation('tasks', 'reservedMemory') reservedMemory;
|
|
|
|
@sumAggregation('tasks', 'reservedDisk') reservedDisk;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@attr('number') reservedEphemeralDisk;
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('job.latestFailureEvaluation.failedTGAllocs.[]')
|
|
|
|
get placementFailures() {
|
2017-11-29 01:23:30 +00:00
|
|
|
const placementFailures = this.get('job.latestFailureEvaluation.failedTGAllocs');
|
2019-03-26 07:46:44 +00:00
|
|
|
return placementFailures && placementFailures.findBy('name', this.name);
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2017-11-29 01:23:30 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('summary.{queuedAllocs,startingAllocs}')
|
|
|
|
get queuedOrStartingAllocs() {
|
2017-09-19 14:47:10 +00:00
|
|
|
return this.get('summary.queuedAllocs') + this.get('summary.startingAllocs');
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@computed('job.taskGroupSummaries.[]')
|
|
|
|
get summary() {
|
2019-03-26 07:46:44 +00:00
|
|
|
return maybe(this.get('job.taskGroupSummaries')).findBy('name', this.name);
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
|
|
|
}
|