HADOOP-10462. DF#getFilesystem is not parsing the command output. Contributed by Akira AJISAKA.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1584571 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b6e31fd8ea
commit
362d284e17
@ -344,6 +344,9 @@ Release 2.5.0 - UNRELEASED
|
|||||||
HADOOP-10459. distcp V2 doesn't preserve root dir's attributes when -p is
|
HADOOP-10459. distcp V2 doesn't preserve root dir's attributes when -p is
|
||||||
specified. (Yongjun Zhang via atm)
|
specified. (Yongjun Zhang via atm)
|
||||||
|
|
||||||
|
HADOOP-10462. DF#getFilesystem is not parsing the command output.
|
||||||
|
(Akira AJISAKA via umamahesh)
|
||||||
|
|
||||||
Release 2.4.1 - UNRELEASED
|
Release 2.4.1 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
@ -75,6 +74,8 @@ public String getFilesystem() throws IOException {
|
|||||||
return this.filesystem;
|
return this.filesystem;
|
||||||
} else {
|
} else {
|
||||||
run();
|
run();
|
||||||
|
verifyExitCode();
|
||||||
|
parseOutput();
|
||||||
return filesystem;
|
return filesystem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,14 +115,7 @@ public String getMount() throws IOException {
|
|||||||
this.mount = dirFile.getCanonicalPath().substring(0, 2);
|
this.mount = dirFile.getCanonicalPath().substring(0, 2);
|
||||||
} else {
|
} else {
|
||||||
run();
|
run();
|
||||||
// Skip parsing if df was not successful
|
verifyExitCode();
|
||||||
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());
|
|
||||||
}
|
|
||||||
parseOutput();
|
parseOutput();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,6 +198,17 @@ protected void parseOutput() throws IOException {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
public static void main(String[] args) throws Exception {
|
||||||
String path = ".";
|
String path = ".";
|
||||||
if (args.length > 0)
|
if (args.length > 0)
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.apache.hadoop.test.GenericTestUtils;
|
import org.apache.hadoop.test.GenericTestUtils;
|
||||||
@ -48,16 +47,19 @@ protected String[] getExecString() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout=5000)
|
@Test(timeout=5000)
|
||||||
public void testMountAndFileSystem() throws Exception {
|
public void testMount() throws Exception {
|
||||||
XXDF df = new XXDF();
|
XXDF df = new XXDF();
|
||||||
String expectedMount =
|
String expectedMount =
|
||||||
Shell.WINDOWS ? df.getDirPath().substring(0, 2) : "/foo/bar";
|
Shell.WINDOWS ? df.getDirPath().substring(0, 2) : "/foo/bar";
|
||||||
String expectedFileSystem =
|
|
||||||
Shell.WINDOWS ? df.getDirPath().substring(0, 2) : "/dev/sda3";
|
|
||||||
|
|
||||||
assertEquals("Invalid mount point",
|
assertEquals("Invalid mount point",
|
||||||
expectedMount, df.getMount());
|
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",
|
assertEquals("Invalid filesystem",
|
||||||
expectedFileSystem, df.getFilesystem());
|
expectedFileSystem, df.getFilesystem());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user