hadoop-yarn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vino...@apache.org
Subject svn commit: r1396226 - in /hadoop/common/trunk/hadoop-yarn-project: ./ hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/ hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apac...
Date Tue, 09 Oct 2012 19:40:32 GMT
Author: vinodkv
Date: Tue Oct  9 19:40:31 2012
New Revision: 1396226

URL: http://svn.apache.org/viewvc?rev=1396226&view=rev
Log:
YARN-94. Modify DistributedShell to point to main-class by default, clean up the help message,
and hard-code the AM class. Contributed by Hitesh Shah.

Modified:
    hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt
    hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/pom.xml
    hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
    hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDistributedShell.java

Modified: hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt?rev=1396226&r1=1396225&r2=1396226&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt Tue Oct  9 19:40:31 2012
@@ -55,6 +55,9 @@ Release 2.0.3-alpha - Unreleased 
     YARN-33. Change LocalDirsHandlerService to validate the configured local and
     log dirs. (Mayank Bansal via sseth)
 
+    YARN-94. Modify DistributedShell to point to main-class by default, clean up
+    the help message, and hard-code the AM class. (Hitesh Shah via vinodkv)
+
   OPTIMIZATIONS
 
   BUG FIXES

Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/pom.xml
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/pom.xml?rev=1396226&r1=1396225&r2=1396226&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/pom.xml
(original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/pom.xml
Tue Oct  9 19:40:31 2012
@@ -82,6 +82,13 @@
             <phase>test-compile</phase>
           </execution>
         </executions>
+        <configuration>
+           <archive>
+             <manifest>
+               <mainClass>org.apache.hadoop.yarn.applications.distributedshell.Client</mainClass>
+             </manifest>
+           </archive>
+        </configuration>
       </plugin>
       <plugin>
         <artifactId>maven-dependency-plugin</artifactId>

Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java?rev=1396226&r1=1396225&r2=1396226&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
(original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/main/java/org/apache/hadoop/yarn/applications/distributedshell/Client.java
Tue Oct  9 19:40:31 2012
@@ -119,7 +119,8 @@ public class Client extends YarnClientIm
   // Application master jar file
   private String appMasterJar = ""; 
   // Main class to invoke application master
-  private String appMasterMainClass = "";
+  private final String appMasterMainClass =
+      "org.apache.hadoop.yarn.applications.distributedshell.ApplicationMaster";
 
   // Shell command to be executed 
   private String shellCommand = ""; 
@@ -149,6 +150,9 @@ public class Client extends YarnClientIm
   // Debug flag
   boolean debugFlag = false;	
 
+  // Command line options
+  private Options opts;
+
   /**
    * @param args Command line arguments 
    */
@@ -157,9 +161,15 @@ public class Client extends YarnClientIm
     try {
       Client client = new Client();
       LOG.info("Initializing Client");
-      boolean doRun = client.init(args);
-      if (!doRun) {
-        System.exit(0);
+      try {
+        boolean doRun = client.init(args);
+        if (!doRun) {
+          System.exit(0);
+        }
+      } catch (IllegalArgumentException e) {
+        System.err.println(e.getLocalizedMessage());
+        client.printUsage();
+        System.exit(-1);
       }
       result = client.run();
     } catch (Throwable t) {
@@ -180,6 +190,23 @@ public class Client extends YarnClientIm
     super();
     this.conf = conf;
     init(conf);
+    opts = new Options();
+    opts.addOption("appname", true, "Application Name. Default value - DistributedShell");
+    opts.addOption("priority", true, "Application Priority. Default 0");
+    opts.addOption("queue", true, "RM Queue in which this application is to be submitted");
+    opts.addOption("timeout", true, "Application timeout in milliseconds");
+    opts.addOption("master_memory", true, "Amount of memory in MB to be requested to run
the application master");
+    opts.addOption("jar", true, "Jar file containing the application master");
+    opts.addOption("shell_command", true, "Shell command to be executed by the Application
Master");
+    opts.addOption("shell_script", true, "Location of the shell script to be executed");
+    opts.addOption("shell_args", true, "Command line args for the shell script");
+    opts.addOption("shell_env", true, "Environment for shell script. Specified as env_key=env_val
pairs");
+    opts.addOption("shell_cmd_priority", true, "Priority for the shell command containers");
+    opts.addOption("container_memory", true, "Amount of memory in MB to be requested to run
the shell command");
+    opts.addOption("num_containers", true, "No. of containers on which the shell command
needs to be executed");
+    opts.addOption("log_properties", true, "log4j.properties file");
+    opts.addOption("debug", false, "Dump out debug information");
+    opts.addOption("help", false, "Print usage");
   }
 
   /**
@@ -192,7 +219,7 @@ public class Client extends YarnClientIm
    * Helper function to print out usage
    * @param opts Parsed command line options 
    */
-  private void printUsage(Options opts) {
+  private void printUsage() {
     new HelpFormatter().printHelp("Client", opts);
   }
 
@@ -204,33 +231,14 @@ public class Client extends YarnClientIm
    */
   public boolean init(String[] args) throws ParseException {
 
-    Options opts = new Options();
-    opts.addOption("appname", true, "Application Name. Default value - DistributedShell");
-    opts.addOption("priority", true, "Application Priority. Default 0");
-    opts.addOption("queue", true, "RM Queue in which this application is to be submitted");
-    opts.addOption("timeout", true, "Application timeout in milliseconds");
-    opts.addOption("master_memory", true, "Amount of memory in MB to be requested to run
the application master");
-    opts.addOption("jar", true, "Jar file containing the application master");
-    opts.addOption("class", true, "Main class to  be run for the Application Master.");
-    opts.addOption("shell_command", true, "Shell command to be executed by the Application
Master");
-    opts.addOption("shell_script", true, "Location of the shell script to be executed");
-    opts.addOption("shell_args", true, "Command line args for the shell script");
-    opts.addOption("shell_env", true, "Environment for shell script. Specified as env_key=env_val
pairs");
-    opts.addOption("shell_cmd_priority", true, "Priority for the shell command containers");
	
-    opts.addOption("container_memory", true, "Amount of memory in MB to be requested to run
the shell command");
-    opts.addOption("num_containers", true, "No. of containers on which the shell command
needs to be executed");
-    opts.addOption("log_properties", true, "log4j.properties file");
-    opts.addOption("debug", false, "Dump out debug information");
-    opts.addOption("help", false, "Print usage");
     CommandLine cliParser = new GnuParser().parse(opts, args);
 
     if (args.length == 0) {
-      printUsage(opts);
       throw new IllegalArgumentException("No args specified for client to initialize");
     }		
 
     if (cliParser.hasOption("help")) {
-      printUsage(opts);
+      printUsage();
       return false;
     }
 
@@ -254,8 +262,6 @@ public class Client extends YarnClientIm
     }		
 
     appMasterJar = cliParser.getOptionValue("jar");
-    appMasterMainClass = cliParser.getOptionValue("class",
-        "org.apache.hadoop.yarn.applications.distributedshell.ApplicationMaster");		
 
     if (!cliParser.hasOption("shell_command")) {
       throw new IllegalArgumentException("No shell command specified to be executed by application
master");

Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDistributedShell.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDistributedShell.java?rev=1396226&r1=1396225&r2=1396226&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDistributedShell.java
(original)
+++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-distributedshell/src/test/java/org/apache/hadoop/yarn/applications/distributedshell/TestDistributedShell.java
Tue Oct  9 19:40:31 2012
@@ -110,6 +110,22 @@ public class TestDistributedShell {
 
   }
 
+  @Test
+  public void testDSShellWithNoArgs() throws Exception {
+
+    String[] args = {};
+
+    LOG.info("Initializing DS Client with no args");
+    Client client = new Client(new Configuration(yarnCluster.getConfig()));
+    boolean exceptionThrown = false;
+    try {
+      boolean initSuccess = client.init(args);
+    }
+    catch (IllegalArgumentException e) {
+      exceptionThrown = true;
+    }
+    Assert.assertTrue(exceptionThrown);
+  }
 
 }
 



Mime
View raw message