You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by iv...@apache.org on 2014/12/05 12:27:08 UTC

[1/2] bookkeeper git commit: Changed version 4.3.0 -> 4.3.1-SNAPSHOT, and prepared CHANGES.txt

Repository: bookkeeper
Updated Branches:
  refs/heads/branch-4.3 946fa5446 -> 3a6830c05


Changed version 4.3.0 -> 4.3.1-SNAPSHOT, and prepared CHANGES.txt

Change-Id: I92bde89473a0551c9d59d7620d582e57a3014ffd


Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/9d19bae2
Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/9d19bae2
Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/9d19bae2

Branch: refs/heads/branch-4.3
Commit: 9d19bae267deb72f8721661f998e4cc6ff542d24
Parents: 946fa54
Author: Ivan Kelly <iv...@apache.org>
Authored: Thu Dec 4 12:33:03 2014 +0100
Committer: Ivan Kelly <iv...@apache.org>
Committed: Thu Dec 4 12:35:36 2014 +0100

----------------------------------------------------------------------
 CHANGES.txt                                                  | 6 ++++++
 bookkeeper-benchmark/pom.xml                                 | 2 +-
 bookkeeper-server/pom.xml                                    | 2 +-
 bookkeeper-stats-providers/codahale-metrics-provider/pom.xml | 2 +-
 bookkeeper-stats-providers/pom.xml                           | 4 ++--
 bookkeeper-stats-providers/twitter-ostrich-provider/pom.xml  | 2 +-
 bookkeeper-stats-providers/twitter-science-provider/pom.xml  | 2 +-
 bookkeeper-stats/pom.xml                                     | 2 +-
 compat-deps/bookkeeper-server-compat-4.0.0/pom.xml           | 2 +-
 compat-deps/bookkeeper-server-compat-4.1.0/pom.xml           | 2 +-
 compat-deps/bookkeeper-server-compat-4.2.0/pom.xml           | 2 +-
 compat-deps/hedwig-server-compat-4.0.0/pom.xml               | 2 +-
 compat-deps/hedwig-server-compat-4.1.0/pom.xml               | 2 +-
 compat-deps/hedwig-server-compat-4.2.0/pom.xml               | 2 +-
 compat-deps/pom.xml                                          | 4 ++--
 hedwig-client-jms/pom.xml                                    | 2 +-
 hedwig-client/pom.xml                                        | 2 +-
 hedwig-protocol/pom.xml                                      | 2 +-
 hedwig-server/pom.xml                                        | 2 +-
 pom.xml                                                      | 2 +-
 20 files changed, 27 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 43c4c7c..411bc1b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,9 @@
+Release 4.3.1 - unreleased
+
+  Backward compatible changes:
+
+    BUGFIXES:
+
 Release 4.3.0 - 2014-10-03
 
   Non-backward compatible changes:

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/bookkeeper-benchmark/pom.xml
----------------------------------------------------------------------
diff --git a/bookkeeper-benchmark/pom.xml b/bookkeeper-benchmark/pom.xml
index a303d27..e874b00 100644
--- a/bookkeeper-benchmark/pom.xml
+++ b/bookkeeper-benchmark/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <artifactId>bookkeeper</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <groupId>org.apache.bookkeeper</groupId>
   <artifactId>bookkeeper-benchmark</artifactId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/bookkeeper-server/pom.xml
----------------------------------------------------------------------
diff --git a/bookkeeper-server/pom.xml b/bookkeeper-server/pom.xml
index adc8ae8..f7d3304 100644
--- a/bookkeeper-server/pom.xml
+++ b/bookkeeper-server/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>bookkeeper</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <groupId>org.apache.bookkeeper</groupId>
   <artifactId>bookkeeper-server</artifactId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/bookkeeper-stats-providers/codahale-metrics-provider/pom.xml
----------------------------------------------------------------------
diff --git a/bookkeeper-stats-providers/codahale-metrics-provider/pom.xml b/bookkeeper-stats-providers/codahale-metrics-provider/pom.xml
index 0c6f07c..88a396d 100644
--- a/bookkeeper-stats-providers/codahale-metrics-provider/pom.xml
+++ b/bookkeeper-stats-providers/codahale-metrics-provider/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>bookkeeper</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
     <relativePath>../..</relativePath>
   </parent>
   <groupId>org.apache.bookkeeper.stats</groupId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/bookkeeper-stats-providers/pom.xml
----------------------------------------------------------------------
diff --git a/bookkeeper-stats-providers/pom.xml b/bookkeeper-stats-providers/pom.xml
index f4287ff..6f6af91 100644
--- a/bookkeeper-stats-providers/pom.xml
+++ b/bookkeeper-stats-providers/pom.xml
@@ -22,11 +22,11 @@
   <parent>
     <artifactId>bookkeeper</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.bookkeeper</groupId>
-  <version>4.3.0</version>
+  <version>4.3.1-SNAPSHOT</version>
   <artifactId>bookkeeper-stats-providers</artifactId>
   <packaging>pom</packaging>
   <name>bookkeeper-stats-providers</name>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/bookkeeper-stats-providers/twitter-ostrich-provider/pom.xml
----------------------------------------------------------------------
diff --git a/bookkeeper-stats-providers/twitter-ostrich-provider/pom.xml b/bookkeeper-stats-providers/twitter-ostrich-provider/pom.xml
index e2b50f5..3307618 100644
--- a/bookkeeper-stats-providers/twitter-ostrich-provider/pom.xml
+++ b/bookkeeper-stats-providers/twitter-ostrich-provider/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>bookkeeper</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
     <relativePath>../..</relativePath>
   </parent>
   <groupId>org.apache.bookkeeper.stats</groupId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/bookkeeper-stats-providers/twitter-science-provider/pom.xml
----------------------------------------------------------------------
diff --git a/bookkeeper-stats-providers/twitter-science-provider/pom.xml b/bookkeeper-stats-providers/twitter-science-provider/pom.xml
index 0b0ad02..57a4f45 100644
--- a/bookkeeper-stats-providers/twitter-science-provider/pom.xml
+++ b/bookkeeper-stats-providers/twitter-science-provider/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>bookkeeper</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
     <relativePath>../..</relativePath>
   </parent>
   <groupId>org.apache.bookkeeper.stats</groupId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/bookkeeper-stats/pom.xml
----------------------------------------------------------------------
diff --git a/bookkeeper-stats/pom.xml b/bookkeeper-stats/pom.xml
index 286c01c..771f7af 100644
--- a/bookkeeper-stats/pom.xml
+++ b/bookkeeper-stats/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>bookkeeper</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <groupId>org.apache.bookkeeper.stats</groupId>
   <artifactId>bookkeeper-stats-api</artifactId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/compat-deps/bookkeeper-server-compat-4.0.0/pom.xml
----------------------------------------------------------------------
diff --git a/compat-deps/bookkeeper-server-compat-4.0.0/pom.xml b/compat-deps/bookkeeper-server-compat-4.0.0/pom.xml
index 297cda6..15fd49d 100644
--- a/compat-deps/bookkeeper-server-compat-4.0.0/pom.xml
+++ b/compat-deps/bookkeeper-server-compat-4.0.0/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>compat-deps</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <groupId>org.apache.bookkeeper</groupId>
   <artifactId>bookkeeper-server-compat400</artifactId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/compat-deps/bookkeeper-server-compat-4.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/compat-deps/bookkeeper-server-compat-4.1.0/pom.xml b/compat-deps/bookkeeper-server-compat-4.1.0/pom.xml
index 5259316..b70f638 100644
--- a/compat-deps/bookkeeper-server-compat-4.1.0/pom.xml
+++ b/compat-deps/bookkeeper-server-compat-4.1.0/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>compat-deps</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <groupId>org.apache.bookkeeper</groupId>
   <artifactId>bookkeeper-server-compat410</artifactId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/compat-deps/bookkeeper-server-compat-4.2.0/pom.xml
----------------------------------------------------------------------
diff --git a/compat-deps/bookkeeper-server-compat-4.2.0/pom.xml b/compat-deps/bookkeeper-server-compat-4.2.0/pom.xml
index 092e12f..c562191 100644
--- a/compat-deps/bookkeeper-server-compat-4.2.0/pom.xml
+++ b/compat-deps/bookkeeper-server-compat-4.2.0/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>compat-deps</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <groupId>org.apache.bookkeeper</groupId>
   <artifactId>bookkeeper-server-compat420</artifactId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/compat-deps/hedwig-server-compat-4.0.0/pom.xml
----------------------------------------------------------------------
diff --git a/compat-deps/hedwig-server-compat-4.0.0/pom.xml b/compat-deps/hedwig-server-compat-4.0.0/pom.xml
index 1d7d38e..9a6dff3 100644
--- a/compat-deps/hedwig-server-compat-4.0.0/pom.xml
+++ b/compat-deps/hedwig-server-compat-4.0.0/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>compat-deps</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <groupId>org.apache.bookkeeper</groupId>
   <artifactId>hedwig-server-compat400</artifactId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/compat-deps/hedwig-server-compat-4.1.0/pom.xml
----------------------------------------------------------------------
diff --git a/compat-deps/hedwig-server-compat-4.1.0/pom.xml b/compat-deps/hedwig-server-compat-4.1.0/pom.xml
index 8534cd4..d019a79 100644
--- a/compat-deps/hedwig-server-compat-4.1.0/pom.xml
+++ b/compat-deps/hedwig-server-compat-4.1.0/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>compat-deps</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <groupId>org.apache.bookkeeper</groupId>
   <artifactId>hedwig-server-compat410</artifactId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/compat-deps/hedwig-server-compat-4.2.0/pom.xml
----------------------------------------------------------------------
diff --git a/compat-deps/hedwig-server-compat-4.2.0/pom.xml b/compat-deps/hedwig-server-compat-4.2.0/pom.xml
index 069b242..b37e014 100644
--- a/compat-deps/hedwig-server-compat-4.2.0/pom.xml
+++ b/compat-deps/hedwig-server-compat-4.2.0/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <artifactId>compat-deps</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <groupId>org.apache.bookkeeper</groupId>
   <artifactId>hedwig-server-compat420</artifactId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/compat-deps/pom.xml
----------------------------------------------------------------------
diff --git a/compat-deps/pom.xml b/compat-deps/pom.xml
index 0aab5cc..c54c779 100644
--- a/compat-deps/pom.xml
+++ b/compat-deps/pom.xml
@@ -22,11 +22,11 @@
   <parent>
     <artifactId>bookkeeper</artifactId>
     <groupId>org.apache.bookkeeper</groupId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.bookkeeper</groupId>
-  <version>4.3.0</version>
+  <version>4.3.1-SNAPSHOT</version>
   <artifactId>compat-deps</artifactId>
   <packaging>pom</packaging>
   <name>compability dependencies</name>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/hedwig-client-jms/pom.xml
----------------------------------------------------------------------
diff --git a/hedwig-client-jms/pom.xml b/hedwig-client-jms/pom.xml
index 97ee5e3..8edbc3d 100644
--- a/hedwig-client-jms/pom.xml
+++ b/hedwig-client-jms/pom.xml
@@ -21,7 +21,7 @@
   <parent>
     <groupId>org.apache.bookkeeper</groupId>
     <artifactId>bookkeeper</artifactId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <groupId>org.apache.bookkeeper</groupId>
   <artifactId>hedwig-client-jms</artifactId>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/hedwig-client/pom.xml
----------------------------------------------------------------------
diff --git a/hedwig-client/pom.xml b/hedwig-client/pom.xml
index 989f718..e0c4021 100644
--- a/hedwig-client/pom.xml
+++ b/hedwig-client/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.bookkeeper</groupId>
     <artifactId>bookkeeper</artifactId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <properties>
       <mainclass>org.apache.hedwig.client.App</mainclass>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/hedwig-protocol/pom.xml
----------------------------------------------------------------------
diff --git a/hedwig-protocol/pom.xml b/hedwig-protocol/pom.xml
index f4093f8..14398f9 100644
--- a/hedwig-protocol/pom.xml
+++ b/hedwig-protocol/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.bookkeeper</groupId>
     <artifactId>bookkeeper</artifactId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <artifactId>hedwig-protocol</artifactId>
   <packaging>jar</packaging>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/hedwig-server/pom.xml
----------------------------------------------------------------------
diff --git a/hedwig-server/pom.xml b/hedwig-server/pom.xml
index 1bf5e45..de442a7 100644
--- a/hedwig-server/pom.xml
+++ b/hedwig-server/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache.bookkeeper</groupId>
     <artifactId>bookkeeper</artifactId>
-    <version>4.3.0</version>
+    <version>4.3.1-SNAPSHOT</version>
   </parent>
   <properties>
       <mainclass>org.apache.hedwig.server.netty.PubSubServer</mainclass>

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/9d19bae2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3bb2629..f926258 100644
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.bookkeeper</groupId>
-  <version>4.3.0</version>
+  <version>4.3.1-SNAPSHOT</version>
   <artifactId>bookkeeper</artifactId>
   <packaging>pom</packaging>
   <name>bookkeeper</name>


[2/2] bookkeeper git commit: BOOKKEEPER-815: Ledger fence state is lost when the ledger file is evicted (Charles Xie via ivank)

Posted by iv...@apache.org.
BOOKKEEPER-815: Ledger fence state is lost when the ledger file is evicted (Charles Xie via ivank)


Project: http://git-wip-us.apache.org/repos/asf/bookkeeper/repo
Commit: http://git-wip-us.apache.org/repos/asf/bookkeeper/commit/3a6830c0
Tree: http://git-wip-us.apache.org/repos/asf/bookkeeper/tree/3a6830c0
Diff: http://git-wip-us.apache.org/repos/asf/bookkeeper/diff/3a6830c0

Branch: refs/heads/branch-4.3
Commit: 3a6830c05b1cb078abb191e1e23fabebf1f9312b
Parents: 9d19bae
Author: Ivan Kelly <iv...@apache.org>
Authored: Thu Dec 4 12:28:25 2014 +0100
Committer: Ivan Kelly <iv...@apache.org>
Committed: Fri Dec 5 12:24:55 2014 +0100

----------------------------------------------------------------------
 CHANGES.txt                                     |   2 +
 .../org/apache/bookkeeper/bookie/FileInfo.java  |   6 +-
 .../bookie/IndexPersistenceMgrTest.java         | 125 +++++++++++++++++++
 3 files changed, 132 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/3a6830c0/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 411bc1b..85b88c0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,8 @@ Release 4.3.1 - unreleased
 
     BUGFIXES:
 
+      BOOKKEEPER-815: Ledger fence state is lost when the ledger file is evicted (Charles Xie via ivank)
+
 Release 4.3.0 - 2014-10-03
 
   Non-backward compatible changes:

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/3a6830c0/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
index f96627b..44f004a 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/FileInfo.java
@@ -136,7 +136,7 @@ class FileInfo {
         }
     }
 
-    synchronized private void checkOpen(boolean create) throws IOException {
+    synchronized void checkOpen(boolean create) throws IOException {
         if (fc != null) {
             return;
         }
@@ -259,6 +259,10 @@ class FileInfo {
     synchronized public void close(boolean force) throws IOException {
         isClosed = true;
         checkOpen(force);
+        // Any time when we force close a file, we should try to flush header. otherwise, we might lose fence bit.
+        if (force) {
+            flushHeader();
+        }
         if (useCount.get() == 0 && fc != null) {
             fc.close();
         }

http://git-wip-us.apache.org/repos/asf/bookkeeper/blob/3a6830c0/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/IndexPersistenceMgrTest.java
----------------------------------------------------------------------
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/IndexPersistenceMgrTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/IndexPersistenceMgrTest.java
new file mode 100644
index 0000000..d97343c
--- /dev/null
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/IndexPersistenceMgrTest.java
@@ -0,0 +1,125 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.bookkeeper.bookie;
+
+import org.apache.bookkeeper.conf.ServerConfiguration;
+import org.apache.bookkeeper.stats.NullStatsLogger;
+import org.apache.bookkeeper.util.SnapshotMap;
+import org.apache.commons.io.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+
+import static com.google.common.base.Charsets.UTF_8;
+import static org.junit.Assert.*;
+
+/**
+ * Test cases for IndexPersistenceMgr
+ */
+public class IndexPersistenceMgrTest {
+
+    static final Logger logger = LoggerFactory.getLogger(IndexPersistenceMgr.class);
+
+    ServerConfiguration conf;
+    File journalDir, ledgerDir;
+    LedgerDirsManager ledgerDirsManager;
+
+    @Before
+    public void setUp() throws Exception {
+        journalDir = File.createTempFile("IndexPersistenceMgr", "Journal");
+        journalDir.delete();
+        journalDir.mkdir();
+        ledgerDir = File.createTempFile("IndexPersistenceMgr", "Ledger");
+        ledgerDir.delete();
+        ledgerDir.mkdir();
+        // Create current directories
+        Bookie.getCurrentDirectory(journalDir).mkdir();
+        Bookie.getCurrentDirectory(ledgerDir).mkdir();
+
+        conf = new ServerConfiguration();
+        conf.setZkServers(null);
+        conf.setJournalDirName(journalDir.getPath());
+        conf.setLedgerDirNames(new String[] { ledgerDir.getPath() });
+
+        ledgerDirsManager = new LedgerDirsManager(conf, conf.getLedgerDirs());
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        ledgerDirsManager.shutdown();
+        FileUtils.deleteDirectory(journalDir);
+        FileUtils.deleteDirectory(ledgerDir);
+    }
+
+    private IndexPersistenceMgr createIndexPersistenceManager(int openFileLimit) throws Exception {
+        ServerConfiguration newConf = new ServerConfiguration();
+        newConf.addConfiguration(conf);
+        newConf.setOpenFileLimit(openFileLimit);
+
+        return new IndexPersistenceMgr(
+                newConf.getPageSize(), newConf.getPageSize() / LedgerEntryPage.getIndexEntrySize(),
+                newConf, new SnapshotMap<Long, Boolean>(), ledgerDirsManager, NullStatsLogger.INSTANCE);
+    }
+
+    private static void getNumFileInfos(IndexPersistenceMgr indexPersistenceMgr,
+                                        int numFiles, byte[] masterKey) throws Exception {
+        for (int i = 0; i < numFiles; i++) {
+            indexPersistenceMgr.getFileInfo((long) i, masterKey);
+        }
+    }
+
+    @Test(timeout = 60000)
+    public void testEvictFileInfoWhenUnderlyingFileExists() throws Exception {
+        evictFileInfoTest(true);
+    }
+
+    @Test(timeout = 60000)
+    public void testEvictFileInfoWhenUnderlyingFileDoesntExist() throws Exception {
+        evictFileInfoTest(false);
+    }
+
+    private void evictFileInfoTest(boolean createFile) throws Exception {
+        IndexPersistenceMgr indexPersistenceMgr = createIndexPersistenceManager(5);
+        try {
+            long lid = 99999L;
+            byte[] masterKey = "evict-file-info".getBytes(UTF_8);
+            // get file info and make sure the file created
+            FileInfo fi = indexPersistenceMgr.getFileInfo(lid, masterKey);
+            if (createFile) {
+                fi.checkOpen(true);
+            }
+            fi.setFenced();
+
+            // fill up the cache to evict file infos
+            getNumFileInfos(indexPersistenceMgr, 10, masterKey);
+
+            // get the file info again, state should have been flushed
+            fi = indexPersistenceMgr.getFileInfo(lid, masterKey);
+            assertTrue("Fence bit should be persisted", fi.isFenced());
+        } finally {
+            indexPersistenceMgr.close();
+        }
+    }
+}