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 org.apache.hadoop.classification.InterfaceAudience.Private;
022import org.apache.hadoop.classification.InterfaceAudience.Public;
023import org.apache.hadoop.classification.InterfaceStability.Stable;
024import org.apache.hadoop.classification.InterfaceStability.Unstable;
025import org.apache.hadoop.yarn.util.Records;
026
027/**
028 * Contains various scheduling metrics to be reported by UI and CLI.
029 */
030@Public
031@Stable
032public abstract class ApplicationResourceUsageReport {
033
034  @Private
035  @Unstable
036  public static ApplicationResourceUsageReport newInstance(
037      int numUsedContainers, int numReservedContainers, Resource usedResources,
038      Resource reservedResources, Resource neededResources, long memorySeconds,
039      long vcoreSeconds) {
040    ApplicationResourceUsageReport report =
041        Records.newRecord(ApplicationResourceUsageReport.class);
042    report.setNumUsedContainers(numUsedContainers);
043    report.setNumReservedContainers(numReservedContainers);
044    report.setUsedResources(usedResources);
045    report.setReservedResources(reservedResources);
046    report.setNeededResources(neededResources);
047    report.setMemorySeconds(memorySeconds);
048    report.setVcoreSeconds(vcoreSeconds);
049    return report;
050  }
051
052  /**
053   * Get the number of used containers.  -1 for invalid/inaccessible reports.
054   * @return the number of used containers
055   */
056  @Public
057  @Stable
058  public abstract int getNumUsedContainers();
059
060  /**
061   * Set the number of used containers
062   * @param num_containers the number of used containers
063   */
064  @Private
065  @Unstable
066  public abstract void setNumUsedContainers(int num_containers);
067
068  /**
069   * Get the number of reserved containers.  -1 for invalid/inaccessible reports.
070   * @return the number of reserved containers
071   */
072  @Private
073  @Unstable
074  public abstract int getNumReservedContainers();
075
076  /**
077   * Set the number of reserved containers
078   * @param num_reserved_containers the number of reserved containers
079   */
080  @Private
081  @Unstable
082  public abstract void setNumReservedContainers(int num_reserved_containers);
083
084  /**
085   * Get the used <code>Resource</code>.  -1 for invalid/inaccessible reports.
086   * @return the used <code>Resource</code>
087   */
088  @Public
089  @Stable
090  public abstract Resource getUsedResources();
091
092  @Private
093  @Unstable
094  public abstract void setUsedResources(Resource resources);
095
096  /**
097   * Get the reserved <code>Resource</code>.  -1 for invalid/inaccessible reports.
098   * @return the reserved <code>Resource</code>
099   */
100  @Public
101  @Stable
102  public abstract Resource getReservedResources();
103
104  @Private
105  @Unstable
106  public abstract void setReservedResources(Resource reserved_resources);
107
108  /**
109   * Get the needed <code>Resource</code>.  -1 for invalid/inaccessible reports.
110   * @return the needed <code>Resource</code>
111   */
112  @Public
113  @Stable
114  public abstract Resource getNeededResources();
115
116  @Private
117  @Unstable
118  public abstract void setNeededResources(Resource needed_resources);
119
120  /**
121   * Set the aggregated amount of memory (in megabytes) the application has
122   * allocated times the number of seconds the application has been running.
123   * @param memory_seconds the aggregated amount of memory seconds
124   */
125  @Private
126  @Unstable
127  public abstract void setMemorySeconds(long memory_seconds);
128
129  /**
130   * Get the aggregated amount of memory (in megabytes) the application has
131   * allocated times the number of seconds the application has been running.
132   * @return the aggregated amount of memory seconds
133   */
134  @Public
135  @Unstable
136  public abstract long getMemorySeconds();
137
138  /**
139   * Set the aggregated number of vcores that the application has allocated
140   * times the number of seconds the application has been running.
141   * @param vcore_seconds the aggregated number of vcore seconds
142   */
143  @Private
144  @Unstable
145  public abstract void setVcoreSeconds(long vcore_seconds);
146
147  /**
148   * Get the aggregated number of vcores that the application has allocated
149   * times the number of seconds the application has been running.
150   * @return the aggregated number of vcore seconds
151   */
152  @Public
153  @Unstable
154  public abstract long getVcoreSeconds();
155}