Return-Path: X-Original-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Delivered-To: apmail-hadoop-hdfs-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B27A1CA9C for ; Thu, 3 May 2012 21:14:09 +0000 (UTC) Received: (qmail 58557 invoked by uid 500); 3 May 2012 21:14:09 -0000 Delivered-To: apmail-hadoop-hdfs-commits-archive@hadoop.apache.org Received: (qmail 58529 invoked by uid 500); 3 May 2012 21:14:09 -0000 Mailing-List: contact hdfs-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hdfs-dev@hadoop.apache.org Delivered-To: mailing list hdfs-commits@hadoop.apache.org Received: (qmail 58485 invoked by uid 99); 3 May 2012 21:14:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 May 2012 21:14:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 May 2012 21:14:05 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2AD9D2388C18; Thu, 3 May 2012 21:13:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1333624 - in /hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs: CHANGES.txt src/main/java/org/apache/hadoop/hdfs/DFSClient.java src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java Date: Thu, 03 May 2012 21:13:43 -0000 To: hdfs-commits@hadoop.apache.org From: todd@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120503211344.2AD9D2388C18@eris.apache.org> Author: todd Date: Thu May 3 21:13:43 2012 New Revision: 1333624 URL: http://svn.apache.org/viewvc?rev=1333624&view=rev Log: HDFS-3359. DFSClient.close should close cached sockets. Contributed by Todd Lipcon. Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1333624&r1=1333623&r2=1333624&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Thu May 3 21:13:43 2012 @@ -592,6 +592,8 @@ Release 2.0.0 - UNRELEASED HDFS-3351. NameNode#initializeGenericKeys should always set fs.defaultFS regardless of whether HA or Federation is enabled. (atm) + HDFS-3359. DFSClient.close should close cached sockets. (todd) + BREAKDOWN OF HDFS-1623 SUBTASKS HDFS-2179. Add fencing framework and mechanisms for NameNode HA. (todd) Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java?rev=1333624&r1=1333623&r2=1333624&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSClient.java Thu May 3 21:13:43 2012 @@ -560,6 +560,7 @@ public class DFSClient implements java.i void abort() { clientRunning = false; closeAllFilesBeingWritten(true); + socketCache.clear(); closeConnectionToNamenode(); } @@ -597,6 +598,7 @@ public class DFSClient implements java.i public synchronized void close() throws IOException { if(clientRunning) { closeAllFilesBeingWritten(false); + socketCache.clear(); clientRunning = false; leaserenewer.closeClient(this); // close connections to the namenode Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java?rev=1333624&r1=1333623&r2=1333624&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java (original) +++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java Thu May 3 21:13:43 2012 @@ -85,6 +85,7 @@ public class TestDistributedFileSystem { /** * Tests DFSClient.close throws no ConcurrentModificationException if * multiple files are open. + * Also tests that any cached sockets are closed. (HDFS-3359) */ @Test public void testDFSClose() throws Exception { @@ -94,11 +95,23 @@ public class TestDistributedFileSystem { cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build(); FileSystem fileSys = cluster.getFileSystem(); - // create two files + // create two files, leaving them open fileSys.create(new Path("/test/dfsclose/file-0")); fileSys.create(new Path("/test/dfsclose/file-1")); + + // create another file, close it, and read it, so + // the client gets a socket in its SocketCache + Path p = new Path("/non-empty-file"); + DFSTestUtil.createFile(fileSys, p, 1L, (short)1, 0L); + DFSTestUtil.readFile(fileSys, p); + + DFSClient client = ((DistributedFileSystem)fileSys).dfs; + SocketCache cache = client.socketCache; + assertEquals(1, cache.size()); fileSys.close(); + + assertEquals(0, cache.size()); } finally { if (cluster != null) {cluster.shutdown();} }