|
| 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 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.helper; |
| 18 | + |
| 19 | +import org.apache.hadoop.yarn.exceptions.YarnRuntimeException; |
| 20 | +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.AbstractCSQueue; |
| 21 | +import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CSQueue; |
| 22 | + |
| 23 | +public class CapacitySchedulerInfoHelper { |
| 24 | + |
| 25 | + private CapacitySchedulerInfoHelper() {} |
| 26 | + |
| 27 | + public static String getMode(CSQueue queue) throws YarnRuntimeException { |
| 28 | + if (queue.getCapacityConfigType() == |
| 29 | + AbstractCSQueue.CapacityConfigType.ABSOLUTE_RESOURCE) { |
| 30 | + return "absolute"; |
| 31 | + } else if (queue.getCapacityConfigType() == |
| 32 | + AbstractCSQueue.CapacityConfigType.PERCENTAGE) { |
| 33 | + float weight = queue.getQueueCapacities().getWeight(); |
| 34 | + if (weight == -1) { |
| 35 | + //-1 indicates we are not in weight mode |
| 36 | + return "percentage"; |
| 37 | + } else { |
| 38 | + return "weight"; |
| 39 | + } |
| 40 | + } |
| 41 | + throw new YarnRuntimeException("Unknown mode for queue: " + |
| 42 | + queue.getQueuePath() + ". Queue details: " + queue); |
| 43 | + } |
| 44 | +} |
0 commit comments