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 19 package org.apache.hadoop.yarn.server.resourcemanager.webapp.dao; 20 21 import java.util.EnumSet; 22 23 import javax.xml.bind.annotation.XmlRootElement; 24 import javax.xml.bind.annotation.XmlSeeAlso; 25 26 import org.apache.hadoop.yarn.proto.YarnServiceProtos.SchedulerResourceTypes; 27 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager; 28 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler; 29 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler; 30 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler; 31 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo.FifoScheduler; 32 33 @XmlRootElement 34 @XmlSeeAlso({ CapacitySchedulerInfo.class, FairSchedulerInfo.class, 35 FifoSchedulerInfo.class }) 36 public class SchedulerInfo { 37 protected String schedulerName; 38 protected ResourceInfo minAllocResource; 39 protected ResourceInfo maxAllocResource; 40 protected EnumSet<SchedulerResourceTypes> schedulingResourceTypes; 41 SchedulerInfo()42 public SchedulerInfo() { 43 } // JAXB needs this 44 SchedulerInfo(final ResourceManager rm)45 public SchedulerInfo(final ResourceManager rm) { 46 ResourceScheduler rs = rm.getResourceScheduler(); 47 48 if (rs instanceof CapacityScheduler) { 49 this.schedulerName = "Capacity Scheduler"; 50 } else if (rs instanceof FairScheduler) { 51 this.schedulerName = "Fair Scheduler"; 52 } else if (rs instanceof FifoScheduler) { 53 this.schedulerName = "Fifo Scheduler"; 54 } 55 this.minAllocResource = new ResourceInfo(rs.getMinimumResourceCapability()); 56 this.maxAllocResource = new ResourceInfo(rs.getMaximumResourceCapability()); 57 this.schedulingResourceTypes = rs.getSchedulingResourceTypes(); 58 } 59 getSchedulerType()60 public String getSchedulerType() { 61 return this.schedulerName; 62 } 63 getMinAllocation()64 public ResourceInfo getMinAllocation() { 65 return this.minAllocResource; 66 } 67 getMaxAllocation()68 public ResourceInfo getMaxAllocation() { 69 return this.maxAllocResource; 70 } 71 getSchedulerResourceTypes()72 public String getSchedulerResourceTypes() { 73 return this.schedulingResourceTypes.toString(); 74 } 75 76 } 77