HADOOP-9337. org.apache.hadoop.fs.DF.getMount() does not work on Mac OS. Contributed by Ivan A. Veselovsky.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1452624 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3cfae3cc79
commit
e998b63dd9
|
@ -66,6 +66,9 @@ Release 2.0.4-beta - UNRELEASED
|
||||||
HADOOP-9349. Confusing output when running hadoop version from one hadoop
|
HADOOP-9349. Confusing output when running hadoop version from one hadoop
|
||||||
installation when HADOOP_HOME points to another. (sandyr via tucu)
|
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
|
Release 2.0.3-alpha - 2013-02-06
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -166,7 +166,7 @@ public class DF extends Shell {
|
||||||
@Override
|
@Override
|
||||||
protected String[] getExecString() {
|
protected String[] getExecString() {
|
||||||
// ignoring the error since the exit code it enough
|
// 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"};
|
+ "' 2>/dev/null"};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,28 +210,11 @@ public class DF extends Shell {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch(getOSType()) {
|
Long.parseLong(tokens.nextToken()); // capacity
|
||||||
case OS_TYPE_AIX:
|
Long.parseLong(tokens.nextToken()); // used
|
||||||
Long.parseLong(tokens.nextToken()); // capacity
|
Long.parseLong(tokens.nextToken()); // available
|
||||||
Long.parseLong(tokens.nextToken()); // available
|
Integer.parseInt(tokens.nextToken()); // pct used
|
||||||
Integer.parseInt(tokens.nextToken()); // pct used
|
this.mount = tokens.nextToken();
|
||||||
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;
|
|
||||||
}
|
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
throw new IOException("Could not parse line: " + line);
|
throw new IOException("Could not parse line: " + line);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import org.apache.hadoop.test.GenericTestUtils;
|
import org.apache.hadoop.test.GenericTestUtils;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
public class TestDFVariations {
|
public class TestDFVariations {
|
||||||
|
|
||||||
|
@ -45,14 +46,8 @@ public class TestDFVariations {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected String[] getExecString() {
|
protected String[] getExecString() {
|
||||||
switch(getOSType()) {
|
return new String[] { "echo", "IGNORE\n",
|
||||||
case OS_TYPE_AIX:
|
"/dev/sda3", "453115160", "53037920", "400077240", "11%", "/foo/bar\n"};
|
||||||
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" };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,5 +127,20 @@ public class TestDFVariations {
|
||||||
System.out.println(e.toString());
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue