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) {
059    QueueInfo queueInfo = Records.newRecord(QueueInfo.class);
060    queueInfo.setQueueName(queueName);
061    queueInfo.setCapacity(capacity);
062    queueInfo.setMaximumCapacity(maximumCapacity);
063    queueInfo.setCurrentCapacity(currentCapacity);
064    queueInfo.setChildQueues(childQueues);
065    queueInfo.setApplications(applications);
066    queueInfo.setQueueState(queueState);
067    queueInfo.setAccessibleNodeLabels(accessibleNodeLabels);
068    queueInfo.setDefaultNodeLabelExpression(defaultNodeLabelExpression);
069    return queueInfo;
070  }
071
072  /**
073   * Get the <em>name</em> of the queue.
074   * @return <em>name</em> of the queue
075   */
076  @Public
077  @Stable
078  public abstract String getQueueName();
079  
080  @Private
081  @Unstable
082  public abstract void setQueueName(String queueName);
083  
084  /**
085   * Get the <em>configured capacity</em> of the queue.
086   * @return <em>configured capacity</em> of the queue
087   */
088  @Public
089  @Stable
090  public abstract float getCapacity();
091  
092  @Private
093  @Unstable
094  public abstract void setCapacity(float capacity);
095  
096  /**
097   * Get the <em>maximum capacity</em> of the queue.
098   * @return <em>maximum capacity</em> of the queue
099   */
100  @Public
101  @Stable
102  public abstract float getMaximumCapacity();
103  
104  @Private
105  @Unstable
106  public abstract void setMaximumCapacity(float maximumCapacity);
107  
108  /**
109   * Get the <em>current capacity</em> of the queue.
110   * @return <em>current capacity</em> of the queue
111   */
112  @Public
113  @Stable
114  public abstract float getCurrentCapacity();
115  
116  @Private
117  @Unstable
118  public abstract void setCurrentCapacity(float currentCapacity);
119  
120  /**
121   * Get the <em>child queues</em> of the queue.
122   * @return <em>child queues</em> of the queue
123   */
124  @Public
125  @Stable
126  public abstract List<QueueInfo> getChildQueues();
127  
128  @Private
129  @Unstable
130  public abstract void setChildQueues(List<QueueInfo> childQueues);
131  
132  /**
133   * Get the <em>running applications</em> of the queue.
134   * @return <em>running applications</em> of the queue
135   */
136  @Public
137  @Stable
138  public abstract List<ApplicationReport> getApplications();
139  
140  @Private
141  @Unstable
142  public abstract void setApplications(List<ApplicationReport> applications);
143  
144  /**
145   * Get the <code>QueueState</code> of the queue.
146   * @return <code>QueueState</code> of the queue
147   */
148  @Public
149  @Stable
150  public abstract QueueState getQueueState();
151  
152  @Private
153  @Unstable
154  public abstract void setQueueState(QueueState queueState);
155  
156  /**
157   * Get the <code>accessible node labels</code> of the queue.
158   * @return <code>accessible node labels</code> of the queue
159   */
160  @Public
161  @Stable
162  public abstract Set<String> getAccessibleNodeLabels();
163  
164  /**
165   * Set the <code>accessible node labels</code> of the queue.
166   */
167  @Private
168  @Unstable
169  public abstract void setAccessibleNodeLabels(Set<String> labels);
170  
171  /**
172   * Get the <code>default node label expression</code> of the queue, this takes
173   * affect only when the <code>ApplicationSubmissionContext</code> and
174   * <code>ResourceRequest</code> don't specify their
175   * <code>NodeLabelExpression</code>.
176   * 
177   * @return <code>default node label expression</code> of the queue
178   */
179  @Public
180  @Stable
181  public abstract String getDefaultNodeLabelExpression();
182  
183  @Public
184  @Stable
185  public abstract void setDefaultNodeLabelExpression(
186      String defaultLabelExpression);
187}