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 sz...@apache.org on 2013/05/31 07:10:06 UTC
svn commit: r1488094 - in
/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs: ./
src/main/java/ src/main/java/org/apache/hadoop/hdfs/server/namenode/
src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/
src/test/java/org/apache/...
Author: szetszwo
Date: Fri May 31 05:10:06 2013
New Revision: 1488094
URL: http://svn.apache.org/r1488094
Log:
svn merge -c 1487655 from trunk for HDFS-4857. Snapshot.Root and AbstractINodeDiff#snapshotINode should not be put into INodeMap when loading FSImage.
Modified:
hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/ (props changed)
hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/ (props changed)
hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java
hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/Snapshot.java
hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotFSImageFormat.java
hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java
Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/
------------------------------------------------------------------------------
Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs:r1487655
Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1488094&r1=1488093&r2=1488094&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Fri May 31 05:10:06 2013
@@ -774,6 +774,9 @@ Release 2.0.5-beta - UNRELEASED
HDFS-4846. Clean up snapshot CLI commands output stacktrace for invalid
arguments. (Jing Zhao via brandonli)
+ HDFS-4857. Snapshot.Root and AbstractINodeDiff#snapshotINode should not be
+ put into INodeMap when loading FSImage. (jing9)
+
Release 2.0.4-alpha - 2013-04-25
INCOMPATIBLE CHANGES
Propchange: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/
------------------------------------------------------------------------------
Merged /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java:r1487655
Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java?rev=1488094&r1=1488093&r2=1488094&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java Fri May 31 05:10:06 2013
@@ -407,7 +407,7 @@ public class FSImageFormat {
int numChildren = in.readInt();
for (int i = 0; i < numChildren; i++) {
// load single inode
- INode newNode = loadINodeWithLocalName(false, in);
+ INode newNode = loadINodeWithLocalName(false, in, true);
addToParent(parent, newNode);
}
return numChildren;
@@ -556,10 +556,11 @@ public class FSImageFormat {
}
public INode loadINodeWithLocalName(boolean isSnapshotINode,
- DataInput in) throws IOException {
+ DataInput in, boolean updateINodeMap) throws IOException {
final byte[] localName = FSImageSerialization.readLocalName(in);
INode inode = loadINode(localName, isSnapshotINode, in);
- if (LayoutVersion.supports(Feature.ADD_INODE_ID, getLayoutVersion())) {
+ if (updateINodeMap
+ && LayoutVersion.supports(Feature.ADD_INODE_ID, getLayoutVersion())) {
namesystem.dir.addToInodeMap(inode);
}
return inode;
Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/Snapshot.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/Snapshot.java?rev=1488094&r1=1488093&r2=1488094&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/Snapshot.java (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/Snapshot.java Fri May 31 05:10:06 2013
@@ -129,7 +129,7 @@ public class Snapshot implements Compara
static Snapshot read(DataInput in, FSImageFormat.Loader loader)
throws IOException {
final int snapshotId = in.readInt();
- final INode root = loader.loadINodeWithLocalName(false, in);
+ final INode root = loader.loadINodeWithLocalName(false, in, false);
return new Snapshot(snapshotId, root.asDirectory(), null);
}
Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotFSImageFormat.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotFSImageFormat.java?rev=1488094&r1=1488093&r2=1488094&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotFSImageFormat.java (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotFSImageFormat.java Fri May 31 05:10:06 2013
@@ -127,7 +127,7 @@ public class SnapshotFSImageFormat {
// 3. Load snapshotINode
final INodeFile snapshotINode = in.readBoolean()?
- loader.loadINodeWithLocalName(true, in).asFile(): null;
+ loader.loadINodeWithLocalName(true, in, false).asFile(): null;
return new FileDiff(snapshot, snapshotINode, posterior, fileSize);
}
@@ -194,7 +194,7 @@ public class SnapshotFSImageFormat {
int deletedSize = in.readInt();
List<INode> deletedList = new ArrayList<INode>(deletedSize);
for (int i = 0; i < deletedSize; i++) {
- final INode deleted = loader.loadINodeWithLocalName(true, in);
+ final INode deleted = loader.loadINodeWithLocalName(true, in, true);
deletedList.add(deleted);
// set parent: the parent field of an INode in the deleted list is not
// useful, but set the parent here to be consistent with the original
@@ -246,8 +246,8 @@ public class SnapshotFSImageFormat {
}
/**
- * Load the snapshotINode field of {@link SnapshotDiff}.
- * @param snapshot The Snapshot associated with the {@link SnapshotDiff}.
+ * Load the snapshotINode field of {@link AbstractINodeDiff}.
+ * @param snapshot The Snapshot associated with the {@link AbstractINodeDiff}.
* @param in The {@link DataInput} to read.
* @param loader The {@link Loader} instance that this loading procedure is
* using.
@@ -263,7 +263,7 @@ public class SnapshotFSImageFormat {
} else {
// another boolean is used to indicate whether snapshotINode is non-null
return in.readBoolean()?
- loader.loadINodeWithLocalName(true, in).asDirectory(): null;
+ loader.loadINodeWithLocalName(true, in, false).asDirectory(): null;
}
}
@@ -348,7 +348,8 @@ public class SnapshotFSImageFormat {
final INodeReference.WithCount withCount;
if (firstReferred) {
- final INode referred = loader.loadINodeWithLocalName(isSnapshotINode, in);
+ final INode referred = loader.loadINodeWithLocalName(isSnapshotINode,
+ in, true);
withCount = new INodeReference.WithCount(null, referred);
referenceMap.put(withCount.getId(), withCount);
} else {
Modified: hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java?rev=1488094&r1=1488093&r2=1488094&view=diff
==============================================================================
--- hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java (original)
+++ hadoop/common/branches/branch-2/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImageWithSnapshot.java Fri May 31 05:10:06 2013
@@ -18,6 +18,7 @@
package org.apache.hadoop.hdfs.server.namenode;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.IOException;
@@ -40,6 +41,8 @@ import org.apache.hadoop.hdfs.client.Hdf
import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
import org.apache.hadoop.hdfs.protocol.SnapshottableDirectoryStatus;
import org.apache.hadoop.hdfs.server.namenode.NNStorage.NameNodeFile;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.INodeDirectorySnapshottable;
+import org.apache.hadoop.hdfs.server.namenode.snapshot.INodeDirectoryWithSnapshot.DirectoryDiff;
import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotTestHelper;
import org.apache.hadoop.hdfs.util.Canceler;
import org.apache.log4j.Level;
@@ -163,6 +166,43 @@ public class TestFSImageWithSnapshot {
}
/**
+ * Test when there is snapshot taken on root
+ */
+ @Test
+ public void testSnapshotOnRoot() throws Exception {
+ final Path root = new Path("/");
+ hdfs.allowSnapshot(root);
+ hdfs.createSnapshot(root, "s1");
+
+ cluster.shutdown();
+ cluster = new MiniDFSCluster.Builder(conf).format(false)
+ .numDataNodes(REPLICATION).build();
+ cluster.waitActive();
+ fsn = cluster.getNamesystem();
+ hdfs = cluster.getFileSystem();
+
+ // save namespace and restart cluster
+ hdfs.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
+ hdfs.saveNamespace();
+ hdfs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
+ cluster.shutdown();
+ cluster = new MiniDFSCluster.Builder(conf).format(false)
+ .numDataNodes(REPLICATION).build();
+ cluster.waitActive();
+ fsn = cluster.getNamesystem();
+ hdfs = cluster.getFileSystem();
+
+ INodeDirectorySnapshottable rootNode =
+ (INodeDirectorySnapshottable) fsn.dir.getINode4Write(root.toString());
+ assertTrue("The children list of root should be empty",
+ rootNode.getChildrenList(null).isEmpty());
+ // one snapshot on root: s1
+ List<DirectoryDiff> diffList = rootNode.getDiffs().asList();
+ assertEquals(1, diffList.size());
+ assertEquals("s1", diffList.get(0).getSnapshot().getRoot().getLocalName());
+ }
+
+ /**
* Testing steps:
* <pre>
* 1. Creating/modifying directories/files while snapshots are being taken.