Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 03CD8200AED for ; Wed, 4 May 2016 00:04:23 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 014191609F7; Wed, 4 May 2016 00:04:23 +0200 (CEST) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 45CE81609F8 for ; Wed, 4 May 2016 00:04:22 +0200 (CEST) Received: (qmail 29014 invoked by uid 500); 3 May 2016 22:04:20 -0000 Mailing-List: contact common-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list common-commits@hadoop.apache.org Received: (qmail 28767 invoked by uid 99); 3 May 2016 22:04:20 -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, 03 May 2016 22:04:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E6530DFFAB; Tue, 3 May 2016 22:04:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: aw@apache.org To: common-commits@hadoop.apache.org Date: Tue, 03 May 2016 22:04:23 -0000 Message-Id: <318ffbe5fb0c47a9b9634e5817c5b34d@git.apache.org> In-Reply-To: <5a0b1c2bd6d741a88151e42bcdb6bb62@git.apache.org> References: <5a0b1c2bd6d741a88151e42bcdb6bb62@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [5/7] hadoop git commit: HDFS-10344. DistributedFileSystem#getTrashRoots should skip encryption zone that does not have .Trash. Contributed by Xiaoyu Yao. archived-at: Tue, 03 May 2016 22:04:23 -0000 HDFS-10344. DistributedFileSystem#getTrashRoots should skip encryption zone that does not have .Trash. Contributed by Xiaoyu Yao. (cherry picked from commit 45a753ccf79d334513c7bc8f2b81c89a4697075d) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ceb9a49d Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ceb9a49d Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ceb9a49d Branch: refs/heads/branch-2 Commit: ceb9a49d0373d80ba3bd15a10bd98a252756db55 Parents: 89c00da Author: Xiaoyu Yao Authored: Mon May 2 19:30:47 2016 -0700 Committer: Xiaoyu Yao Committed: Mon May 2 19:37:48 2016 -0700 ---------------------------------------------------------------------- .../hadoop/hdfs/DistributedFileSystem.java | 3 ++ .../apache/hadoop/hdfs/TestEncryptionZones.java | 38 ++++++++++++++++++++ 2 files changed, 41 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/ceb9a49d/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index 06f3da7..8442a6b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -2406,6 +2406,9 @@ public class DistributedFileSystem extends FileSystem { while (it.hasNext()) { Path ezTrashRoot = new Path(it.next().getPath(), FileSystem.TRASH_PREFIX); + if (!exists(ezTrashRoot)) { + continue; + } if (allUsers) { for (FileStatus candidate : listStatus(ezTrashRoot)) { if (exists(candidate.getPath())) { http://git-wip-us.apache.org/repos/asf/hadoop/blob/ceb9a49d/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java index 4d56153..bf4586c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestEncryptionZones.java @@ -28,6 +28,7 @@ import java.net.URI; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; @@ -1442,6 +1443,43 @@ public class TestEncryptionZones { verifyShellDeleteWithTrash(shell, encFile); } + @Test(timeout = 120000) + public void testGetTrashRoots() throws Exception { + final HdfsAdmin dfsAdmin = + new HdfsAdmin(FileSystem.getDefaultUri(conf), conf); + Path ezRoot1 = new Path("/ez1"); + fs.mkdirs(ezRoot1); + dfsAdmin.createEncryptionZone(ezRoot1, TEST_KEY); + Path ezRoot2 = new Path("/ez2"); + fs.mkdirs(ezRoot2); + dfsAdmin.createEncryptionZone(ezRoot2, TEST_KEY); + Path ezRoot3 = new Path("/ez3"); + fs.mkdirs(ezRoot3); + dfsAdmin.createEncryptionZone(ezRoot3, TEST_KEY); + Collection trashRootsBegin = fs.getTrashRoots(true); + assertEquals("Unexpected getTrashRoots result", 0, trashRootsBegin.size()); + + final Path encFile = new Path(ezRoot2, "encFile"); + final int len = 8192; + DFSTestUtil.createFile(fs, encFile, len, (short) 1, 0xFEED); + Configuration clientConf = new Configuration(conf); + clientConf.setLong(FS_TRASH_INTERVAL_KEY, 1); + FsShell shell = new FsShell(clientConf); + verifyShellDeleteWithTrash(shell, encFile); + + Collection trashRootsDelete1 = fs.getTrashRoots(true); + assertEquals("Unexpected getTrashRoots result", 1, + trashRootsDelete1.size()); + + final Path nonEncFile = new Path("/nonEncFile"); + DFSTestUtil.createFile(fs, nonEncFile, len, (short) 1, 0xFEED); + verifyShellDeleteWithTrash(shell, nonEncFile); + + Collection trashRootsDelete2 = fs.getTrashRoots(true); + assertEquals("Unexpected getTrashRoots result", 2, + trashRootsDelete2.size()); + } + private void verifyShellDeleteWithTrash(FsShell shell, Path path) throws Exception{ try { --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org