hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ni...@apache.org
Subject svn commit: r772688 [1/3] - in /hadoop/core/trunk: ./ src/test/org/apache/hadoop/cli/ src/test/org/apache/hadoop/cli/util/
Date Thu, 07 May 2009 16:01:45 GMT
Author: nigel
Date: Thu May  7 16:01:44 2009
New Revision: 772688

URL: http://svn.apache.org/viewvc?rev=772688&view=rev
Log:
HADOOP-5080. Add new test cases to TestMRCLI and TestHDFSCLI.  Contributed by V.Karthikeyan

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/test/org/apache/hadoop/cli/TestCLI.java
    hadoop/core/trunk/src/test/org/apache/hadoop/cli/TestMRCLI.java
    hadoop/core/trunk/src/test/org/apache/hadoop/cli/testHDFSConf.xml
    hadoop/core/trunk/src/test/org/apache/hadoop/cli/testMRConf.xml
    hadoop/core/trunk/src/test/org/apache/hadoop/cli/util/CLITestData.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=772688&r1=772687&r2=772688&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Thu May  7 16:01:44 2009
@@ -317,6 +317,9 @@
     HADOOP-5015. Separate block management code from FSNamesystem.  (Suresh
     Srinivas via szetszwo)
 
+    HADOOP-5080. Add new test cases to TestMRCLI and TestHDFSCLI
+    (V.Karthikeyan via nigel)
+
   OPTIMIZATIONS
 
     HADOOP-5595. NameNode does not need to run a replicator to choose a

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/cli/TestCLI.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/cli/TestCLI.java?rev=772688&r1=772687&r2=772688&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/cli/TestCLI.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/cli/TestCLI.java Thu May  7 16:01:44 2009
@@ -406,17 +406,23 @@
           cleanupCommands.add(new TestCmd(charString, CommandType.FS));
         }
       } else if (qName.equals("dfs-admin-command")) {
-          if (testCommands != null) {
-              testCommands.add(new TestCmd(charString,CommandType.DFSADMIN));
-            } else if (cleanupCommands != null) {
-              cleanupCommands.add(new TestCmd(charString, CommandType.DFSADMIN));
-            } 
+        if (testCommands != null) {
+          testCommands.add(new TestCmd(charString, CommandType.DFSADMIN));
+        } else if (cleanupCommands != null) {
+          cleanupCommands.add(new TestCmd(charString, CommandType.DFSADMIN));
+        } 
       } else if (qName.equals("mr-admin-command")) {
         if (testCommands != null) {
-            testCommands.add(new TestCmd(charString,CommandType.MRADMIN));
-          } else if (cleanupCommands != null) {
-            cleanupCommands.add(new TestCmd(charString, CommandType.MRADMIN));
-          } 
+          testCommands.add(new TestCmd(charString, CommandType.MRADMIN));
+        } else if (cleanupCommands != null) {
+          cleanupCommands.add(new TestCmd(charString, CommandType.MRADMIN));
+        } 
+      } else if (qName.equals("archive-command")) {
+        if (testCommands != null) {
+          testCommands.add(new TestCmd(charString, CommandType.ARCHIVE));
+        } else if (cleanupCommands != null) {
+          cleanupCommands.add(new TestCmd(charString, CommandType.ARCHIVE));
+        }
       } else if (qName.equals("comparators")) {
         td.setComparatorData(testComparators);
       } else if (qName.equals("comparator")) {

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/cli/TestMRCLI.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/cli/TestMRCLI.java?rev=772688&r1=772687&r2=772688&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/cli/TestMRCLI.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/cli/TestMRCLI.java Thu May  7 16:01:44 2009
@@ -21,6 +21,7 @@
 import org.apache.hadoop.cli.util.CommandExecutor;
 import org.apache.hadoop.cli.util.CLITestData.TestCmd;
 import org.apache.hadoop.cli.util.CommandExecutor.Result;
+import org.apache.hadoop.tools.HadoopArchives;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.MiniMRCluster;
 import org.apache.hadoop.mapred.tools.MRAdmin;
@@ -31,6 +32,7 @@
   protected MiniMRCluster mrCluster = null;
   protected String jobtracker = null;
   protected MRCmdExecutor cmdExecutor = null;
+  protected ArchiveCmdExecutor archiveCmdExecutor = null;
   
   public void setUp() throws Exception {
     super.setUp();
@@ -39,6 +41,7 @@
                            null, null, mrConf);
     jobtracker = mrCluster.createJobConf().get("mapred.job.tracker", "local");
     cmdExecutor = new MRCmdExecutor(jobtracker);
+    archiveCmdExecutor = new ArchiveCmdExecutor(namenode, mrConf);
   }
 
   
@@ -61,8 +64,11 @@
   protected Result execute(TestCmd cmd) throws Exception {
     if(cmd.getType() == TestCmd.CommandType.MRADMIN) {
       return cmdExecutor.executeCommand(cmd.getCmd());
+    } else if(cmd.getType() == TestCmd.CommandType.ARCHIVE) {
+      return archiveCmdExecutor.executeCommand(cmd.getCmd());
+    } else {
+      return super.execute(cmd);
     }
-    else throw new Exception("Unknow type of Test command:"+ cmd.getType());
   }
   
   public static class MRCmdExecutor extends CommandExecutor {
@@ -76,4 +82,19 @@
       ToolRunner.run(mradmin, args);
     }
   }
+  
+  public static class ArchiveCmdExecutor extends CommandExecutor {
+    private String namenode = null;
+    private JobConf jobConf = null;
+    public ArchiveCmdExecutor(String namenode, JobConf jobConf) {
+      this.namenode = namenode;
+      this.jobConf = jobConf;
+    }
+    protected void execute(final String cmd) throws Exception {
+//      JobConf job=new JobConf(conf);
+      HadoopArchives archive = new HadoopArchives(jobConf);
+      String[] args = getCommandAsArgs(cmd, "NAMENODE", namenode);
+      ToolRunner.run(archive, args);
+    }
+  }
 }



Mime
View raw message