zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iv...@apache.org
Subject svn commit: r1293372 - in /zookeeper/bookkeeper/trunk: CHANGES.txt bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCache.java
Date Fri, 24 Feb 2012 18:20:56 GMT
Author: ivank
Date: Fri Feb 24 18:20:56 2012
New Revision: 1293372

URL: http://svn.apache.org/viewvc?rev=1293372&view=rev
Log:
BOOKKEEPER-178: Delay ledger directory creation until the ledger index file was created (sijie
via ivank)

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/LedgerCache.java

Modified: zookeeper/bookkeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/CHANGES.txt?rev=1293372&r1=1293371&r2=1293372&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/CHANGES.txt (original)
+++ zookeeper/bookkeeper/trunk/CHANGES.txt Fri Feb 24 18:20:56 2012
@@ -51,6 +51,7 @@ Trunk (unreleased changes)
         BOOKKEEPER-140: Hub server doesn't subscribe remote region correctly when a region
is down. (Sijie Gou via ivank)
 
         BOOKKEEPER-133: Hub server should update subscription state to zookeeper when losing
topic or shutting down (Sijie Gou via ivank)
+
     IMPROVEMENTS:
 
       bookkeeper-server/
@@ -67,6 +68,8 @@ Trunk (unreleased changes)
 
 	BOOKKEEPER-172: Upgrade framework for filesystem layouts (ivank via fpj)
 
+        BOOKKEEPER-178: Delay ledger directory creation until the ledger index file was created
(sijie via ivank)
+
       hedwig-server/
 
         BOOKKEEPER-77: Add a console client for hedwig (Sijie Guo 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=1293372&r1=1293371&r2=1293372&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
Fri Feb 24 18:20:56 2012
@@ -120,6 +120,8 @@ class FileInfo {
 
         if (!exists) { 
             if (create) {
+                // delayed the creation of parents directories
+                checkParents(lf);
                 fc = new RandomAccessFile(lf, "rw").getChannel();
                 size = fc.size();
                 if (size == 0) {
@@ -232,4 +234,14 @@ class FileInfo {
     public boolean delete() {
         return lf.delete();
     }
+
+    static final private void checkParents(File f) throws IOException {
+        File parent = f.getParentFile();
+        if (parent.exists()) {
+            return;
+        }
+        if (parent.mkdirs() == false) {
+            throw new IOException("Counldn't mkdirs for " + parent);
+        }
+    }
 }

Modified: zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCache.java
URL: http://svn.apache.org/viewvc/zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCache.java?rev=1293372&r1=1293371&r2=1293372&view=diff
==============================================================================
--- zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCache.java
(original)
+++ zookeeper/bookkeeper/trunk/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerCache.java
Fri Feb 24 18:20:56 2012
@@ -211,16 +211,6 @@ public class LedgerCache {
         return sb.toString();
     }
 
-    static final private void checkParents(File f) throws IOException {
-        File parent = f.getParentFile();
-        if (parent.exists()) {
-            return;
-        }
-        if (parent.mkdirs() == false) {
-            throw new IOException("Counldn't mkdirs for " + parent);
-        }
-    }
-
     static final private Random rand = new Random();
 
     static final private File pickDirs(File dirs[]) {
@@ -246,7 +236,6 @@ public class LedgerCache {
                     }
                     File dir = pickDirs(ledgerDirectories);
                     lf = new File(dir, ledgerName);
-                    checkParents(lf);
                     // A new ledger index file has been created for this Bookie.
                     // Add this new ledger to the set of active ledgers.
                     if (LOG.isDebugEnabled()) {



Mime
View raw message