From 267d7ca14e271ae7b3ee8f56a0eb1749c39d1324 Mon Sep 17 00:00:00 2001 From: Tsz-wo Sze Date: Wed, 5 Jun 2013 13:53:12 +0000 Subject: [PATCH] svn merge -c -1489709 for reverting HDFS-4876. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1489875 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 - .../hdfs/server/namenode/FSImageFormat.java | 2 +- .../hdfs/server/namenode/INodeFile.java | 4 +- .../hadoop/hdfs/server/namenode/INodeMap.java | 2 +- .../namenode/snapshot/FileDiffList.java | 57 +++++++++++++++++++ .../namenode/snapshot/FileWithSnapshot.java | 35 ++---------- .../snapshot/SnapshotFSImageFormat.java | 2 +- 7 files changed, 67 insertions(+), 38 deletions(-) create mode 100644 hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileDiffList.java diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 01379c876f5..e05e235811c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -829,9 +829,6 @@ Release 2.1.0-beta - UNRELEASED HDFS-4826. TestNestedSnapshots times out due to repeated slow edit log flushes when running on virtualized disk. (Chris Nauroth via szetszwo) - HDFS-4876. Fix the javadoc of FileWithSnapshot and move FileDiffList to - FileWithSnapshot. (szetszwo) - Release 2.0.5-alpha - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java index 8cea71365c0..22b4c6b49b1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImageFormat.java @@ -50,7 +50,7 @@ import org.apache.hadoop.hdfs.protocol.LayoutVersion.Feature; import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo; import org.apache.hadoop.hdfs.server.blockmanagement.BlockManager; import org.apache.hadoop.hdfs.server.common.InconsistentFSStateException; -import org.apache.hadoop.hdfs.server.namenode.snapshot.FileWithSnapshot.FileDiffList; +import org.apache.hadoop.hdfs.server.namenode.snapshot.FileDiffList; import org.apache.hadoop.hdfs.server.namenode.snapshot.INodeDirectorySnapshottable; import org.apache.hadoop.hdfs.server.namenode.snapshot.INodeDirectoryWithSnapshot; import org.apache.hadoop.hdfs.server.namenode.snapshot.INodeFileUnderConstructionWithSnapshot; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java index e04016582f0..53df0691ea4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeFile.java @@ -23,15 +23,17 @@ import java.io.PrintWriter; import java.util.List; import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.fs.permission.FsAction; +import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.fs.permission.PermissionStatus; import org.apache.hadoop.hdfs.protocol.QuotaExceededException; import org.apache.hadoop.hdfs.server.blockmanagement.BlockCollection; import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfo; import org.apache.hadoop.hdfs.server.blockmanagement.BlockInfoUnderConstruction; import org.apache.hadoop.hdfs.server.blockmanagement.DatanodeDescriptor; +import org.apache.hadoop.hdfs.server.namenode.snapshot.FileDiffList; import org.apache.hadoop.hdfs.server.namenode.snapshot.FileWithSnapshot; import org.apache.hadoop.hdfs.server.namenode.snapshot.FileWithSnapshot.FileDiff; -import org.apache.hadoop.hdfs.server.namenode.snapshot.FileWithSnapshot.FileDiffList; import org.apache.hadoop.hdfs.server.namenode.snapshot.FileWithSnapshot.Util; import org.apache.hadoop.hdfs.server.namenode.snapshot.INodeFileWithSnapshot; import org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeMap.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeMap.java index a5c4d6f51bd..18c8adf3fa8 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeMap.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/INodeMap.java @@ -45,7 +45,7 @@ public class INodeMap { } /** Synchronized by external lock. */ - private final GSet map; + private GSet map; private INodeMap(GSet map) { Preconditions.checkArgument(map != null); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileDiffList.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileDiffList.java new file mode 100644 index 00000000000..ae5afa281ba --- /dev/null +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileDiffList.java @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.hadoop.hdfs.server.namenode.snapshot; + + +import org.apache.hadoop.classification.InterfaceAudience; +import org.apache.hadoop.hdfs.server.namenode.INodeFile; +import org.apache.hadoop.hdfs.server.namenode.INodeFileUnderConstruction; +import org.apache.hadoop.hdfs.server.namenode.snapshot.FileWithSnapshot.FileDiff; + +/** + * A list of FileDiffs for storing snapshot data. + */ +@InterfaceAudience.Private +public class FileDiffList + extends AbstractINodeDiffList { + + + @Override + FileDiff createDiff(Snapshot snapshot, INodeFile file) { + return new FileDiff(snapshot, file); + } + + @Override + INodeFile createSnapshotCopy(INodeFile currentINode) { + if (currentINode instanceof INodeFileUnderConstructionWithSnapshot) { + final INodeFileUnderConstruction uc = + (INodeFileUnderConstruction) currentINode; + + final INodeFileUnderConstruction copy = new INodeFileUnderConstruction( + uc, uc.getClientName(), uc.getClientMachine(), uc.getClientNode()); + + copy.setBlocks(null); + return copy; + } else { + final INodeFile copy = new INodeFile(currentINode); + copy.setBlocks(null); + return copy; + } + } +} diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileWithSnapshot.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileWithSnapshot.java index 6a4c99bb1f3..4c3e451a831 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileWithSnapshot.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/FileWithSnapshot.java @@ -27,12 +27,13 @@ import org.apache.hadoop.hdfs.server.namenode.FSImageSerialization; import org.apache.hadoop.hdfs.server.namenode.INode.BlocksMapUpdateInfo; import org.apache.hadoop.hdfs.server.namenode.INode; import org.apache.hadoop.hdfs.server.namenode.INodeFile; -import org.apache.hadoop.hdfs.server.namenode.INodeFileUnderConstruction; import org.apache.hadoop.hdfs.server.namenode.Quota; import org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotFSImageFormat.ReferenceMap; /** - * An interface for {@link INodeFile} to support snapshot. + * {@link INodeFile} with a link to the next element. + * The link of all the snapshot files and the original file form a circular + * linked list so that all elements are accessible by any of the elements. */ @InterfaceAudience.Private public interface FileWithSnapshot { @@ -43,7 +44,7 @@ public interface FileWithSnapshot { /** The file size at snapshot creation time. */ private final long fileSize; - private FileDiff(Snapshot snapshot, INodeFile file) { + FileDiff(Snapshot snapshot, INodeFile file) { super(snapshot, null, null); fileSize = file.computeFileSize(); } @@ -118,34 +119,6 @@ public interface FileWithSnapshot { } } - /** A list of FileDiffs for storing snapshot data. */ - public static class FileDiffList - extends AbstractINodeDiffList { - - @Override - FileDiff createDiff(Snapshot snapshot, INodeFile file) { - return new FileDiff(snapshot, file); - } - - @Override - INodeFile createSnapshotCopy(INodeFile currentINode) { - if (currentINode instanceof INodeFileUnderConstructionWithSnapshot) { - final INodeFileUnderConstruction uc = - (INodeFileUnderConstruction) currentINode; - - final INodeFileUnderConstruction copy = new INodeFileUnderConstruction( - uc, uc.getClientName(), uc.getClientMachine(), uc.getClientNode()); - - copy.setBlocks(null); - return copy; - } else { - final INodeFile copy = new INodeFile(currentINode); - copy.setBlocks(null); - return copy; - } - } - } - /** @return the {@link INodeFile} view of this object. */ public INodeFile asINodeFile(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotFSImageFormat.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotFSImageFormat.java index 9761b7b2017..a969e1f3efa 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotFSImageFormat.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotFSImageFormat.java @@ -34,7 +34,7 @@ import org.apache.hadoop.hdfs.server.namenode.INodeDirectory; import org.apache.hadoop.hdfs.server.namenode.INodeFile; import org.apache.hadoop.hdfs.server.namenode.INodeReference; import org.apache.hadoop.hdfs.server.namenode.snapshot.FileWithSnapshot.FileDiff; -import org.apache.hadoop.hdfs.server.namenode.snapshot.FileWithSnapshot.FileDiffList; +import org.apache.hadoop.hdfs.server.namenode.snapshot.FileDiffList; import org.apache.hadoop.hdfs.server.namenode.snapshot.INodeDirectoryWithSnapshot.DirectoryDiff; import org.apache.hadoop.hdfs.server.namenode.snapshot.INodeDirectoryWithSnapshot.DirectoryDiffList; import org.apache.hadoop.hdfs.tools.snapshot.SnapshotDiff;