123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- /**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- import DS from 'ember-data';
- import Converter from 'yarn-ui/utils/converter';
- export default DS.Model.extend({
- name: DS.attr("string"),
- queuePath: DS.attr("string"),
- children: DS.attr("array"),
- parent: DS.attr("string"),
- capacity: DS.attr("number"),
- partitions: DS.attr("array"),
- partitionMap: DS.attr("object"),
- resourceUsagesByPartitionMap: DS.attr("object"),
- maxCapacity: DS.attr("number"),
- usedCapacity: DS.attr("number"),
- absCapacity: DS.attr("number"),
- absMaxCapacity: DS.attr("number"),
- absUsedCapacity: DS.attr("number"),
- weight: DS.attr("number"),
- normalizedWeight: DS.attr("number"),
- creationMethod: DS.attr("string"),
- orderingPolicyInfo: DS.attr("string"),
- state: DS.attr("string"),
- userLimit: DS.attr("number"),
- userLimitFactor: DS.attr("number"),
- preemptionDisabled: DS.attr("string"),
- intraQueuePreemptionDisabled: DS.attr("string"),
- defaultPriority: DS.attr("number"),
- numPendingApplications: DS.attr("number"),
- numActiveApplications: DS.attr("number"),
- numContainers: DS.attr("number"),
- maxApplications: DS.attr("number"),
- maxApplicationsPerUser: DS.attr("number"),
- nodeLabels: DS.attr("string"),
- defaultNodeLabelExpression: DS.attr("string"),
- users: DS.hasMany("YarnUser"),
- type: DS.attr("string"),
- resources: DS.attr("object"),
- isLeafQueue: function() {
- var len = this.get("children.length");
- if (!len) {
- return true;
- }
- return len <= 0;
- }.property("children"),
- isWeightMode: function() {
- return this.get("weight") !== -1;
- }.property("children"),
- isFlexibleDynamicQueue: function() {
- return this.get("creationMethod") === "dynamicFlexible";
- }.property("children"),
- capacitiesBarChartData: function() {
- var floatToFixed = Converter.floatToFixed;
- return [
- {
- label: "Absolute Used",
- style: "primary",
- value:
- this.get("name") === "root"
- ? floatToFixed(this.get("usedCapacity"))
- : floatToFixed(this.get("absUsedCapacity"))
- },
- {
- label: "Absolute Capacity",
- style: "primary",
- value:
- this.get("name") === "root"
- ? 100
- : floatToFixed(this.get("absCapacity"))
- },
- {
- label: "Absolute Max Capacity",
- style: "secondary",
- value:
- this.get("name") === "root"
- ? 100
- : floatToFixed(this.get("absMaxCapacity"))
- }
- ];
- }.property("absCapacity", "usedCapacity", "absMaxCapacity"),
- userUsagesDonutChartData: function() {
- var data = [];
- if (this.get("users")) {
- this.get("users").forEach(function(o) {
- data.push({
- label: o.get("name"),
- value: o.get("usedMemoryMB")
- });
- });
- }
- return data;
- }.property("users"),
- hasUserUsages: function() {
- return this.get("userUsagesDonutChartData").length > 0;
- }.property("userUsagesDonutChartData"),
- numOfApplicationsDonutChartData: function() {
- return [
- {
- label: "Pending Apps",
- value: this.get("numPendingApplications") || 0 // TODO, fix the REST API so root will return #applications as well.
- },
- {
- label: "Active Apps",
- value: this.get("numActiveApplications") || 0
- }
- ];
- }.property("numPendingApplications", "numActiveApplications")
- });
|