hadoop-mapreduce-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acmur...@apache.org
Subject svn commit: r1145871 - in /hadoop/common/trunk/mapreduce: ./ src/java/org/apache/hadoop/mapred/ src/java/org/apache/hadoop/mapreduce/ src/java/org/apache/hadoop/mapreduce/tools/
Date Wed, 13 Jul 2011 06:04:05 GMT
Author: acmurthy
Date: Wed Jul 13 06:04:04 2011
New Revision: 1145871

URL: http://svn.apache.org/viewvc?rev=1145871&view=rev
Log:
MAPREDUCE-2680. Display queue name in job client CLI.

Modified:
    hadoop/common/trunk/mapreduce/CHANGES.txt
    hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapred/JobClient.java
    hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapred/JobStatus.java
    hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/Cluster.java
    hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/JobStatus.java
    hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/tools/CLI.java

Modified: hadoop/common/trunk/mapreduce/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/mapreduce/CHANGES.txt?rev=1145871&r1=1145870&r2=1145871&view=diff
==============================================================================
--- hadoop/common/trunk/mapreduce/CHANGES.txt (original)
+++ hadoop/common/trunk/mapreduce/CHANGES.txt Wed Jul 13 06:04:04 2011
@@ -37,6 +37,8 @@ Trunk (unreleased changes)
 
   IMPROVEMENTS
 
+    MAPREDUCE-2680. Display queue name in job client CLI. (acmurthy) 
+ 
     MAPREDUCE-2679. Minor changes to sync trunk with MR-279 branch. (acmurthy) 
  
     MAPREDUCE-2400. Remove Cluster's dependency on JobTracker via a 

Modified: hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapred/JobClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapred/JobClient.java?rev=1145871&r1=1145870&r2=1145871&view=diff
==============================================================================
--- hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapred/JobClient.java (original)
+++ hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapred/JobClient.java Wed Jul
13 06:04:04 2011
@@ -755,10 +755,10 @@ public class JobClient extends CLI {
    */
   public JobStatus[] getAllJobs() throws IOException {
     try {
-      Job jobs[] = cluster.getAllJobs();
+      org.apache.hadoop.mapreduce.JobStatus[] jobs = cluster.getAllJobStatuses();
       JobStatus[] stats = new JobStatus[jobs.length];
       for (int i = 0; i < jobs.length; i++) {
-        stats[i] = JobStatus.downgrade(jobs[i].getStatus());
+        stats[i] = JobStatus.downgrade(jobs[i]);
       }
       return stats;
     } catch (InterruptedException ie) {
@@ -870,10 +870,10 @@ public class JobClient extends CLI {
   }
   
   void displayJobList(JobStatus[] jobs) {
-    System.out.printf("JobId\tState\tStartTime\tUserName\tPriority\tSchedulingInfo\n");
+    System.out.printf("JobId\tState\tStartTime\tUserName\tQueue\tPriority\tSchedulingInfo\n");
     for (JobStatus job : jobs) {
-      System.out.printf("%s\t%d\t%d\t%s\t%s\t%s\n", job.getJobID(), job.getRunState(),
-          job.getStartTime(), job.getUsername(), 
+      System.out.printf("%s\t%d\t%d\t%s\t%s\t%s\t%s\n", job.getJobID(), job.getRunState(),
+          job.getStartTime(), job.getUsername(), job.getQueue(), 
           job.getJobPriority().name(), job.getSchedulingInfo());
     }
   }

Modified: hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapred/JobStatus.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapred/JobStatus.java?rev=1145871&r1=1145870&r2=1145871&view=diff
==============================================================================
--- hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapred/JobStatus.java (original)
+++ hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapred/JobStatus.java Wed Jul
13 06:04:04 2011
@@ -156,11 +156,37 @@ public class JobStatus extends org.apach
                     float reduceProgress, float cleanupProgress, 
                     int runState, JobPriority jp, String user, String jobName, 
                     String jobFile, String trackingUrl) {
-     super(jobid, setupProgress, mapProgress, reduceProgress, cleanupProgress,
-       getEnum(runState), org.apache.hadoop.mapreduce.JobPriority.valueOf(jp.name()),
-       user, jobName, jobFile, trackingUrl);
+     this(jobid, setupProgress, mapProgress, reduceProgress, cleanupProgress,
+         runState, jp,
+         user, jobName, "default", jobFile, trackingUrl);
    }
    
+   /**
+    * Create a job status object for a given jobid.
+    * @param jobid The jobid of the job
+    * @param setupProgress The progress made on the setup
+    * @param mapProgress The progress made on the maps
+    * @param reduceProgress The progress made on the reduces
+    * @param cleanupProgress The progress made on the cleanup
+    * @param runState The current state of the job
+    * @param jp Priority of the job.
+    * @param user userid of the person who submitted the job.
+    * @param jobName user-specified job name.
+    * @param queue job queue name.
+    * @param jobFile job configuration file. 
+    * @param trackingUrl link to the web-ui for details of the job.
+    */
+   public JobStatus(JobID jobid, float setupProgress, float mapProgress,
+       float reduceProgress, float cleanupProgress, 
+       int runState, JobPriority jp, 
+       String user, String jobName, String queue, 
+       String jobFile, String trackingUrl) {
+     super(jobid, setupProgress, mapProgress, reduceProgress, cleanupProgress,
+         getEnum(runState), org.apache.hadoop.mapreduce.JobPriority.valueOf(jp.name()),
+         user, jobName, queue, jobFile, trackingUrl);
+   }
+
+
   public static JobStatus downgrade(org.apache.hadoop.mapreduce.JobStatus stat){
     JobStatus old = new JobStatus(JobID.downgrade(stat.getJobID()),
       stat.getSetupProgress(), stat.getMapProgress(), stat.getReduceProgress(),

Modified: hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/Cluster.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/Cluster.java?rev=1145871&r1=1145870&r2=1145871&view=diff
==============================================================================
--- hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/Cluster.java (original)
+++ hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/Cluster.java Wed Jul
13 06:04:04 2011
@@ -224,11 +224,23 @@ public class Cluster {
    * @return array of {@link Job}
    * @throws IOException
    * @throws InterruptedException
+   * @deprecated Use {@link #getAllJobStatuses()} instead.
    */
+  @Deprecated
   public Job[] getAllJobs() throws IOException, InterruptedException {
     return getJobs(client.getAllJobs());
   }
-  
+
+  /**
+   * Get job status for all jobs in the cluster.
+   * @return job status for all jobs in cluster
+   * @throws IOException
+   * @throws InterruptedException
+   */
+  public JobStatus[] getAllJobStatuses() throws IOException, InterruptedException {
+    return client.getAllJobs();
+  }
+
   /**
    * Grab the jobtracker system directory path where 
    * job-specific files will  be placed.

Modified: hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/JobStatus.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/JobStatus.java?rev=1145871&r1=1145870&r2=1145871&view=diff
==============================================================================
--- hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/JobStatus.java (original)
+++ hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/JobStatus.java Wed
Jul 13 06:04:04 2011
@@ -78,6 +78,7 @@ public class JobStatus implements Writab
   private State runState;
   private long startTime;
   private String user;
+  private String queue;
   private JobPriority priority;
   private String schedulingInfo="NA";
 
@@ -115,22 +116,48 @@ public class JobStatus implements Writab
                     float reduceProgress, float cleanupProgress, 
                     State runState, JobPriority jp, String user, String jobName, 
                     String jobFile, String trackingUrl) {
-     this.jobid = jobid;
-     this.setupProgress = setupProgress;
-     this.mapProgress = mapProgress;
-     this.reduceProgress = reduceProgress;
-     this.cleanupProgress = cleanupProgress;
-     this.runState = runState;
-     this.user = user;
-     if (jp == null) {
-       throw new IllegalArgumentException("Job Priority cannot be null.");
-     }
-     priority = jp;
-     this.jobName = jobName;
-     this.jobFile = jobFile;
-     this.trackingUrl = trackingUrl;
+     this(jobid, setupProgress, mapProgress, reduceProgress, cleanupProgress, 
+         runState, jp, user, jobName, "default", jobFile, trackingUrl);
    }
-   
+           
+   /**
+    * Create a job status object for a given jobid.
+    * @param jobid The jobid of the job
+    * @param setupProgress The progress made on the setup
+    * @param mapProgress The progress made on the maps
+    * @param reduceProgress The progress made on the reduces
+    * @param cleanupProgress The progress made on the cleanup
+    * @param runState The current state of the job
+    * @param jp Priority of the job.
+    * @param user userid of the person who submitted the job.
+    * @param jobName user-specified job name.
+    * @param queue queue name
+    * @param jobFile job configuration file. 
+    * @param trackingUrl link to the web-ui for details of the job.
+    */
+    public JobStatus(JobID jobid, float setupProgress, float mapProgress,
+                     float reduceProgress, float cleanupProgress, 
+                     State runState, JobPriority jp, 
+                     String user, String jobName, String queue, 
+                     String jobFile, String trackingUrl) {
+      this.jobid = jobid;
+      this.setupProgress = setupProgress;
+      this.mapProgress = mapProgress;
+      this.reduceProgress = reduceProgress;
+      this.cleanupProgress = cleanupProgress;
+      this.runState = runState;
+      this.user = user;
+      this.queue = queue;
+      if (jp == null) {
+        throw new IllegalArgumentException("Job Priority cannot be null.");
+      }
+      priority = jp;
+      this.jobName = jobName;
+      this.jobFile = jobFile;
+      this.trackingUrl = trackingUrl;
+    }
+    
+
   /**
    * Sets the map progress of this job
    * @param p The value of map progress to set to
@@ -244,6 +271,22 @@ public class JobStatus implements Writab
   }
 
   /**
+   * Set queue name
+   * @param queue queue name
+   */
+  protected synchronized void setQueue(String queue) {
+    this.queue = queue;
+  }
+
+  /**
+   * Get queue name
+   * @return queue name
+   */
+  public synchronized String getQueue() {
+    return queue;
+  }
+
+  /**
    * @return Percentage of progress in maps 
    */
   public synchronized float getMapProgress() { return mapProgress; }

Modified: hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/tools/CLI.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/tools/CLI.java?rev=1145871&r1=1145870&r2=1145871&view=diff
==============================================================================
--- hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/tools/CLI.java (original)
+++ hadoop/common/trunk/mapreduce/src/java/org/apache/hadoop/mapreduce/tools/CLI.java Wed
Jul 13 06:04:04 2011
@@ -444,13 +444,13 @@ public class CLI extends Configured impl
    */
   private void listJobs(Cluster cluster) 
       throws IOException, InterruptedException {
-    List<Job> runningJobs = new ArrayList<Job>();
-    for (Job job : cluster.getAllJobs()) {
-      if (!job.isComplete()) {
+    List<JobStatus> runningJobs = new ArrayList<JobStatus>();
+    for (JobStatus job : cluster.getAllJobStatuses()) {
+      if (!job.isJobComplete()) {
         runningJobs.add(job);
       }
     }
-    displayJobList(runningJobs.toArray(new Job[0]));
+    displayJobList(runningJobs.toArray(new JobStatus[0]));
   }
     
   /**
@@ -459,7 +459,7 @@ public class CLI extends Configured impl
    */
   private void listAllJobs(Cluster cluster) 
       throws IOException, InterruptedException {
-    displayJobList(cluster.getAllJobs());
+    displayJobList(cluster.getAllJobStatuses());
   }
   
   /**
@@ -523,15 +523,16 @@ public class CLI extends Configured impl
     }
   }
   
-  protected void displayJobList(Job[] jobs) 
+  protected void displayJobList(JobStatus[] jobs) 
       throws IOException, InterruptedException {
     System.out.println("Total jobs:" + jobs.length);
     System.out.println("JobId\tState\tStartTime\t" +
-      "UserName\tPriority\tSchedulingInfo");
-    for (Job job : jobs) {
-      System.out.printf("%s\t%s\t%d\t%s\t%s\t%s\n", job.getJobID().toString(),
-        job.getJobState(), job.getStartTime(),
-        job.getUser(), job.getPriority().name(), job.getSchedulingInfo());
+        "UserName\tQueue\tPriority\tSchedulingInfo");
+    for (JobStatus job : jobs) {
+      System.out.printf("%s\t%s\t%d\t%s\t%s\t%s\t%s\n", job.getJobID().toString(),
+          job.getState(), job.getStartTime(),
+          job.getUsername(), job.getQueue(), 
+          job.getPriority().name(), job.getSchedulingInfo());
     }
   }
   



Mime
View raw message