You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by to...@apache.org on 2011/06/10 00:57:51 UTC
svn commit: r1134127 - in /hadoop/hdfs/branches/HDFS-1073: ./
src/java/org/apache/hadoop/hdfs/server/namenode/
src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/
Author: todd
Date: Thu Jun 9 22:57:50 2011
New Revision: 1134127
URL: http://svn.apache.org/viewvc?rev=1134127&view=rev
Log:
HDFS-2027. Image inspector should return finalized logs before unfinalize logs. Contributed by Todd Lipcon.
Modified:
hadoop/hdfs/branches/HDFS-1073/CHANGES.HDFS-1073.txt
hadoop/hdfs/branches/HDFS-1073/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageTransactionalStorageInspector.java
hadoop/hdfs/branches/HDFS-1073/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImageStorageInspector.java
Modified: hadoop/hdfs/branches/HDFS-1073/CHANGES.HDFS-1073.txt
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/HDFS-1073/CHANGES.HDFS-1073.txt?rev=1134127&r1=1134126&r2=1134127&view=diff
==============================================================================
--- hadoop/hdfs/branches/HDFS-1073/CHANGES.HDFS-1073.txt (original)
+++ hadoop/hdfs/branches/HDFS-1073/CHANGES.HDFS-1073.txt Thu Jun 9 22:57:50 2011
@@ -48,3 +48,5 @@ HDFS-2016. Add infrastructure to remove
HDFS-2047. Improve TestNamespace and TestEditLog in HDFS-1073 branch. (todd)
HDFS-2048. Add upgrade tests and fix upgrade from 0.22 with corrupt image.
(todd)
+HDFS-2027. Image inspector should return finalized logs before unfinalized
+ logs. (todd)
Modified: hadoop/hdfs/branches/HDFS-1073/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageTransactionalStorageInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/HDFS-1073/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageTransactionalStorageInspector.java?rev=1134127&r1=1134126&r2=1134127&view=diff
==============================================================================
--- hadoop/hdfs/branches/HDFS-1073/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageTransactionalStorageInspector.java (original)
+++ hadoop/hdfs/branches/HDFS-1073/src/java/org/apache/hadoop/hdfs/server/namenode/FSImageTransactionalStorageInspector.java Thu Jun 9 22:57:50 2011
@@ -289,11 +289,19 @@ class FSImageTransactionalStorageInspect
}
FoundEditLog getBestNonCorruptLog() {
+ // First look for non-corrupt finalized logs
+ for (FoundEditLog log : logs) {
+ if (!log.isCorrupt() && !log.isInProgress()) {
+ return log;
+ }
+ }
+ // Then look for non-corrupt in-progress logs
for (FoundEditLog log : logs) {
if (!log.isCorrupt()) {
return log;
}
}
+
// We should never get here, because we don't get to the planning stage
// without calling planRecovery first, and if we've called planRecovery,
// we would have already thrown if there were no non-corrupt logs!
Modified: hadoop/hdfs/branches/HDFS-1073/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImageStorageInspector.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/branches/HDFS-1073/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImageStorageInspector.java?rev=1134127&r1=1134126&r2=1134127&view=diff
==============================================================================
--- hadoop/hdfs/branches/HDFS-1073/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImageStorageInspector.java (original)
+++ hadoop/hdfs/branches/HDFS-1073/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestFSImageStorageInspector.java Thu Jun 9 22:57:50 2011
@@ -332,11 +332,11 @@ public class TestFSImageStorageInspector
mockDirectoryWithEditLogs("/foo1/current/edits_1-1",
"/foo1/current/edits_2-200"));
inspector.inspectDirectory(
- mockDirectoryWithEditLogs("/foo2/current/edits_1-inprogress",
+ mockDirectoryWithEditLogs("/foo2/current/edits_inprogress_1",
"/foo2/current/edits_201-400"));
inspector.inspectDirectory(
mockDirectoryWithEditLogs("/foo3/current/edits_1-1",
- "/foo3/current/edts_2-200"));
+ "/foo3/current/edits_2-200"));
assertEquals("[[1,1], [2,200], [201,400]]",
inspector.getEditLogManifest(1).toString());
@@ -346,8 +346,31 @@ public class TestFSImageStorageInspector
inspector.getEditLogManifest(10).toString());
assertEquals("[[201,400]]",
inspector.getEditLogManifest(201).toString());
- }
+ }
+ /**
+ * Test case where an in-progress log is in an earlier name directory
+ * than a finalized log. Previously, getEditLogManifest wouldn't
+ * see this log.
+ */
+ @Test
+ public void testLogManifestInProgressComesFirst() throws IOException {
+ FSImageTransactionalStorageInspector inspector =
+ new FSImageTransactionalStorageInspector();
+ inspector.inspectDirectory(
+ mockDirectoryWithEditLogs("/foo1/current/edits_2622-2623",
+ "/foo1/current/edits_2624-2625",
+ "/foo1/current/edits_inprogress_2626"));
+ inspector.inspectDirectory(
+ mockDirectoryWithEditLogs("/foo2/current/edits_2622-2623",
+ "/foo2/current/edits_2624-2625",
+ "/foo2/current/edits_2626-2627",
+ "/foo2/current/edits_2628-2629"));
+
+ assertEquals("[[2622,2623], [2624,2625], [2626,2627], [2628,2629]]",
+ inspector.getEditLogManifest(2621).toString());
+ }
+
private StorageDirectory mockDirectoryWithEditLogs(String... fileNames) {
return mockDirectory(NameNodeDirType.EDITS, false, fileNames);
}