hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1452622 - in /hadoop/common/trunk/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 Tue, 05 Mar 2013 01:30:05 GMT
Author: atm
Date: Tue Mar  5 01:30:05 2013
New Revision: 1452622

URL: http://svn.apache.org/r1452622
Log:
HADOOP-9337. org.apache.hadoop.fs.DF.getMount() does not work on Mac OS. Contributed by Ivan
A. Veselovsky.

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

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1452622&r1=1452621&r2=1452622&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Tue Mar  5 01:30:05
2013
@@ -406,6 +406,9 @@ Release 2.0.4-beta - UNRELEASED
     HADOOP-9349. Confusing output when running hadoop version from one hadoop 
     installation when HADOOP_HOME points to another. (sandyr via tucu)
 
+    HADOOP-9337. org.apache.hadoop.fs.DF.getMount() does not work on Mac OS.
+    (Ivan A. Veselovsky via atm)
+
 Release 2.0.3-alpha - 2013-02-06 
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DF.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DF.java?rev=1452622&r1=1452621&r2=1452622&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DF.java
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DF.java
Tue Mar  5 01:30:05 2013
@@ -166,7 +166,7 @@ public class DF extends Shell {
   @Override
   protected String[] getExecString() {
     // ignoring the error since the exit code it enough
-    return new String[] {"bash","-c","exec 'df' '-k' '" + dirPath 
+    return new String[] {"bash","-c","exec 'df' '-k' '-P' '" + dirPath 
                          + "' 2>/dev/null"};
   }
 
@@ -210,28 +210,11 @@ public class DF extends Shell {
     }
 
     try {
-      switch(getOSType()) {
-        case OS_TYPE_AIX:
-          Long.parseLong(tokens.nextToken()); // capacity
-          Long.parseLong(tokens.nextToken()); // available
-          Integer.parseInt(tokens.nextToken()); // pct used
-          tokens.nextToken();
-          tokens.nextToken();
-          this.mount = tokens.nextToken();
-          break;
-
-        case OS_TYPE_WIN:
-        case OS_TYPE_SOLARIS:
-        case OS_TYPE_MAC:
-        case OS_TYPE_UNIX:
-        default:
-          Long.parseLong(tokens.nextToken()); // capacity
-          Long.parseLong(tokens.nextToken()); // used
-          Long.parseLong(tokens.nextToken()); // available
-          Integer.parseInt(tokens.nextToken()); // pct used
-          this.mount = tokens.nextToken();
-          break;
-     }
+      Long.parseLong(tokens.nextToken()); // capacity
+      Long.parseLong(tokens.nextToken()); // used
+      Long.parseLong(tokens.nextToken()); // available
+      Integer.parseInt(tokens.nextToken()); // pct used
+      this.mount = tokens.nextToken();
     } catch (NoSuchElementException e) {
       throw new IOException("Could not parse line: " + line);
     } catch (NumberFormatException e) {

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java?rev=1452622&r1=1452621&r2=1452622&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java
Tue Mar  5 01:30:05 2013
@@ -31,6 +31,7 @@ import java.util.Random;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.Shell;
 import org.junit.Test;
+import static org.junit.Assert.*;
 
 public class TestDFVariations {
 
@@ -46,14 +47,8 @@ public class TestDFVariations {
     }
     @Override
     protected String[] getExecString() {
-      switch(getOSType()) {
-        case OS_TYPE_AIX:
-          return new String[] { "echo", "IGNORE\n", "/dev/sda3",
-            "453115160", "400077240", "11%", "18", "skip%", "/foo/bar", "\n" };
-        default:
-          return new String[] { "echo", "IGNORE\n", "/dev/sda3",
-            "453115160", "53037920", "400077240", "11%", "/foo/bar", "\n" };
-      }
+      return new String[] { "echo", "IGNORE\n", 
+        "/dev/sda3", "453115160", "53037920", "400077240", "11%", "/foo/bar\n"};
     }
   }
 
@@ -135,5 +130,20 @@ public class TestDFVariations {
       System.out.println(e.toString());
     }
   }
+
+  @Test(timeout=5000)
+  public void testGetMountCurrentDirectory() throws Exception {
+    File currentDirectory = new File(".");
+    String workingDir = currentDirectory.getAbsoluteFile().getCanonicalPath();
+    DF df = new DF(new File(workingDir), 0L);
+    String mountPath = df.getMount();
+    File mountDir = new File(mountPath);
+    assertTrue("Mount dir ["+mountDir.getAbsolutePath()+"] should exist.", 
+        mountDir.exists());
+    assertTrue("Mount dir ["+mountDir.getAbsolutePath()+"] should be directory.", 
+        mountDir.isDirectory());
+    assertTrue("Working dir ["+workingDir+"] should start with ["+mountPath+"].",
+        workingDir.startsWith(mountPath));
+  }
 }
 



Mime
View raw message