zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject svn commit: r1445033 - in /zookeeper/bookkeeper/trunk: ./ bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/ bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/
Date Tue, 12 Feb 2013 05:00:19 GMT
Author: sijie
Date: Tue Feb 12 05:00:18 2013
New Revision: 1445033

URL: http://svn.apache.org/r1445033
Log:
BOOKKEEPER-554: fd leaking when move ledger index file (sijie, ivank via sijie)

Modified:
    zookeeper/bookkeeper/trunk/CHANGES.txt
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java
    zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1445033&r1=1445032&r2=1445033&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Tue Feb 12 05:00:18 2013
@@ -12,6 +12,8 @@ Trunk (unreleased changes)
 
       BOOKKEEPER-561: Findbugs report errors with openjdk (ivank via umamahesh)
 
+      BOOKKEEPER-554: fd leaking when move ledger index file (sijie, ivank via sijie)
+
     IMPROVEMENTS:
 
       BOOKKEEPER-526: multiple threads for delivery manager (sijie via ivank)

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java?rev=1445033&r1=1445032&r2=1445033&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
Tue Feb 12 05:00:18 2013
@@ -29,6 +29,7 @@ import java.nio.BufferUnderflowException
 import java.nio.channels.FileChannel;
 
 import static com.google.common.base.Charsets.UTF_8;
+import com.google.common.annotations.VisibleForTesting;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -336,6 +337,11 @@ class FileInfo {
         useCount++;
     }
 
+    @VisibleForTesting
+    synchronized int getUseCount() {
+        return useCount;
+    }
+
     synchronized public void release() {
         useCount--;
         if (isClosed && useCount == 0 && fc != null) {

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java?rev=1445033&r1=1445032&r2=1445033&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCacheImpl.java
Tue Feb 12 05:00:18 2013
@@ -360,10 +360,17 @@ public class LedgerCacheImpl implements 
                 // if some new dir detected as full, then move all corresponding
                 // open index files to new location
                 for (Long l : dirtyLedgers) {
-                    FileInfo fi = getFileInfo(l, null);
-                    File currentDir = getLedgerDirForLedger(fi);
-                    if (ledgerDirsManager.isDirFull(currentDir)) {
-                        moveLedgerIndexFile(l, fi);
+                    FileInfo fi = null;
+                    try {
+                        fi = getFileInfo(l, null);
+                        File currentDir = getLedgerDirForLedger(fi);
+                        if (ledgerDirsManager.isDirFull(currentDir)) {
+                            moveLedgerIndexFile(l, fi);
+                        }
+                    } finally {
+                        if (null != fi) {
+                            fi.release();
+                        }
                     }
                 }
                 shouldRelocateIndexFile.set(false);

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java?rev=1445033&r1=1445032&r2=1445033&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java
Tue Feb 12 05:00:18 2013
@@ -282,6 +282,8 @@ public class LedgerCacheTest extends Tes
         ledgerStorage.flush();
         File after = newFileInfo.getLf();
 
+        assertEquals("Reference counting for the file info should be zero.", 0, newFileInfo.getUseCount());
+
         assertFalse("After flush index file should be changed", before.equals(after));
         // Verify written entries
         Assert.assertArrayEquals(generateEntry(1, 1).array(), ledgerStorage.getEntry(1, 1).array());



Mime
View raw message