001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019 package org.apache.hadoop.yarn.api.records; 020 021 import org.apache.hadoop.classification.InterfaceAudience.Public; 022 import org.apache.hadoop.classification.InterfaceStability.Stable; 023 import org.apache.hadoop.yarn.api.AMRMProtocol; 024 025 /** 026 * <p><code>ResourceRequest</code> represents the request made by an 027 * application to the <code>ResourceManager</code> to obtain various 028 * <code>Container</code> allocations.</p> 029 * 030 * <p>It includes: 031 * <ul> 032 * <li>{@link Priority} of the request.</li> 033 * <li> 034 * The <em>name</em> of the machine or rack on which the allocation is 035 * desired. A special value of <em>*</em> signifies that 036 * <em>any</em> host/rack is acceptable to the application. 037 * </li> 038 * <li>{@link Resource} required for each request.</li> 039 * <li> 040 * Number of containers of such specifications which are required 041 * by the application. 042 * </li> 043 * </ul> 044 * </p> 045 * 046 * @see Resource 047 * @see AMRMProtocol#allocate(org.apache.hadoop.yarn.api.protocolrecords.AllocateRequest) 048 */ 049 @Public 050 @Stable 051 public interface ResourceRequest extends Comparable<ResourceRequest> { 052 /** 053 * Get the <code>Priority</code> of the request. 054 * @return <code>Priority</code> of the request 055 */ 056 @Public 057 @Stable 058 public abstract Priority getPriority(); 059 060 /** 061 * Set the <code>Priority</code> of the request 062 * @param priority <code>Priority</code> of the request 063 */ 064 @Public 065 @Stable 066 public abstract void setPriority(Priority priority); 067 068 /** 069 * Get the <em>host/rack</em> on which the allocation is desired. 070 * 071 * A special value of <em>*</em> signifies that <em>any</em> host/rack is 072 * acceptable. 073 * 074 * @return <em>host/rack</em> on which the allocation is desired 075 */ 076 @Public 077 @Stable 078 public abstract String getHostName(); 079 080 /** 081 * Set <em>host/rack</em> on which the allocation is desired. 082 * 083 * A special value of <em>*</em> signifies that <em>any</em> host/rack is 084 * acceptable. 085 * 086 * @param hostName <em>host/rack</em> on which the allocation is desired 087 */ 088 @Public 089 @Stable 090 public abstract void setHostName(String hostName); 091 092 /** 093 * Get the <code>Resource</code> capability of the request. 094 * @return <code>Resource</code> capability of the request 095 */ 096 @Public 097 @Stable 098 public abstract Resource getCapability(); 099 100 /** 101 * Set the <code>Resource</code> capability of the request 102 * @param capability <code>Resource</code> capability of the request 103 */ 104 @Public 105 @Stable 106 public abstract void setCapability(Resource capability); 107 108 /** 109 * Get the number of containers required with the given specifications. 110 * @return number of containers required with the given specifications 111 */ 112 @Public 113 @Stable 114 public abstract int getNumContainers(); 115 116 /** 117 * Set the number of containers required with the given specifications 118 * @param numContainers number of containers required with the given 119 * specifications 120 */ 121 @Public 122 @Stable 123 public abstract void setNumContainers(int numContainers); 124 }