fair-queue.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. import DS from 'ember-data';
  19. import Converter from 'yarn-ui/utils/converter';
  20. export default DS.Model.extend({
  21. name: DS.attr('string'),
  22. children: DS.attr('array'),
  23. parent: DS.attr('string'),
  24. maxApps: DS.attr('number'),
  25. minResources: DS.attr(),
  26. maxResources: DS.attr(),
  27. usedResources: DS.attr(),
  28. demandResources: DS.attr(),
  29. steadyFairResources: DS.attr(),
  30. fairResources: DS.attr(),
  31. clusterResources: DS.attr(),
  32. pendingContainers: DS.attr('number'),
  33. allocatedContainers: DS.attr('number'),
  34. reservedContainers: DS.attr('number'),
  35. schedulingPolicy: DS.attr('string'),
  36. preemptable: DS.attr('number'),
  37. numPendingApplications: DS.attr('number'),
  38. numActiveApplications: DS.attr('number'),
  39. type: DS.attr('string'),
  40. isLeafQueue: function() {
  41. var len = this.get("children.length");
  42. if (!len) {
  43. return true;
  44. }
  45. return len <= 0;
  46. }.property("children"),
  47. capacitiesBarChartData: function() {
  48. var floatToFixed = Converter.floatToFixed;
  49. return [
  50. {
  51. label: "Steady Fair Memory",
  52. value: floatToFixed(this.get("steadyFairResources.memory"))
  53. },
  54. {
  55. label: "Used Memory",
  56. value: floatToFixed(this.get("usedResources.memory"))
  57. },
  58. {
  59. label: "Maximum Memory",
  60. value: floatToFixed(this.get("maxResources.memory"))
  61. }
  62. ];
  63. }.property("maxResources.memory", "usedResources.memory", "maxResources.memory"),
  64. numOfApplicationsDonutChartData: function() {
  65. return [
  66. {
  67. label: "Pending Apps",
  68. value: this.get("numPendingApplications") || 0 // TODO, fix the REST API so root will return #applications as well.
  69. },
  70. {
  71. label: "Active Apps",
  72. value: this.get("numActiveApplications") || 0
  73. }
  74. ];
  75. }.property()
  76. });