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 46EB3200BC5 for ; Tue, 22 Nov 2016 22:33:24 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 458FE160B1C; Tue, 22 Nov 2016 21:33:24 +0000 (UTC) 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 97A31160B1F for ; Tue, 22 Nov 2016 22:33:23 +0100 (CET) Received: (qmail 81547 invoked by uid 500); 22 Nov 2016 21:33:19 -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 81098 invoked by uid 99); 22 Nov 2016 21:33:18 -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, 22 Nov 2016 21:33:18 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 77C61F16B8; Tue, 22 Nov 2016 21:33:18 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sjlee@apache.org To: common-commits@hadoop.apache.org Date: Tue, 22 Nov 2016 21:33:26 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [09/50] [abbrv] hadoop git commit: HDFS-8870. Lease is leaked on write failure. Contributed by Kuhu Shukla. archived-at: Tue, 22 Nov 2016 21:33:24 -0000 HDFS-8870. Lease is leaked on write failure. Contributed by Kuhu Shukla. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/4fcea8a0 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/4fcea8a0 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/4fcea8a0 Branch: refs/heads/HADOOP-13070 Commit: 4fcea8a0c8019d6d9a5e6f315c83659938b93a40 Parents: 5af572b Author: Kihwal Lee Authored: Tue Nov 15 14:47:53 2016 -0600 Committer: Kihwal Lee Committed: Tue Nov 15 14:47:53 2016 -0600 ---------------------------------------------------------------------- .../org/apache/hadoop/hdfs/DFSOutputStream.java | 5 +---- .../apache/hadoop/hdfs/TestDFSOutputStream.java | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/4fcea8a0/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java index a73ab95..e4929e1 100755 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSOutputStream.java @@ -749,8 +749,6 @@ public class DFSOutputStream extends FSOutputSummer b.add(e); } } - - dfsClient.endFileLease(fileId); final IOException ioe = b.build(); if (ioe != null) { throw ioe; @@ -763,6 +761,7 @@ public class DFSOutputStream extends FSOutputSummer void setClosed() { closed = true; + dfsClient.endFileLease(fileId); getStreamer().release(); } @@ -796,8 +795,6 @@ public class DFSOutputStream extends FSOutputSummer b.add(e); } } - - dfsClient.endFileLease(fileId); final IOException ioe = b.build(); if (ioe != null) { throw ioe; http://git-wip-us.apache.org/repos/asf/hadoop/blob/4fcea8a0/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSOutputStream.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSOutputStream.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSOutputStream.java index d9df1ff..750103d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSOutputStream.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSOutputStream.java @@ -50,6 +50,11 @@ import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import static org.mockito.Matchers.anyBoolean; +import static org.mockito.Matchers.anyLong; +import org.mockito.Mockito; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; import org.mockito.internal.util.reflection.Whitebox; import static org.junit.Assert.assertEquals; @@ -202,6 +207,20 @@ public class TestDFSOutputStream { assertEquals(1, 3 - numDataNodesWithData); } + @Test + public void testEndLeaseCall() throws Exception { + Configuration conf = new Configuration(); + DFSClient client = new DFSClient(cluster.getNameNode(0) + .getNameNodeAddress(), conf); + DFSClient spyClient = Mockito.spy(client); + DFSOutputStream dfsOutputStream = spyClient.create("/file2", + FsPermission.getFileDefault(), + EnumSet.of(CreateFlag.CREATE), (short) 3, 1024, null , 1024, null); + DFSOutputStream spyDFSOutputStream = Mockito.spy(dfsOutputStream); + spyDFSOutputStream.closeThreads(anyBoolean()); + verify(spyClient, times(1)).endFileLease(anyLong()); + } + @AfterClass public static void tearDown() { if (cluster != null) { --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org For additional commands, e-mail: common-commits-help@hadoop.apache.org