hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r379955 - /lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java
Date Wed, 22 Feb 2006 22:55:31 GMT
Author: cutting
Date: Wed Feb 22 14:55:20 2006
New Revision: 379955

URL: http://svn.apache.org/viewcvs?rev=379955&view=rev
Log:
Fix for HADOOP-49: Permit specification of jobtracker when submitting jobs.

Modified:
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java?rev=379955&r1=379954&r2=379955&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobClient.java Wed Feb 22 14:55:20
2006
@@ -319,26 +319,48 @@
       }
     }
 
+    static Configuration getConfiguration(String jobTrackerSpec)
+    {
+      Configuration conf = new Configuration();
+      if(jobTrackerSpec != null) {        
+        if(jobTrackerSpec.indexOf(":") >= 0) {
+          conf.set("mapred.job.tracker", jobTrackerSpec);
+        } else {
+          String classpathFile = "hadoop-" + jobTrackerSpec + ".xml";
+          URL validate = conf.getResource(classpathFile);
+          if(validate == null) {
+            throw new RuntimeException(classpathFile + " not found on CLASSPATH");
+          }
+          conf.addFinalResource(classpathFile);
+        }
+      }
+      return conf;
+    }
+        
 
     /**
      */
     public static void main(String argv[]) throws IOException {
         if (argv.length < 2) {
-            System.out.println("JobClient -submit <job> | -status <id> | -kill
<id>");
+            System.out.println("JobClient -submit <job> | -status <id> | -kill
<id> [-jt <jobtracker:port>|<config>]");
             System.exit(-1);
         }
 
         // Process args
         String jobTrackerStr = argv[0];
+        String jobTrackerSpec = null;
         String submitJobFile = null;
         String jobid = null;
         boolean getStatus = false;
         boolean killJob = false;
 
         for (int i = 0; i < argv.length; i++) {
-            if ("-submit".equals(argv[i])) {
+            if ("-jt".equals(argv[i])) {
+                jobTrackerSpec = argv[i+1];
+                i++;
+            } else if ("-submit".equals(argv[i])) {
                 submitJobFile = argv[i+1];
-                i+=2;
+                i++;
             } else if ("-status".equals(argv[i])) {
                 jobid = argv[i+1];
                 getStatus = true;
@@ -351,7 +373,7 @@
         }
 
         // Submit the request
-        JobClient jc = new JobClient(new Configuration());
+        JobClient jc = new JobClient(getConfiguration(jobTrackerSpec));
         try {
             if (submitJobFile != null) {
                 RunningJob job = jc.submitJob(submitJobFile);



Mime
View raw message