yarn-queue.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import DS from 'ember-data';
  2. export default DS.Model.extend({
  3. name: DS.attr('string'),
  4. children: DS.attr('array'),
  5. parent: DS.attr('string'),
  6. capacity: DS.attr('number'),
  7. maxCapacity: DS.attr('number'),
  8. usedCapacity: DS.attr('number'),
  9. absCapacity: DS.attr('number'),
  10. absMaxCapacity: DS.attr('number'),
  11. absUsedCapacity: DS.attr('number'),
  12. state: DS.attr('string'),
  13. userLimit: DS.attr('number'),
  14. userLimitFactor: DS.attr('number'),
  15. preemptionDisabled: DS.attr('number'),
  16. numPendingApplications: DS.attr('number'),
  17. numActiveApplications: DS.attr('number'),
  18. users: DS.hasMany('YarnUser'),
  19. isLeafQueue: function() {
  20. var len = this.get("children.length");
  21. if (!len) {
  22. return true;
  23. }
  24. return len <= 0;
  25. }.property("children"),
  26. capacitiesBarChartData: function() {
  27. return [
  28. {
  29. label: "Absolute Capacity",
  30. value: this.get("name") == "root" ? 100 : this.get("absCapacity")
  31. },
  32. {
  33. label: "Absolute Used",
  34. value: this.get("name") == "root" ? this.get("usedCapacity") : this.get("absUsedCapacity")
  35. },
  36. {
  37. label: "Absolute Max Capacity",
  38. value: this.get("name") == "root" ? 100 : this.get("absMaxCapacity")
  39. }
  40. ]
  41. }.property("absCapacity", "absUsedCapacity", "absMaxCapacity"),
  42. userUsagesDonutChartData: function() {
  43. var data = [];
  44. if (this.get("users")) {
  45. this.get("users").forEach(function(o) {
  46. data.push({
  47. label: o.get("name"),
  48. value: o.get("usedMemoryMB")
  49. })
  50. });
  51. }
  52. return data;
  53. }.property("users"),
  54. hasUserUsages: function() {
  55. return this.get("userUsagesDonutChartData").length > 0;
  56. }.property(),
  57. numOfApplicationsDonutChartData: function() {
  58. return [
  59. {
  60. label: "Pending Apps",
  61. value: this.get("numPendingApplications") || 0 // TODO, fix the REST API so root will return #applications as well.
  62. },
  63. {
  64. label: "Active Apps",
  65. value: this.get("numActiveApplications") || 0
  66. }
  67. ]
  68. }.property(),
  69. });