HADOOP-9915. o.a.h.fs.Stat support on Mac OS X (Contributed by Binglin Chang)
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1520192 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e8ce7cd541
commit
a1db4783a4
|
@ -46,6 +46,9 @@ Release 2.3.0 - UNRELEASED
|
||||||
HADOOP-9889. Refresh the Krb5 configuration when creating a new kdc in
|
HADOOP-9889. Refresh the Krb5 configuration when creating a new kdc in
|
||||||
Hadoop-MiniKDC (Wei Yan via Sandy Ryza)
|
Hadoop-MiniKDC (Wei Yan via Sandy Ryza)
|
||||||
|
|
||||||
|
HADOOP-9915. o.a.h.fs.Stat support on Mac OS X (Binglin Chang via Colin
|
||||||
|
Patrick McCabe)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
HADOOP-9748. Reduce blocking on UGI.ensureInitialized (daryn)
|
HADOOP-9748. Reduce blocking on UGI.ensureInitialized (daryn)
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class Stat extends Shell {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isAvailable() {
|
public static boolean isAvailable() {
|
||||||
if (Shell.LINUX || Shell.FREEBSD) {
|
if (Shell.LINUX || Shell.FREEBSD || Shell.MAC) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -100,7 +100,7 @@ public class Stat extends Shell {
|
||||||
if (Shell.LINUX) {
|
if (Shell.LINUX) {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
"stat", derefFlag + "c", "%s,%F,%Y,%X,%a,%U,%G,%N", path.toString() };
|
"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[] {
|
return new String[] {
|
||||||
"stat", derefFlag + "f", "%z,%HT,%m,%a,%Op,%Su,%Sg,`link' -> `%Y'",
|
"stat", derefFlag + "f", "%z,%HT,%m,%a,%Op,%Su,%Sg,`link' -> `%Y'",
|
||||||
path.toString() };
|
path.toString() };
|
||||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.hadoop.fs;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
@ -26,10 +27,11 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestStat {
|
public class TestStat extends FileSystemTestHelper {
|
||||||
|
|
||||||
private static Stat stat;
|
private static Stat stat;
|
||||||
|
|
||||||
|
@ -113,6 +115,7 @@ public class TestStat {
|
||||||
|
|
||||||
@Test(timeout=10000)
|
@Test(timeout=10000)
|
||||||
public void testStatFileNotFound() throws Exception {
|
public void testStatFileNotFound() throws Exception {
|
||||||
|
Assume.assumeTrue(Stat.isAvailable());
|
||||||
try {
|
try {
|
||||||
stat.getFileStatus();
|
stat.getFileStatus();
|
||||||
fail("Expected FileNotFoundException");
|
fail("Expected FileNotFoundException");
|
||||||
|
@ -125,4 +128,21 @@ public class TestStat {
|
||||||
public void testStatEnvironment() throws Exception {
|
public void testStatEnvironment() throws Exception {
|
||||||
assertEquals(stat.getEnvironment("LANG"), "C");
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue