Return-Path: X-Original-To: apmail-hadoop-common-commits-archive@www.apache.org Delivered-To: apmail-hadoop-common-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 88A4510443 for ; Tue, 27 Jan 2015 18:40:19 +0000 (UTC) Received: (qmail 15757 invoked by uid 500); 27 Jan 2015 18:40:19 -0000 Delivered-To: apmail-hadoop-common-commits-archive@hadoop.apache.org Received: (qmail 15691 invoked by uid 500); 27 Jan 2015 18:40:19 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: common-dev@hadoop.apache.org Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 15682 invoked by uid 99); 27 Jan 2015 18:40:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Jan 2015 18:40:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 86B63E03F8; Tue, 27 Jan 2015 18:40:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: zjshen@apache.org To: common-commits@hadoop.apache.org Date: Tue, 27 Jan 2015 18:40:19 -0000 Message-Id: <158b2e76aebd4713b64ed29e19ad7a86@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/50] [abbrv] hadoop git commit: HDFS-7643. Test case to ensure lazy persist files cannot be truncated. (Contributed by Yi Liu) Repository: hadoop Updated Branches: refs/heads/YARN-2928 630f1cd44 -> 3cd9e8dd1 HDFS-7643. Test case to ensure lazy persist files cannot be truncated. (Contributed by Yi Liu) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/6b17eb9e Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/6b17eb9e Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/6b17eb9e Branch: refs/heads/YARN-2928 Commit: 6b17eb9eac7a6073750a062830054efb103059f5 Parents: a122278 Author: Arpit Agarwal Authored: Tue Jan 20 21:58:15 2015 -0800 Committer: Arpit Agarwal Committed: Tue Jan 20 21:58:38 2015 -0800 ---------------------------------------------------------------------- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../fsdataset/impl/TestLazyPersistFiles.java | 26 +++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/6b17eb9e/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 2c7fbc7..1801d2f 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -281,6 +281,9 @@ Trunk (Unreleased) HDFS-7634. Disallow truncation of Lazy persist files. (Yi Liu via Arpit Agarwal) + HDFS-7643. Test case to ensure lazy persist files cannot be truncated. + (Yi Liu via Arpit Agarwal) + Release 2.7.0 - UNRELEASED INCOMPATIBLE CHANGES http://git-wip-us.apache.org/repos/asf/hadoop/blob/6b17eb9e/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestLazyPersistFiles.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestLazyPersistFiles.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestLazyPersistFiles.java index ad2197a..84ac2a5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestLazyPersistFiles.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/TestLazyPersistFiles.java @@ -23,13 +23,10 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants; import org.apache.hadoop.hdfs.protocol.HdfsFileStatus; import org.apache.hadoop.hdfs.protocol.LocatedBlock; import org.apache.hadoop.hdfs.protocol.LocatedBlocks; -import org.apache.hadoop.hdfs.server.datanode.DatanodeUtil; -import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsVolumeSpi; import org.apache.hadoop.test.GenericTestUtils; import org.junit.Assert; import org.junit.Test; -import java.io.File; import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; @@ -37,9 +34,6 @@ import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicBoolean; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; import static org.apache.hadoop.hdfs.DFSConfigKeys.*; import static org.apache.hadoop.hdfs.StorageType.DEFAULT; @@ -248,6 +242,26 @@ public class TestLazyPersistFiles extends LazyPersistTestCase { } /** + * Truncate to lazy persist file is denied. + * @throws IOException + */ + @Test + public void testTruncateIsDenied() throws IOException { + startUpCluster(true, -1); + final String METHOD_NAME = GenericTestUtils.getMethodName(); + Path path = new Path("/" + METHOD_NAME + ".dat"); + + makeTestFile(path, BLOCK_SIZE, true); + + try { + client.truncate(path.toString(), BLOCK_SIZE/2); + fail("Truncate to LazyPersist file did not fail as expected"); + } catch (Throwable t) { + LOG.info("Got expected exception ", t); + } + } + + /** * If one or more replicas of a lazyPersist file are lost, then the file * must be discarded by the NN, instead of being kept around as a * 'corrupt' file.