dataset.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. App.Dataset = DS.Model.extend({
  20. id: DS.attr('string'),
  21. name: DS.attr('string'),
  22. status: DS.attr('string'),
  23. sourceClusterName: DS.attr('string'),
  24. targetCluster: DS.belongsTo('App.TargetCluster'),
  25. sourceDir: DS.attr('string'),
  26. targetDir: DS.attr('string'),
  27. schedule: DS.belongsTo('App.Dataset.Schedule'),
  28. lastSucceededDate: DS.attr('number'),
  29. lastFailedDate: DS.attr('number'),
  30. lastDuration: DS.attr('number'),
  31. avgData: DS.attr('string'),
  32. createdDate: DS.attr('string'),
  33. datasetJobs: DS.hasMany('App.DataSetJob'),
  34. //Next instance to run. Will be calculated later.
  35. nextInstance: function () {
  36. return '';
  37. }.property(),
  38. //Name of target cluster related to dataset
  39. cluster: function () {
  40. return this.get('targetCluster.clusterName');
  41. }.property('targetCluster.clusterName'),
  42. //Class name for dataset health status indicator
  43. healthClass: function () {
  44. var jobs = this.get('datasetJobs').toArray();
  45. jobs = jobs.filterProperty('status', 'FAILED').concat(jobs.filterProperty('status', 'SUCCESSFUL'));
  46. jobs.sort(function (a, b) {
  47. return a.get('endDate') - b.get('endDate');
  48. });
  49. return jobs.length && jobs[0].get('status') === 'FAILED' ? 'health-status-DEAD-RED' : 'health-status-LIVE';
  50. }.property('datasetJobs', 'datasetJobs.@each.status')
  51. });
  52. App.Dataset.Schedule = DS.Model.extend({
  53. id: DS.attr('string'),
  54. startDate: DS.attr('string'),
  55. endDate: DS.attr('string'),
  56. startTime: DS.attr('string'),
  57. endTime: DS.attr('string'),
  58. timezone: DS.attr('string'),
  59. frequency: DS.attr('string'),
  60. dataset: DS.belongsTo('App.Dataset')
  61. });
  62. App.Dataset.FIXTURES = [/*
  63. {
  64. id: 1,
  65. cluster_name: 'cluster1',
  66. stack_name: 'HDP',
  67. hosts: [1, 2, 3, 4],
  68. racks: [1, 2, 3, 4, 5, 6],
  69. max_hosts_per_rack: 10
  70. }*/
  71. ];
  72. App.Dataset.Schedule.FIXTURES = [/*
  73. {
  74. id: 1,
  75. cluster_name: 'cluster1',
  76. stack_name: 'HDP',
  77. hosts: [1, 2, 3, 4],
  78. racks: [1, 2, 3, 4, 5, 6],
  79. max_hosts_per_rack: 10
  80. }*/
  81. ];