Return-Path: X-Original-To: apmail-zookeeper-commits-archive@www.apache.org Delivered-To: apmail-zookeeper-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 8697810248 for ; Sat, 7 Dec 2013 10:17:06 +0000 (UTC) Received: (qmail 80781 invoked by uid 500); 7 Dec 2013 10:17:04 -0000 Delivered-To: apmail-zookeeper-commits-archive@zookeeper.apache.org Received: (qmail 80679 invoked by uid 500); 7 Dec 2013 10:16:58 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 80664 invoked by uid 99); 7 Dec 2013 10:16:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Dec 2013 10:16:56 +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; Sat, 07 Dec 2013 10:16:54 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id CE86F23888FE; Sat, 7 Dec 2013 10:16:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1548825 - in /zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java Date: Sat, 07 Dec 2013 10:16:34 -0000 To: commits@zookeeper.apache.org From: fpj@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131207101634.CE86F23888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fpj Date: Sat Dec 7 10:16:34 2013 New Revision: 1548825 URL: http://svn.apache.org/r1548825 Log: ZOOKEEPER-1459. Standalone ZooKeeperServer is not closing the transaction log files on shutdown (Rakesh R via fpj) Modified: zookeeper/trunk/CHANGES.txt zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java Modified: zookeeper/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1548825&r1=1548824&r2=1548825&view=diff ============================================================================== --- zookeeper/trunk/CHANGES.txt (original) +++ zookeeper/trunk/CHANGES.txt Sat Dec 7 10:16:34 2013 @@ -485,6 +485,9 @@ BUGFIXES: ZOOKEEPER-1632. fix memory leaks in cli_st (fpj via michim) + ZOOKEEPER-1459. Standalone ZooKeeperServer is not closing + the transaction log files on shutdown (Rakesh R via fpj) + IMPROVEMENTS: ZOOKEEPER-1170. Fix compiler (eclipse) warnings: unused imports, Modified: zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java?rev=1548825&r1=1548824&r2=1548825&view=diff ============================================================================== --- zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java (original) +++ zookeeper/trunk/src/java/main/org/apache/zookeeper/server/ZooKeeperServerMain.java Sat Dec 7 10:16:34 2013 @@ -97,12 +97,14 @@ public class ZooKeeperServerMain { */ public void runFromConfig(ServerConfig config) throws IOException { LOG.info("Starting server"); + FileTxnSnapLog txnLog = null; try { // Note that this thread isn't going to be doing anything else, // so rather than spawning another thread, we will just call // run() in this thread. // create a file logger url from the command line args - ZooKeeperServer zkServer = new ZooKeeperServer( new FileTxnSnapLog(config.dataLogDir, config.dataDir), + txnLog = new FileTxnSnapLog(config.dataLogDir, config.dataDir); + ZooKeeperServer zkServer = new ZooKeeperServer( txnLog, config.tickTime, config.minSessionTimeout, config.maxSessionTimeout, null); cnxnFactory = ServerCnxnFactory.createFactory(); @@ -116,6 +118,10 @@ public class ZooKeeperServerMain { } catch (InterruptedException e) { // warn, but generally this is ok LOG.warn("Server interrupted", e); + } finally { + if (txnLog != null) { + txnLog.close(); + } } } Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java?rev=1548825&r1=1548824&r2=1548825&view=diff ============================================================================== --- zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java (original) +++ zookeeper/trunk/src/java/test/org/apache/zookeeper/server/ZooKeeperServerMainTest.java Sat Dec 7 10:16:34 2013 @@ -47,10 +47,11 @@ public class ZooKeeperServerMainTest ext public static class MainThread extends Thread { final File confFile; final TestZKSMain main; + final File tmpDir; public MainThread(int clientPort) throws IOException { super("Standalone server with clientPort:" + clientPort); - File tmpDir = ClientBase.createTmpDir(); + tmpDir = ClientBase.createTmpDir(); confFile = new File(tmpDir, "zoo.cfg"); FileWriter fwriter = new FileWriter(confFile); @@ -89,9 +90,25 @@ public class ZooKeeperServerMainTest ext } } - public void shutdown() { + public void shutdown() throws IOException { main.shutdown(); } + + void deleteDirs() throws IOException{ + delete(tmpDir); + } + + void delete(File f) throws IOException { + if (f.isDirectory()) { + for (File c : f.listFiles()) + delete(c); + } + if (!f.delete()) + // double check for the file existence + if (f.exists()) { + throw new IOException("Failed to delete file: " + f); + } + } } public static class TestZKSMain extends ZooKeeperServerMain { @@ -126,6 +143,8 @@ public class ZooKeeperServerMainTest ext zk.close(); main.shutdown(); + main.join(); + main.deleteDirs(); Assert.assertTrue("waiting for server down", ClientBase.waitForServerDown("127.0.0.1:" + CLIENT_PORT,