浏览代码

MAPREDUCE-2796. Set start times for MR applications for clients to see. Contributed by Devaraj K.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1161704 13f79535-47bb-0310-9956-ffa450edef68
Arun Murthy 13 年之前
父节点
当前提交
1dd113b24a

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

@@ -1143,6 +1143,9 @@ Trunk (unreleased changes)
     MAPREDUCE-2877. Add missing Apache license header in some files in MR 
     and also add the rat plugin to the poms. (mahadev)
 
+    MAPREDUCE-2796. Set start times for MR applications for clients to see.
+    (Devaraj K via acmurthy) 
+
 Release 0.22.0 - Unreleased
 
   INCOMPATIBLE CHANGES

+ 1 - 0
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/main/java/org/apache/hadoop/mapreduce/TypeConverter.java

@@ -409,6 +409,7 @@ public class TypeConverter {
           application.getQueue(), "", trackingUrl
       ); 
     jobStatus.setSchedulingInfo(trackingUrl); // Set AM tracking url
+    jobStatus.setStartTime(application.getStartTime());
     return jobStatus;
   }
 

+ 42 - 0
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-common/src/test/java/org/apache/hadoop/mapreduce/TestTypeConverter.java

@@ -0,0 +1,42 @@
+/**
+ * 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.mapreduce;
+
+import junit.framework.Assert;
+
+import org.apache.hadoop.yarn.api.records.ApplicationId;
+import org.apache.hadoop.yarn.api.records.ApplicationState;
+import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationIdPBImpl;
+import org.apache.hadoop.yarn.api.records.impl.pb.ApplicationReportPBImpl;
+import org.junit.Test;
+
+public class TestTypeConverter {
+  @Test
+  public void testFromYarn() throws Exception {
+    int appStartTime = 612354;
+    ApplicationState state = ApplicationState.RUNNING;
+    ApplicationId applicationId = new ApplicationIdPBImpl();
+    ApplicationReportPBImpl applicationReport = new ApplicationReportPBImpl();
+    applicationReport.setApplicationId(applicationId);
+    applicationReport.setState(state);
+    applicationReport.setStartTime(appStartTime);
+    JobStatus jobStatus = TypeConverter.fromYarn(applicationReport);
+    Assert.assertEquals(appStartTime, jobStatus.getStartTime());
+    Assert.assertEquals(state.toString(), jobStatus.getState().toString());
+  }
+}

+ 3 - 0
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/ApplicationReport.java

@@ -49,4 +49,7 @@ public interface ApplicationReport {
 
   String getTrackingUrl();
   void setTrackingUrl(String url);
+  
+  long getStartTime();
+  void setStartTime(long startTime);
 }

+ 12 - 0
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/api/records/impl/pb/ApplicationReportPBImpl.java

@@ -279,4 +279,16 @@ implements ApplicationReport {
       ApplicationIdProto applicationId) {
     return new ApplicationIdPBImpl(applicationId);
   }
+
+  @Override
+  public long getStartTime() {
+    ApplicationReportProtoOrBuilder p = viaProto ? proto : builder;
+    return p.getStartTime();
+  }
+
+  @Override
+  public void setStartTime(long startTime) {
+    maybeInitBuilder();
+    builder.setStartTime(startTime);
+  }
 }

+ 1 - 0
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-api/src/main/proto/yarn_protos.proto

@@ -139,6 +139,7 @@ message ApplicationReportProto {
   optional ContainerProto masterContainer = 10;
   optional string trackingUrl = 11;
   optional string diagnostics = 12 [default = "N/A"];
+  optional int64 startTime = 13;
 }
 
 message NodeIdProto {

+ 2 - 1
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/BuilderUtils.java

@@ -211,7 +211,7 @@ public class BuilderUtils {
   public static ApplicationReport newApplicationReport(
       ApplicationId applicationId, String user, String queue, String name,
       String host, int rpcPort, String clientToken, ApplicationState state,
-      String diagnostics, String url) {
+      String diagnostics, String url, long startTime) {
     ApplicationReport report = recordFactory
         .newRecordInstance(ApplicationReport.class);
     report.setApplicationId(applicationId);
@@ -224,6 +224,7 @@ public class BuilderUtils {
     report.setState(state);
     report.setDiagnostics(diagnostics);
     report.setTrackingUrl(url);
+    report.setStartTime(startTime);
     return report;
   }
 }

+ 12 - 0
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/MockApps.java

@@ -155,6 +155,18 @@ public class MockApps {
         // TODO Auto-generated method stub
         
       }
+      
+      @Override
+      public long getStartTime() {
+        // TODO Auto-generated method stub
+        return 0;
+      }
+
+      @Override
+      public void setStartTime(long startTime) {
+        // TODO Auto-generated method stub
+
+      }
     };
   }
 

+ 1 - 1
hadoop-mapreduce-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/rmapp/RMAppImpl.java

@@ -300,7 +300,7 @@ public class RMAppImpl implements RMApp {
       return BuilderUtils.newApplicationReport(this.applicationId, this.user,
           this.queue, this.name, host, rpcPort, clientToken,
           createApplicationState(this.stateMachine.getCurrentState()),
-          this.diagnostics.toString(), trackingUrl);
+          this.diagnostics.toString(), trackingUrl, this.startTime);
     } finally {
       this.readLock.unlock();
     }