HDFS-4743. TestNNStorageRetentionManager fails on Windows. Contributed by Chris Nauroth.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1476591 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
90612f6423
commit
0181ce03af
@ -314,6 +314,9 @@ Trunk (Unreleased)
|
|||||||
HDFS-4741. TestStorageRestore#testStorageRestoreFailure fails on Windows.
|
HDFS-4741. TestStorageRestore#testStorageRestoreFailure fails on Windows.
|
||||||
(Arpit Agarwal via suresh)
|
(Arpit Agarwal via suresh)
|
||||||
|
|
||||||
|
HDFS-4743. TestNNStorageRetentionManager fails on Windows.
|
||||||
|
(Chris Nauroth via suresh)
|
||||||
|
|
||||||
BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS
|
BREAKDOWN OF HDFS-347 SUBTASKS AND RELATED JIRAS
|
||||||
|
|
||||||
HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes.
|
HDFS-4353. Encapsulate connections to peers in Peer and PeerServer classes.
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
import static org.apache.hadoop.hdfs.server.namenode.NNStorage.getImageFileName;
|
import static org.apache.hadoop.hdfs.server.namenode.NNStorage.getImageFileName;
|
||||||
import static org.apache.hadoop.hdfs.server.namenode.NNStorage.getInProgressEditsFileName;
|
import static org.apache.hadoop.hdfs.server.namenode.NNStorage.getInProgressEditsFileName;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -247,30 +248,32 @@ private void runTest(TestCaseDescription tc) throws IOException {
|
|||||||
.purgeLog(logsPurgedCaptor.capture());
|
.purgeLog(logsPurgedCaptor.capture());
|
||||||
|
|
||||||
// Check images
|
// Check images
|
||||||
Set<String> purgedPaths = Sets.newHashSet();
|
Set<String> purgedPaths = Sets.newLinkedHashSet();
|
||||||
for (FSImageFile purged : imagesPurgedCaptor.getAllValues()) {
|
for (FSImageFile purged : imagesPurgedCaptor.getAllValues()) {
|
||||||
purgedPaths.add(purged.getFile().toString());
|
purgedPaths.add(fileToPath(purged.getFile()));
|
||||||
}
|
}
|
||||||
Assert.assertEquals(Joiner.on(",").join(tc.expectedPurgedImages),
|
Assert.assertEquals(
|
||||||
Joiner.on(",").join(purgedPaths));
|
Joiner.on(",").join(filesToPaths(tc.expectedPurgedImages)),
|
||||||
|
Joiner.on(",").join(purgedPaths));
|
||||||
|
|
||||||
// Check images
|
// Check images
|
||||||
purgedPaths.clear();
|
purgedPaths.clear();
|
||||||
for (EditLogFile purged : logsPurgedCaptor.getAllValues()) {
|
for (EditLogFile purged : logsPurgedCaptor.getAllValues()) {
|
||||||
purgedPaths.add(purged.getFile().toString());
|
purgedPaths.add(fileToPath(purged.getFile()));
|
||||||
}
|
}
|
||||||
Assert.assertEquals(Joiner.on(",").join(tc.expectedPurgedLogs),
|
Assert.assertEquals(
|
||||||
Joiner.on(",").join(purgedPaths));
|
Joiner.on(",").join(filesToPaths(tc.expectedPurgedLogs)),
|
||||||
|
Joiner.on(",").join(purgedPaths));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestCaseDescription {
|
private static class TestCaseDescription {
|
||||||
private Map<String, FakeRoot> dirRoots = Maps.newHashMap();
|
private Map<File, FakeRoot> dirRoots = Maps.newHashMap();
|
||||||
private Set<String> expectedPurgedLogs = Sets.newHashSet();
|
private Set<File> expectedPurgedLogs = Sets.newLinkedHashSet();
|
||||||
private Set<String> expectedPurgedImages = Sets.newHashSet();
|
private Set<File> expectedPurgedImages = Sets.newLinkedHashSet();
|
||||||
|
|
||||||
private static class FakeRoot {
|
private static class FakeRoot {
|
||||||
NameNodeDirType type;
|
NameNodeDirType type;
|
||||||
List<String> files;
|
List<File> files;
|
||||||
|
|
||||||
FakeRoot(NameNodeDirType type) {
|
FakeRoot(NameNodeDirType type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
@ -280,33 +283,35 @@ private static class FakeRoot {
|
|||||||
StorageDirectory mockStorageDir() {
|
StorageDirectory mockStorageDir() {
|
||||||
return FSImageTestUtil.mockStorageDirectory(
|
return FSImageTestUtil.mockStorageDirectory(
|
||||||
type, false,
|
type, false,
|
||||||
files.toArray(new String[0]));
|
filesToPaths(files).toArray(new String[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addRoot(String root, NameNodeDirType dir) {
|
void addRoot(String root, NameNodeDirType dir) {
|
||||||
dirRoots.put(root, new FakeRoot(dir));
|
dirRoots.put(new File(root), new FakeRoot(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addFile(String path) {
|
private void addFile(File file) {
|
||||||
for (Map.Entry<String, FakeRoot> entry : dirRoots.entrySet()) {
|
for (Map.Entry<File, FakeRoot> entry : dirRoots.entrySet()) {
|
||||||
if (path.startsWith(entry.getKey())) {
|
if (fileToPath(file).startsWith(fileToPath(entry.getKey()))) {
|
||||||
entry.getValue().files.add(path);
|
entry.getValue().files.add(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addLog(String path, boolean expectPurge) {
|
void addLog(String path, boolean expectPurge) {
|
||||||
addFile(path);
|
File file = new File(path);
|
||||||
|
addFile(file);
|
||||||
if (expectPurge) {
|
if (expectPurge) {
|
||||||
expectedPurgedLogs.add(path);
|
expectedPurgedLogs.add(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addImage(String path, boolean expectPurge) {
|
void addImage(String path, boolean expectPurge) {
|
||||||
addFile(path);
|
File file = new File(path);
|
||||||
|
addFile(file);
|
||||||
if (expectPurge) {
|
if (expectPurge) {
|
||||||
expectedPurgedImages.add(path);
|
expectedPurgedImages.add(file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -364,6 +369,30 @@ public Void answer(InvocationOnMock invocation) throws Throwable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a file to a platform-agnostic URI path.
|
||||||
|
*
|
||||||
|
* @param file File to convert
|
||||||
|
* @return String path
|
||||||
|
*/
|
||||||
|
private static String fileToPath(File file) {
|
||||||
|
return file.toURI().getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts multiple files to platform-agnostic URI paths.
|
||||||
|
*
|
||||||
|
* @param files Collection<File> files to convert
|
||||||
|
* @return Collection<String> paths
|
||||||
|
*/
|
||||||
|
private static Collection<String> filesToPaths(Collection<File> files) {
|
||||||
|
List<String> paths = Lists.newArrayList();
|
||||||
|
for (File file: files) {
|
||||||
|
paths.add(fileToPath(file));
|
||||||
|
}
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
private static NNStorage mockStorageForDirs(final StorageDirectory ... mockDirs)
|
private static NNStorage mockStorageForDirs(final StorageDirectory ... mockDirs)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
NNStorage mockStorage = Mockito.mock(NNStorage.class);
|
NNStorage mockStorage = Mockito.mock(NNStorage.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user