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
019package org.apache.hadoop.yarn.api.records;
020
021import java.util.List;
022import java.util.Set;
023
024import org.apache.hadoop.classification.InterfaceAudience.Private;
025import org.apache.hadoop.classification.InterfaceAudience.Public;
026import org.apache.hadoop.classification.InterfaceStability.Stable;
027import org.apache.hadoop.classification.InterfaceStability.Unstable;
028import org.apache.hadoop.yarn.api.ApplicationClientProtocol;
029import org.apache.hadoop.yarn.util.Records;
030
031/**
032 * QueueInfo is a report of the runtime information of the queue.
033 * <p>
034 * It includes information such as:
035 * <ul>
036 *   <li>Queue name.</li>
037 *   <li>Capacity of the queue.</li>
038 *   <li>Maximum capacity of the queue.</li>
039 *   <li>Current capacity of the queue.</li>
040 *   <li>Child queues.</li>
041 *   <li>Running applications.</li>
042 *   <li>{@link QueueState} of the queue.</li>
043 * </ul>
044 *
045 * @see QueueState
046 * @see ApplicationClientProtocol#getQueueInfo(org.apache.hadoop.yarn.api.protocolrecords.GetQueueInfoRequest)
047 */
048@Public
049@Stable
050public abstract class QueueInfo {
051  
052  @Private
053  @Unstable
054  public static QueueInfo newInstance(String queueName, float capacity,
055      float maximumCapacity, float currentCapacity,
056      List<QueueInfo> childQueues, List<ApplicationReport> applications,
057      QueueState queueState, Set<String> accessibleNodeLabels,
058      String defaultNodeLabelExpression, QueueStatistics queueStatistics,
059      boolean preemptionDisabled) {
060    QueueInfo queueInfo = Records.newRecord(QueueInfo.class);
061    queueInfo.setQueueName(queueName);
062    queueInfo.setCapacity(capacity);
063    queueInfo.setMaximumCapacity(maximumCapacity);
064    queueInfo.setCurrentCapacity(currentCapacity);
065    queueInfo.setChildQueues(childQueues);
066    queueInfo.setApplications(applications);
067    queueInfo.setQueueState(queueState);
068    queueInfo.setAccessibleNodeLabels(accessibleNodeLabels);
069    queueInfo.setDefaultNodeLabelExpression(defaultNodeLabelExpression);
070    queueInfo.setQueueStatistics(queueStatistics);
071    queueInfo.setPreemptionDisabled(preemptionDisabled);
072    return queueInfo;
073  }
074
075  /**
076   * Get the <em>name</em> of the queue.
077   * @return <em>name</em> of the queue
078   */
079  @Public
080  @Stable
081  public abstract String getQueueName();
082  
083  @Private
084  @Unstable
085  public abstract void setQueueName(String queueName);
086  
087  /**
088   * Get the <em>configured capacity</em> of the queue.
089   * @return <em>configured capacity</em> of the queue
090   */
091  @Public
092  @Stable
093  public abstract float getCapacity();
094  
095  @Private
096  @Unstable
097  public abstract void setCapacity(float capacity);
098  
099  /**
100   * Get the <em>maximum capacity</em> of the queue.
101   * @return <em>maximum capacity</em> of the queue
102   */
103  @Public
104  @Stable
105  public abstract float getMaximumCapacity();
106  
107  @Private
108  @Unstable
109  public abstract void setMaximumCapacity(float maximumCapacity);
110  
111  /**
112   * Get the <em>current capacity</em> of the queue.
113   * @return <em>current capacity</em> of the queue
114   */
115  @Public
116  @Stable
117  public abstract float getCurrentCapacity();
118  
119  @Private
120  @Unstable
121  public abstract void setCurrentCapacity(float currentCapacity);
122  
123  /**
124   * Get the <em>child queues</em> of the queue.
125   * @return <em>child queues</em> of the queue
126   */
127  @Public
128  @Stable
129  public abstract List<QueueInfo> getChildQueues();
130  
131  @Private
132  @Unstable
133  public abstract void setChildQueues(List<QueueInfo> childQueues);
134  
135  /**
136   * Get the <em>running applications</em> of the queue.
137   * @return <em>running applications</em> of the queue
138   */
139  @Public
140  @Stable
141  public abstract List<ApplicationReport> getApplications();
142  
143  @Private
144  @Unstable
145  public abstract void setApplications(List<ApplicationReport> applications);
146  
147  /**
148   * Get the <code>QueueState</code> of the queue.
149   * @return <code>QueueState</code> of the queue
150   */
151  @Public
152  @Stable
153  public abstract QueueState getQueueState();
154  
155  @Private
156  @Unstable
157  public abstract void setQueueState(QueueState queueState);
158  
159  /**
160   * Get the <code>accessible node labels</code> of the queue.
161   * @return <code>accessible node labels</code> of the queue
162   */
163  @Public
164  @Stable
165  public abstract Set<String> getAccessibleNodeLabels();
166  
167  /**
168   * Set the <code>accessible node labels</code> of the queue.
169   */
170  @Private
171  @Unstable
172  public abstract void setAccessibleNodeLabels(Set<String> labels);
173  
174  /**
175   * Get the <code>default node label expression</code> of the queue, this takes
176   * affect only when the <code>ApplicationSubmissionContext</code> and
177   * <code>ResourceRequest</code> don't specify their
178   * <code>NodeLabelExpression</code>.
179   * 
180   * @return <code>default node label expression</code> of the queue
181   */
182  @Public
183  @Stable
184  public abstract String getDefaultNodeLabelExpression();
185  
186  @Public
187  @Stable
188  public abstract void setDefaultNodeLabelExpression(
189      String defaultLabelExpression);
190
191  /**
192   * Get the <code>queue stats</code> for the queue
193   *
194   * @return <code>queue stats</code> of the queue
195   */
196  @Public
197  @Unstable
198  public abstract QueueStatistics getQueueStatistics();
199
200  /**
201   * Set the queue statistics for the queue
202   * 
203   * @param queueStatistics
204   *          the queue statistics
205   */
206  @Public
207  @Unstable
208  public abstract void setQueueStatistics(QueueStatistics queueStatistics);
209
210  /**
211   * Get the <em>preemption status</em> of the queue.
212   * @return if property is not in proto, return null;
213   *        otherwise, return <em>preemption status</em> of the queue
214   */
215  @Public
216  @Stable
217  public abstract Boolean getPreemptionDisabled();
218
219  @Private
220  @Unstable
221  public abstract void setPreemptionDisabled(boolean preemptionDisabled);
222}