Explorar o código

YARN-711. Copied BuilderUtil methods in individual API records as BuilderUtils is going to be dismantled. Contributed by Jian He.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1485888 13f79535-47bb-0310-9956-ffa450edef68
Vinod Kumar Vavilapalli %!s(int64=12) %!d(string=hai) anos
pai
achega
61885df2fa
Modificáronse 43 ficheiros con 755 adicións e 852 borrados
  1. 3 0
      hadoop-yarn-project/CHANGES.txt
  2. 12 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationAttemptId.java
  3. 0 60
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationMaster.java
  4. 68 37
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationReport.java
  5. 26 15
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationResourceUsageReport.java
  6. 0 38
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationStatus.java
  7. 57 21
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationSubmissionContext.java
  8. 32 15
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Container.java
  9. 11 0
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java
  10. 36 15
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerLaunchContext.java
  11. 22 9
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerStatus.java
  12. 37 13
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/LocalResource.java
  13. 18 7
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/NodeHealthStatus.java
  14. 9 0
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/NodeId.java
  15. 35 17
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/NodeReport.java
  16. 13 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Priority.java
  17. 33 15
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueInfo.java
  18. 16 5
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueUserACLInfo.java
  19. 10 0
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java
  20. 13 0
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceRequest.java
  21. 15 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/URL.java
  22. 9 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/YarnClusterMetrics.java
  23. 0 294
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationMasterPBImpl.java
  24. 21 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java
  25. 21 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationResourceUsageReportPBImpl.java
  26. 0 134
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationStatusPBImpl.java
  27. 21 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.java
  28. 32 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java
  29. 16 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java
  30. 21 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java
  31. 21 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.java
  32. 21 3
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeHealthStatusPBImpl.java
  33. 21 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java
  34. 21 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java
  35. 21 4
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueUserACLInfoPBImpl.java
  36. 21 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java
  37. 21 2
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java
  38. 1 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/LocalResourceRequest.java
  39. 0 106
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java
  40. 0 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMLaunchFailure.java
  41. 0 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java
  42. 0 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestASMStateMachine.java
  43. 0 1
      hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestSchedulerNegotiator.java

+ 3 - 0
hadoop-yarn-project/CHANGES.txt

@@ -266,6 +266,9 @@ Release 2.0.5-beta - UNRELEASED
     YARN-708. Moved RecordFactory classes to hadoop-yarn-api, and put some
     miscellaneous fixes to the interfaces. (Siddharth Seth via vinodkv)
 
+    YARN-711. Copied BuilderUtil methods in individual API records as
+    BuilderUtils is going to be dismantled. (Jian He via vinodkv)
+
   OPTIMIZATIONS
 
   BUG FIXES

+ 12 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationAttemptId.java

@@ -24,6 +24,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>ApplicationAttemptId</code> denotes the particular <em>attempt</em>
@@ -37,9 +38,19 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable;
 @Stable
 public abstract class ApplicationAttemptId implements
     Comparable<ApplicationAttemptId> {
-  
+
   public static final String appAttemptIdStrPrefix = "appattempt_";
 
+  @Private
+  public static ApplicationAttemptId newInstance(ApplicationId appId,
+      int attemptId) {
+    ApplicationAttemptId appAttemptId =
+        Records.newRecord(ApplicationAttemptId.class);
+    appAttemptId.setApplicationId(appId);
+    appAttemptId.setAttemptId(attemptId);
+    return appAttemptId;
+  }
+
   /**
    * Get the <code>ApplicationId</code> of the <code>ApplicationAttempId</code>. 
    * @return <code>ApplicationId</code> of the <code>ApplicationAttempId</code>

+ 0 - 60
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationMaster.java

@@ -1,60 +0,0 @@
-/**
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.apache.hadoop.yarn.api.records;
-
-import org.apache.hadoop.classification.InterfaceAudience.Private;
-import org.apache.hadoop.classification.InterfaceStability.Unstable;
-
-/**
- * <em>For internal use only...</em>
- */
-@Private
-@Unstable
-public interface ApplicationMaster {
-  ApplicationId getApplicationId();
-  void setApplicationId(ApplicationId appId);
-
-  String getHost();
-  void setHost(String host);
-
-  int getRpcPort();
-  void setRpcPort(int rpcPort);
-
-  String getTrackingUrl();
-  void setTrackingUrl(String url);
-
-  ApplicationStatus getStatus();
-  void setStatus(ApplicationStatus status);
-
-  YarnApplicationState getState();
-  void setState(YarnApplicationState state);
-
-  ClientToken getClientToken();
-  void setClientToken(ClientToken clientToken);
-
-  int getAMFailCount();
-  void setAMFailCount(int amFailCount);
-
-  int getContainerCount();
-  void setContainerCount(int containerCount);
-
-  String getDiagnostics();
-  void setDiagnostics(String diagnostics);
-}
-

+ 68 - 37
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationReport.java

@@ -23,6 +23,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
 import org.apache.hadoop.yarn.api.ClientRMProtocol;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>ApplicationReport</code> is a report of an application.</p>
@@ -47,7 +48,37 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
  */
 @Public
 @Stable
-public interface ApplicationReport {
+public abstract class ApplicationReport {
+
+  @Private
+  public static ApplicationReport newInstance(ApplicationId applicationId,
+      ApplicationAttemptId applicationAttemptId, String user, String queue,
+      String name, String host, int rpcPort, ClientToken clientToken,
+      YarnApplicationState state, String diagnostics, String url,
+      long startTime, long finishTime, FinalApplicationStatus finalStatus,
+      ApplicationResourceUsageReport appResources, String origTrackingUrl,
+      float progress, String applicationType) {
+    ApplicationReport report = Records.newRecord(ApplicationReport.class);
+    report.setApplicationId(applicationId);
+    report.setCurrentApplicationAttemptId(applicationAttemptId);
+    report.setUser(user);
+    report.setQueue(queue);
+    report.setName(name);
+    report.setHost(host);
+    report.setRpcPort(rpcPort);
+    report.setClientToken(clientToken);
+    report.setYarnApplicationState(state);
+    report.setDiagnostics(diagnostics);
+    report.setTrackingUrl(url);
+    report.setStartTime(startTime);
+    report.setFinishTime(finishTime);
+    report.setFinalApplicationStatus(finalStatus);
+    report.setApplicationResourceUsageReport(appResources);
+    report.setOriginalTrackingUrl(origTrackingUrl);
+    report.setProgress(progress);
+    report.setApplicationType(applicationType);
+    return report;
+  }
 
   /**
    * Get the <code>ApplicationId</code> of the application.
@@ -55,11 +86,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  ApplicationId getApplicationId();
+  public abstract ApplicationId getApplicationId();
 
   @Private
   @Unstable
-  void setApplicationId(ApplicationId applicationId);
+  public abstract void setApplicationId(ApplicationId applicationId);
   
   /**
    * Get the <code>ApplicationAttemptId</code> of the current
@@ -68,11 +99,11 @@ public interface ApplicationReport {
    */
   @Private
   @Unstable
-  ApplicationAttemptId getCurrentApplicationAttemptId();
+  public abstract ApplicationAttemptId getCurrentApplicationAttemptId();
   
   @Private
   @Unstable
-  void setCurrentApplicationAttemptId(ApplicationAttemptId applicationAttemptId);
+  public abstract void setCurrentApplicationAttemptId(ApplicationAttemptId applicationAttemptId);
 
   /**
    * Get the <em>user</em> who submitted the application.
@@ -80,11 +111,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  String getUser();
+  public abstract String getUser();
 
   @Private
   @Unstable
-  void setUser(String user);
+  public abstract void setUser(String user);
 
   /**
    * Get the <em>queue</em> to which the application was submitted.
@@ -92,11 +123,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  String getQueue();
+  public abstract String getQueue();
 
   @Private
   @Unstable
-  void setQueue(String queue);
+  public abstract void setQueue(String queue);
 
   /**
    * Get the user-defined <em>name</em> of the application.
@@ -104,11 +135,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  String getName();
+  public abstract String getName();
 
   @Private
   @Unstable
-  void setName(String name);
+  public abstract void setName(String name);
 
   /**
    * Get the <em>host</em> on which the <code>ApplicationMaster</code>
@@ -118,11 +149,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  String getHost();
+  public abstract String getHost();
 
   @Private
   @Unstable
-  void setHost(String host);
+  public abstract void setHost(String host);
 
   /**
    * Get the <em>RPC port</em> of the <code>ApplicationMaster</code>.
@@ -130,11 +161,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  int getRpcPort();
+  public abstract int getRpcPort();
 
   @Private
   @Unstable
-  void setRpcPort(int rpcPort);
+  public abstract void setRpcPort(int rpcPort);
 
   /**
    * Get the <em>client token</em> for communicating with the
@@ -144,11 +175,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  ClientToken getClientToken();
+  public abstract ClientToken getClientToken();
 
   @Private
   @Unstable
-  void setClientToken(ClientToken clientToken);
+  public abstract void setClientToken(ClientToken clientToken);
 
   /**
    * Get the <code>YarnApplicationState</code> of the application.
@@ -156,11 +187,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  YarnApplicationState getYarnApplicationState();
+  public abstract YarnApplicationState getYarnApplicationState();
 
   @Private
   @Unstable
-  void setYarnApplicationState(YarnApplicationState state);
+  public abstract void setYarnApplicationState(YarnApplicationState state);
 
   /**
    * Get  the <em>diagnositic information</em> of the application in case of
@@ -170,11 +201,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  String getDiagnostics();
+  public abstract String getDiagnostics();
 
   @Private
   @Unstable
-  void setDiagnostics(String diagnostics);
+  public abstract void setDiagnostics(String diagnostics);
 
   /**
    * Get the <em>tracking url</em> for the application.
@@ -182,11 +213,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  String getTrackingUrl();
+  public abstract String getTrackingUrl();
 
   @Private
   @Unstable
-  void setTrackingUrl(String url);
+  public abstract void setTrackingUrl(String url);
   
   /**
    * Get the original not-proxied <em>tracking url</em> for the application.
@@ -195,11 +226,11 @@ public interface ApplicationReport {
    */
   @Private
   @Unstable
-  String getOriginalTrackingUrl();
+  public abstract String getOriginalTrackingUrl();
 
   @Private
   @Unstable
-  void setOriginalTrackingUrl(String url);
+  public abstract void setOriginalTrackingUrl(String url);
 
   /**
    * Get the <em>start time</em> of the application.
@@ -207,11 +238,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  long getStartTime();
+  public abstract long getStartTime();
 
   @Private
   @Unstable
-  void setStartTime(long startTime);
+  public abstract void setStartTime(long startTime);
 
   /**
    * Get the <em>finish time</em> of the application.
@@ -219,11 +250,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  long getFinishTime();
+  public abstract long getFinishTime();
 
   @Private
   @Unstable
-  void setFinishTime(long finishTime);
+  public abstract void setFinishTime(long finishTime);
 
 
   /**
@@ -232,11 +263,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  FinalApplicationStatus getFinalApplicationStatus();
+  public abstract FinalApplicationStatus getFinalApplicationStatus();
 
   @Private
   @Unstable
-  void setFinalApplicationStatus(FinalApplicationStatus finishState);
+  public abstract void setFinalApplicationStatus(FinalApplicationStatus finishState);
 
   /**
    * Retrieve the structure containing the job resources for this application
@@ -244,7 +275,7 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  ApplicationResourceUsageReport getApplicationResourceUsageReport();
+  public abstract ApplicationResourceUsageReport getApplicationResourceUsageReport();
 
   /**
    * Store the structure containing the job resources for this application
@@ -252,7 +283,7 @@ public interface ApplicationReport {
    */
   @Private
   @Unstable
-  void setApplicationResourceUsageReport(ApplicationResourceUsageReport appResources);
+  public abstract void setApplicationResourceUsageReport(ApplicationResourceUsageReport appResources);
 
   /**
    * Get the application's progress ( range 0.0 to 1.0 )
@@ -260,11 +291,11 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  float getProgress();
+  public abstract float getProgress();
 
   @Private
   @Unstable
-  void setProgress(float progress);
+  public abstract void setProgress(float progress);
   
   /**
    * Get the application's Type 
@@ -272,9 +303,9 @@ public interface ApplicationReport {
    */
   @Public
   @Stable
-  String getApplicationType();
+  public abstract String getApplicationType();
 
   @Private
   @Unstable
-  void setApplicationType(String applicationType);
+  public abstract void setApplicationType(String applicationType);
 }

+ 26 - 15
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationResourceUsageReport.java

@@ -18,21 +18,32 @@
 
 package org.apache.hadoop.yarn.api.records;
 
-import java.io.DataInput;
-import java.io.DataOutput;
-import java.io.IOException;
-
 import org.apache.hadoop.classification.InterfaceAudience.Private;
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * Contains various scheduling metrics to be reported by UI and CLI.
  */
 @Public
 @Stable
-public interface ApplicationResourceUsageReport {
+public abstract class ApplicationResourceUsageReport {
+
+  @Private
+  public static ApplicationResourceUsageReport newInstance(
+      int numUsedContainers, int numReservedContainers, Resource usedResources,
+      Resource reservedResources, Resource neededResources) {
+    ApplicationResourceUsageReport report =
+        Records.newRecord(ApplicationResourceUsageReport.class);
+    report.setNumUsedContainers(numUsedContainers);
+    report.setNumReservedContainers(numReservedContainers);
+    report.setUsedResources(usedResources);
+    report.setReservedResources(reservedResources);
+    report.setNeededResources(neededResources);
+    return report;
+  }
 
   /**
    * Get the number of used containers
@@ -40,7 +51,7 @@ public interface ApplicationResourceUsageReport {
    */
   @Public
   @Stable
-  int getNumUsedContainers();
+  public abstract int getNumUsedContainers();
 
   /**
    * Set the number of used containers
@@ -48,7 +59,7 @@ public interface ApplicationResourceUsageReport {
    */
   @Private
   @Unstable
-  void setNumUsedContainers(int num_containers);
+  public abstract void setNumUsedContainers(int num_containers);
 
   /**
    * Get the number of reserved containers
@@ -56,7 +67,7 @@ public interface ApplicationResourceUsageReport {
    */
   @Public
   @Stable
-  int getNumReservedContainers();
+  public abstract int getNumReservedContainers();
 
   /**
    * Set the number of reserved containers
@@ -64,7 +75,7 @@ public interface ApplicationResourceUsageReport {
    */
   @Private
   @Unstable
-  void setNumReservedContainers(int num_reserved_containers);
+  public abstract void setNumReservedContainers(int num_reserved_containers);
 
   /**
    * Get the used <code>Resource</code>
@@ -72,11 +83,11 @@ public interface ApplicationResourceUsageReport {
    */
   @Public
   @Stable
-  Resource getUsedResources();
+  public abstract Resource getUsedResources();
 
   @Private
   @Unstable
-  void setUsedResources(Resource resources);
+  public abstract void setUsedResources(Resource resources);
 
   /**
    * Get the reserved <code>Resource</code>
@@ -84,11 +95,11 @@ public interface ApplicationResourceUsageReport {
    */
   @Public
   @Stable
-  Resource getReservedResources();
+  public abstract Resource getReservedResources();
 
   @Private
   @Unstable
-  void setReservedResources(Resource reserved_resources);
+  public abstract void setReservedResources(Resource reserved_resources);
 
   /**
    * Get the needed <code>Resource</code>
@@ -96,9 +107,9 @@ public interface ApplicationResourceUsageReport {
    */
   @Public
   @Stable
-  Resource getNeededResources();
+  public abstract Resource getNeededResources();
 
   @Private
   @Unstable
-  void setNeededResources(Resource needed_resources);
+  public abstract void setNeededResources(Resource needed_resources);
 }

+ 0 - 38
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationStatus.java

@@ -1,38 +0,0 @@
-/**
-* Licensed to the Apache Software Foundation (ASF) under one
-* or more contributor license agreements.  See the NOTICE file
-* distributed with this work for additional information
-* regarding copyright ownership.  The ASF licenses this file
-* to you under the Apache License, Version 2.0 (the
-* "License"); you may not use this file except in compliance
-* with the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-package org.apache.hadoop.yarn.api.records;
-
-import org.apache.hadoop.classification.InterfaceAudience.Private;
-import org.apache.hadoop.classification.InterfaceStability.Unstable;
-
-/**
- * <em>For internal use only...</em> 
- */
-@Private
-@Unstable
-public interface ApplicationStatus {
-  ApplicationAttemptId getApplicationAttemptId();
-  void setApplicationAttemptId(ApplicationAttemptId applicationAttemptId);
-  
-  int getResponseId();
-  void setResponseId(int id);
-  
-  float getProgress();
-  void setProgress(float progress);
-}

+ 57 - 21
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationSubmissionContext.java

@@ -23,6 +23,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
 import org.apache.hadoop.yarn.api.ClientRMProtocol;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>ApplicationSubmissionContext</code> represents all of the
@@ -47,14 +48,49 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
  */
 @Public
 @Stable
-public interface ApplicationSubmissionContext {
+public abstract class ApplicationSubmissionContext {
+
+  @Public
+  @Stable
+  public static ApplicationSubmissionContext newInstance(
+      ApplicationId applicationId, String applicationName, String queue,
+      Priority priority, ContainerLaunchContext amContainer,
+      boolean isUnmanagedAM, boolean cancelTokensWhenComplete,
+      int maxAppAttempts, Resource resource, String applicationType) {
+    ApplicationSubmissionContext context =
+        Records.newRecord(ApplicationSubmissionContext.class);
+    context.setApplicationId(applicationId);
+    context.setApplicationName(applicationName);
+    context.setQueue(queue);
+    context.setPriority(priority);
+    context.setAMContainerSpec(amContainer);
+    context.setUnmanagedAM(isUnmanagedAM);
+    context.setCancelTokensWhenComplete(cancelTokensWhenComplete);
+    context.setMaxAppAttempts(maxAppAttempts);
+    context.setResource(resource);
+    context.setApplicationType(applicationType);
+    return context;
+  }
+
+  @Public
+  @Stable
+  public static ApplicationSubmissionContext newInstance(
+      ApplicationId applicationId, String applicationName, String queue,
+      Priority priority, ContainerLaunchContext amContainer,
+      boolean isUnmanagedAM, boolean cancelTokensWhenComplete,
+      int maxAppAttempts, Resource resource) {
+    return newInstance(applicationId, applicationName, queue, priority,
+      amContainer, isUnmanagedAM, cancelTokensWhenComplete, maxAppAttempts,
+      resource, null);
+  }
+
   /**
    * Get the <code>ApplicationId</code> of the submitted application.
    * @return <code>ApplicationId</code> of the submitted application
    */
   @Public
   @Stable
-  public ApplicationId getApplicationId();
+  public abstract ApplicationId getApplicationId();
   
   /**
    * Set the <code>ApplicationId</code> of the submitted application.
@@ -63,7 +99,7 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Stable
-  public void setApplicationId(ApplicationId applicationId);
+  public abstract void setApplicationId(ApplicationId applicationId);
 
   /**
    * Get the application <em>name</em>.
@@ -71,7 +107,7 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Stable
-  public String getApplicationName();
+  public abstract String getApplicationName();
   
   /**
    * Set the application <em>name</em>.
@@ -79,7 +115,7 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Stable
-  public void setApplicationName(String applicationName);
+  public abstract void setApplicationName(String applicationName);
   
   /**
    * Get the <em>queue</em> to which the application is being submitted.
@@ -87,7 +123,7 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Stable
-  public String getQueue();
+  public abstract String getQueue();
   
   /**
    * Set the <em>queue</em> to which the application is being submitted
@@ -95,7 +131,7 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Stable
-  public void setQueue(String queue);
+  public abstract void setQueue(String queue);
   
   /**
    * Get the <code>Priority</code> of the application.
@@ -103,7 +139,7 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Stable
-  public Priority getPriority();
+  public abstract Priority getPriority();
 
   /**
    * Set the <code>Priority</code> of the application.
@@ -111,7 +147,7 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Stable
-  public void setPriority(Priority priority);
+  public abstract void setPriority(Priority priority);
 
   /**
    * Get the <code>ContainerLaunchContext</code> to describe the 
@@ -122,7 +158,7 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Stable
-  public ContainerLaunchContext getAMContainerSpec();
+  public abstract ContainerLaunchContext getAMContainerSpec();
   
   /**
    * Set the <code>ContainerLaunchContext</code> to describe the 
@@ -133,7 +169,7 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Stable
-  public void setAMContainerSpec(ContainerLaunchContext amContainer);
+  public abstract void setAMContainerSpec(ContainerLaunchContext amContainer);
   
   /**
    * Get if the RM should manage the execution of the AM. 
@@ -148,21 +184,21 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Unstable
-  public boolean getUnmanagedAM();
+  public abstract boolean getUnmanagedAM();
   
   /**
    * @param value true if RM should not manage the AM
    */
   @Public
   @Unstable
-  public void setUnmanagedAM(boolean value);
+  public abstract void setUnmanagedAM(boolean value);
 
   /**
    * @return true if tokens should be canceled when the app completes.
    */
   @LimitedPrivate("mapreduce")
   @Unstable
-  public boolean getCancelTokensWhenComplete();
+  public abstract boolean getCancelTokensWhenComplete();
   
   /**
    * Set to false if tokens should not be canceled when the app finished else
@@ -172,14 +208,14 @@ public interface ApplicationSubmissionContext {
    */
   @LimitedPrivate("mapreduce")
   @Unstable
-  public void setCancelTokensWhenComplete(boolean cancel);
+  public abstract void setCancelTokensWhenComplete(boolean cancel);
 
   /**
    * @return the number of max attempts of the application to be submitted
    */
   @Public
   @Unstable
-  public int getMaxAppAttempts();
+  public abstract int getMaxAppAttempts();
 
   /**
    * Set the number of max attempts of the application to be submitted. WARNING:
@@ -190,15 +226,15 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Unstable
-  public void setMaxAppAttempts(int maxAppAttempts);
+  public abstract void setMaxAppAttempts(int maxAppAttempts);
 
   @Public
   @Stable
-  public Resource getResource();
+  public abstract Resource getResource();
 
   @Public
   @Stable
-  public void setResource(Resource resource);
+  public abstract void setResource(Resource resource);
   
   /**
    * Get the <em>applicationType</em> is the application type
@@ -207,7 +243,7 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Stable
-  public String getApplicationType();
+  public abstract String getApplicationType();
 
   /**
    * Set the <em>applicationType</em> is the application type
@@ -217,5 +253,5 @@ public interface ApplicationSubmissionContext {
    */
   @Public
   @Stable
-  public void setApplicationType(String applicationType);
+  public abstract void setApplicationType(String applicationType);
 }

+ 32 - 15
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Container.java

@@ -24,6 +24,7 @@ import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
 import org.apache.hadoop.yarn.api.AMRMProtocol;
 import org.apache.hadoop.yarn.api.ContainerManager;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>Container</code> represents an allocated resource in the cluster.
@@ -63,18 +64,34 @@ import org.apache.hadoop.yarn.api.ContainerManager;
  */
 @Public
 @Stable
-public interface Container extends Comparable<Container> {
+public abstract class Container implements Comparable<Container> {
+
+  @Private
+  public static Container newInstance(ContainerId containerId, NodeId nodeId,
+      String nodeHttpAddress, Resource resource, Priority priority,
+      ContainerToken containerToken, long rmIdentifier) {
+    Container container = Records.newRecord(Container.class);
+    container.setId(containerId);
+    container.setNodeId(nodeId);
+    container.setNodeHttpAddress(nodeHttpAddress);
+    container.setResource(resource);
+    container.setPriority(priority);
+    container.setContainerToken(containerToken);
+    container.setRMIdentifier(rmIdentifier);
+    return container;
+  }
+
   /**
    * Get the globally unique identifier for the container.
    * @return globally unique identifier for the container
    */
   @Public
   @Stable
-  ContainerId getId();
+  public abstract ContainerId getId();
   
   @Private
   @Unstable
-  void setId(ContainerId id);
+  public abstract void setId(ContainerId id);
 
   /**
    * Get the identifier of the node on which the container is allocated.
@@ -82,11 +99,11 @@ public interface Container extends Comparable<Container> {
    */
   @Public
   @Stable
-  NodeId getNodeId();
+  public abstract NodeId getNodeId();
   
   @Private
   @Unstable
-  void setNodeId(NodeId nodeId);
+  public abstract void setNodeId(NodeId nodeId);
   
   /**
    * Get the http uri of the node on which the container is allocated.
@@ -94,11 +111,11 @@ public interface Container extends Comparable<Container> {
    */
   @Public
   @Stable
-  String getNodeHttpAddress();
+  public abstract String getNodeHttpAddress();
   
   @Private
   @Unstable
-  void setNodeHttpAddress(String nodeHttpAddress);
+  public abstract void setNodeHttpAddress(String nodeHttpAddress);
   
   /**
    * Get the <code>Resource</code> allocated to the container.
@@ -106,11 +123,11 @@ public interface Container extends Comparable<Container> {
    */
   @Public
   @Stable
-  Resource getResource();
+  public abstract Resource getResource();
   
   @Private
   @Unstable
-  void setResource(Resource resource);
+  public abstract void setResource(Resource resource);
 
   /**
    * Get the <code>Priority</code> at which the <code>Container</code> was
@@ -118,11 +135,11 @@ public interface Container extends Comparable<Container> {
    * @return <code>Priority</code> at which the <code>Container</code> was
    *         allocated
    */
-  Priority getPriority();
+  public abstract Priority getPriority();
   
   @Private
   @Unstable
-  void setPriority(Priority priority);
+  public abstract void setPriority(Priority priority);
   
   /**
    * Get the <code>ContainerToken</code> for the container.
@@ -130,11 +147,11 @@ public interface Container extends Comparable<Container> {
    */
   @Public
   @Stable
-  ContainerToken getContainerToken();
+  public abstract ContainerToken getContainerToken();
   
   @Private
   @Unstable
-  void setContainerToken(ContainerToken containerToken);
+  public abstract void setContainerToken(ContainerToken containerToken);
 
   /**
    * Get the RMIdentifier of RM in which containers are allocated
@@ -142,9 +159,9 @@ public interface Container extends Comparable<Container> {
    */
   @Private
   @Unstable
-  long getRMIdentifer();
+  public abstract long getRMIdentifer();
 
   @Private
   @Unstable
-  void setRMIdentifier(long rmIdentifier);
+  public abstract void setRMIdentifier(long rmIdentifier);
 }

+ 11 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerId.java

@@ -24,6 +24,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>ContainerId</code> represents a globally unique identifier
@@ -32,6 +33,16 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable;
 @Public
 @Stable
 public abstract class ContainerId implements Comparable<ContainerId>{
+
+  @Private
+  public static ContainerId newInstance(ApplicationAttemptId appAttemptId,
+      int containerId) {
+    ContainerId id = Records.newRecord(ContainerId.class);
+    id.setId(containerId);
+    id.setApplicationAttemptId(appAttemptId);
+    return id;
+  }
+
   /**
    * Get the <code>ApplicationAttemptId</code> of the application to which
    * the <code>Container</code> was assigned.

+ 36 - 15
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerLaunchContext.java

@@ -25,6 +25,7 @@ import java.util.Map;
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.yarn.api.ContainerManager;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>ContainerLaunchContext</code> represents all of the information
@@ -50,14 +51,34 @@ import org.apache.hadoop.yarn.api.ContainerManager;
  */
 @Public
 @Stable
-public interface ContainerLaunchContext {
+public abstract class ContainerLaunchContext {
+
+  @Public
+  @Stable
+  public static ContainerLaunchContext newInstance(
+      String user, Map<String, LocalResource> localResources,
+      Map<String, String> environment, List<String> commands,
+      Map<String, ByteBuffer> serviceData,  ByteBuffer tokens,
+      Map<ApplicationAccessType, String> acls) {
+    ContainerLaunchContext container =
+        Records.newRecord(ContainerLaunchContext.class);
+    container.setUser(user);
+    container.setLocalResources(localResources);
+    container.setEnvironment(environment);
+    container.setCommands(commands);
+    container.setServiceData(serviceData);
+    container.setTokens(tokens);
+    container.setApplicationACLs(acls);
+    return container;
+  }
+
   /**
    * Get the <em>user</em> to whom the container has been allocated.
    * @return the <em>user</em> to whom the container has been allocated
    */
   @Public
   @Stable
-  String getUser();
+  public abstract String getUser();
   
   /**
    * Set the <em>user</em> to whom the container has been allocated
@@ -65,7 +86,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  void setUser(String user);
+  public abstract void setUser(String user);
 
   /**
    * Get all the tokens needed by this container. It may include file-system
@@ -77,7 +98,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  ByteBuffer getTokens();
+  public abstract ByteBuffer getTokens();
 
   /**
    * Set security tokens needed by this container.
@@ -85,7 +106,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  void setTokens(ByteBuffer tokens);
+  public abstract void setTokens(ByteBuffer tokens);
 
   /**
    * Get <code>LocalResource</code> required by the container.
@@ -93,7 +114,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  Map<String, LocalResource> getLocalResources();
+  public abstract Map<String, LocalResource> getLocalResources();
   
   /**
    * Set <code>LocalResource</code> required by the container. All pre-existing
@@ -102,7 +123,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  void setLocalResources(Map<String, LocalResource> localResources);
+  public abstract void setLocalResources(Map<String, LocalResource> localResources);
 
   /**
    * Get application-specific binary <em>service data</em>.
@@ -110,7 +131,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  Map<String, ByteBuffer> getServiceData();
+  public abstract Map<String, ByteBuffer> getServiceData();
   
   /**
    * Set application-specific binary <em>service data</em>. All pre-existing Map
@@ -119,7 +140,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  void setServiceData(Map<String, ByteBuffer> serviceData);
+  public abstract void setServiceData(Map<String, ByteBuffer> serviceData);
 
   /**
    * Get <em>environment variables</em> for the container.
@@ -127,7 +148,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  Map<String, String> getEnvironment();
+  public abstract Map<String, String> getEnvironment();
     
   /**
    * Add <em>environment variables</em> for the container. All pre-existing Map
@@ -136,7 +157,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  void setEnvironment(Map<String, String> environment);
+  public abstract void setEnvironment(Map<String, String> environment);
 
   /**
    * Get the list of <em>commands</em> for launching the container.
@@ -144,7 +165,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  List<String> getCommands();
+  public abstract List<String> getCommands();
   
   /**
    * Add the list of <em>commands</em> for launching the container. All
@@ -153,7 +174,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  void setCommands(List<String> commands);
+  public abstract void setCommands(List<String> commands);
 
   /**
    * Get the <code>ApplicationACL</code>s for the application. 
@@ -161,7 +182,7 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  public Map<ApplicationAccessType, String> getApplicationACLs();
+  public abstract  Map<ApplicationAccessType, String> getApplicationACLs();
 
   /**
    * Set the <code>ApplicationACL</code>s for the application. All pre-existing
@@ -170,5 +191,5 @@ public interface ContainerLaunchContext {
    */
   @Public
   @Stable
-  public void setApplicationACLs(Map<ApplicationAccessType, String> acls);
+  public abstract  void setApplicationACLs(Map<ApplicationAccessType, String> acls);
 }

+ 22 - 9
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ContainerStatus.java

@@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>ContainerStatus</code> represents the current status of a 
@@ -38,18 +39,30 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable;
  */
 @Public
 @Stable
-public interface ContainerStatus {
+public abstract class ContainerStatus {
+
+  @Private
+  public static ContainerStatus newInstance(ContainerId containerId,
+      ContainerState containerState, String diagnostics, int exitStatus) {
+    ContainerStatus containerStatus = Records.newRecord(ContainerStatus.class);
+    containerStatus.setState(containerState);
+    containerStatus.setContainerId(containerId);
+    containerStatus.setDiagnostics(diagnostics);
+    containerStatus.setExitStatus(exitStatus);
+    return containerStatus;
+  }
+
   /**
    * Get the <code>ContainerId</code> of the container.
    * @return <code>ContainerId</code> of the container
    */
   @Public
   @Stable
-  ContainerId getContainerId();
+  public abstract ContainerId getContainerId();
   
   @Private
   @Unstable
-  void setContainerId(ContainerId containerId);
+  public abstract void setContainerId(ContainerId containerId);
 
   /**
    * Get the <code>ContainerState</code> of the container.
@@ -57,11 +70,11 @@ public interface ContainerStatus {
    */
   @Public
   @Stable
-  ContainerState getState();
+  public abstract ContainerState getState();
   
   @Private
   @Unstable
-  void setState(ContainerState state);
+  public abstract void setState(ContainerState state);
 
   /**
    * <p>Get the <em>exit status</em> for the container.</p>
@@ -84,11 +97,11 @@ public interface ContainerStatus {
    */
   @Public
   @Stable
-  int getExitStatus();
+  public abstract int getExitStatus();
   
   @Private
   @Unstable
-  void setExitStatus(int exitStatus);
+  public abstract void setExitStatus(int exitStatus);
 
   /**
    * Get <em>diagnostic messages</em> for failed containers.
@@ -96,9 +109,9 @@ public interface ContainerStatus {
    */
   @Public
   @Stable
-  String getDiagnostics();
+  public abstract String getDiagnostics();
   
   @Private
   @Unstable
-  void setDiagnostics(String diagnostics);
+  public abstract void setDiagnostics(String diagnostics);
 }

+ 37 - 13
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/LocalResource.java

@@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.api.records;
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.yarn.api.ContainerManager;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>LocalResource</code> represents a local resource required to
@@ -40,56 +41,79 @@ import org.apache.hadoop.yarn.api.ContainerManager;
  */
 @Public
 @Stable
-public interface LocalResource {
+public abstract class LocalResource {
+
+  @Public
+  @Stable
+  public static LocalResource newInstance(URL url, LocalResourceType type,
+      LocalResourceVisibility visibility, long size, long timestamp,
+      String pattern) {
+    LocalResource resource = Records.newRecord(LocalResource.class);
+    resource.setResource(url);
+    resource.setType(type);
+    resource.setVisibility(visibility);
+    resource.setSize(size);
+    resource.setTimestamp(timestamp);
+    resource.setPattern(pattern);
+    return resource;
+  }
+
+  @Public
+  @Stable
+  public static LocalResource newInstance(URL url, LocalResourceType type,
+      LocalResourceVisibility visibility, long size, long timestamp) {
+    return newInstance(url, type, visibility, size, timestamp, null);
+  }
+
   /**
    * Get the <em>location</em> of the resource to be localized.
    * @return <em>location</em> of the resource to be localized
    */
-  public URL getResource();
+  public abstract URL getResource();
   
   /**
    * Set <em>location</em> of the resource to be localized.
    * @param resource <em>location</em> of the resource to be localized
    */
-  public void setResource(URL resource);
+  public abstract void setResource(URL resource);
   
   /**
    * Get the <em>size</em> of the resource to be localized.
    * @return <em>size</em> of the resource to be localized
    */
-  public long getSize();
+  public abstract long getSize();
   
   /**
    * Set the <em>size</em> of the resource to be localized.
    * @param size <em>size</em> of the resource to be localized
    */
-  public void setSize(long size);
+  public abstract void setSize(long size);
   
   /**
    * Get the original <em>timestamp</em> of the resource to be localized, used
    * for verification.
    * @return <em>timestamp</em> of the resource to be localized
    */
-  public long getTimestamp();
+  public abstract long getTimestamp();
   
   /**
    * Set the <em>timestamp</em> of the resource to be localized, used
    * for verification.
    * @param timestamp <em>timestamp</em> of the resource to be localized
    */
-  public void setTimestamp(long timestamp);
+  public abstract void setTimestamp(long timestamp);
   
   /**
    * Get the <code>LocalResourceType</code> of the resource to be localized.
    * @return <code>LocalResourceType</code> of the resource to be localized
    */
-  public LocalResourceType getType();
+  public abstract LocalResourceType getType();
   
   /**
    * Set the <code>LocalResourceType</code> of the resource to be localized.
    * @param type <code>LocalResourceType</code> of the resource to be localized
    */
-  public void setType(LocalResourceType type);
+  public abstract void setType(LocalResourceType type);
   
   /**
    * Get the <code>LocalResourceVisibility</code> of the resource to be 
@@ -97,7 +121,7 @@ public interface LocalResource {
    * @return <code>LocalResourceVisibility</code> of the resource to be 
    *         localized
    */
-  public LocalResourceVisibility getVisibility();
+  public abstract LocalResourceVisibility getVisibility();
   
   /**
    * Set the <code>LocalResourceVisibility</code> of the resource to be 
@@ -105,7 +129,7 @@ public interface LocalResource {
    * @param visibility <code>LocalResourceVisibility</code> of the resource to be 
    *                   localized
    */
-  public void setVisibility(LocalResourceVisibility visibility);
+  public abstract void setVisibility(LocalResourceVisibility visibility);
   
   /**
    * Get the <em>pattern</em> that should be used to extract entries from the
@@ -113,7 +137,7 @@ public interface LocalResource {
    * @return <em>pattern</em> that should be used to extract entries from the 
    * archive. 
    */
-  public String getPattern();
+  public abstract String getPattern();
   
   /**
    * Set the <em>pattern</em> that should be used to extract entries from the
@@ -121,5 +145,5 @@ public interface LocalResource {
    * @param pattern <em>pattern</em> that should be used to extract entries 
    * from the archive.
    */
-  public void setPattern(String pattern);
+  public abstract void setPattern(String pattern);
 }

+ 18 - 7
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/NodeHealthStatus.java

@@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
 import org.apache.hadoop.yarn.api.ClientRMProtocol;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>NodeHealthStatus</code> is a summary of the health status of the
@@ -43,7 +44,17 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
  */
 @Public
 @Stable
-public interface NodeHealthStatus {
+public abstract class NodeHealthStatus {
+
+  @Private
+  public static NodeHealthStatus newInstance(boolean isNodeHealthy,
+      String healthReport, long lastHealthReport) {
+    NodeHealthStatus status = Records.newRecord(NodeHealthStatus.class);
+    status.setIsNodeHealthy(isNodeHealthy);
+    status.setHealthReport(healthReport);
+    status.setLastHealthReportTime(lastHealthReport);
+    return status;
+  }
 
   /**
    * Is the node healthy?
@@ -51,11 +62,11 @@ public interface NodeHealthStatus {
    */
   @Public
   @Stable
-  boolean getIsNodeHealthy();
+  public abstract boolean getIsNodeHealthy();
 
   @Private
   @Unstable
-  void setIsNodeHealthy(boolean isNodeHealthy);
+  public abstract void setIsNodeHealthy(boolean isNodeHealthy);
 
   /**
    * Get the <em>diagnostic health report</em> of the node.
@@ -63,11 +74,11 @@ public interface NodeHealthStatus {
    */
   @Public
   @Stable
-  String getHealthReport();
+  public abstract String getHealthReport();
 
   @Private
   @Unstable
-  void setHealthReport(String healthReport);
+  public abstract void setHealthReport(String healthReport);
 
   /**
    * Get the <em>last timestamp</em> at which the health report was received.
@@ -75,9 +86,9 @@ public interface NodeHealthStatus {
    */
   @Public
   @Stable
-  long getLastHealthReportTime();
+  public abstract long getLastHealthReportTime();
 
   @Private
   @Unstable
-  void setLastHealthReportTime(long lastHealthReport);
+  public abstract void setLastHealthReportTime(long lastHealthReport);
 }

+ 9 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/NodeId.java

@@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>NodeId</code> is the unique identifier for a node.</p>
@@ -34,6 +35,14 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable;
 @Stable
 public abstract class NodeId implements Comparable<NodeId> {
 
+  @Private
+  public static NodeId newInstance(String host, int port) {
+    NodeId nodeId = Records.newRecord(NodeId.class);
+    nodeId.setHost(host);
+    nodeId.setPort(port);
+    return nodeId;
+  }
+
   /**
    * Get the <em>hostname</em> of the node.
    * @return <em>hostname</em> of the node

+ 35 - 17
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/NodeReport.java

@@ -23,6 +23,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
 import org.apache.hadoop.yarn.api.ClientRMProtocol;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>NodeReport</code> is a summary of runtime information of a 
@@ -45,26 +46,43 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
  */
 @Public
 @Stable
-public interface NodeReport {
+public abstract class NodeReport {
+
+  @Private
+  public static NodeReport newInstance(NodeId nodeId, NodeState nodeState,
+      String httpAddress, String rackName, Resource used, Resource capability,
+      int numContainers, NodeHealthStatus nodeHealthStatus) {
+    NodeReport nodeReport = Records.newRecord(NodeReport.class);
+    nodeReport.setNodeId(nodeId);
+    nodeReport.setNodeState(nodeState);
+    nodeReport.setHttpAddress(httpAddress);
+    nodeReport.setRackName(rackName);
+    nodeReport.setUsed(used);
+    nodeReport.setCapability(capability);
+    nodeReport.setNumContainers(numContainers);
+    nodeReport.setNodeHealthStatus(nodeHealthStatus);
+    return nodeReport;
+  }
+
   /**
    * Get the <code>NodeId</code> of the node.
    * @return <code>NodeId</code> of the node
    */
-  NodeId getNodeId();
+  public abstract NodeId getNodeId();
   
   @Private
   @Unstable
-  void setNodeId(NodeId nodeId);
+  public abstract void setNodeId(NodeId nodeId);
   
   /**
    * Get the <code>NodeState</code> of the node.
    * @return <code>NodeState</code> of the node
    */
-  NodeState getNodeState();
+  public abstract NodeState getNodeState();
   
   @Private
   @Unstable
-  void setNodeState(NodeState nodeState);
+  public abstract void setNodeState(NodeState nodeState);
   
   /**
    * Get the <em>http address</em> of the node.
@@ -72,11 +90,11 @@ public interface NodeReport {
    */
   @Public
   @Stable
-  String getHttpAddress();
+  public abstract String getHttpAddress();
   
   @Private
   @Unstable
-  void setHttpAddress(String httpAddress);
+  public abstract void setHttpAddress(String httpAddress);
   
   /**
    * Get the <em>rack name</em> for the node.
@@ -84,11 +102,11 @@ public interface NodeReport {
    */
   @Public
   @Stable
-  String getRackName();
+  public abstract String getRackName();
   
   @Private
   @Unstable
-  void setRackName(String rackName);
+  public abstract void setRackName(String rackName);
   
   /**
    * Get <em>used</em> <code>Resource</code> on the node.
@@ -96,11 +114,11 @@ public interface NodeReport {
    */
   @Public
   @Stable
-  Resource getUsed();        
+  public abstract Resource getUsed();
   
   @Private
   @Unstable
-  void setUsed(Resource used);
+  public abstract void setUsed(Resource used);
   
   /**
    * Get the <em>total</em> <code>Resource</code> on the node.
@@ -108,11 +126,11 @@ public interface NodeReport {
    */
   @Public
   @Stable
-  Resource getCapability();
+  public abstract Resource getCapability();
   
   @Private
   @Unstable
-  void setCapability(Resource capability);
+  public abstract void setCapability(Resource capability);
   
   /**
    * Get the <em>number of running containers</em> on the node.
@@ -120,11 +138,11 @@ public interface NodeReport {
    */
   @Public
   @Stable
-  int getNumContainers();
+  public abstract int getNumContainers();
   
   @Private
   @Unstable
-  void setNumContainers(int numContainers);
+  public abstract void setNumContainers(int numContainers);
   
   /**
    * Get the <code>NodeHealthStatus</code> of the node. 
@@ -132,9 +150,9 @@ public interface NodeReport {
    */
   @Public
   @Stable
-  NodeHealthStatus getNodeHealthStatus();
+  public abstract NodeHealthStatus getNodeHealthStatus();
   
   @Private
   @Unstable
-  void setNodeHealthStatus(NodeHealthStatus nodeHealthStatus);
+  public abstract void setNodeHealthStatus(NodeHealthStatus nodeHealthStatus);
 }

+ 13 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Priority.java

@@ -18,13 +18,25 @@
 
 package org.apache.hadoop.yarn.api.records;
 
+import org.apache.hadoop.classification.InterfaceAudience.Public;
+import org.apache.hadoop.classification.InterfaceStability.Stable;
+import org.apache.hadoop.yarn.util.Records;
+
 /**
  * The priority assigned to a ResourceRequest or Application or Container 
  * allocation 
  *
  */
 public abstract class Priority implements Comparable<Priority> {
-  
+
+  @Public
+  @Stable
+  public static Priority newInstance(int p) {
+    Priority priority = Records.newRecord(Priority.class);
+    priority.setPriority(p);
+    return priority;
+  }
+
   /**
    * Get the assigned priority
    * @return the assigned priority

+ 33 - 15
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueInfo.java

@@ -25,6 +25,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
 import org.apache.hadoop.yarn.api.ClientRMProtocol;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p>QueueInfo is a report of the runtime information of the queue.</p>
@@ -46,18 +47,35 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
  */
 @Public
 @Stable
-public interface QueueInfo {
+public abstract class QueueInfo {
+
+  @Private
+  public static QueueInfo newInstance(String queueName, float capacity,
+      float maximumCapacity, float currentCapacity,
+      List<QueueInfo> childQueues, List<ApplicationReport> applications,
+      QueueState queueState) {
+    QueueInfo queueInfo = Records.newRecord(QueueInfo.class);
+    queueInfo.setQueueName(queueName);
+    queueInfo.setCapacity(capacity);
+    queueInfo.setMaximumCapacity(maximumCapacity);
+    queueInfo.setCurrentCapacity(currentCapacity);
+    queueInfo.setChildQueues(childQueues);
+    queueInfo.setApplications(applications);
+    queueInfo.setQueueState(queueState);
+    return queueInfo;
+  }
+
   /**
    * Get the <em>name</em> of the queue.
    * @return <em>name</em> of the queue
    */
   @Public
   @Stable
-  String getQueueName();
+  public abstract String getQueueName();
   
   @Private
   @Unstable
-  void setQueueName(String queueName);
+  public abstract void setQueueName(String queueName);
   
   /**
    * Get the <em>configured capacity</em> of the queue.
@@ -65,11 +83,11 @@ public interface QueueInfo {
    */
   @Public
   @Stable
-  float getCapacity();
+  public abstract float getCapacity();
   
   @Private
   @Unstable
-  void setCapacity(float capacity);
+  public abstract void setCapacity(float capacity);
   
   /**
    * Get the <em>maximum capacity</em> of the queue.
@@ -77,11 +95,11 @@ public interface QueueInfo {
    */
   @Public
   @Stable
-  float getMaximumCapacity();
+  public abstract float getMaximumCapacity();
   
   @Private
   @Unstable
-  void setMaximumCapacity(float maximumCapacity);
+  public abstract void setMaximumCapacity(float maximumCapacity);
   
   /**
    * Get the <em>current capacity</em> of the queue.
@@ -89,11 +107,11 @@ public interface QueueInfo {
    */
   @Public
   @Stable
-  float getCurrentCapacity();
+  public abstract float getCurrentCapacity();
   
   @Private
   @Unstable
-  void setCurrentCapacity(float currentCapacity);
+  public abstract void setCurrentCapacity(float currentCapacity);
   
   /**
    * Get the <em>child queues</em> of the queue.
@@ -101,11 +119,11 @@ public interface QueueInfo {
    */
   @Public
   @Stable
-  List<QueueInfo> getChildQueues();
+  public abstract List<QueueInfo> getChildQueues();
   
   @Private
   @Unstable
-  void setChildQueues(List<QueueInfo> childQueues);
+  public abstract void setChildQueues(List<QueueInfo> childQueues);
   
   /**
    * Get the <em>running applications</em> of the queue.
@@ -113,11 +131,11 @@ public interface QueueInfo {
    */
   @Public
   @Stable
-  List<ApplicationReport> getApplications();
+  public abstract List<ApplicationReport> getApplications();
   
   @Private
   @Unstable
-  void setApplications(List<ApplicationReport> applications);
+  public abstract void setApplications(List<ApplicationReport> applications);
   
   /**
    * Get the <code>QueueState</code> of the queue.
@@ -125,9 +143,9 @@ public interface QueueInfo {
    */
   @Public
   @Stable
-  QueueState getQueueState();
+  public abstract QueueState getQueueState();
   
   @Private
   @Unstable
-  void setQueueState(QueueState queueState);
+  public abstract void setQueueState(QueueState queueState);
 }

+ 16 - 5
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/QueueUserACLInfo.java

@@ -25,6 +25,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
 import org.apache.hadoop.yarn.api.ClientRMProtocol;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>QueueUserACLInfo</code> provides information {@link QueueACL} for
@@ -35,18 +36,28 @@ import org.apache.hadoop.yarn.api.ClientRMProtocol;
  */
 @Public
 @Stable
-public interface QueueUserACLInfo {
+public abstract class QueueUserACLInfo {
+
+  @Private
+  public static QueueUserACLInfo newInstance(String queueName,
+      List<QueueACL> acls) {
+    QueueUserACLInfo info = Records.newRecord(QueueUserACLInfo.class);
+    info.setQueueName(queueName);
+    info.setUserAcls(acls);
+    return info;
+  }
+
   /**
    * Get the <em>queue name</em> of the queue.
    * @return <em>queue name</em> of the queue
    */
   @Public
   @Stable
-  String getQueueName();
+  public abstract String getQueueName();
   
   @Private
   @Unstable
-  void setQueueName(String queueName);
+  public abstract void setQueueName(String queueName);
 
   /**
    * Get the list of <code>QueueACL</code> for the given user.
@@ -54,9 +65,9 @@ public interface QueueUserACLInfo {
    */
   @Public
   @Stable
-  List<QueueACL> getUserAcls();
+  public abstract List<QueueACL> getUserAcls();
 
   @Private
   @Unstable
-  void setUserAcls(List<QueueACL> acls);
+  public abstract void setUserAcls(List<QueueACL> acls);
 }

+ 10 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/Resource.java

@@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Evolving;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.yarn.api.AMRMProtocol;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>Resource</code> models a set of computer resources in the 
@@ -39,6 +40,15 @@ import org.apache.hadoop.yarn.api.AMRMProtocol;
 @Stable
 public abstract class Resource implements Comparable<Resource> {
 
+  @Public
+  @Stable
+  public static Resource newInstance(int memory, int vCores) {
+    Resource resource = Records.newRecord(Resource.class);
+    resource.setMemory(memory);
+    resource.setVirtualCores(vCores);
+    return resource;
+  }
+
   /**
    * Get <em>memory</em> of the resource.
    * @return <em>memory</em> of the resource

+ 13 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ResourceRequest.java

@@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.api.records;
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.yarn.api.AMRMProtocol;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>ResourceRequest</code> represents the request made by an
@@ -50,6 +51,18 @@ import org.apache.hadoop.yarn.api.AMRMProtocol;
 @Stable
 public abstract class ResourceRequest implements Comparable<ResourceRequest> {
 
+  @Public
+  @Stable
+  public static ResourceRequest newInstance(Priority priority,
+      String hostName, Resource capability, int numContainers) {
+    ResourceRequest request = Records.newRecord(ResourceRequest.class);
+    request.setPriority(priority);
+    request.setHostName(hostName);
+    request.setCapability(capability);
+    request.setNumContainers(numContainers);
+    return request;
+  }
+
   /**
    * The constant string representing no locality.
    * It should be used by all references that want to pass an arbitrary host

+ 15 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/URL.java

@@ -20,14 +20,27 @@ package org.apache.hadoop.yarn.api.records;
 
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Evolving;
+import org.apache.hadoop.classification.InterfaceStability.Stable;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>URL</code> represents a serializable {@link java.net.URL}.</p>
  */
 @Public
 @Evolving
-public interface URL {
-  
+public abstract class URL {
+
+  @Public
+  @Stable
+  public static URL newInstance(String scheme, String host, int port, String file) {
+    URL url = Records.newRecord(URL.class);
+    url.setScheme(scheme);
+    url.setHost(host);
+    url.setPort(port);
+    url.setFile(file);
+    return url;
+  }
+
   /**
    * Get the scheme of the URL.
    * @return scheme of the URL

+ 9 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/YarnClusterMetrics.java

@@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
 import org.apache.hadoop.classification.InterfaceAudience.Public;
 import org.apache.hadoop.classification.InterfaceStability.Stable;
 import org.apache.hadoop.classification.InterfaceStability.Unstable;
+import org.apache.hadoop.yarn.util.Records;
 
 /**
  * <p><code>YarnClusterMetrics</code> represents cluster metrics.</p>
@@ -30,8 +31,15 @@ import org.apache.hadoop.classification.InterfaceStability.Unstable;
  */
 @Public
 @Stable
-public interface YarnClusterMetrics {
+public abstract class YarnClusterMetrics {
   
+  @Private
+  public static YarnClusterMetrics newInstance(int numNodeManagers) {
+    YarnClusterMetrics metrics = Records.newRecord(YarnClusterMetrics.class);
+    metrics.setNumNodeManagers(numNodeManagers);
+    return metrics;
+  }
+
   /**
    * Get the number of <code>NodeManager</code>s in the cluster.
    * @return number of <code>NodeManager</code>s in the cluster

+ 0 - 294
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationMasterPBImpl.java

@@ -1,294 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.yarn.api.records.impl.pb;
-
-import org.apache.hadoop.security.proto.SecurityProtos.TokenProto;
-import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.ApplicationMaster;
-import org.apache.hadoop.yarn.api.records.ApplicationStatus;
-import org.apache.hadoop.yarn.api.records.ClientToken;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
-import org.apache.hadoop.yarn.api.records.YarnApplicationState;
-import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto;
-import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationMasterProto;
-import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationMasterProtoOrBuilder;
-import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationStatusProto;
-import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationStateProto;
-import org.apache.hadoop.yarn.util.ProtoUtils;
-
-public class ApplicationMasterPBImpl extends ProtoBase<ApplicationMasterProto>
-    implements ApplicationMaster {
-  ApplicationMasterProto proto = ApplicationMasterProto.getDefaultInstance();
-  ApplicationMasterProto.Builder builder = null;
-  boolean viaProto = false;
-
-  private ApplicationId applicationId = null;
-  private ApplicationStatus applicationStatus = null;
-  private ClientToken clientToken = null;
-
-  public ApplicationMasterPBImpl() {
-    builder = ApplicationMasterProto.newBuilder();
-  }
-
-  public ApplicationMasterPBImpl(ApplicationMasterProto proto) {
-    this.proto = proto;
-    viaProto = true;
-  }
-
-  public ApplicationMasterProto getProto() {
-
-      mergeLocalToProto();
-    proto = viaProto ? proto : builder.build();
-    viaProto = true;
-    return proto;
-  }
-
-  private void mergeLocalToBuilder() {
-    if (this.applicationId != null
-        && !((ApplicationIdPBImpl) this.applicationId).getProto().equals(
-          builder.getApplicationId())) {
-      builder.setApplicationId(convertToProtoFormat(this.applicationId));
-    }
-
-    if (this.applicationStatus != null
-        && !((ApplicationStatusPBImpl) this.applicationStatus).getProto()
-          .equals(builder.getStatus())) {
-      builder.setStatus(convertToProtoFormat(this.applicationStatus));
-    }
-    if (this.clientToken != null
-        && !((ClientTokenPBImpl) this.clientToken).getProto().equals(
-          builder.getClientToken())) {
-      builder.setClientToken(convertToProtoFormat(this.clientToken));
-    }
-  }
-
-  private void mergeLocalToProto() {
-    if (viaProto)
-      maybeInitBuilder();
-    mergeLocalToBuilder();
-    proto = builder.build();
-
-    viaProto = true;
-  }
-
-  private void maybeInitBuilder() {
-    if (viaProto || builder == null) {
-      builder = ApplicationMasterProto.newBuilder(proto);
-    }
-    viaProto = false;
-  }
-
-
-  @Override
-  public YarnApplicationState getState() {
-    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
-    if (!p.hasState()) {
-      return null;
-    }
-    return convertFromProtoFormat(p.getState());
-  }
-
-  @Override
-  public void setState(YarnApplicationState state) {
-    maybeInitBuilder();
-    if (state == null) {
-      builder.clearState();
-      return;
-    }
-    builder.setState(convertToProtoFormat(state));
-  }
-  @Override
-  public String getHost() {
-    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
-    if (!p.hasHost()) {
-      return null;
-    }
-    return (p.getHost());
-  }
-
-  @Override
-  public void setHost(String host) {
-    maybeInitBuilder();
-    if (host == null) {
-      builder.clearHost();
-      return;
-    }
-    builder.setHost((host));
-  }
-
-  @Override
-  public ApplicationId getApplicationId() {
-    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.applicationId != null) {
-      return applicationId;
-    } // Else via proto
-    if (!p.hasApplicationId()) {
-      return null;
-    }
-    applicationId = convertFromProtoFormat(p.getApplicationId());
-
-    return applicationId;
-  }
-
-  @Override
-  public void setApplicationId(ApplicationId applicationId) {
-    maybeInitBuilder();
-    if (applicationId == null)
-      builder.clearApplicationId();
-    this.applicationId = applicationId;
-
-  }
-  @Override
-  public int getRpcPort() {
-    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
-    return (p.getRpcPort());
-  }
-
-  @Override
-  public void setRpcPort(int rpcPort) {
-    maybeInitBuilder();
-    builder.setRpcPort((rpcPort));
-  }
-  @Override
-  public String getTrackingUrl() {
-    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
-    return (p.getTrackingUrl());
-  }
-
-  @Override
-  public void setTrackingUrl(String url) {
-    maybeInitBuilder();
-    builder.setTrackingUrl(url);
-  }
-  @Override
-  public ApplicationStatus getStatus() {
-    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.applicationStatus != null) {
-      return this.applicationStatus;
-    } // Else via proto
-    if (!p.hasStatus()) {
-      return null;
-    }
-    this.applicationStatus = convertFromProtoFormat(p.getStatus());
-
-    return this.applicationStatus;
-  }
-
-  @Override
-  public void setStatus(ApplicationStatus status) {
-    maybeInitBuilder();
-    if (status == null)
-      builder.clearStatus();
-    this.applicationStatus = status;
-
-  }
-
-  @Override
-  public ClientToken getClientToken() {
-    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.clientToken != null) {
-      return this.clientToken;
-    }
-    if (!p.hasClientToken()) {
-      return null;
-    }
-    this.clientToken = convertFromProtoFormat(p.getClientToken());
-    return this.clientToken;
-  }
-  
-  @Override
-  public void setClientToken(ClientToken clientToken) {
-    maybeInitBuilder();
-    if (clientToken == null) 
-      builder.clearClientToken();
-    this.clientToken = clientToken;
-  }
-
-  @Override
-  public int getAMFailCount() {
-    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
-    return (p.getAmFailCount());
-  }
-
-  @Override
-  public int getContainerCount() {
-    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
-    return (p.getContainerCount());
-  }
-
-  @Override
-  public void setAMFailCount(int amFailCount) {
-    maybeInitBuilder();
-    builder.setAmFailCount(amFailCount);
-  }
-
-  @Override
-  public void setContainerCount(int containerCount) {
-    maybeInitBuilder();
-    builder.setContainerCount(containerCount);
-  }
-
-  @Override
-  public String getDiagnostics() {
-    ApplicationMasterProtoOrBuilder p = viaProto ? proto : builder;
-    return p.getDiagnostics();
-  }
-
-  @Override
-  public void setDiagnostics(String diagnostics) {
-    maybeInitBuilder();
-    if (diagnostics == null) {
-      builder.clearDiagnostics();
-      return;
-    }
-    builder.setDiagnostics(diagnostics);
-  }
-
-  private YarnApplicationStateProto convertToProtoFormat(YarnApplicationState e) {
-    return ProtoUtils.convertToProtoFormat(e);
-  }
-
-  private YarnApplicationState convertFromProtoFormat(YarnApplicationStateProto e) {
-    return ProtoUtils.convertFromProtoFormat(e);
-  }
-
-  private ApplicationIdPBImpl convertFromProtoFormat(ApplicationIdProto p) {
-    return new ApplicationIdPBImpl(p);
-  }
-
-  private ApplicationIdProto convertToProtoFormat(ApplicationId t) {
-    return ((ApplicationIdPBImpl)t).getProto();
-  }
-
-  private ApplicationStatusPBImpl convertFromProtoFormat(ApplicationStatusProto p) {
-    return new ApplicationStatusPBImpl(p);
-  }
-
-  private ApplicationStatusProto convertToProtoFormat(ApplicationStatus t) {
-    return ((ApplicationStatusPBImpl)t).getProto();
-  }
-
-  private ClientTokenPBImpl convertFromProtoFormat(TokenProto p) {
-    return new ClientTokenPBImpl(p);
-  }
-
-  private TokenProto convertToProtoFormat(ClientToken t) {
-    return ((ClientTokenPBImpl)t).getProto();
-  }
-}

+ 21 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java

@@ -25,7 +25,6 @@ import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport;
 import org.apache.hadoop.yarn.api.records.ClientToken;
 import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto;
@@ -36,8 +35,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.FinalApplicationStatusProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.YarnApplicationStateProto;
 import org.apache.hadoop.yarn.util.ProtoUtils;
 
-public class ApplicationReportPBImpl extends ProtoBase<ApplicationReportProto>
-implements ApplicationReport {
+public class ApplicationReportPBImpl extends ApplicationReport {
   ApplicationReportProto proto = ApplicationReportProto.getDefaultInstance();
   ApplicationReportProto.Builder builder = null;
   boolean viaProto = false;
@@ -376,7 +374,6 @@ implements ApplicationReport {
     builder.setProgress(progress);
   }
 
-  @Override
   public ApplicationReportProto getProto() {
     mergeLocalToProto();
     proto = viaProto ? proto : builder.build();
@@ -384,6 +381,26 @@ implements ApplicationReport {
     return proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
   private void mergeLocalToBuilder() {
     if (this.applicationId != null
         && !((ApplicationIdPBImpl) this.applicationId).getProto().equals(

+ 21 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationResourceUsageReportPBImpl.java

@@ -19,15 +19,13 @@
 package org.apache.hadoop.yarn.api.records.impl.pb;
 
 import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationResourceUsageReportProtoOrBuilder;
 import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
 
 public class ApplicationResourceUsageReportPBImpl 
-extends ProtoBase<ApplicationResourceUsageReportProto> 
-implements ApplicationResourceUsageReport {
+extends ApplicationResourceUsageReport {
   ApplicationResourceUsageReportProto proto = 
       ApplicationResourceUsageReportProto.getDefaultInstance();
   ApplicationResourceUsageReportProto.Builder builder = null;
@@ -54,6 +52,26 @@ implements ApplicationResourceUsageReport {
     return proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
   private void mergeLocalToBuilder() {
     if (this.usedResources != null
         && !((ResourcePBImpl) this.usedResources).getProto().equals(

+ 0 - 134
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationStatusPBImpl.java

@@ -1,134 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.yarn.api.records.impl.pb;
-
-
-import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
-import org.apache.hadoop.yarn.api.records.ApplicationStatus;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
-import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationAttemptIdProto;
-import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationStatusProto;
-import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationStatusProtoOrBuilder;
-
-
-    
-public class ApplicationStatusPBImpl extends ProtoBase<ApplicationStatusProto> implements ApplicationStatus {
-  ApplicationStatusProto proto = ApplicationStatusProto.getDefaultInstance();
-  ApplicationStatusProto.Builder builder = null;
-  boolean viaProto = false;
-  
-  private ApplicationAttemptId applicationAttemptId = null;  
-  
-  
-  public ApplicationStatusPBImpl() {
-    builder = ApplicationStatusProto.newBuilder();
-  }
-
-  public ApplicationStatusPBImpl(ApplicationStatusProto proto) {
-    this.proto = proto;
-    viaProto = true;
-  }
-  
-  public ApplicationStatusProto getProto() {
-  
-      mergeLocalToProto();
-    proto = viaProto ? proto : builder.build();
-    viaProto = true;
-    return proto;
-  }
-
-  private void mergeLocalToBuilder() {
-    if (this.applicationAttemptId != null && !((ApplicationAttemptIdPBImpl)this.applicationAttemptId).getProto().equals(builder.getApplicationAttemptId())) {
-      builder.setApplicationAttemptId(convertToProtoFormat(this.applicationAttemptId));
-    }
-  }
-
-  private void mergeLocalToProto() {
-    if (viaProto) 
-      maybeInitBuilder();
-    mergeLocalToBuilder();
-    proto = builder.build();
-    
-    viaProto = true;
-  }
-
-  private void maybeInitBuilder() {
-    if (viaProto || builder == null) {
-      builder = ApplicationStatusProto.newBuilder(proto);
-    }
-    viaProto = false;
-  }
-    
-  
-  @Override
-  public int getResponseId() {
-    ApplicationStatusProtoOrBuilder p = viaProto ? proto : builder;
-    return (p.getResponseId());
-  }
-
-  @Override
-  public void setResponseId(int responseId) {
-    maybeInitBuilder();
-    builder.setResponseId((responseId));
-  }
-
-  @Override
-  public ApplicationAttemptId getApplicationAttemptId() {
-    ApplicationStatusProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.applicationAttemptId != null) {
-      return this.applicationAttemptId;
-    }
-    if (!p.hasApplicationAttemptId()) {
-      return null;
-    }
-    this.applicationAttemptId = convertFromProtoFormat(p.getApplicationAttemptId());
-    return this.applicationAttemptId;
-  }
-
-  @Override
-  public void setApplicationAttemptId(ApplicationAttemptId applicationAttemptId) {
-    maybeInitBuilder();
-    if (applicationAttemptId == null) 
-      builder.clearApplicationAttemptId();
-    this.applicationAttemptId = applicationAttemptId;
-  }
-
-  @Override
-  public float getProgress() {
-    ApplicationStatusProtoOrBuilder p = viaProto ? proto : builder;
-    return (p.getProgress());
-  }
-
-  @Override
-  public void setProgress(float progress) {
-    maybeInitBuilder();
-    builder.setProgress((progress));
-  }
-
-  private ApplicationAttemptIdPBImpl convertFromProtoFormat(ApplicationAttemptIdProto p) {
-    return new ApplicationAttemptIdPBImpl(p);
-  }
-
-  private ApplicationAttemptIdProto convertToProtoFormat(ApplicationAttemptId t) {
-    return ((ApplicationAttemptIdPBImpl)t).getProto();
-  }
-
-
-
-}  

+ 21 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationSubmissionContextPBImpl.java

@@ -22,7 +22,6 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
 import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
 import org.apache.hadoop.yarn.api.records.Priority;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationIdProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationSubmissionContextProto;
@@ -32,8 +31,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
     
 public class ApplicationSubmissionContextPBImpl 
-extends ProtoBase<ApplicationSubmissionContextProto> 
-implements ApplicationSubmissionContext {
+extends ApplicationSubmissionContext {
   ApplicationSubmissionContextProto proto = 
       ApplicationSubmissionContextProto.getDefaultInstance();
   ApplicationSubmissionContextProto.Builder builder = null;
@@ -61,6 +59,26 @@ implements ApplicationSubmissionContext {
     return proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
   private void mergeLocalToBuilder() {
     if (this.applicationId != null) {
       builder.setApplicationId(convertToProtoFormat(this.applicationId));

+ 32 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerLaunchContextPBImpl.java

@@ -28,7 +28,6 @@ import java.util.Map;
 import org.apache.hadoop.yarn.api.records.ApplicationAccessType;
 import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
 import org.apache.hadoop.yarn.api.records.LocalResource;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationACLMapProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerLaunchContextProtoOrBuilder;
@@ -38,9 +37,10 @@ import org.apache.hadoop.yarn.proto.YarnProtos.StringLocalResourceMapProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.StringStringMapProto;
 import org.apache.hadoop.yarn.util.ProtoUtils;
 
+import com.google.protobuf.ByteString;
+
 public class ContainerLaunchContextPBImpl 
-extends ProtoBase<ContainerLaunchContextProto> 
-implements ContainerLaunchContext {
+extends ContainerLaunchContext {
   ContainerLaunchContextProto proto = 
       ContainerLaunchContextProto.getDefaultInstance();
   ContainerLaunchContextProto.Builder builder = null;
@@ -68,7 +68,35 @@ implements ContainerLaunchContext {
     viaProto = true;
     return proto;
   }
-  
+
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
+  protected final ByteBuffer convertFromProtoFormat(ByteString byteString) {
+    return ProtoUtils.convertFromProtoFormat(byteString);
+  }
+
+  protected final ByteString convertToProtoFormat(ByteBuffer byteBuffer) {
+    return ProtoUtils.convertToProtoFormat(byteBuffer);
+  }
+
   private void mergeLocalToBuilder() {
     if (this.localResources != null) {
       addLocalResourcesToProto();

+ 16 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerPBImpl.java

@@ -24,7 +24,6 @@ import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerToken;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.Priority;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerProto;
@@ -33,7 +32,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.PriorityProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
     
-public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Container {
+public class ContainerPBImpl extends Container {
 
   ContainerProto proto = ContainerProto.getDefaultInstance();
   ContainerProto.Builder builder = null;
@@ -62,6 +61,21 @@ public class ContainerPBImpl extends ProtoBase<ContainerProto> implements Contai
     return proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
   private void mergeLocalToBuilder() {
     if (this.containerId != null
         && !((ContainerIdPBImpl) containerId).getProto().equals(

+ 21 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ContainerStatusPBImpl.java

@@ -22,7 +22,6 @@ package org.apache.hadoop.yarn.api.records.impl.pb;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.ContainerState;
 import org.apache.hadoop.yarn.api.records.ContainerStatus;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerIdProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStateProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.ContainerStatusProto;
@@ -31,8 +30,7 @@ import org.apache.hadoop.yarn.util.ProtoUtils;
 
 
     
-public class ContainerStatusPBImpl extends ProtoBase<ContainerStatusProto> 
-implements ContainerStatus {
+public class ContainerStatusPBImpl extends ContainerStatus {
   ContainerStatusProto proto = ContainerStatusProto.getDefaultInstance();
   ContainerStatusProto.Builder builder = null;
   boolean viaProto = false;
@@ -56,6 +54,26 @@ implements ContainerStatus {
     return proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
   private void mergeLocalToBuilder() {
     if (containerId != null) {
       builder.setContainerId(convertToProtoFormat(this.containerId));

+ 21 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/LocalResourcePBImpl.java

@@ -21,7 +21,6 @@ package org.apache.hadoop.yarn.api.records.impl.pb;
 import org.apache.hadoop.yarn.api.records.LocalResource;
 import org.apache.hadoop.yarn.api.records.LocalResourceType;
 import org.apache.hadoop.yarn.api.records.LocalResourceVisibility;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.api.records.URL;
 import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.LocalResourceProtoOrBuilder;
@@ -32,8 +31,7 @@ import org.apache.hadoop.yarn.util.ProtoUtils;
 
 
     
-public class LocalResourcePBImpl extends ProtoBase<LocalResourceProto>
-    implements LocalResource {
+public class LocalResourcePBImpl extends LocalResource {
   LocalResourceProto proto = LocalResourceProto.getDefaultInstance();
   LocalResourceProto.Builder builder = null;
   boolean viaProto = false;
@@ -56,6 +54,26 @@ public class LocalResourcePBImpl extends ProtoBase<LocalResourceProto>
     return proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
   private synchronized void mergeLocalToBuilder() {
     LocalResourceProtoOrBuilder l = viaProto ? proto : builder;
     if (this.url != null

+ 21 - 3
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeHealthStatusPBImpl.java

@@ -19,12 +19,10 @@
 package org.apache.hadoop.yarn.api.records.impl.pb;
 
 import org.apache.hadoop.yarn.api.records.NodeHealthStatus;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeHealthStatusProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeHealthStatusProtoOrBuilder;
 
-public class NodeHealthStatusPBImpl extends ProtoBase<NodeHealthStatusProto>
-    implements NodeHealthStatus {
+public class NodeHealthStatusPBImpl extends NodeHealthStatus {
 
   private NodeHealthStatusProto.Builder builder;
   private boolean viaProto = false;
@@ -47,6 +45,26 @@ public class NodeHealthStatusPBImpl extends ProtoBase<NodeHealthStatusProto>
     return this.proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
   private void mergeLocalToProto() {
     if (this.viaProto)
       maybeInitBuilder();

+ 21 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/NodeReportPBImpl.java

@@ -22,7 +22,6 @@ import org.apache.hadoop.yarn.api.records.NodeHealthStatus;
 import org.apache.hadoop.yarn.api.records.NodeId;
 import org.apache.hadoop.yarn.api.records.NodeReport;
 import org.apache.hadoop.yarn.api.records.NodeState;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.api.records.Resource;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeHealthStatusProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.NodeIdProto;
@@ -31,8 +30,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.NodeReportProtoOrBuilder;
 import org.apache.hadoop.yarn.proto.YarnProtos.ResourceProto;
 import org.apache.hadoop.yarn.util.ProtoUtils;
 
-public class NodeReportPBImpl extends ProtoBase<NodeReportProto>
-    implements NodeReport {
+public class NodeReportPBImpl extends NodeReport {
 
   private NodeReportProto proto = NodeReportProto.getDefaultInstance();
   private NodeReportProto.Builder builder = null;
@@ -206,7 +204,6 @@ public class NodeReportPBImpl extends ProtoBase<NodeReportProto>
     this.used = used;
   }
 
-  @Override
   public NodeReportProto getProto() {
     mergeLocalToProto();
     proto = viaProto ? proto : builder.build();
@@ -214,6 +211,26 @@ public class NodeReportPBImpl extends ProtoBase<NodeReportProto>
     return proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
   private void mergeLocalToBuilder() {
     if (this.nodeId != null
         && !((NodeIdPBImpl) this.nodeId).getProto().equals(

+ 21 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueInfoPBImpl.java

@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.api.records.QueueInfo;
 import org.apache.hadoop.yarn.api.records.QueueState;
 import org.apache.hadoop.yarn.proto.YarnProtos.ApplicationReportProto;
@@ -32,8 +31,7 @@ import org.apache.hadoop.yarn.proto.YarnProtos.QueueInfoProtoOrBuilder;
 import org.apache.hadoop.yarn.proto.YarnProtos.QueueStateProto;
 import org.apache.hadoop.yarn.util.ProtoUtils;
 
-public class QueueInfoPBImpl extends ProtoBase<QueueInfoProto> implements
-    QueueInfo {
+public class QueueInfoPBImpl extends QueueInfo {
 
   QueueInfoProto proto = QueueInfoProto.getDefaultInstance();
   QueueInfoProto.Builder builder = null;
@@ -150,7 +148,6 @@ public class QueueInfoPBImpl extends ProtoBase<QueueInfoProto> implements
     builder.setState(convertToProtoFormat(queueState));
   }
 
-  @Override
   public QueueInfoProto getProto() {
     mergeLocalToProto();
     proto = viaProto ? proto : builder.build();
@@ -158,6 +155,26 @@ public class QueueInfoPBImpl extends ProtoBase<QueueInfoProto> implements
     return proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
   private void initLocalApplicationsList() {
     if (this.applicationsList != null) {
       return;

+ 21 - 4
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/QueueUserACLInfoPBImpl.java

@@ -23,15 +23,13 @@ import java.util.Iterator;
 import java.util.List;
 
 import org.apache.hadoop.yarn.api.records.QueueACL;
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.api.records.QueueUserACLInfo;
 import org.apache.hadoop.yarn.proto.YarnProtos.QueueACLProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.QueueUserACLInfoProtoOrBuilder;
 import org.apache.hadoop.yarn.util.ProtoUtils;
 
-public class QueueUserACLInfoPBImpl extends ProtoBase<QueueUserACLInfoProto> 
-implements QueueUserACLInfo {
+public class QueueUserACLInfoPBImpl extends QueueUserACLInfo {
 
   QueueUserACLInfoProto proto = QueueUserACLInfoProto.getDefaultInstance();
   QueueUserACLInfoProto.Builder builder = null;
@@ -78,7 +76,6 @@ implements QueueUserACLInfo {
     this.userAclsList = userAclsList;
   }
 
-  @Override
   public QueueUserACLInfoProto getProto() {
     mergeLocalToProto();
     proto = viaProto ? proto : builder.build();
@@ -86,6 +83,26 @@ implements QueueUserACLInfo {
     return proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
   private void initLocalQueueUserAclsList() {
     if (this.userAclsList != null) {
       return;

+ 21 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/URLPBImpl.java

@@ -19,14 +19,13 @@
 package org.apache.hadoop.yarn.api.records.impl.pb;
 
 
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.api.records.URL;
 import org.apache.hadoop.yarn.proto.YarnProtos.URLProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.URLProtoOrBuilder;
 
 
     
-public class URLPBImpl extends ProtoBase<URLProto> implements URL {
+public class URLPBImpl extends URL {
   URLProto proto = URLProto.getDefaultInstance();
   URLProto.Builder builder = null;
   boolean viaProto = false;
@@ -46,6 +45,26 @@ public class URLPBImpl extends ProtoBase<URLProto> implements URL {
     return proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
   private void maybeInitBuilder() {
     if (viaProto || builder == null) {
       builder = URLProto.newBuilder(proto);

+ 21 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/YarnClusterMetricsPBImpl.java

@@ -19,14 +19,13 @@
 package org.apache.hadoop.yarn.api.records.impl.pb;
 
 
-import org.apache.hadoop.yarn.api.records.ProtoBase;
 import org.apache.hadoop.yarn.api.records.YarnClusterMetrics;
 import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProto;
 import org.apache.hadoop.yarn.proto.YarnProtos.YarnClusterMetricsProtoOrBuilder;
 
 
     
-public class YarnClusterMetricsPBImpl extends ProtoBase<YarnClusterMetricsProto> implements YarnClusterMetrics {
+public class YarnClusterMetricsPBImpl extends YarnClusterMetrics {
   YarnClusterMetricsProto proto = YarnClusterMetricsProto.getDefaultInstance();
   YarnClusterMetricsProto.Builder builder = null;
   boolean viaProto = false;
@@ -46,6 +45,26 @@ public class YarnClusterMetricsPBImpl extends ProtoBase<YarnClusterMetricsProto>
     return proto;
   }
 
+  @Override
+  public int hashCode() {
+    return getProto().hashCode();
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == null)
+      return false;
+    if (other.getClass().isAssignableFrom(this.getClass())) {
+      return this.getProto().equals(this.getClass().cast(other).getProto());
+    }
+    return false;
+  }
+
+  @Override
+  public String toString() {
+    return getProto().toString().replaceAll("\\n", ", ").replaceAll("\\s+", " ");
+  }
+
   private void maybeInitBuilder() {
     if (viaProto || builder == null) {
       builder = YarnClusterMetricsProto.newBuilder(proto);

+ 1 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/LocalResourceRequest.java

@@ -28,7 +28,7 @@ import org.apache.hadoop.yarn.api.records.URL;
 import org.apache.hadoop.yarn.util.ConverterUtils;
 
 public class LocalResourceRequest
-    implements LocalResource, Comparable<LocalResourceRequest> {
+    extends LocalResource implements Comparable<LocalResourceRequest> {
 
   private final Path loc;
   private final long timestamp;

+ 0 - 106
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/MockAsm.java

@@ -25,15 +25,11 @@ import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.yarn.MockApps;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.ApplicationMaster;
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
-import org.apache.hadoop.yarn.api.records.ApplicationStatus;
 import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
-import org.apache.hadoop.yarn.api.records.ClientToken;
 import org.apache.hadoop.yarn.api.records.Container;
 import org.apache.hadoop.yarn.api.records.ContainerId;
 import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
-import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 import org.apache.hadoop.yarn.conf.YarnConfiguration;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp;
 import org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMAppEvent;
@@ -47,108 +43,6 @@ import com.google.common.collect.Lists;
 @InterfaceAudience.Private
 public abstract class MockAsm extends MockApps {
 
-  public static class AppMasterBase implements ApplicationMaster {
-    @Override
-    public ApplicationId getApplicationId() {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public String getHost() {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public int getRpcPort() {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public String getTrackingUrl() {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public ApplicationStatus getStatus() {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public YarnApplicationState getState() {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public ClientToken getClientToken() {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public int getAMFailCount() {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public int getContainerCount() {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public String getDiagnostics() {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void setApplicationId(ApplicationId appId) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void setHost(String host) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void setRpcPort(int rpcPort) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void setTrackingUrl(String url) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void setStatus(ApplicationStatus status) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void setState(YarnApplicationState state) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void setClientToken(ClientToken clientToken) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void setAMFailCount(int amFailCount) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void setContainerCount(int containerCount) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    @Override
-    public void setDiagnostics(String diagnostics) {
-      throw new UnsupportedOperationException("Not supported yet.");
-    }
-  }
-
   public static class ApplicationBase implements RMApp {
     @Override
     public String getUser() {

+ 0 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMLaunchFailure.java

@@ -30,7 +30,6 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.ApplicationMaster;
 import org.apache.hadoop.yarn.api.records.ApplicationReport;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;

+ 0 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestAMRestart.java

@@ -32,7 +32,6 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.protocolrecords.SubmitApplicationRequest;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.ApplicationMaster;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
 import org.apache.hadoop.yarn.api.records.Container;

+ 0 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestASMStateMachine.java

@@ -27,7 +27,6 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
-import org.apache.hadoop.yarn.api.records.ApplicationStatus;
 import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
 import org.apache.hadoop.yarn.event.EventHandler;
 import org.apache.hadoop.yarn.factories.RecordFactory;

+ 0 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/applicationsmanager/TestSchedulerNegotiator.java

@@ -27,7 +27,6 @@ import junit.framework.Assert;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.yarn.api.records.ApplicationId;
-import org.apache.hadoop.yarn.api.records.ApplicationMaster;
 import org.apache.hadoop.yarn.api.records.YarnApplicationState;
 import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext;
 import org.apache.hadoop.yarn.api.records.Container;