HADOOP-8437. getLocalPathForWrite should throw IOException for invalid paths. Contributed by Brahma Reddy Battula

(cherry picked from commit fd026f535c)
This commit is contained in:
Zhihai Xu 2015-10-01 11:56:49 -07:00
parent db145e0c9a
commit 07f9405692
3 changed files with 24 additions and 2 deletions

View File

@ -601,6 +601,9 @@ Release 2.8.0 - UNRELEASED
HADOOP-10296. Incorrect null check in SwiftRestClient#buildException(). HADOOP-10296. Incorrect null check in SwiftRestClient#buildException().
(Rahul Palamuttam and Kanaka Kumar Avvaru via aajisaka) (Rahul Palamuttam and Kanaka Kumar Avvaru via aajisaka)
HADOOP-8437. getLocalPathForWrite should throw IOException for invalid
paths. (Brahma Reddy Battula via zxu)
OPTIMIZATIONS OPTIMIZATIONS
HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString() HADOOP-12051. ProtobufRpcEngine.invoke() should use Exception.toString()

View File

@ -304,10 +304,12 @@ public class LocalDirAllocator {
dirDF = dfList.toArray(new DF[dirs.size()]); dirDF = dfList.toArray(new DF[dirs.size()]);
savedLocalDirs = newLocalDirs; savedLocalDirs = newLocalDirs;
if (dirs.size() > 0) {
// randomize the first disk picked in the round-robin selection // randomize the first disk picked in the round-robin selection
dirNumLastAccessed = dirIndexRandomizer.nextInt(dirs.size()); dirNumLastAccessed = dirIndexRandomizer.nextInt(dirs.size());
} }
} }
}
private Path createPath(String path, private Path createPath(String path,
boolean checkWrite) throws IOException { boolean checkWrite) throws IOException {

View File

@ -458,4 +458,21 @@ public class TestLocalDirAllocator {
} }
} }
/**
* Test to check the LocalDirAllocation for the invalid path HADOOP-8437
*
* @throws Exception
*/
@Test(timeout = 30000)
public void testGetLocalPathForWriteForInvalidPaths() throws Exception {
conf.set(CONTEXT, " ");
try {
dirAllocator.getLocalPathForWrite("/test", conf);
fail("not throwing the exception");
} catch (IOException e) {
assertEquals("Incorrect exception message",
"No space available in any of the local directories.", e.getMessage());
}
}
} }