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