incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1079644 - in /incubator/hama/trunk: CHANGES.txt src/java/org/apache/hama/bsp/BSPJobClient.java
Date Wed, 09 Mar 2011 02:38:55 GMT
Author: edwardyoon
Date: Wed Mar  9 02:38:55 2011
New Revision: 1079644

URL: http://svn.apache.org/viewvc?rev=1079644&view=rev
Log:
Add job status command

Modified:
    incubator/hama/trunk/CHANGES.txt
    incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPJobClient.java

Modified: incubator/hama/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/CHANGES.txt?rev=1079644&r1=1079643&r2=1079644&view=diff
==============================================================================
--- incubator/hama/trunk/CHANGES.txt (original)
+++ incubator/hama/trunk/CHANGES.txt Wed Mar  9 02:38:55 2011
@@ -4,6 +4,7 @@ Trunk (unreleased changes)
 
   NEW FEATURES
 
+    HAMA-339: Add job status command (edwardyoon)
     HAMA-337: Provide Apache Maven building support (Tommaso Teofili via edwardyoon)
     HAMA-304: Allow BSP peers to get a list of all other peers 
                 executing tasks of the same job (Filipe Manana via edwardyoon)

Modified: incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPJobClient.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPJobClient.java?rev=1079644&r1=1079643&r2=1079644&view=diff
==============================================================================
--- incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPJobClient.java (original)
+++ incubator/hama/trunk/src/java/org/apache/hama/bsp/BSPJobClient.java Wed Mar  9 02:38:55
2011
@@ -473,6 +473,7 @@ public class BSPJobClient extends Config
     boolean listActiveGrooms = false;
     boolean killJob = false;
     boolean submitJob = false;
+    boolean getStatus = false;
     String submitJobFile = null;
     String jobid = null;
 
@@ -511,6 +512,14 @@ public class BSPJobClient extends Config
       killJob = true;
       jobid = args[1];
 
+    } else if ("-status".equals(cmd)) {
+      if (args.length != 2) {
+        displayUsage(cmd);
+        return exitCode;
+      }
+      jobid = args[1];
+      getStatus = true;
+      
       // TODO Later, below functions should be implemented
       // with the Fault Tolerant mechanism.
     } else if ("-list-attempt-ids".equals(cmd)) {
@@ -547,11 +556,35 @@ public class BSPJobClient extends Config
         System.out.println("Killed job " + jobid);
       }
       exitCode = 0;
+    } else if (getStatus) {
+      RunningJob job = jc.getJob(new BSPJobID().forName(jobid));
+      if (job == null) {
+        System.out.println("Could not find job " + jobid);
+      } else {
+        System.out.println("Job name: " + job.getJobName());
+        System.out.println("Job status: " + getStatusString(job.getJobState()));
+        exitCode = 0;
+      }
     }
 
     return 0;
   }
 
+  private String getStatusString(int jobState) {
+    if(jobState == 1)
+      return "Running";
+    else if (jobState == 2)
+      return "Succeded";
+    else if (jobState == 3)
+      return "Failed";
+    else if (jobState == 4)
+      return "Prepare";
+    else if (jobState == 5)
+      return "Killed";
+    else
+      return "";
+  }
+
   /**
    * Display usage of the command-line tool and terminate execution
    */



Mime
View raw message