eolivelli closed pull request #797: ISSUE 230: Enable Checkstyle on the meta 
package
URL: https://github.com/apache/bookkeeper/pull/797
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractHierarchicalLedgerManager.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractHierarchicalLedgerManager.java
index 02359e00e..9d25ac345 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractHierarchicalLedgerManager.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractHierarchicalLedgerManager.java
@@ -29,18 +29,20 @@
 import org.apache.bookkeeper.util.StringUtils;
 import org.apache.zookeeper.AsyncCallback;
 import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.AsyncCallback.VoidCallback;
 import org.apache.zookeeper.KeeperException.Code;
+import org.apache.zookeeper.ZooKeeper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * An abstract class for managing hierarchical ledgers.
+ */
 public abstract class AbstractHierarchicalLedgerManager extends 
AbstractZkLedgerManager {
-    
+
     private static final Logger LOG = 
LoggerFactory.getLogger(AbstractHierarchicalLedgerManager.class);
 
     /**
-     * Constructor
+     * Constructor.
      *
      * @param conf
      *          Configuration object
@@ -50,9 +52,9 @@
     public AbstractHierarchicalLedgerManager(AbstractConfiguration conf, 
ZooKeeper zk) {
         super(conf, zk);
     }
-    
+
     /**
-     * Process hash nodes in a given path
+     * Process hash nodes in a given path.
      */
     void asyncProcessLevelNodes(
         final String path, final Processor<String> processor,
@@ -88,7 +90,7 @@ public void processResult(int rc, String path, Object ctx,
             }
         }, null);
     }
-    
+
     /**
      * Process list one by one in asynchronize way. Process will be stopped 
immediately
      * when error occurred.
@@ -98,7 +100,7 @@ public void processResult(int rc, String path, Object ctx,
         ScheduledExecutorService scheduler;
 
         /**
-         * Constructor
+         * Constructor.
          *
          * @param scheduler
          *          Executor used to prevent long stack chains
@@ -108,7 +110,7 @@ public AsyncListProcessor(ScheduledExecutorService 
scheduler) {
         }
 
         /**
-         * Process list of items
+         * Process list of items.
          *
          * @param data
          *          List of data to process
@@ -150,7 +152,7 @@ public void processResult(int rc, String path, Object ctx) {
                     final AsyncCallback.VoidCallback stub = this;
                     scheduler.submit(new Runnable() {
                         @Override
-                        public final void run() {
+                        public void run() {
                             processor.process(dataToProcess, stub);
                         }
                     });
@@ -160,12 +162,12 @@ public final void run() {
             processor.process(firstElement, stubCallback);
         }
     }
-    
+
     // get ledger from all level nodes
     long getLedgerId(String...levelNodes) throws IOException {
         return StringUtils.stringToHierarchicalLedgerId(levelNodes);
     }
-    
+
     /**
      * Get all ledger ids in the given zk path.
      *
@@ -189,8 +191,9 @@ long getLedgerId(String...levelNodes) throws IOException {
         char ch;
         for (int i = ledgerRootPath.length() + 1; i < path.length(); i++) {
             ch = path.charAt(i);
-            if (ch < '0' || ch > '9')
+            if (ch < '0' || ch > '9') {
                 continue;
+            }
             ledgerIdPrefix = ledgerIdPrefix * 10 + (ch - '0');
         }
 
@@ -201,8 +204,9 @@ long getLedgerId(String...levelNodes) throws IOException {
             long ledgerId = ledgerIdPrefix;
             for (int i = 0; i < ledgerNode.length(); i++) {
                 ch = ledgerNode.charAt(i);
-                if (ch < '0' || ch > '9')
+                if (ch < '0' || ch > '9') {
                     continue;
+                }
                 ledgerId = ledgerId * 10 + (ch - '0');
             }
             zkActiveLedgers.add(ledgerId);
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractZkLedgerManager.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractZkLedgerManager.java
index c93a8a944..3546d89a2 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractZkLedgerManager.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractZkLedgerManager.java
@@ -19,6 +19,7 @@
 
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.List;
@@ -30,6 +31,7 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
+
 import org.apache.bookkeeper.client.BKException;
 import org.apache.bookkeeper.client.LedgerMetadata;
 import org.apache.bookkeeper.conf.AbstractConfiguration;
@@ -52,8 +54,8 @@
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.data.Stat;
 import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -62,9 +64,9 @@
  */
 abstract class AbstractZkLedgerManager implements LedgerManager, Watcher {
 
-    private final static Logger LOG = 
LoggerFactory.getLogger(AbstractZkLedgerManager.class);
+    private static final Logger LOG = 
LoggerFactory.getLogger(AbstractZkLedgerManager.class);
 
-    static int ZK_CONNECT_BACKOFF_MS = 200;
+    private static final int ZK_CONNECT_BACKOFF_MS = 200;
 
     protected final AbstractConfiguration conf;
     protected final ZooKeeper zk;
@@ -109,7 +111,7 @@ public void operationComplete(int rc, final LedgerMetadata 
result) {
                     scheduler.submit(new Runnable() {
                         @Override
                         public void run() {
-                            synchronized(listenerSet) {
+                            synchronized (listenerSet) {
                                 for (LedgerMetadataListener listener : 
listenerSet) {
                                     listener.onChanged(ledgerId, result);
                                 }
@@ -134,7 +136,7 @@ public void run() {
     }
 
     /**
-     * ZooKeeper-based Ledger Manager Constructor
+     * ZooKeeper-based Ledger Manager Constructor.
      *
      * @param conf
      *          Configuration object
@@ -155,7 +157,7 @@ protected AbstractZkLedgerManager(AbstractConfiguration 
conf, ZooKeeper zk) {
     }
 
     /**
-     * Get the znode path that is used to store ledger metadata
+     * Get the znode path that is used to store ledger metadata.
      *
      * @param ledgerId
      *          Ledger ID
@@ -164,7 +166,7 @@ protected AbstractZkLedgerManager(AbstractConfiguration 
conf, ZooKeeper zk) {
     protected abstract String getLedgerPath(long ledgerId);
 
     /**
-     * Get ledger id from its znode ledger path
+     * Get ledger id from its znode ledger path.
      *
      * @param ledgerPath
      *          Ledger path to store metadata
@@ -194,13 +196,13 @@ public void process(WatchedEvent event) {
         case NodeDeleted:
             Set<LedgerMetadataListener> listenerSet = listeners.get(ledgerId);
             if (null != listenerSet) {
-                synchronized(listenerSet){
+                synchronized (listenerSet){
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Removed ledger metadata listeners on ledger 
{} : {}",
                                 ledgerId, listenerSet);
                     }
                     for (LedgerMetadataListener l : listenerSet) {
-                        l.onChanged( ledgerId, null );
+                        l.onChanged(ledgerId, null);
                     }
                     listeners.remove(ledgerId, listenerSet);
                 }
@@ -264,18 +266,18 @@ public void removeLedgerMetadata(final long ledgerId, 
final Version version,
         int znodeVersion = -1;
         if (Version.NEW == version) {
             LOG.error("Request to delete ledger {} metadata with version set 
to the initial one", ledgerId);
-            cb.operationComplete(BKException.Code.MetadataVersionException, 
(Void)null);
+            cb.operationComplete(BKException.Code.MetadataVersionException, 
(Void) null);
             return;
         } else if (Version.ANY != version) {
             if (!(version instanceof LongVersion)) {
                 LOG.info("Not an instance of ZKVersion: {}", ledgerId);
-                
cb.operationComplete(BKException.Code.MetadataVersionException, (Void)null);
+                
cb.operationComplete(BKException.Code.MetadataVersionException, (Void) null);
                 return;
             } else {
                 znodeVersion = (int) ((LongVersion) version).getLongVersion();
             }
         }
-        
+
         VoidCallback callbackForDelete = new VoidCallback() {
             @Override
             public void processResult(int rc, String path, Object ctx) {
@@ -288,7 +290,8 @@ public void processResult(int rc, String path, Object ctx) {
                     Set<LedgerMetadataListener> listenerSet = 
listeners.remove(ledgerId);
                     if (null != listenerSet) {
                         if (LOG.isDebugEnabled()) {
-                            LOG.debug("Remove registered ledger metadata 
listeners on ledger {} after ledger is deleted.",
+                            LOG.debug(
+                                    "Remove registered ledger metadata 
listeners on ledger {} after ledger is deleted.",
                                     ledgerId, listenerSet);
                         }
                     } else {
@@ -380,13 +383,14 @@ public void processResult(int rc, String path, Object 
ctx, byte[] data, Stat sta
                     return;
                 }
                 if (stat == null) {
-                    LOG.error("Could not parse ledger metadata for ledger: " + 
ledgerId+". Stat object is null");
+                    LOG.error("Could not parse ledger metadata for ledger: {}. 
Stat object is null", ledgerId);
                     readCb.operationComplete(BKException.Code.ZKException, 
null);
                     return;
                 }
                 LedgerMetadata metadata;
                 try {
-                    metadata = LedgerMetadata.parseConfig(data, new 
LongVersion(stat.getVersion()), Optional.of(stat.getCtime()));
+                    metadata = LedgerMetadata.parseConfig(data, new 
LongVersion(stat.getVersion()),
+                            Optional.of(stat.getCtime()));
                 } catch (IOException e) {
                     LOG.error("Could not parse ledger metadata for ledger: " + 
ledgerId, e);
                     readCb.operationComplete(BKException.Code.ZKException, 
null);
@@ -485,7 +489,7 @@ public void operationComplete(int rc, List<String> 
ledgerNodes) {
     }
 
     /**
-     * Whether the znode a special znode
+     * Whether the znode a special znode.
      *
      * @param znode
      *          Znode Name
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/CleanupLedgerManager.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/CleanupLedgerManager.java
index 50117feed..3b71a02d2 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/CleanupLedgerManager.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/CleanupLedgerManager.java
@@ -18,13 +18,6 @@
 package org.apache.bookkeeper.meta;
 
 import com.google.common.annotations.VisibleForTesting;
-import org.apache.bookkeeper.client.BKException;
-import org.apache.bookkeeper.client.LedgerMetadata;
-import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
-import 
org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.LedgerMetadataListener;
-import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.Processor;
-import org.apache.bookkeeper.versioning.Version;
-import org.apache.zookeeper.AsyncCallback;
 
 import java.io.IOException;
 import java.util.HashSet;
@@ -33,6 +26,17 @@
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import org.apache.bookkeeper.client.BKException;
+import org.apache.bookkeeper.client.LedgerMetadata;
+import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
+import 
org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.LedgerMetadataListener;
+import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.Processor;
+import org.apache.bookkeeper.versioning.Version;
+import org.apache.zookeeper.AsyncCallback;
+
+/**
+ * A ledger manager that cleans up resources upon closing.
+ */
 public class CleanupLedgerManager implements LedgerManager {
 
     private class CleanupGenericCallback<T> implements GenericCallback<T> {
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManager.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManager.java
index 36db62a35..a155c4d28 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManager.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManager.java
@@ -46,7 +46,7 @@
     private final String ledgerPrefix;
 
     /**
-     * Constructor
+     * Constructor.
      *
      * @param conf
      *          Configuration object
@@ -87,9 +87,9 @@ public void asyncProcessLedgers(final Processor<Long> 
processor,
         asyncProcessLedgersInSingleNode(ledgerRootPath, processor, finalCb, 
ctx, successRc, failureRc);
     }
 
-    
     protected static boolean isSpecialZnode(String znode) {
-        return znode.startsWith(ZkLedgerIdGenerator.LEDGER_ID_GEN_PREFIX) || 
AbstractZkLedgerManager.isSpecialZnode(znode);
+        return znode.startsWith(ZkLedgerIdGenerator.LEDGER_ID_GEN_PREFIX)
+            || AbstractZkLedgerManager.isSpecialZnode(znode);
     }
 
     @Override
@@ -99,7 +99,7 @@ public LedgerRangeIterator getLedgerRanges() {
             boolean nextCalled = false;
             LedgerRange nextRange = null;
 
-            synchronized private void preload() throws IOException {
+            private synchronized void preload() throws IOException {
                 if (nextRange != null) {
                     return;
                 }
@@ -116,13 +116,13 @@ synchronized private void preload() throws IOException {
             }
 
             @Override
-            synchronized public boolean hasNext() throws IOException {
+            public synchronized boolean hasNext() throws IOException {
                 preload();
                 return nextRange != null && nextRange.size() > 0 && 
!nextCalled;
             }
 
             @Override
-            synchronized public LedgerRange next() throws IOException {
+            public synchronized LedgerRange next() throws IOException {
                 if (!hasNext()) {
                     throw new NoSuchElementException();
                 }
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java
index 33a46c62e..c736e0ecc 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/FlatLedgerManagerFactory.java
@@ -1,5 +1,3 @@
-package org.apache.bookkeeper.meta;
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -17,20 +15,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.bookkeeper.meta;
 
 import java.io.IOException;
 import java.util.List;
 
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZKUtil;
-import org.apache.bookkeeper.replication.ReplicationException;
 import org.apache.bookkeeper.conf.AbstractConfiguration;
+import org.apache.bookkeeper.replication.ReplicationException;
 import org.apache.bookkeeper.util.ZkUtils;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZKUtil;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.data.ACL;
 
 /**
- * Flat Ledger Manager Factory
+ * Flat Ledger Manager Factory.
  */
 public class FlatLedgerManagerFactory extends LedgerManagerFactory {
 
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManager.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManager.java
index fe260fce0..07607e41a 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManager.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManager.java
@@ -24,18 +24,18 @@
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.Processor;
 import org.apache.bookkeeper.util.StringUtils;
 import org.apache.zookeeper.AsyncCallback.VoidCallback;
+import org.apache.zookeeper.ZooKeeper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.zookeeper.ZooKeeper;
 
 /**
  * HierarchicalLedgerManager makes use of both LongHierarchicalLedgerManager 
and LegacyHierarchicalLedgerManager
- * to extend the 31-bit ledger id range of the LegacyHierarchicalLedgerManager 
to that of the LongHierarchicalLedgerManager
- * while remaining backwards-compatible with the legacy manager.
+ * to extend the 31-bit ledger id range of the LegacyHierarchicalLedgerManager 
to that of the
+ * LongHierarchicalLedgerManager while remaining backwards-compatible with the 
legacy manager.
  *
- * In order to achieve backwards-compatibility, the HierarchicalLedgerManager 
forwards requests relating to ledger IDs which
- * are < Integer.MAX_INT to the LegacyHierarchicalLedgerManager. The new 
5-part directory structure will not appear until a
- * ledger with an ID >= Integer.MAX_INT is created.
+ * <p>In order to achieve backwards-compatibility, the 
HierarchicalLedgerManager forwards requests relating to ledger
+ * IDs which are < Integer.MAX_INT to the LegacyHierarchicalLedgerManager. The 
new 5-part directory structure will not
+ * appear until a ledger with an ID >= Integer.MAX_INT is created.
  *
  * @see LongHierarchicalLedgerManager
  * @see LegacyHierarchicalLedgerManager
@@ -60,11 +60,10 @@ public void asyncProcessLedgers(Processor<Long> processor, 
VoidCallback finalCb,
 
             @Override
             public void processResult(int rc, String path, Object ctx) {
-                if(rc == failureRc) {
+                if (rc == failureRc) {
                     // If it fails, return the failure code to the callback
                     finalCb.processResult(rc, path, ctx);
-                }
-                else {
+                } else {
                     // If it succeeds, proceed with our own recursive ledger 
processing for the 63-bit id ledgers
                     longLM.asyncProcessLedgers(processor, finalCb, context, 
successRc, failureRc);
                 }
@@ -99,7 +98,8 @@ public LedgerRangeIterator getLedgerRanges() {
         LedgerRangeIterator legacyLedgerRangeIterator;
         LedgerRangeIterator longLedgerRangeIterator;
 
-        HierarchicalLedgerRangeIterator(LedgerRangeIterator 
legacyLedgerRangeIterator, LedgerRangeIterator longLedgerRangeIterator) {
+        HierarchicalLedgerRangeIterator(LedgerRangeIterator 
legacyLedgerRangeIterator,
+                LedgerRangeIterator longLedgerRangeIterator) {
             this.legacyLedgerRangeIterator = legacyLedgerRangeIterator;
             this.longLedgerRangeIterator = longLedgerRangeIterator;
         }
@@ -111,7 +111,7 @@ public boolean hasNext() throws IOException {
 
         @Override
         public LedgerRange next() throws IOException {
-            if(legacyLedgerRangeIterator.hasNext()) {
+            if (legacyLedgerRangeIterator.hasNext()) {
                 return legacyLedgerRangeIterator.next();
             }
             return longLedgerRangeIterator.next();
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java
index a74a63364..eeeb6e98c 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/HierarchicalLedgerManagerFactory.java
@@ -23,17 +23,19 @@
 import org.apache.zookeeper.data.ACL;
 
 /**
- * Legacy Hierarchical Ledger Manager Factory
+ * Legacy Hierarchical Ledger Manager Factory.
  */
 public class HierarchicalLedgerManagerFactory extends 
LegacyHierarchicalLedgerManagerFactory {
 
     public static final String NAME = "hierarchical";
-    
+
     @Override
     public LedgerIdGenerator newLedgerIdGenerator() {
         List<ACL> zkAcls = ZkUtils.getACLs(conf);
-        ZkLedgerIdGenerator subIdGenerator = new ZkLedgerIdGenerator(zk, 
conf.getZkLedgersRootPath(), LegacyHierarchicalLedgerManager.IDGEN_ZNODE, 
zkAcls);
-        return new LongZkLedgerIdGenerator(zk, conf.getZkLedgersRootPath(), 
LongHierarchicalLedgerManager.IDGEN_ZNODE, subIdGenerator, zkAcls);
+        ZkLedgerIdGenerator subIdGenerator = new ZkLedgerIdGenerator(zk, 
conf.getZkLedgersRootPath(),
+                LegacyHierarchicalLedgerManager.IDGEN_ZNODE, zkAcls);
+        return new LongZkLedgerIdGenerator(zk, conf.getZkLedgersRootPath(), 
LongHierarchicalLedgerManager.IDGEN_ZNODE,
+                subIdGenerator, zkAcls);
     }
-    
+
 }
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerIdGenerator.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerIdGenerator.java
index 24d1f01ed..a110334fb 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerIdGenerator.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerIdGenerator.java
@@ -19,16 +19,15 @@
 
 import java.io.Closeable;
 
-import org.apache.bookkeeper.client.BKException;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
 
 /**
- * The interface for global unique ledger ID generation
+ * The interface for global unique ledger ID generation.
  */
 public interface LedgerIdGenerator extends Closeable {
 
     /**
-     * generate a global unique ledger id
+     * Generate a global unique ledger id.
      *
      * @param cb
      *            Callback when a new ledger id is generated, return code:<ul>
@@ -36,6 +35,6 @@
      *            <li>{@link BKException.Code.ZKException} when can't generate 
new ledger id</li>
      *            </ul>
      */
-    public void generateLedgerId(GenericCallback<Long> cb);
+    void generateLedgerId(GenericCallback<Long> cb);
 
 }
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java
index 730e288ff..a1e2cef0b 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerLayout.java
@@ -45,7 +45,7 @@
     public static final int LAYOUT_FORMAT_VERSION = 2;
 
     /**
-     * Read ledger layout from zookeeper
+     * Read ledger layout from zookeeper.
      *
      * @param zk            ZooKeeper Client
      * @param ledgersRoot   Root of the ledger namespace to check
@@ -71,8 +71,8 @@ public static LedgerLayout readLayout(final ZooKeeper zk, 
final String ledgersRo
         }
     }
 
-    static final String splitter = ":";
-    static final String lSplitter = "\n";
+    private static final String splitter = ":";
+    private static final String lSplitter = "\n";
 
     // ledger manager factory class
     private String managerFactoryCls;
@@ -83,7 +83,7 @@ public static LedgerLayout readLayout(final ZooKeeper zk, 
final String ledgersRo
     private int layoutFormatVersion = LAYOUT_FORMAT_VERSION;
 
     /**
-     * Ledger Layout Constructor
+     * Ledger Layout Constructor.
      *
      * @param managerFactoryCls
      *          Ledger Manager Factory Class
@@ -104,7 +104,7 @@ public LedgerLayout(String managerFactoryCls, int 
managerVersion) {
     }
 
     /**
-     * Get Ledger Manager Type
+     * Get Ledger Manager Type.
      *
      * @return ledger manager type
      * @deprecated replaced by {@link #getManagerFactoryClass()}
@@ -116,7 +116,7 @@ public String getManagerType() {
     }
 
     /**
-     * Get ledger manager factory class
+     * Get ledger manager factory class.
      *
      * @return ledger manager factory class
      */
@@ -129,7 +129,7 @@ public int getManagerVersion() {
     }
 
     /**
-     * Return layout format version
+     * Return layout format version.
      *
      * @return layout format version
      */
@@ -138,7 +138,7 @@ public int getLayoutFormatVersion() {
     }
 
     /**
-     * Store the ledger layout into zookeeper
+     * Store the ledger layout into zookeeper.
      */
     public void store(final ZooKeeper zk, String ledgersRoot, List<ACL> zkAcls)
             throws IOException, KeeperException, InterruptedException {
@@ -149,7 +149,7 @@ public void store(final ZooKeeper zk, String ledgersRoot, 
List<ACL> zkAcls)
     }
 
     /**
-     * Delete the LAYOUT from zookeeper
+     * Delete the LAYOUT from zookeeper.
      */
     public void delete(final ZooKeeper zk, String ledgersRoot)
             throws KeeperException, InterruptedException {
@@ -175,7 +175,7 @@ public void delete(final ZooKeeper zk, String ledgersRoot)
     }
 
     /**
-     * Parses a given byte array and transforms into a LedgerLayout object
+     * Parses a given byte array and transforms into a LedgerLayout object.
      *
      * @param bytes
      *          byte array to parse
@@ -195,8 +195,7 @@ private static LedgerLayout parseLayout(byte[] bytes) 
throws IOException {
 
         try {
             int layoutFormatVersion = Integer.parseInt(lines[0]);
-            if (LAYOUT_FORMAT_VERSION < layoutFormatVersion ||
-                LAYOUT_MIN_COMPAT_VERSION > layoutFormatVersion) {
+            if (LAYOUT_FORMAT_VERSION < layoutFormatVersion || 
LAYOUT_MIN_COMPAT_VERSION > layoutFormatVersion) {
                 throw new IOException("Metadata version not compatible. 
Expected "
                         + LAYOUT_FORMAT_VERSION + ", but got " + 
layoutFormatVersion);
             }
@@ -227,9 +226,8 @@ public boolean equals(Object obj) {
         if (!(obj instanceof LedgerLayout)) {
             return false;
         }
-        LedgerLayout other = (LedgerLayout)obj;
-        return managerFactoryCls.equals(other.managerFactoryCls)
-            && managerVersion == other.managerVersion;
+        LedgerLayout other = (LedgerLayout) obj;
+        return managerFactoryCls.equals(other.managerFactoryCls) && 
managerVersion == other.managerVersion;
     }
 
     @Override
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerManager.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerManager.java
index fe3c2cf4d..3d8b693eb 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerManager.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerManager.java
@@ -1,5 +1,3 @@
-package org.apache.bookkeeper.meta;
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -17,6 +15,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.bookkeeper.meta;
 
 import java.io.Closeable;
 import java.io.IOException;
@@ -24,13 +23,12 @@
 import java.util.SortedSet;
 import java.util.TreeSet;
 
-import org.apache.zookeeper.AsyncCallback;
-import org.apache.bookkeeper.client.BKException;
 import org.apache.bookkeeper.client.LedgerMetadata;
-import 
org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.LedgerMetadataListener;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
+import 
org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.LedgerMetadataListener;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.Processor;
 import org.apache.bookkeeper.versioning.Version;
+import org.apache.zookeeper.AsyncCallback;
 
 /**
  * LedgerManager takes responsibility of ledger management in client side.
@@ -42,7 +40,7 @@
 public interface LedgerManager extends Closeable {
 
     /**
-     * Create a new ledger with provided ledger id and metadata
+     * Create a new ledger with provided ledger id and metadata.
      *
      * @param ledgerId
      *            Ledger id provided to be created
@@ -56,7 +54,7 @@
      *                 for other issue</li>
      *            </ul>
      */
-    public void createLedgerMetadata(long ledgerId, LedgerMetadata metadata, 
GenericCallback<Void> cb);
+    void createLedgerMetadata(long ledgerId, LedgerMetadata metadata, 
GenericCallback<Void> cb);
 
     /**
      * Remove a specified ledger metadata by ledgerId and version.
@@ -73,7 +71,7 @@
      *          <li>{@link BKException.Code.ZKException} for other issue</li>
      *          </ul>
      */
-    public void removeLedgerMetadata(long ledgerId, Version version, 
GenericCallback<Void> vb);
+    void removeLedgerMetadata(long ledgerId, Version version, 
GenericCallback<Void> cb);
 
     /**
      * Read ledger metadata of a specified ledger.
@@ -87,7 +85,7 @@
      *          <li>{@link BKException.Code.ZKException} for other issue</li>
      *          </ul>
      */
-    public void readLedgerMetadata(long ledgerId, 
GenericCallback<LedgerMetadata> readCb);
+    void readLedgerMetadata(long ledgerId, GenericCallback<LedgerMetadata> 
readCb);
 
     /**
      * Write ledger metadata.
@@ -103,7 +101,7 @@
      *          <li>{@link BKException.Code.ZKException} for other issue</li>
      *          </ul>
      */
-    public void writeLedgerMetadata(long ledgerId, LedgerMetadata metadata, 
GenericCallback<Void> cb);
+    void writeLedgerMetadata(long ledgerId, LedgerMetadata metadata, 
GenericCallback<Void> cb);
 
     /**
      * Register the ledger metadata <i>listener</i> on <i>ledgerId</i>.
@@ -113,7 +111,7 @@
      * @param listener
      *          listener.
      */
-    public abstract void registerLedgerMetadataListener(long ledgerId, 
LedgerMetadataListener listener);
+    void registerLedgerMetadataListener(long ledgerId, LedgerMetadataListener 
listener);
 
     /**
      * Unregister the ledger metadata <i>listener</i> on <i>ledgerId</i>.
@@ -123,7 +121,7 @@
      * @param listener
      *          ledger metadata listener.
      */
-    public abstract void unregisterLedgerMetadataListener(long ledgerId, 
LedgerMetadataListener listener);
+    void unregisterLedgerMetadataListener(long ledgerId, 
LedgerMetadataListener listener);
 
     /**
      * Loop to process all ledgers.
@@ -146,21 +144,21 @@
      * @param failureRc
      *          Failure RC code passed to finalCb when exceptions occured.
      */
-    public void asyncProcessLedgers(Processor<Long> processor, 
AsyncCallback.VoidCallback finalCb,
+    void asyncProcessLedgers(Processor<Long> processor, 
AsyncCallback.VoidCallback finalCb,
                                     Object context, int successRc, int 
failureRc);
 
     /**
-     * Loop to scan a range of metadata from metadata storage
+     * Loop to scan a range of metadata from metadata storage.
      *
      * @return will return a iterator of the Ranges
      */
-    public LedgerRangeIterator getLedgerRanges();
+    LedgerRangeIterator getLedgerRanges();
 
-    /*
+    /**
      * Used to represent the Ledgers range returned from the
      * current scan.
      */
-    public static class LedgerRange {
+    class LedgerRange {
         // returned ledgers
         private final SortedSet<Long> ledgers;
 
@@ -187,7 +185,7 @@ public Long end() {
 
     /**
      * Interface of the ledger meta range iterator from
-     * storage (e.g. in ZooKeeper or other key/value store)
+     * storage (e.g. in ZooKeeper or other key/value store).
      */
     interface LedgerRangeIterator {
 
@@ -199,7 +197,7 @@ public Long end() {
          * in the case it fails to access the ledger metadata store. Otherwise 
it
          * will end up deleting all ledgers by accident.
          */
-        public boolean hasNext() throws IOException;
+        boolean hasNext() throws IOException;
 
         /**
          * Get the next element.
@@ -210,6 +208,6 @@ public Long end() {
          * in the case it fails to access the ledger metadata store. Otherwise 
it
          * will end up deleting all ledgers by accident.
          */
-        public LedgerRange next() throws IOException;
+        LedgerRange next() throws IOException;
     }
 }
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerManagerFactory.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerManagerFactory.java
index 3dc639f16..91d83e79d 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerManagerFactory.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerManagerFactory.java
@@ -1,5 +1,3 @@
-package org.apache.bookkeeper.meta;
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -17,22 +15,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.bookkeeper.meta;
 
 import java.io.IOException;
 import java.util.List;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.bookkeeper.replication.ReplicationException;
 import org.apache.bookkeeper.conf.AbstractConfiguration;
+import org.apache.bookkeeper.replication.ReplicationException;
 import org.apache.bookkeeper.util.ReflectionUtils;
 import org.apache.bookkeeper.util.ZkUtils;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.data.ACL;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
+/**
+ * A factory for creating ledger managers.
+ */
 public abstract class LedgerManagerFactory {
 
     static final Logger LOG = 
LoggerFactory.getLogger(LedgerManagerFactory.class);
@@ -165,9 +166,9 @@ public static LedgerManagerFactory newLedgerManagerFactory(
         }
 
         // handle V2 layout case
-        if (factoryClass != null &&
-            !layout.getManagerFactoryClass().equals(factoryClass.getName()) &&
-            
conf.getProperty(AbstractConfiguration.LEDGER_MANAGER_FACTORY_DISABLE_CLASS_CHECK)
 == null) { // Disable should ONLY happen during compatibility testing.
+        if (factoryClass != null && 
!layout.getManagerFactoryClass().equals(factoryClass.getName())
+                && 
conf.getProperty(AbstractConfiguration.LEDGER_MANAGER_FACTORY_DISABLE_CLASS_CHECK)
 == null) {
+                // Disable should ONLY happen during compatibility testing.
 
             throw new IOException("Configured layout " + factoryClass.getName()
                                 + " does not match existing layout "  + 
layout.getManagerFactoryClass());
@@ -181,7 +182,8 @@ public static LedgerManagerFactory newLedgerManagerFactory(
                 }
                 factoryClass = theCls.asSubclass(LedgerManagerFactory.class);
             } catch (ClassNotFoundException cnfe) {
-                throw new IOException("Failed to instantiate ledger manager 
factory " + layout.getManagerFactoryClass());
+                throw new IOException("Failed to instantiate ledger manager 
factory "
+                        + layout.getManagerFactoryClass());
             }
         }
         // instantiate a factory
@@ -243,7 +245,7 @@ private static LedgerManagerFactory createNewLMFactory(
     }
 
     /**
-     * Format the ledger metadata for LedgerManager
+     * Format the ledger metadata for LedgerManager.
      *
      * @param conf
      *            Configuration instance
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerUnderreplicationManager.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerUnderreplicationManager.java
index 014c1a803..22abcb6a7 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerUnderreplicationManager.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LedgerUnderreplicationManager.java
@@ -17,15 +17,15 @@
  */
 package org.apache.bookkeeper.meta;
 
-import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
-import org.apache.bookkeeper.replication.ReplicationException;
-
 import java.util.Iterator;
 import java.util.List;
 import java.util.function.Predicate;
 
+import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
+import org.apache.bookkeeper.replication.ReplicationException;
+
 /**
- * Interface for marking ledgers which need to be rereplicated
+ * Interface for marking ledgers which need to be rereplicated.
  */
 public interface LedgerUnderreplicationManager {
     /**
@@ -45,13 +45,13 @@ void markLedgerReplicated(long ledgerId)
     /**
      * Get a list of all the ledgers which have been
      * marked for rereplication, filtered by the predicate on the missing 
replicas list.
-     * 
-     * Missing replicas list of an underreplicated ledger is the list of the 
bookies which are part of 
+     *
+     * <p>Missing replicas list of an underreplicated ledger is the list of 
the bookies which are part of
      * the ensemble of this ledger and are currently unavailable/down.
-     * 
-     * If filtering is not needed then it is suggested to pass null for 
predicate,
+     *
+     * <p>If filtering is not needed then it is suggested to pass null for 
predicate,
      * otherwise it will read the content of the ZNode to decide on filtering.
-     * 
+     *
      * @param predicate filter to use while listing under replicated ledgers. 
'null' if filtering is not required
      * @return an iterator which returns ledger ids
      */
@@ -79,14 +79,13 @@ long pollLedgerToRereplicate()
 
 
     /**
-     * Release a previously acquired ledger. This allows others to acquire
-     * the ledger
+     * Release a previously acquired ledger. This allows others to acquire the 
ledger.
      */
     void releaseUnderreplicatedLedger(long ledgerId)
             throws ReplicationException.UnavailableException;
 
     /**
-     * Release all resources held by the ledger underreplication manager
+     * Release all resources held by the ledger underreplication manager.
      */
     void close()
             throws ReplicationException.UnavailableException;
@@ -95,22 +94,22 @@ void close()
      * Stop ledger replication. Currently running ledger rereplication tasks
      * will be continued and will be stopped from next task. This will block
      * ledger replication {@link #Auditor} and {@link 
#getLedgerToRereplicate()}
-     * tasks
+     * tasks.
      */
     void disableLedgerReplication()
             throws ReplicationException.UnavailableException;
 
     /**
      * Resuming ledger replication. This will allow ledger replication
-     * {@link #Auditor} and {@link #getLedgerToRereplicate()} tasks to continue
+     * {@link #Auditor} and {@link #getLedgerToRereplicate()} tasks to 
continue.
      */
     void enableLedgerReplication()
             throws ReplicationException.UnavailableException;
 
     /**
      * Check whether the ledger replication is enabled or not. This will return
-     * true if the ledger replication is enabled, otherwise return false
-     * 
+     * true if the ledger replication is enabled, otherwise return false.
+     *
      * @return - return true if it is enabled otherwise return false
      */
     boolean isLedgerReplicationEnabled()
@@ -118,8 +117,8 @@ boolean isLedgerReplicationEnabled()
 
     /**
      * Receive notification asynchronously when the ledger replication process
-     * is enabled
-     * 
+     * is enabled.
+     *
      * @param cb
      *            - callback implementation to receive the notification
      */
@@ -128,8 +127,8 @@ void notifyLedgerReplicationEnabled(GenericCallback<Void> 
cb)
 
     /**
      * Creates the zNode for lostBookieRecoveryDelay with the specified value 
and returns true.
-     * If the node is already existing, then it returns false   
-     * 
+     * If the node is already existing, then it returns false.
+     *
      * @param lostBookieRecoveryDelay
      * @return
      *      true if it succeeds in creating zNode for lostBookieRecoveryDelay, 
false if it is already existing
@@ -139,24 +138,24 @@ boolean initializeLostBookieRecoveryDelay(int 
lostBookieRecoveryDelay)
             throws ReplicationException.UnavailableException;
 
     /**
-     * Setter for the lostBookieRecoveryDelay znode
-     * 
+     * Setter for the lostBookieRecoveryDelay znode.
+     *
      * @param lostBookieRecoveryDelay
      * @throws ReplicationException.UnavailableException
      */
     void setLostBookieRecoveryDelay(int lostBookieRecoveryDelay) throws 
ReplicationException.UnavailableException;
 
     /**
-     * Getter for the lostBookieRecoveryDelay
-     * 
+     * Getter for the lostBookieRecoveryDelay.
+     *
      * @return the int value of lostBookieRecoveryDelay
      * @throws ReplicationException.UnavailableException
      */
     int getLostBookieRecoveryDelay() throws 
ReplicationException.UnavailableException;
 
     /**
-     * Receive notification asynchronously when the lostBookieRecoveryDelay 
value is Changed
-     * 
+     * Receive notification asynchronously when the lostBookieRecoveryDelay 
value is Changed.
+     *
      * @param cb
      * @throws ReplicationException.UnavailableException
      */
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManager.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManager.java
index 60c44f749..11e2314f3 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManager.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManager.java
@@ -37,8 +37,7 @@
 /**
  * Hierarchical Ledger Manager which manages ledger meta in zookeeper using 
2-level hierarchical znodes.
  *
- * <p>
- * LegacyHierarchicalLedgerManager splits the generated id into 3 parts 
(2-4-4):
+ * <p>LegacyHierarchicalLedgerManager splits the generated id into 3 parts 
(2-4-4):
  * <pre>&lt;level1 (2 digits)&gt;&lt;level2 (4 digits)&gt;&lt;level3 (4 
digits)&gt;</pre>
  * These 3 parts are used to form the actual ledger node path used to store 
ledger metadata:
  * <pre>(ledgersRootPath)/level1/level2/L(level3)</pre>
@@ -60,9 +59,9 @@ protected StringBuilder initialValue() {
             return new StringBuilder();
         }
     };
-    
+
     /**
-     * Constructor
+     * Constructor.
      *
      * @param conf
      *          Configuration object
@@ -92,7 +91,7 @@ public long getLedgerId(String pathName) throws IOException {
     //
 
     /**
-     * Get the smallest cache id in a specified node /level1/level2
+     * Get the smallest cache id in a specified node /level1/level2.
      *
      * @param level1
      *          1st level node name
@@ -105,7 +104,7 @@ private long getStartLedgerIdByLevel(String level1, String 
level2) throws IOExce
     }
 
     /**
-     * Get the largest cache id in a specified node /level1/level2
+     * Get the largest cache id in a specified node /level1/level2.
      *
      * @param level1
      *          1st level node name
@@ -148,7 +147,8 @@ public void process(String l2Node, 
AsyncCallback.VoidCallback cb2) {
     }
 
     protected static boolean isSpecialZnode(String znode) {
-        return IDGEN_ZNODE.equals(znode) || 
LongHierarchicalLedgerManager.IDGEN_ZNODE.equals(znode) || 
AbstractHierarchicalLedgerManager.isSpecialZnode(znode);
+        return IDGEN_ZNODE.equals(znode) || 
LongHierarchicalLedgerManager.IDGEN_ZNODE.equals(znode)
+            || AbstractHierarchicalLedgerManager.isSpecialZnode(znode);
     }
 
     @Override
@@ -157,7 +157,7 @@ public LedgerRangeIterator getLedgerRanges() {
     }
 
     /**
-     * Iterator through each metadata bucket with hierarchical mode
+     * Iterator through each metadata bucket with hierarchical mode.
      */
     private class HierarchicalLedgerRangeIterator implements 
LedgerRangeIterator {
         private Iterator<String> l1NodesIter = null;
@@ -167,7 +167,7 @@ public LedgerRangeIterator getLedgerRanges() {
         private LedgerRange nextRange = null;
 
         /**
-         * iterate next level1 znode
+         * Iterate next level1 znode.
          *
          * @return false if have visited all level1 nodes
          * @throws InterruptedException/KeeperException if error occurs 
reading zookeeper children
@@ -195,7 +195,7 @@ private boolean nextL1Node() throws KeeperException, 
InterruptedException {
             return true;
         }
 
-        synchronized private void preload() throws IOException {
+        private synchronized void preload() throws IOException {
             while (nextRange == null && !iteratorDone) {
                 boolean hasMoreElements = false;
                 try {
@@ -227,13 +227,13 @@ synchronized private void preload() throws IOException {
         }
 
         @Override
-        synchronized public boolean hasNext() throws IOException {
+        public synchronized boolean hasNext() throws IOException {
             preload();
             return nextRange != null && !iteratorDone;
         }
 
         @Override
-        synchronized public LedgerRange next() throws IOException {
+        public synchronized LedgerRange next() throws IOException {
             if (!hasNext()) {
                 throw new NoSuchElementException();
             }
@@ -243,7 +243,7 @@ synchronized public LedgerRange next() throws IOException {
         }
 
         /**
-         * Get a single node level1/level2
+         * Get a single node level1/level2.
          *
          * @param level1
          *          1st level node name
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManagerFactory.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManagerFactory.java
index 1ac403823..1d82d95a4 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManagerFactory.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LegacyHierarchicalLedgerManagerFactory.java
@@ -1,5 +1,3 @@
-package org.apache.bookkeeper.meta;
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -17,20 +15,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.bookkeeper.meta;
 
 import java.io.IOException;
 import java.util.List;
 
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZKUtil;
+import org.apache.bookkeeper.conf.AbstractConfiguration;
 import org.apache.bookkeeper.replication.ReplicationException;
 import org.apache.bookkeeper.util.ZkUtils;
-import org.apache.bookkeeper.conf.AbstractConfiguration;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.ZKUtil;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.data.ACL;
 
 /**
- * Hierarchical Ledger Manager Factory
+ * Hierarchical Ledger Manager Factory.
  */
 public class LegacyHierarchicalLedgerManagerFactory extends 
LedgerManagerFactory {
 
@@ -68,7 +67,8 @@ public void uninitialize() throws IOException {
     @Override
     public LedgerIdGenerator newLedgerIdGenerator() {
         List<ACL> zkAcls = ZkUtils.getACLs(conf);
-        return new ZkLedgerIdGenerator(zk, conf.getZkLedgersRootPath(), 
LegacyHierarchicalLedgerManager.IDGEN_ZNODE, zkAcls);
+        return new ZkLedgerIdGenerator(zk, conf.getZkLedgersRootPath(), 
LegacyHierarchicalLedgerManager.IDGEN_ZNODE,
+                zkAcls);
     }
 
     @Override
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongHierarchicalLedgerManager.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongHierarchicalLedgerManager.java
index b01886e6c..d9f2c1f21 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongHierarchicalLedgerManager.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongHierarchicalLedgerManager.java
@@ -39,24 +39,22 @@
 /**
  * LongHierarchical Ledger Manager which manages ledger meta in zookeeper 
using 5-level hierarchical znodes.
  *
- * <p>
- * LongHierarchicalLedgerManager splits the generated id into 5 parts 
(3-4-4-4-4):
+ * <p>LongHierarchicalLedgerManager splits the generated id into 5 parts 
(3-4-4-4-4):
  *
  * <pre>
  * &lt;level0 (3 digits)&gt;&lt;level1 (4 digits)&gt;&lt;level2 (4 
digits)&gt;&lt;level3 (4 digits)&gt;
  * &lt;level4 (4 digits)&gt;
  * </pre>
  *
- * These 5 parts are used to form the actual ledger node path used to store 
ledger metadata:
+ * <p>These 5 parts are used to form the actual ledger node path used to store 
ledger metadata:
  *
  * <pre>
  * (ledgersRootPath) / level0 / level1 / level2 / level3 / L(level4)
  * </pre>
  *
- * E.g Ledger 0000000000000000001 is split into 5 parts <i>000</i>, 
<i>0000</i>, <i>0000</i>, <i>0000</i>, <i>0001</i>,
- * which is stored in <i>(ledgersRootPath)/000/0000/0000/0000/L0001</i>. So 
each znode could have at most 10000 ledgers,
- * which avoids errors during garbage collection due to lists of children that 
are too long.
- *
+ * <p>E.g Ledger 0000000000000000001 is split into 5 parts <i>000</i>, 
<i>0000</i>, <i>0000</i>, <i>0000</i>,
+ * <i>0001</i>, which is stored in 
<i>(ledgersRootPath)/000/0000/0000/0000/L0001</i>. So each znode could have at 
most
+ * 10000 ledgers, which avoids errors during garbage collection due to lists 
of children that are too long.
  */
 class LongHierarchicalLedgerManager extends AbstractHierarchicalLedgerManager {
 
@@ -68,7 +66,7 @@
 
 
     /**
-     * Constructor
+     * Constructor.
      *
      * @param conf
      *            Configuration object
@@ -87,7 +85,7 @@ public long getLedgerId(String pathName) throws IOException {
         String hierarchicalPath = pathName.substring(ledgerRootPath.length() + 
1);
         return StringUtils.stringToLongHierarchicalLedgerId(hierarchicalPath);
     }
-    
+
     @Override
     public String getLedgerPath(long ledgerId) {
         return ledgerRootPath + 
StringUtils.getLongHierarchicalLedgerPath(ledgerId);
@@ -98,7 +96,7 @@ public String getLedgerPath(long ledgerId) {
     //
 
     /**
-     * Get the smallest cache id in a specified node 
/level0/level1/level2/level3
+     * Get the smallest cache id in a specified node 
/level0/level1/level2/level3.
      *
      * @param level0
      *            1st level node name
@@ -116,7 +114,7 @@ private long getStartLedgerIdByLevel(String level0, String 
level1, String level2
     }
 
     /**
-     * Get the largest cache id in a specified node 
/level0/level1/level2/level3
+     * Get the largest cache id in a specified node 
/level0/level1/level2/level3.
      *
      * @param level0
      *            1st level node name
@@ -148,7 +146,7 @@ protected static boolean isSpecialZnode(String znode) {
         // hierarchical paths (2-4-4)
         return LegacyHierarchicalLedgerManager.isSpecialZnode(znode) || 
znode.length() < 3;
     }
-    
+
     private class RecursiveProcessor implements Processor<String> {
         private final int level;
         private final String path;
@@ -191,7 +189,7 @@ public LedgerRangeIterator getLedgerRanges() {
     }
 
     /**
-     * Iterator through each metadata bucket with hierarchical mode
+     * Iterator through each metadata bucket with hierarchical mode.
      */
     private class LongHierarchicalLedgerRangeIterator implements 
LedgerRangeIterator {
         private List<Iterator<String>> levelNodesIter;
@@ -206,7 +204,8 @@ private LongHierarchicalLedgerRangeIterator() {
             curLevelNodes = new ArrayList<String>(Collections.nCopies(4, 
(String) null));
         }
 
-        synchronized private void initialize(String path, int level) throws 
KeeperException, InterruptedException, IOException {
+        private synchronized void initialize(String path, int level) throws 
KeeperException, InterruptedException,
+                IOException {
             List<String> levelNodes = zk.getChildren(path, null);
             Collections.sort(levelNodes);
             if (level == 0) {
@@ -245,12 +244,12 @@ synchronized private void initialize(String path, int 
level) throws KeeperExcept
         }
 
         private void clearHigherLevels(int level) {
-            for(int i = level+1; i < 4; i++) {
+            for (int i = level + 1; i < 4; i++) {
                 curLevelNodes.set(i, null);
             }
         }
 
-        synchronized private boolean moveToNext(int level) throws 
KeeperException, InterruptedException {
+        private synchronized boolean moveToNext(int level) throws 
KeeperException, InterruptedException {
             Iterator<String> curLevelNodesIter = levelNodesIter.get(level);
             boolean movedToNextNode = false;
             if (level == 0) {
@@ -293,7 +292,7 @@ synchronized private boolean moveToNext(int level) throws 
KeeperException, Inter
             return movedToNextNode;
         }
 
-        synchronized private void preload() throws IOException, 
KeeperException, InterruptedException {
+        private synchronized void preload() throws IOException, 
KeeperException, InterruptedException {
             if (!iteratorDone && !initialized) {
                 initialize(ledgerRootPath, 0);
             }
@@ -308,7 +307,7 @@ synchronized private void preload() throws IOException, 
KeeperException, Interru
         }
 
         @Override
-        synchronized public boolean hasNext() throws IOException {
+        public synchronized boolean hasNext() throws IOException {
             try {
                 preload();
             } catch (KeeperException ke) {
@@ -321,7 +320,7 @@ synchronized public boolean hasNext() throws IOException {
         }
 
         @Override
-        synchronized public LedgerRange next() throws IOException {
+        public synchronized LedgerRange next() throws IOException {
             if (!hasNext()) {
                 throw new NoSuchElementException();
             }
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongHierarchicalLedgerManagerFactory.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongHierarchicalLedgerManagerFactory.java
index 06e7b9e2f..93ad9ddc6 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongHierarchicalLedgerManagerFactory.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongHierarchicalLedgerManagerFactory.java
@@ -17,6 +17,9 @@
  */
 package org.apache.bookkeeper.meta;
 
+/**
+ * LongHierarchical Ledger Manager Factory.
+ */
 public class LongHierarchicalLedgerManagerFactory extends 
HierarchicalLedgerManagerFactory {
 
     public static final String NAME = "longhierarchical";
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongZkLedgerIdGenerator.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongZkLedgerIdGenerator.java
index f41074443..5f7c4d8a3 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongZkLedgerIdGenerator.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/LongZkLedgerIdGenerator.java
@@ -26,11 +26,11 @@
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
 import org.apache.bookkeeper.util.ZkUtils;
 import org.apache.commons.lang.StringUtils;
+import org.apache.zookeeper.AsyncCallback.StringCallback;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.AsyncCallback.StringCallback;
 import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.data.ACL;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -43,16 +43,16 @@
  * fundamentally limited to 9 billion. In practice, the id generated by 
zookeeper
  * is only 31 bits (signed 32-bit integer), so the limit is much lower than 9 
billion.
  *
- * In order to support the full range of the long ledgerId, once ledgerIds 
reach Integer.MAX_INT,
+ * <p>In order to support the full range of the long ledgerId, once ledgerIds 
reach Integer.MAX_INT,
  * a new system is employed. The 32 most significant bits of the ledger ID are 
taken and turned into
  * a directory prefixed with <i>HOB-</i> under <i>(ledgerIdGenPath)</i>
  *
- * Under this <i>HOB-</i> directory, zookeeper is used to continue generating 
EPHEMERAL_SEQUENTIAL ids
- * which constitute the lower 32-bits of the ledgerId (sign bit is always 0). 
Once the <i>HOB-</i> directory runs out of available
- * ids, the process is repeated. The higher bits are incremented, a new 
<i>HOB-</i> directory is created, and
- * zookeeper generates sequential ids underneath it.
+ * <p>Under this <i>HOB-</i> directory, zookeeper is used to continue 
generating EPHEMERAL_SEQUENTIAL ids
+ * which constitute the lower 32-bits of the ledgerId (sign bit is always 0). 
Once the <i>HOB-</i> directory runs out
+ * of available ids, the process is repeated. The higher bits are incremented, 
a new <i>HOB-</i> directory is created,
+ * and zookeeper generates sequential ids underneath it.
  *
- * The reason for treating ids which are less than Integer.MAX_INT differently 
is to maintain backwards
+ * <p>The reason for treating ids which are less than Integer.MAX_INT 
differently is to maintain backwards
  * compatibility. This is a drop-in replacement for ZkLedgerIdGenerator.
  */
 public class LongZkLedgerIdGenerator implements LedgerIdGenerator {
@@ -70,7 +70,8 @@
         NOT_PRESENT
     }
 
-    public LongZkLedgerIdGenerator(ZooKeeper zk, String ledgersPath, String 
idGenZnodeName, ZkLedgerIdGenerator shortIdGen, List<ACL> zkAcls) {
+    public LongZkLedgerIdGenerator(ZooKeeper zk, String ledgersPath, String 
idGenZnodeName,
+            ZkLedgerIdGenerator shortIdGen, List<ACL> zkAcls) {
         this.zk = zk;
         if (StringUtils.isBlank(idGenZnodeName)) {
             this.ledgerIdGenPath = ledgersPath;
@@ -83,27 +84,25 @@ public LongZkLedgerIdGenerator(ZooKeeper zk, String 
ledgersPath, String idGenZno
         this.zkAcls = zkAcls;
     }
 
-    private void generateLongLedgerIdLowBits(final String ledgerPrefix, long 
highBits, final GenericCallback<Long> cb) throws KeeperException, 
InterruptedException, IOException {
-        String highPath = ledgerPrefix + formatHalfId((int)highBits);
+    private void generateLongLedgerIdLowBits(final String ledgerPrefix, long 
highBits, final GenericCallback<Long> cb)
+            throws KeeperException, InterruptedException, IOException {
+        String highPath = ledgerPrefix + formatHalfId((int) highBits);
         ZkLedgerIdGenerator.generateLedgerIdImpl(new GenericCallback<Long>(){
             @Override
             public void operationComplete(int rc, Long result) {
-                if(rc == BKException.Code.OK) {
+                if (rc == BKException.Code.OK) {
                     assert((highBits & 0xFFFFFFFF00000000L) == 0);
                     assert((result & 0xFFFFFFFF00000000L) == 0);
                     cb.operationComplete(rc, (highBits << 32) | result);
-                }
-                else if(rc == BKException.Code.LedgerIdOverflowException) {
+                } else if (rc == BKException.Code.LedgerIdOverflowException) {
                     // Lower bits are full. Need to expand and create another 
HOB node.
                     try {
                         Long newHighBits = highBits + 1;
                         createHOBPathAndGenerateId(ledgerPrefix, 
newHighBits.intValue(), cb);
-                    }
-                    catch (KeeperException e) {
+                    } catch (KeeperException e) {
                         LOG.error("Failed to create long ledger ID path", e);
                         cb.operationComplete(BKException.Code.ZKException, 
null);
-                    }
-                    catch (InterruptedException e) {
+                    } catch (InterruptedException e) {
                         LOG.error("Failed to create long ledger ID path", e);
                         
cb.operationComplete(BKException.Code.InterruptedException, null);
                     } catch (IOException e) {
@@ -118,7 +117,7 @@ else if(rc == BKException.Code.LedgerIdOverflowException) {
     }
 
     /**
-     * Formats half an ID as 10-character 0-padded string
+     * Formats half an ID as 10-character 0-padded string.
      * @param i - 32 bits of the ID to format
      * @return a 10-character 0-padded string.
      */
@@ -126,14 +125,14 @@ private String formatHalfId(int i) {
         return String.format("%010d", i);
     }
 
-    private void createHOBPathAndGenerateId(String ledgerPrefix, int hob, 
final GenericCallback<Long> cb) throws KeeperException, InterruptedException, 
IOException {
+    private void createHOBPathAndGenerateId(String ledgerPrefix, int hob, 
final GenericCallback<Long> cb)
+            throws KeeperException, InterruptedException, IOException {
         try {
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Creating HOB path: {}", ledgerPrefix + 
formatHalfId(hob));
             }
             zk.create(ledgerPrefix + formatHalfId(hob), new byte[0], 
Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-        }
-        catch(KeeperException.NodeExistsException e) {
+        } catch (KeeperException.NodeExistsException e) {
             // It's fine if we lost a race to create the node 
(NodeExistsException).
             // All other exceptions should continue unwinding.
             if (LOG.isDebugEnabled()) {
@@ -149,13 +148,14 @@ private void invalidateDirectoryCache() {
         highOrderDirectories = null;
     }
 
-    private void generateLongLedgerId(final GenericCallback<Long> cb) throws 
KeeperException, InterruptedException, IOException {
+    private void generateLongLedgerId(final GenericCallback<Long> cb) throws 
KeeperException, InterruptedException,
+            IOException {
         final String hobPrefix = "HOB-";
         final String ledgerPrefix = this.ledgerIdGenPath + "/" + hobPrefix;
 
         // Only pull the directories from zk if we don't have any cached.
         boolean refreshedDirectories = false;
-        if(highOrderDirectories == null) {
+        if (highOrderDirectories == null) {
             refreshedDirectories = true;
             highOrderDirectories = zk.getChildren(ledgerIdGenPath, false);
         }
@@ -164,8 +164,7 @@ private void generateLongLedgerId(final 
GenericCallback<Long> cb) throws KeeperE
             .map((t) -> {
                     try {
                         return Long.parseLong(t.replace(hobPrefix, ""));
-                    }
-                    catch(NumberFormatException e) {
+                    } catch (NumberFormatException e) {
                         return null;
                     }
                 })
@@ -173,13 +172,12 @@ private void generateLongLedgerId(final 
GenericCallback<Long> cb) throws KeeperE
             .reduce(Math::max);
 
         // If we didn't get any valid IDs from the directory...
-        if(!largest.isPresent()) {
-            if(!refreshedDirectories) {
+        if (!largest.isPresent()) {
+            if (!refreshedDirectories) {
                 // Our cache might be bad. Invalidate it and retry.
                 invalidateDirectoryCache();
                 generateLongLedgerId(cb); // Try again
-            }
-            else {
+            } else {
                 // else, Start at HOB-0000000001;
                 createHOBPathAndGenerateId(ledgerPrefix, 1, cb);
             }
@@ -193,13 +191,12 @@ private void generateLongLedgerId(final 
GenericCallback<Long> cb) throws KeeperE
 
         // Perform garbage collection on HOB- directories.
         // Keeping 3 should be plenty to prevent races
-        if(highOrderDirectories.size() > 3) {
+        if (highOrderDirectories.size() > 3) {
             Object[] highOrderDirs = highOrderDirectories.stream()
                     .map((t) -> {
                             try {
                                 return Long.parseLong(t.replace(hobPrefix, 
""));
-                            }
-                            catch(NumberFormatException e) {
+                            } catch (NumberFormatException e) {
                                 return null;
                             }
                         })
@@ -210,15 +207,14 @@ private void generateLongLedgerId(final 
GenericCallback<Long> cb) throws KeeperE
             // Go ahead and invalidate. We want to reload cache even if we 
fail.
             invalidateDirectoryCache();
 
-            for(int i = 0; i < highOrderDirs.length - 3; i++) {
-                String path = ledgerPrefix + 
formatHalfId(((Long)highOrderDirs[i]).intValue());
+            for (int i = 0; i < highOrderDirs.length - 3; i++) {
+                String path = ledgerPrefix + formatHalfId(((Long) 
highOrderDirs[i]).intValue());
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("DELETING HIGH ORDER DIR: {}", path);
                 }
                 try {
                     zk.delete(path, 0);
-                }
-                catch (KeeperException e) {
+                } catch (KeeperException e) {
                     // We don't care if we fail. Just warn about it.
                     if (LOG.isDebugEnabled()) {
                         LOG.debug("Failed to delete {}", path);
@@ -230,34 +226,34 @@ private void generateLongLedgerId(final 
GenericCallback<Long> cb) throws KeeperE
 
     private void createLongLedgerIdPathAndGenerateLongLedgerId(final 
GenericCallback<Long> cb, String createPath) {
         ZkUtils.asyncCreateFullPathOptimistic(zk, ledgerIdGenPath, new 
byte[0], Ids.OPEN_ACL_UNSAFE,
-                                              CreateMode.PERSISTENT, new 
StringCallback() {
-                                                      @Override
-                                                      public void 
processResult(int rc, String path, Object ctx, String name) {
-                                                          try {
-                                                              
setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus.PRESENT);
-                                                              
generateLongLedgerId(cb);
-                                                          } catch 
(KeeperException e) {
-                                                              
LOG.error("Failed to create long ledger ID path", e);
-                                                              
setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus.UNKNOWN);
-                                                              
cb.operationComplete(BKException.Code.ZKException, null);
-                                                          } catch 
(InterruptedException e) {
-                                                              
LOG.error("Failed to create long ledger ID path", e);
-                                                              
setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus.UNKNOWN);
-                                                              
cb.operationComplete(BKException.Code.InterruptedException, null);
-                                                          } catch (IOException 
e) {
-                                                              
LOG.error("Failed to create long ledger ID path", e);
-                                                              
setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus.UNKNOWN);
-                                                              
cb.operationComplete(BKException.Code.IllegalOpException, null);
-                                                          }
-                                                      }
-                                                  }, null);
+                CreateMode.PERSISTENT, new StringCallback() {
+                    @Override
+                    public void processResult(int rc, String path, Object ctx, 
String name) {
+                        try {
+                            
setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus.PRESENT);
+                            generateLongLedgerId(cb);
+                        } catch (KeeperException e) {
+                            LOG.error("Failed to create long ledger ID path", 
e);
+                            
setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus.UNKNOWN);
+                            cb.operationComplete(BKException.Code.ZKException, 
null);
+                        } catch (InterruptedException e) {
+                            LOG.error("Failed to create long ledger ID path", 
e);
+                            
setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus.UNKNOWN);
+                            
cb.operationComplete(BKException.Code.InterruptedException, null);
+                        } catch (IOException e) {
+                            LOG.error("Failed to create long ledger ID path", 
e);
+                            
setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus.UNKNOWN);
+                            
cb.operationComplete(BKException.Code.IllegalOpException, null);
+                        }
+                    }
+                }, null);
     }
 
     public void invalidateLedgerIdGenPathStatus() {
         setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus.UNKNOWN);
     }
 
-    synchronized private void 
setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus status) {
+    private synchronized void 
setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatus status) {
         ledgerIdGenPathStatus = status;
     }
 
@@ -272,14 +268,13 @@ synchronized private void 
setLedgerIdGenPathStatus(HighOrderLedgerIdGenPathStatu
      * @throws KeeperException
      * @throws InterruptedException
      */
-    synchronized public boolean ledgerIdGenPathPresent(ZooKeeper zk) throws 
KeeperException, InterruptedException {
+    public synchronized boolean ledgerIdGenPathPresent(ZooKeeper zk) throws 
KeeperException, InterruptedException {
         switch(ledgerIdGenPathStatus) {
         case UNKNOWN:
-            if(zk.exists(ledgerIdGenPath, false) != null) {
+            if (zk.exists(ledgerIdGenPath, false) != null) {
                 ledgerIdGenPathStatus = HighOrderLedgerIdGenPathStatus.PRESENT;
                 return true;
-            }
-            else {
+            } else {
                 ledgerIdGenPathStatus = 
HighOrderLedgerIdGenPathStatus.NOT_PRESENT;
                 return false;
             }
@@ -295,24 +290,22 @@ synchronized public boolean 
ledgerIdGenPathPresent(ZooKeeper zk) throws KeeperEx
     @Override
     public void generateLedgerId(final GenericCallback<Long> cb) {
         try {
-            if(!ledgerIdGenPathPresent(zk)) {
+            if (!ledgerIdGenPathPresent(zk)) {
                 // We've not moved onto 63-bit ledgers yet.
                 shortIdGen.generateLedgerId(new GenericCallback<Long>(){
                         @Override
                         public void operationComplete(int rc, Long result) {
-                            if(rc == 
BKException.Code.LedgerIdOverflowException) {
+                            if (rc == 
BKException.Code.LedgerIdOverflowException) {
                                 // 31-bit IDs overflowed. Start using 63-bit 
ids.
                                 
createLongLedgerIdPathAndGenerateLongLedgerId(cb, ledgerIdGenPath);
-                            }
-                            else {
+                            } else {
                                 // 31-bit Generation worked OK, or had some 
other
                                 // error that we will pass on.
                                 cb.operationComplete(rc, result);
                             }
                         }
                     });
-            }
-            else {
+            } else {
                 // We've already started generating 63-bit ledger IDs.
                 // Keep doing that.
                 generateLongLedgerId(cb);
@@ -320,12 +313,10 @@ public void operationComplete(int rc, Long result) {
         } catch (KeeperException e) {
             LOG.error("Failed to create long ledger ID path", e);
             cb.operationComplete(BKException.Code.ZKException, null);
-        }
-        catch (InterruptedException e) {
+        } catch (InterruptedException e) {
             LOG.error("Failed to create long ledger ID path", e);
             cb.operationComplete(BKException.Code.InterruptedException, null);
-        }
-        catch (IOException e) {
+        } catch (IOException e) {
             LOG.error("Failed to create long ledger ID path", e);
             cb.operationComplete(BKException.Code.IllegalOpException, null);
         }
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/MSLedgerManagerFactory.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/MSLedgerManagerFactory.java
index 6612683a3..47149d642 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/MSLedgerManagerFactory.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/MSLedgerManagerFactory.java
@@ -17,21 +17,24 @@
  */
 package org.apache.bookkeeper.meta;
 
-import com.google.common.base.Optional;
 import static org.apache.bookkeeper.metastore.MetastoreTable.ALL_FIELDS;
 import static org.apache.bookkeeper.metastore.MetastoreTable.NON_FIELDS;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
+
 import java.io.IOException;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.bookkeeper.client.BKException;
@@ -56,27 +59,25 @@
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.Processor;
 import org.apache.bookkeeper.replication.ReplicationException;
 import org.apache.bookkeeper.util.StringUtils;
+import org.apache.bookkeeper.util.ZkUtils;
 import org.apache.bookkeeper.versioning.Version;
 import org.apache.bookkeeper.versioning.Versioned;
 import org.apache.zookeeper.AsyncCallback;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.data.ACL;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import java.util.List;
-import org.apache.bookkeeper.util.ZkUtils;
-import org.apache.zookeeper.data.ACL;
 
 /**
- * MetaStore Based Ledger Manager Factory
+ * MetaStore Based Ledger Manager Factory.
  */
 public class MSLedgerManagerFactory extends LedgerManagerFactory {
 
-    private final static Logger LOG = 
LoggerFactory.getLogger(MSLedgerManagerFactory.class);
+    private static final Logger LOG = 
LoggerFactory.getLogger(MSLedgerManagerFactory.class);
 
-    static int MS_CONNECT_BACKOFF_MS = 200;
+    private static final int MS_CONNECT_BACKOFF_MS = 200;
 
     public static final int CUR_VERSION = 1;
 
@@ -238,7 +239,7 @@ public void operationComplete(int rc, final LedgerMetadata 
result) {
                         scheduler.submit(new Runnable() {
                             @Override
                             public void run() {
-                                synchronized(listenerSet) {
+                                synchronized (listenerSet) {
                                     for (LedgerMetadataListener listener : 
listenerSet) {
                                         listener.onChanged(ledgerId, result);
                                     }
@@ -295,9 +296,9 @@ public void process(MSWatchedEvent e){
                 Set<LedgerMetadataListener> listenerSet = 
listeners.get(ledgerId);
                 if (listenerSet != null) {
                     synchronized (listenerSet) {
-                        for(LedgerMetadataListener l : listenerSet){
+                        for (LedgerMetadataListener l : listenerSet){
                             unregisterLedgerMetadataListener(ledgerId, l);
-                            l.onChanged( ledgerId, null );
+                            l.onChanged(ledgerId, null);
                         }
                     }
                 }
@@ -423,8 +424,8 @@ public void complete(int rc, Versioned<Value> value, Object 
ctx) {
                     }
                     LedgerMetadata metadata;
                     try {
-                        metadata = LedgerMetadata
-                                
.parseConfig(value.getValue().getField(META_FIELD), value.getVersion(), 
Optional.<Long>absent());
+                        metadata = 
LedgerMetadata.parseConfig(value.getValue().getField(META_FIELD),
+                                value.getVersion(), Optional.<Long>absent());
                     } catch (IOException e) {
                         LOG.error("Could not parse ledger metadata for ledger 
" + ledgerId + " : ", e);
                         
readCb.operationComplete(BKException.Code.MetaStoreException, null);
@@ -635,7 +636,7 @@ public LedgerUnderreplicationManager 
newLedgerUnderreplicationManager() throws K
         ScheduledExecutorService scheduler;
 
         /**
-         * Constructor
+         * Constructor.
          *
          * @param scheduler
          *            Executor used to prevent long stack chains
@@ -645,7 +646,7 @@ public AsyncSetProcessor(ScheduledExecutorService 
scheduler) {
         }
 
         /**
-         * Process set of items
+         * Process set of items.
          *
          * @param data
          *            Set of data to process
@@ -685,7 +686,7 @@ public void processResult(int rc, String path, Object ctx) {
                     final AsyncCallback.VoidCallback stub = this;
                     scheduler.submit(new Runnable() {
                         @Override
-                        public final void run() {
+                        public void run() {
                             processor.process(dataToProcess, stub);
                         }
                     });
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerIdGenerator.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerIdGenerator.java
index 03e471c91..c5d534650 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerIdGenerator.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerIdGenerator.java
@@ -73,7 +73,8 @@ public void generateLedgerId(final GenericCallback<Long> cb) {
         generateLedgerIdImpl(cb, zk, ledgerPrefix, zkAcls);
     }
 
-    public static void generateLedgerIdImpl(final GenericCallback<Long> cb, 
ZooKeeper zk, String ledgerPrefix, List<ACL> zkAcls) {
+    public static void generateLedgerIdImpl(final GenericCallback<Long> cb, 
ZooKeeper zk, String ledgerPrefix,
+            List<ACL> zkAcls) {
         ZkUtils.asyncCreateFullPathOptimistic(zk, ledgerPrefix, new byte[0], 
zkAcls,
                 CreateMode.EPHEMERAL_SEQUENTIAL,
                 new StringCallback() {
@@ -92,10 +93,9 @@ public void processResult(int rc, String path, Object ctx, 
final String idPathNa
                         long ledgerId;
                         try {
                             ledgerId = getLedgerIdFromGenPath(idPathName, 
ledgerPrefix);
-                            if(ledgerId < 0 || ledgerId >= Integer.MAX_VALUE) {
+                            if (ledgerId < 0 || ledgerId >= Integer.MAX_VALUE) 
{
                                 
cb.operationComplete(BKException.Code.LedgerIdOverflowException, null);
-                            }
-                            else {
+                            } else {
                                 cb.operationComplete(BKException.Code.OK, 
ledgerId);
                             }
                         } catch (IOException e) {
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
index e56ee3020..35b76d5fd 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/ZkLedgerUnderreplicationManager.java
@@ -20,6 +20,10 @@
 
 import static com.google.common.base.Charsets.UTF_8;
 
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Joiner;
+import com.google.protobuf.TextFormat;
+
 import java.net.UnknownHostException;
 import java.util.Arrays;
 import java.util.Collections;
@@ -57,29 +61,25 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Joiner;
-import com.google.protobuf.TextFormat;
-
 /**
  * ZooKeeper implementation of underreplication manager.
  * This is implemented in a heirarchical fashion, so it'll work with
  * FlatLedgerManagerFactory and HierarchicalLedgerManagerFactory.
  *
- * Layout is:
+ * <p>Layout is:
  * /root/underreplication/ LAYOUT
  *                         ledgers/(hierarchicalpath)/urL(ledgerId)
  *                         locks/(ledgerId)
  *
- * The hierarchical path is created by splitting the ledger into 4 2byte
+ * <p>The hierarchical path is created by splitting the ledger into 4 2byte
  * segments which are represented in hexidecimal.
  * e.g. For ledger id 0xcafebeef0000feed, the path is
  *  cafe/beef/0000/feed/
  */
 public class ZkLedgerUnderreplicationManager implements 
LedgerUnderreplicationManager {
     static final Logger LOG = 
LoggerFactory.getLogger(ZkLedgerUnderreplicationManager.class);
-    static final String LAYOUT="BASIC";
-    static final int LAYOUT_VERSION=1;
+    static final String LAYOUT = "BASIC";
+    static final int LAYOUT_VERSION = 1;
 
     private static final byte[] LOCK_DATA = getLockData();
 
@@ -92,8 +92,13 @@
             this.ledgerZNodeVersion = ledgerZNodeVersion;
         }
 
-        String getLockZNode() { return lockZNode; }
-        int getLedgerZNodeVersion() { return ledgerZNodeVersion; }
+        String getLockZNode() {
+            return lockZNode;
+        }
+
+        int getLedgerZNodeVersion() {
+            return ledgerZNodeVersion;
+        }
     }
     private final Map<Long, Lock> heldLocks = new ConcurrentHashMap<Long, 
Lock>();
     private final Pattern idExtractionPattern;
@@ -116,7 +121,7 @@ public 
ZkLedgerUnderreplicationManager(AbstractConfiguration conf, ZooKeeper zkc
                 + BookKeeperConstants.DEFAULT_ZK_LEDGERS_ROOT_PATH;
         urLockPath = basePath + '/' + 
BookKeeperConstants.UNDER_REPLICATION_LOCK;
         lostBookieRecoveryDelayZnode = basePath + '/' + 
BookKeeperConstants.LOSTBOOKIERECOVERYDELAY_NODE;
-        
+
         idExtractionPattern = Pattern.compile("urL(\\d+)$");
         this.zkc = zkc;
         this.subTreeCache = new SubTreeCache(new SubTreeCache.TreeProvider() {
@@ -160,8 +165,7 @@ private void checkLayout()
         }
         while (true) {
             if (zkc.exists(layoutZNode, false) == null) {
-                LedgerRereplicationLayoutFormat.Builder builder
-                    = LedgerRereplicationLayoutFormat.newBuilder();
+                LedgerRereplicationLayoutFormat.Builder builder = 
LedgerRereplicationLayoutFormat.newBuilder();
                 builder.setType(LAYOUT).setVersion(LAYOUT_VERSION);
                 try {
                     zkc.create(layoutZNode, 
TextFormat.printToString(builder.build()).getBytes(UTF_8),
@@ -173,8 +177,7 @@ private void checkLayout()
             } else {
                 byte[] layoutData = zkc.getData(layoutZNode, false, null);
 
-                LedgerRereplicationLayoutFormat.Builder builder
-                    = LedgerRereplicationLayoutFormat.newBuilder();
+                LedgerRereplicationLayoutFormat.Builder builder = 
LedgerRereplicationLayoutFormat.newBuilder();
 
                 try {
                     TextFormat.merge(new String(layoutData, UTF_8), builder);
@@ -348,13 +351,13 @@ public void markLedgerReplicated(long ledgerId) throws 
ReplicationException.Unav
     /**
      * Get a list of all the ledgers which have been
      * marked for rereplication, filtered by the predicate on the replicas 
list.
-     * 
-     * Replicas list of an underreplicated ledger is the list of the bookies 
which are part of 
+     *
+     * <p>Replicas list of an underreplicated ledger is the list of the 
bookies which are part of
      * the ensemble of this ledger and are currently unavailable/down.
-     * 
-     * If filtering is not needed then it is suggested to pass null for 
predicate,
+     *
+     * <p>If filtering is not needed then it is suggested to pass null for 
predicate,
      * otherwise it will read the content of the ZNode to decide on filtering.
-     * 
+     *
      * @param predicate filter to use while listing under replicated ledgers. 
'null' if filtering is not required.
      * @return an iterator which returns ledger ids
      */
@@ -692,7 +695,7 @@ public void process(WatchedEvent e) {
     }
 
     /**
-     * Check whether the ledger is being replicated by any bookie
+     * Check whether the ledger is being replicated by any bookie.
      */
     public static boolean isLedgerBeingReplicated(ZooKeeper zkc, String 
zkLedgersRootPath, long ledgerId)
             throws KeeperException,
@@ -701,7 +704,7 @@ public static boolean isLedgerBeingReplicated(ZooKeeper 
zkc, String zkLedgersRoo
     }
 
     /**
-     * Acquire the underreplicated ledger lock
+     * Acquire the underreplicated ledger lock.
      */
     public static void acquireUnderreplicatedLedgerLock(ZooKeeper zkc, String 
zkLedgersRootPath,
         long ledgerId, List<ACL> zkAcls)
@@ -711,7 +714,7 @@ public static void 
acquireUnderreplicatedLedgerLock(ZooKeeper zkc, String zkLedg
     }
 
     /**
-     * Release the underreplicated ledger lock if it exists
+     * Release the underreplicated ledger lock if it exists.
      */
     public static void releaseUnderreplicatedLedgerLock(ZooKeeper zkc, String 
zkLedgersRootPath, long ledgerId)
             throws InterruptedException, KeeperException {
@@ -727,8 +730,8 @@ public boolean initializeLostBookieRecoveryDelay(int 
lostBookieRecoveryDelay) th
             zkc.create(lostBookieRecoveryDelayZnode, 
Integer.toString(lostBookieRecoveryDelay).getBytes(UTF_8),
                     Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
         } catch (KeeperException.NodeExistsException ke) {
-            LOG.info(
-                    "lostBookieRecoveryDelay Znode is already present, so 
using existing lostBookieRecoveryDelay Znode value");
+            LOG.info("lostBookieRecoveryDelay Znode is already present, so 
using "
+                    + "existing lostBookieRecoveryDelay Znode value");
             return false;
         } catch (KeeperException ke) {
             LOG.error("Error while initializing LostBookieRecoveryDelay", ke);
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/package-info.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/package-info.java
new file mode 100644
index 000000000..0cc7ba4fb
--- /dev/null
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+
+/**
+ * Classes for interacting with bookkeeper ledgers and ledger metadata.
+ */
+package org.apache.bookkeeper.meta;
diff --git a/buildtools/src/main/resources/bookkeeper/server-suppressions.xml 
b/buildtools/src/main/resources/bookkeeper/server-suppressions.xml
index 93b821186..328040555 100644
--- a/buildtools/src/main/resources/bookkeeper/server-suppressions.xml
+++ b/buildtools/src/main/resources/bookkeeper/server-suppressions.xml
@@ -25,7 +25,6 @@
     <suppress checks=".*" 
files=".*[\\/]client[\\/](?:[^\\/]+$|(?!api)|(?!impl)[^\\/]+[\\/])"/>
     <suppress checks=".*" files=".*[\\/]conf[\\/].*"/>
     <suppress checks=".*" files=".*[\\/]http[\\/].*"/>
-    <suppress checks=".*" files=".*[\\/]meta[\\/].*"/>
     <suppress checks=".*" files=".*[\\/]metastore[\\/].*"/>
     <suppress checks=".*" files=".*[\\/]net[\\/].*"/>
     <suppress checks=".*" files=".*[\\/]proto[\\/].*"/>


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to