Browse Source

HADOOP-486. Add the job username to JobStatus instances returned by JobClient.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@437846 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting 18 years ago
parent
commit
9060d2eacd

+ 3 - 0
CHANGES.txt

@@ -83,6 +83,9 @@ Trunk (unreleased changes)
 20. HADOOP-281.  Prohibit DFS files that are also directories.
     (Wendy Chien via cutting)
 
+21. HADOOP-486.  Add the job username to JobStatus instances returned
+    by JobClient.  (Mahadev Konar via cutting)
+
 
 Release 0.5.0 - 2006-08-04
 

+ 14 - 0
src/java/org/apache/hadoop/mapred/JobStatus.java

@@ -46,6 +46,7 @@ public class JobStatus implements Writable {
     float reduceProgress;
     int runState;
     long startTime;
+    String user;
     /**
      */
     public JobStatus() {
@@ -63,6 +64,7 @@ public class JobStatus implements Writable {
         this.mapProgress = mapProgress;
         this.reduceProgress = reduceProgress;
         this.runState = runState;
+        this.user = "nobody";
     }
 
     /**
@@ -107,6 +109,16 @@ public class JobStatus implements Writable {
      * @return start time of the job
      */
     public long getStartTime() { return startTime;};
+
+    /**
+      * @param user The username of the job
+      */
+    void setUsername(String userName) { this.user = userName;};
+
+    /**
+      * @return the username of the job
+      */
+    public String getUsername() { return this.user;};
     ///////////////////////////////////////
     // Writable
     ///////////////////////////////////////
@@ -116,6 +128,7 @@ public class JobStatus implements Writable {
         out.writeFloat(reduceProgress);
         out.writeInt(runState);
         out.writeLong(startTime);
+        UTF8.writeString(out, user);
     }
     public void readFields(DataInput in) throws IOException {
         this.jobid = UTF8.readString(in);
@@ -123,5 +136,6 @@ public class JobStatus implements Writable {
         this.reduceProgress = in.readFloat();
         this.runState = in.readInt();
         this.startTime = in.readLong();
+        this.user = UTF8.readString(in);
     }
 }

+ 1 - 0
src/java/org/apache/hadoop/mapred/JobTracker.java

@@ -1109,6 +1109,7 @@ public class JobTracker implements MRConstants, InterTrackerProtocol, JobSubmiss
             if (status.getRunState() == JobStatus.RUNNING 
 		|| status.getRunState() == JobStatus.PREP) {
 		status.setStartTime(jip.getStartTime());
+                status.setUsername(jip.getProfile().getUser());
                 v.add(status);
             }
         }