capacity-queue.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. queuePath: DS.attr("string"),
  23. children: DS.attr("array"),
  24. parent: DS.attr("string"),
  25. capacity: DS.attr("number"),
  26. partitions: DS.attr("array"),
  27. partitionMap: DS.attr("object"),
  28. resourceUsagesByPartitionMap: DS.attr("object"),
  29. maxCapacity: DS.attr("number"),
  30. usedCapacity: DS.attr("number"),
  31. absCapacity: DS.attr("number"),
  32. absMaxCapacity: DS.attr("number"),
  33. absUsedCapacity: DS.attr("number"),
  34. weight: DS.attr("number"),
  35. normalizedWeight: DS.attr("number"),
  36. creationMethod: DS.attr("string"),
  37. orderingPolicyInfo: DS.attr("string"),
  38. state: DS.attr("string"),
  39. userLimit: DS.attr("number"),
  40. userLimitFactor: DS.attr("number"),
  41. preemptionDisabled: DS.attr("string"),
  42. intraQueuePreemptionDisabled: DS.attr("string"),
  43. defaultPriority: DS.attr("number"),
  44. numPendingApplications: DS.attr("number"),
  45. numActiveApplications: DS.attr("number"),
  46. numContainers: DS.attr("number"),
  47. maxApplications: DS.attr("number"),
  48. maxApplicationsPerUser: DS.attr("number"),
  49. nodeLabels: DS.attr("string"),
  50. defaultNodeLabelExpression: DS.attr("string"),
  51. users: DS.hasMany("YarnUser"),
  52. type: DS.attr("string"),
  53. resources: DS.attr("object"),
  54. isLeafQueue: function() {
  55. var len = this.get("children.length");
  56. if (!len) {
  57. return true;
  58. }
  59. return len <= 0;
  60. }.property("children"),
  61. isWeightMode: function() {
  62. return this.get("weight") !== -1;
  63. }.property("children"),
  64. isFlexibleDynamicQueue: function() {
  65. return this.get("creationMethod") === "dynamicFlexible";
  66. }.property("children"),
  67. capacitiesBarChartData: function() {
  68. var floatToFixed = Converter.floatToFixed;
  69. return [
  70. {
  71. label: "Absolute Used",
  72. style: "primary",
  73. value:
  74. this.get("name") === "root"
  75. ? floatToFixed(this.get("usedCapacity"))
  76. : floatToFixed(this.get("absUsedCapacity"))
  77. },
  78. {
  79. label: "Absolute Capacity",
  80. style: "primary",
  81. value:
  82. this.get("name") === "root"
  83. ? 100
  84. : floatToFixed(this.get("absCapacity"))
  85. },
  86. {
  87. label: "Absolute Max Capacity",
  88. style: "secondary",
  89. value:
  90. this.get("name") === "root"
  91. ? 100
  92. : floatToFixed(this.get("absMaxCapacity"))
  93. }
  94. ];
  95. }.property("absCapacity", "usedCapacity", "absMaxCapacity"),
  96. userUsagesDonutChartData: function() {
  97. var data = [];
  98. if (this.get("users")) {
  99. this.get("users").forEach(function(o) {
  100. data.push({
  101. label: o.get("name"),
  102. value: o.get("usedMemoryMB")
  103. });
  104. });
  105. }
  106. return data;
  107. }.property("users"),
  108. hasUserUsages: function() {
  109. return this.get("userUsagesDonutChartData").length > 0;
  110. }.property("userUsagesDonutChartData"),
  111. numOfApplicationsDonutChartData: function() {
  112. return [
  113. {
  114. label: "Pending Apps",
  115. value: this.get("numPendingApplications") || 0 // TODO, fix the REST API so root will return #applications as well.
  116. },
  117. {
  118. label: "Active Apps",
  119. value: this.get("numActiveApplications") || 0
  120. }
  121. ];
  122. }.property("numPendingApplications", "numActiveApplications")
  123. });