You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ni...@apache.org on 2007/08/14 02:50:08 UTC

svn commit: r565591 - in /lucene/hadoop/trunk: CHANGES.txt build.xml src/java/org/apache/hadoop/fs/Command.java src/test/org/apache/hadoop/dfs/MiniDFSCluster.java

Author: nigel
Date: Mon Aug 13 17:50:08 2007
New Revision: 565591

URL: http://svn.apache.org/viewvc?view=rev&rev=565591
Log:
HADOOP-1629.  Added a upgrade test for HADOOP-1134. Contributed by Raghu.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/build.xml
    lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Command.java
    lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/MiniDFSCluster.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=565591&r1=565590&r2=565591
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Mon Aug 13 17:50:08 2007
@@ -515,6 +515,11 @@
 150. HADOOP-1568.  Expose HDFS as xml/http filesystem to provide cross-version
      compatability. (Chris Douglas via omalley)
 
+151. HADOOP-1668.  Added an INCOMPATIBILITY section to CHANGES.txt. (nigel)
+
+152. HADOOP-1629.  Added a upgrade test for HADOOP-1134.
+     (Raghu Angadi via nigel)
+
 Release 0.13.0 - 2007-06-08
 
  1. HADOOP-1047.  Fix TestReplication to succeed more reliably.

Modified: lucene/hadoop/trunk/build.xml
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/build.xml?view=diff&rev=565591&r1=565590&r2=565591
==============================================================================
--- lucene/hadoop/trunk/build.xml (original)
+++ lucene/hadoop/trunk/build.xml Mon Aug 13 17:50:08 2007
@@ -448,6 +448,8 @@
     <copy file="${test.src.dir}/org/apache/hadoop/mapred/test.txt" todir="${test.cache.data}"/>
     <copy file="${test.src.dir}/org/apache/hadoop/mapred/test.jar" todir="${test.cache.data}"/>
     <copy file="${test.src.dir}/org/apache/hadoop/mapred/test.zip" todir="${test.cache.data}"/>
+    <copy file="${test.src.dir}/org/apache/hadoop/dfs/hadoop-12-dfs-dir.tgz" todir="${test.cache.data}"/>
+    <copy file="${test.src.dir}/org/apache/hadoop/dfs/hadoop-12-dfs-dir.txt" todir="${test.cache.data}"/>
   </target>
 
   <!-- ================================================================== -->
@@ -463,6 +465,7 @@
            fork="yes" maxmemory="256m" dir="${basedir}" timeout="${test.timeout}"
       errorProperty="tests.failed" failureProperty="tests.failed">
       <sysproperty key="test.build.data" value="${test.build.data}"/>
+      <sysproperty key="test.cache.data" value="${test.cache.data}"/>    	
       <sysproperty key="hadoop.log.dir" value="${test.log.dir}"/>
       <sysproperty key="test.src.dir" value="${test.src.dir}"/>
       <sysproperty key="java.library.path"

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Command.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Command.java?view=diff&rev=565591&r1=565590&r2=565591
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Command.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/fs/Command.java Mon Aug 13 17:50:08 2007
@@ -49,4 +49,44 @@
   /** Parse the execution result */
   protected abstract void parseExecResult(BufferedReader lines)
   throws IOException;
+
+  /// A simple implementation of Command
+  private static class SimpleCommandExecutor extends Command {
+    
+    private String[] command;
+    private StringBuffer reply;
+    
+    SimpleCommandExecutor(String[] execString) {
+      command = execString;
+    }
+
+    @Override
+    protected String[] getExecString() {
+      return command;
+    }
+
+    @Override
+    protected void parseExecResult(BufferedReader lines) throws IOException {
+      reply = new StringBuffer();
+      char[] buf = new char[512];
+      int nRead;
+      while ( (nRead = lines.read(buf, 0, buf.length)) > 0 ) {
+        reply.append(buf, 0, nRead);
+      }
+    }
+    
+    String getReply() {
+      return (reply == null) ? "" : reply.toString();
+    }
   }
+  
+  /** 
+   * Static method to execute a command. Covers most of the simple cases 
+   * without requiring the user to implement Command interface.
+   */
+  public static String execCommand(String[] cmd) throws IOException {
+    SimpleCommandExecutor exec = new SimpleCommandExecutor(cmd);
+    exec.run();
+    return exec.getReply();
+  }
+}

Modified: lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/MiniDFSCluster.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/MiniDFSCluster.java?view=diff&rev=565591&r1=565590&r2=565591
==============================================================================
--- lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/MiniDFSCluster.java (original)
+++ lucene/hadoop/trunk/src/test/org/apache/hadoop/dfs/MiniDFSCluster.java Mon Aug 13 17:50:08 2007
@@ -178,8 +178,9 @@
     String[] args = (operation == null ||
                      operation == StartupOption.FORMAT ||
                      operation == StartupOption.REGULAR) ?
-      new String[] {} : new String[] {"-"+operation.toString()};
-        
+                    null : new String[] {"-"+operation.toString()};
+    String [] dnArgs = (operation == StartupOption.UPGRADE) ? null : args;
+    
     for (int i = 0; i < numDataNodes; i++) {
       Configuration dnConf = new Configuration(conf);
       if (manageDfsDirs) {
@@ -198,7 +199,7 @@
       }
       System.out.println("Starting DataNode " + i + " with dfs.data.dir: " 
                          + dnConf.get("dfs.data.dir"));
-      dataNodes.add(DataNode.createDataNode(args, dnConf));
+      dataNodes.add(DataNode.createDataNode(dnArgs, dnConf));
     }
   }