Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Fix TestFSEditLogLoader for new layout. (trivial fixup)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hdfs/branches/HDFS-1073@1134166 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
toddlipcon committed Jun 10, 2011
1 parent b3fe242 commit a425c4f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Expand Up @@ -35,6 +35,7 @@
import java.util.Set; import java.util.Set;


import org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory; import org.apache.hadoop.hdfs.server.common.Storage.StorageDirectory;
import org.apache.hadoop.hdfs.server.namenode.FSImageTransactionalStorageInspector.FoundEditLog;
import org.apache.hadoop.hdfs.server.namenode.FSImageTransactionalStorageInspector.FoundFSImage; import org.apache.hadoop.hdfs.server.namenode.FSImageTransactionalStorageInspector.FoundFSImage;
import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeDirType; import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeDirType;
import org.apache.hadoop.hdfs.util.MD5FileUtils; import org.apache.hadoop.hdfs.util.MD5FileUtils;
Expand Down Expand Up @@ -235,6 +236,19 @@ public static File findNewestImageFile(String currentDirPath) throws IOException
return (latestImage == null) ? null : latestImage.getFile(); return (latestImage == null) ? null : latestImage.getFile();
} }


/**
* @return the latest edits log, finalized or otherwise, from the given
* storage directory.
*/
public static FoundEditLog findLatestEditsLog(StorageDirectory sd)
throws IOException {
FSImageTransactionalStorageInspector inspector =
new FSImageTransactionalStorageInspector();
inspector.inspectDirectory(sd);

return inspector.foundEditLogs.get(inspector.foundEditLogs.size() - 1);
}

/** /**
* Corrupt the given VERSION file by replacing a given * Corrupt the given VERSION file by replacing a given
* key with a new value and re-writing the file. * key with a new value and re-writing the file.
Expand Down
Expand Up @@ -57,9 +57,11 @@ public void testDisplayRecentEditLogOpCodes() throws IOException {
fileSys.mkdirs(new Path("/tmp/tmp" + i)); fileSys.mkdirs(new Path("/tmp/tmp" + i));
} }
StorageDirectory sd = fsimage.getStorage().dirIterator(NameNodeDirType.EDITS).next(); StorageDirectory sd = fsimage.getStorage().dirIterator(NameNodeDirType.EDITS).next();
File editFile = NNStorage.getStorageFile(sd, NameNodeFile.EDITS);
cluster.shutdown(); cluster.shutdown();


File editFile = FSImageTestUtil.findLatestEditsLog(sd).getFile();
assertTrue("Should exist: " + editFile, editFile.exists());

// Corrupt the edits file. // Corrupt the edits file.
long fileLen = editFile.length(); long fileLen = editFile.length();
RandomAccessFile rwf = new RandomAccessFile(editFile, "rw"); RandomAccessFile rwf = new RandomAccessFile(editFile, "rw");
Expand Down

0 comments on commit a425c4f

Please sign in to comment.