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 cm...@apache.org on 2013/09/05 03:46:15 UTC
svn commit: r1520190 - in
/hadoop/common/trunk/hadoop-common-project/hadoop-common: CHANGES.txt
src/main/java/org/apache/hadoop/fs/Stat.java
src/test/java/org/apache/hadoop/fs/TestStat.java
Author: cmccabe
Date: Thu Sep 5 01:46:14 2013
New Revision: 1520190
URL: http://svn.apache.org/r1520190
Log:
HADOOP-9915. o.a.h.fs.Stat support on Mac OS X (Contributed by Binglin Chang)
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/Stat.java
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestStat.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=1520190&r1=1520189&r2=1520190&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Thu Sep 5 01:46:14 2013
@@ -105,6 +105,9 @@ Trunk (Unreleased)
HADOOP-9833 move slf4j to version 1.7.5 (Kousuke Saruta via stevel)
+ HADOOP-9915. o.a.h.fs.Stat support on Mac OS X (Binglin Chang via Colin
+ Patrick McCabe)
+
BUG FIXES
HADOOP-9451. Fault single-layer config if node group topology is enabled.
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Stat.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Stat.java?rev=1520190&r1=1520189&r2=1520190&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Stat.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/Stat.java Thu Sep 5 01:46:14 2013
@@ -80,7 +80,7 @@ public class Stat extends Shell {
* @return
*/
public static boolean isAvailable() {
- if (Shell.LINUX || Shell.FREEBSD) {
+ if (Shell.LINUX || Shell.FREEBSD || Shell.MAC) {
return true;
}
return false;
@@ -100,7 +100,7 @@ public class Stat extends Shell {
if (Shell.LINUX) {
return new String[] {
"stat", derefFlag + "c", "%s,%F,%Y,%X,%a,%U,%G,%N", path.toString() };
- } else if (Shell.FREEBSD) {
+ } else if (Shell.FREEBSD || Shell.MAC) {
return new String[] {
"stat", derefFlag + "f", "%z,%HT,%m,%a,%Op,%Su,%Sg,`link' -> `%Y'",
path.toString() };
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestStat.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestStat.java?rev=1520190&r1=1520189&r2=1520190&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestStat.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestStat.java Thu Sep 5 01:46:14 2013
@@ -19,6 +19,7 @@ package org.apache.hadoop.fs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import java.io.BufferedReader;
@@ -26,10 +27,11 @@ import java.io.FileNotFoundException;
import java.io.StringReader;
import org.apache.hadoop.conf.Configuration;
+import org.junit.Assume;
import org.junit.BeforeClass;
import org.junit.Test;
-public class TestStat {
+public class TestStat extends FileSystemTestHelper {
private static Stat stat;
@@ -113,6 +115,7 @@ public class TestStat {
@Test(timeout=10000)
public void testStatFileNotFound() throws Exception {
+ Assume.assumeTrue(Stat.isAvailable());
try {
stat.getFileStatus();
fail("Expected FileNotFoundException");
@@ -125,4 +128,21 @@ public class TestStat {
public void testStatEnvironment() throws Exception {
assertEquals(stat.getEnvironment("LANG"), "C");
}
+
+ @Test(timeout=10000)
+ public void testStat() throws Exception {
+ Assume.assumeTrue(Stat.isAvailable());
+ FileSystem fs = FileSystem.getLocal(new Configuration());
+ Path testDir = new Path(getTestRootPath(fs), "teststat");
+ fs.mkdirs(testDir);
+ Path sub1 = new Path(testDir, "sub1");
+ Path sub2 = new Path(testDir, "sub2");
+ fs.mkdirs(sub1);
+ fs.createSymlink(sub1, sub2, false);
+ FileStatus stat1 = new Stat(sub1, 4096l, false, fs).getFileStatus();
+ FileStatus stat2 = new Stat(sub2, 0, false, fs).getFileStatus();
+ assertTrue(stat1.isDirectory());
+ assertFalse(stat2.isDirectory());
+ fs.delete(testDir, true);
+ }
}