hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From umamah...@apache.org
Subject svn commit: r1584573 - in /hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common: CHANGES.txt src/main/java/org/apache/hadoop/fs/DF.java src/test/java/org/apache/hadoop/fs/TestDFVariations.java
Date Fri, 04 Apr 2014 09:13:20 GMT
Author: umamahesh
Date: Fri Apr  4 09:13:20 2014
New Revision: 1584573

URL: http://svn.apache.org/r1584573
Log:
Merge HADOOP-10462. DF#getFilesystem is not parsing the command output. Contributed by Akira
AJISAKA.

Modified:
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DF.java
    hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1584573&r1=1584572&r2=1584573&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/CHANGES.txt Fri Apr
 4 09:13:20 2014
@@ -39,6 +39,9 @@ Release 2.5.0 - UNRELEASED
     HADOOP-10459. distcp V2 doesn't preserve root dir's attributes when -p is
     specified. (Yongjun Zhang via atm)
 
+    HADOOP-10462. DF#getFilesystem is not parsing the command output. 
+    (Akira AJISAKA via umamahesh)
+
 Release 2.4.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DF.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DF.java?rev=1584573&r1=1584572&r2=1584573&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DF.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DF.java
Fri Apr  4 09:13:20 2014
@@ -22,7 +22,6 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.EnumSet;
 import java.util.NoSuchElementException;
 import java.util.StringTokenizer;
 
@@ -75,6 +74,8 @@ public class DF extends Shell {
       return this.filesystem;
     } else {
       run();
+      verifyExitCode();
+      parseOutput();
       return filesystem;
     }
   }
@@ -114,14 +115,7 @@ public class DF extends Shell {
       this.mount = dirFile.getCanonicalPath().substring(0, 2);
     } else {
       run();
-      // Skip parsing if df was not successful
-      if (getExitCode() != 0) {
-        StringBuffer sb = new StringBuffer("df could not be run successfully: ");
-        for (String line: output) {
-          sb.append(line);
-        }
-        throw new IOException(sb.toString());
-      }
+      verifyExitCode();
       parseOutput();
     }
 
@@ -204,6 +198,17 @@ public class DF extends Shell {
     }
   }
 
+  private void verifyExitCode() throws IOException {
+    if (getExitCode() != 0) {
+      StringBuilder sb =
+          new StringBuilder("df could not be run successfully: ");
+      for (String line : output) {
+        sb.append(line);
+      }
+      throw new IOException(sb.toString());
+    }
+  }
+
   public static void main(String[] args) throws Exception {
     String path = ".";
     if (args.length > 0)

Modified: hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java?rev=1584573&r1=1584572&r2=1584573&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java
(original)
+++ hadoop/common/branches/branch-2/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java
Fri Apr  4 09:13:20 2014
@@ -25,7 +25,6 @@ import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.StringReader;
-import java.util.EnumSet;
 import java.util.Random;
 
 import org.apache.hadoop.test.GenericTestUtils;
@@ -47,16 +46,19 @@ public class TestDFVariations {
     }
   }
 
-  public void testMountAndFileSystem() throws Exception {
+  public void testMount() throws Exception {
     XXDF df = new XXDF();
     String expectedMount =
         Shell.WINDOWS ? df.getDirPath().substring(0, 2) : "/foo/bar";
-    String expectedFileSystem =
-        Shell.WINDOWS ? df.getDirPath().substring(0, 2) : "/dev/sda3";
-
     assertEquals("Invalid mount point",
         expectedMount, df.getMount());
+  }
 
+  @Test(timeout=5000)
+  public void testFileSystem() throws Exception {
+    XXDF df = new XXDF();
+    String expectedFileSystem =
+        Shell.WINDOWS ? df.getDirPath().substring(0, 2) : "/dev/sda3";
     assertEquals("Invalid filesystem",
         expectedFileSystem, df.getFilesystem());
   }



Mime
View raw message