eolivelli closed pull request #670: BP-14 Relax Durability - patch 1 
Introducing LedgerType
URL: https://github.com/apache/bookkeeper/pull/670
 
 
   

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-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchBookie.java
 
b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchBookie.java
index 9c52788eb..9c4925748 100644
--- 
a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchBookie.java
+++ 
b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchBookie.java
@@ -33,6 +33,7 @@
 import org.apache.bookkeeper.proto.BookieClient;
 import org.apache.bookkeeper.proto.BookieProtocol;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 import org.apache.bookkeeper.util.OrderedSafeExecutor;
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
@@ -175,7 +176,7 @@ public static void main(String[] args)
             toSend.writeLong(entry);
             toSend.writerIndex(toSend.capacity());
             bc.addEntry(new BookieSocketAddress(addr, port), ledger, new 
byte[20],
-                        entry, toSend, tc, null, BookieProtocol.FLAG_NONE);
+                        entry, toSend, tc, null, BookieProtocol.FLAG_NONE, 
LedgerType.FORCE_ON_JOURNAL);
         }
         LOG.info("Waiting for warmup");
         tc.waitFor(warmUpCount);
@@ -193,7 +194,7 @@ public static void main(String[] args)
             toSend.writerIndex(toSend.capacity());
             lc.resetComplete();
             bc.addEntry(new BookieSocketAddress(addr, port), ledger, new 
byte[20],
-                        entry, toSend, lc, null, BookieProtocol.FLAG_NONE);
+                        entry, toSend, lc, null, BookieProtocol.FLAG_NONE, 
LedgerType.FORCE_ON_JOURNAL);
             lc.waitForComplete();
         }
         long endTime = System.nanoTime();
@@ -213,7 +214,7 @@ public static void main(String[] args)
             toSend.writeLong(entry);
             toSend.writerIndex(toSend.capacity());
             bc.addEntry(new BookieSocketAddress(addr, port), ledger, new 
byte[20],
-                        entry, toSend, tc, null, BookieProtocol.FLAG_NONE);
+                        entry, toSend, tc, null, BookieProtocol.FLAG_NONE, 
LedgerType.FORCE_ON_JOURNAL);
         }
         tc.waitFor(entryCount);
         endTime = System.currentTimeMillis();
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
index 83888c173..2624c7205 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
@@ -80,6 +80,7 @@
 import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.net.DNS;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 import org.apache.bookkeeper.stats.Counter;
 import org.apache.bookkeeper.stats.Gauge;
 import org.apache.bookkeeper.stats.NullStatsLogger;
@@ -1244,7 +1245,7 @@ private LedgerDescriptor getLedgerForEntry(ByteBuf entry, 
final byte[] masterKey
                 bb.put(masterKey);
                 bb.flip();
 
-                getJournal(ledgerId).logAddEntry(bb, new NopWriteCallback(), 
null);
+                getJournal(ledgerId).logAddEntry(Unpooled.wrappedBuffer(bb), 
true, new NopWriteCallback(), null);
             }
         }
 
@@ -1258,7 +1259,7 @@ private Journal getJournal(long ledgerId) {
     /**
      * Add an entry to a ledger as specified by handle.
      */
-    private void addEntryInternal(LedgerDescriptor handle, ByteBuf entry, 
WriteCallback cb, Object ctx)
+    private void addEntryInternal(LedgerDescriptor handle, ByteBuf entry, 
boolean forceBeforeAck, WriteCallback cb, Object ctx)
             throws IOException, BookieException {
         long ledgerId = handle.getLedgerId();
         long entryId = handle.addEntry(entry);
@@ -1268,7 +1269,7 @@ private void addEntryInternal(LedgerDescriptor handle, 
ByteBuf entry, WriteCallb
         if (LOG.isTraceEnabled()) {
             LOG.trace("Adding {}@{}", entryId, ledgerId);
         }
-        getJournal(ledgerId).logAddEntry(entry, cb, ctx);
+        getJournal(ledgerId).logAddEntry(entry, forceBeforeAck, cb, ctx);
     }
 
     /**
@@ -1277,7 +1278,7 @@ private void addEntryInternal(LedgerDescriptor handle, 
ByteBuf entry, WriteCallb
      * so that they exist on a quorum of bookies. The corresponding client 
side call for this
      * is not exposed to users.
      */
-    public void recoveryAddEntry(ByteBuf entry, WriteCallback cb, Object ctx, 
byte[] masterKey)
+    public void recoveryAddEntry(ByteBuf entry, LedgerType ledgerType, 
WriteCallback cb, Object ctx, byte[] masterKey)
             throws IOException, BookieException {
         long requestNanos = MathUtils.nowInNano();
         boolean success = false;
@@ -1286,7 +1287,7 @@ public void recoveryAddEntry(ByteBuf entry, WriteCallback 
cb, Object ctx, byte[]
             LedgerDescriptor handle = getLedgerForEntry(entry, masterKey);
             synchronized (handle) {
                 entrySize = entry.readableBytes();
-                addEntryInternal(handle, entry, cb, ctx);
+                addEntryInternal(handle, entry, true /*forceBeforeAck*/, cb, 
ctx);
             }
             success = true;
         } catch (NoWritableLedgerDirException e) {
@@ -1333,11 +1334,12 @@ public ByteBuf getExplicitLac(long ledgerId) throws 
IOException, Bookie.NoLedger
      * Add entry to a ledger.
      * @throws BookieException.LedgerFencedException if the ledger is fenced
      */
-    public void addEntry(ByteBuf entry, WriteCallback cb, Object ctx, byte[] 
masterKey)
+    public void addEntry(ByteBuf entry, LedgerType ledgerType, WriteCallback 
cb, Object ctx, byte[] masterKey)
             throws IOException, BookieException.LedgerFencedException, 
BookieException {
         long requestNanos = MathUtils.nowInNano();
         boolean success = false;
         int entrySize = 0;
+        final boolean forceBeforeAck = 
ledgerType.equals(LedgerType.FORCE_ON_JOURNAL);
         try {
             LedgerDescriptor handle = getLedgerForEntry(entry, masterKey);
             synchronized (handle) {
@@ -1346,7 +1348,7 @@ public void addEntry(ByteBuf entry, WriteCallback cb, 
Object ctx, byte[] masterK
                             
.create(BookieException.Code.LedgerFencedException);
                 }
                 entrySize = entry.readableBytes();
-                addEntryInternal(handle, entry, cb, ctx);
+                addEntryInternal(handle, entry, forceBeforeAck, cb, ctx);
             }
             success = true;
         } catch (NoWritableLedgerDirException e) {
@@ -1560,7 +1562,7 @@ public static void main(String[] args)
             buff.writeLong(1);
             buff.writeLong(i);
             cb.incCount();
-            b.addEntry(buff, cb, null, new byte[0]);
+            b.addEntry(buff, LedgerType.FORCE_ON_JOURNAL, cb, null, new 
byte[0]);
         }
         cb.waitZero();
         long end = MathUtils.now();
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
index 1f8aef400..48cf57ba1 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Journal.java
@@ -23,7 +23,6 @@
 
 import com.google.common.base.Stopwatch;
 import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -40,6 +39,7 @@
 import 
org.apache.bookkeeper.bookie.LedgerDirsManager.NoWritableLedgerDirException;
 import org.apache.bookkeeper.conf.ServerConfiguration;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 import org.apache.bookkeeper.stats.Counter;
 import org.apache.bookkeeper.stats.NullStatsLogger;
 import org.apache.bookkeeper.stats.OpStatsLogger;
@@ -271,20 +271,22 @@ public boolean accept(long journalId) {
      * Journal Entry to Record.
      */
     private class QueueEntry implements Runnable {
-        ByteBuf entry;
-        long ledgerId;
-        long entryId;
-        WriteCallback cb;
-        Object ctx;
-        long enqueueTime;
-
-        QueueEntry(ByteBuf entry, long ledgerId, long entryId, WriteCallback 
cb, Object ctx, long enqueueTime) {
+        final ByteBuf entry;
+        final long ledgerId;
+        final long entryId;
+        final WriteCallback cb;
+        final Object ctx;
+        final long enqueueTime;
+        final boolean forceBeforeAck;
+
+        QueueEntry(ByteBuf entry, boolean forceBeforeAck, long ledgerId, long 
entryId, WriteCallback cb, Object ctx, long enqueueTime) {
             this.entry = entry.duplicate();
             this.cb = cb;
             this.ctx = ctx;
             this.ledgerId = ledgerId;
             this.entryId = entryId;
             this.enqueueTime = enqueueTime;
+            this.forceBeforeAck = forceBeforeAck;
         }
 
         @Override
@@ -751,21 +753,17 @@ public boolean accept(long journalId) {
         }
     }
 
-    public void logAddEntry(ByteBuffer entry, WriteCallback cb, Object ctx) {
-        logAddEntry(Unpooled.wrappedBuffer(entry), cb, ctx);
-    }
-
     /**
      * record an add entry operation in journal.
      */
-    public void logAddEntry(ByteBuf entry, WriteCallback cb, Object ctx) {
+    public void logAddEntry(ByteBuf entry, boolean forceBeforeAck, 
WriteCallback cb, Object ctx) {
         long ledgerId = entry.getLong(entry.readerIndex() + 0);
         long entryId = entry.getLong(entry.readerIndex() + 8);
         journalQueueSize.inc();
 
         //Retain entry until it gets written to journal
         entry.retain();
-        queue.add(new QueueEntry(entry, ledgerId, entryId, cb, ctx, 
MathUtils.nowInNano()));
+        queue.add(new QueueEntry(entry, forceBeforeAck, ledgerId, entryId, cb, 
ctx, MathUtils.nowInNano()));
     }
 
     /**
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerDescriptorImpl.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerDescriptorImpl.java
index af55f6a73..67a9c077e 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerDescriptorImpl.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/LedgerDescriptorImpl.java
@@ -122,7 +122,7 @@ ByteBuf getExplicitLac() {
             result = logFenceResult = SettableFuture.create();
         }
         ByteBuf entry = createLedgerFenceEntry(ledgerId);
-        journal.logAddEntry(entry, (rc, ledgerId, entryId, addr, ctx) -> {
+        journal.logAddEntry(entry, true /*forceBeforeAck*/, (rc, ledgerId, 
entryId, addr, ctx) -> {
             LOG.debug("Record fenced state for ledger {} in journal with rc 
{}", ledgerId, rc);
             if (rc == 0) {
                 fenceEntryPersisted.compareAndSet(false, true);
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java
index 8e148129e..9b65c0d7b 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java
@@ -51,6 +51,7 @@
 import org.apache.bookkeeper.client.api.BookKeeperBuilder;
 import org.apache.bookkeeper.client.api.CreateBuilder;
 import org.apache.bookkeeper.client.api.DeleteBuilder;
+import org.apache.bookkeeper.client.api.LedgerType;
 import org.apache.bookkeeper.client.api.OpenBuilder;
 import org.apache.bookkeeper.conf.AbstractConfiguration;
 import org.apache.bookkeeper.conf.ClientConfiguration;
@@ -66,6 +67,7 @@
 import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.net.DNSToSwitchMapping;
 import org.apache.bookkeeper.proto.BookieClient;
+import org.apache.bookkeeper.proto.BookieProtocol;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
 import org.apache.bookkeeper.stats.NullStatsLogger;
 import org.apache.bookkeeper.stats.OpStatsLogger;
@@ -759,7 +761,7 @@ public void asyncCreateLedger(final int ensSize, final int 
writeQuorumSize, fina
                 return;
             }
             new LedgerCreateOp(BookKeeper.this, ensSize, writeQuorumSize,
-                               ackQuorumSize, digestType, passwd, cb, ctx, 
customMetadata)
+                               ackQuorumSize, digestType, passwd, cb, ctx, 
customMetadata, LedgerType.FORCE_ON_JOURNAL)
                 .initiate();
         } finally {
             closeLock.readLock().unlock();
@@ -962,7 +964,8 @@ public void asyncCreateLedgerAdv(final int ensSize, final 
int writeQuorumSize, f
                 return;
             }
             new LedgerCreateOp(BookKeeper.this, ensSize, writeQuorumSize,
-                               ackQuorumSize, digestType, passwd, cb, ctx, 
customMetadata).initiateAdv((long)(-1));
+                               ackQuorumSize, digestType, passwd, cb, ctx, 
customMetadata, LedgerType.FORCE_ON_JOURNAL)
+                .initiateAdv(BookieProtocol.INVALID_LEDGER_ID);
         } finally {
             closeLock.readLock().unlock();
         }
@@ -1070,7 +1073,8 @@ public void asyncCreateLedgerAdv(final long ledgerId,
                 return;
             }
             new LedgerCreateOp(BookKeeper.this, ensSize, writeQuorumSize,
-                               ackQuorumSize, digestType, passwd, cb, ctx, 
customMetadata).initiateAdv(ledgerId);
+                               ackQuorumSize, digestType, passwd, cb, ctx, 
customMetadata, LedgerType.FORCE_ON_JOURNAL)
+                .initiateAdv(ledgerId);
         } finally {
             closeLock.readLock().unlock();
         }
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerCreateOp.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerCreateOp.java
index 4cc62a06e..8ac38e5dc 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerCreateOp.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerCreateOp.java
@@ -36,6 +36,7 @@
 import org.apache.bookkeeper.client.SyncCallbackUtils.SyncCreateCallback;
 import org.apache.bookkeeper.client.api.CreateAdvBuilder;
 import org.apache.bookkeeper.client.api.CreateBuilder;
+import org.apache.bookkeeper.client.api.LedgerType;
 import org.apache.bookkeeper.client.api.WriteAdvHandle;
 import org.apache.bookkeeper.client.api.WriteHandle;
 import org.apache.bookkeeper.meta.LedgerIdGenerator;
@@ -62,6 +63,7 @@
     final byte[] passwd;
     final BookKeeper bk;
     final DigestType digestType;
+    final LedgerType ledgerType;
     final long startTime;
     final OpStatsLogger createOpLogger;
     boolean adv = false;
@@ -80,6 +82,8 @@
      *       ack quorum size
      * @param digestType
      *       digest type, either MAC or CRC32
+     * @param ledgerType
+     *       ledger type
      * @param passwd
      *       password
      * @param cb
@@ -91,13 +95,15 @@
      *       preserve the order(e.g. sortedMap) upon later retireval.
      */
     LedgerCreateOp(BookKeeper bk, int ensembleSize, int writeQuorumSize, int 
ackQuorumSize, DigestType digestType,
-            byte[] passwd, CreateCallback cb, Object ctx, final Map<String, 
byte[]> customMetadata) {
+            byte[] passwd, CreateCallback cb, Object ctx, final Map<String, 
byte[]> customMetadata, LedgerType ledgerType) {
         this.bk = bk;
-        this.metadata = new LedgerMetadata(ensembleSize, writeQuorumSize, 
ackQuorumSize, digestType, passwd, customMetadata);
+        this.metadata = new LedgerMetadata(ensembleSize, writeQuorumSize, 
ackQuorumSize, digestType, passwd,
+            customMetadata, ledgerType);
         this.digestType = digestType;
         this.passwd = passwd;
         this.cb = cb;
         this.ctx = ctx;
+        this.ledgerType = ledgerType;
         this.startTime = MathUtils.nowInNano();
         this.createOpLogger = bk.getCreateOpLogger();
     }
@@ -218,6 +224,7 @@ private void createComplete(int rc, LedgerHandle lh) {
         private byte[] builderPassword;
         private org.apache.bookkeeper.client.api.DigestType builderDigestType
             = org.apache.bookkeeper.client.api.DigestType.CRC32;
+        private LedgerType builderLedgerType = LedgerType.FORCE_ON_JOURNAL;
         private Map<String, byte[]> builderCustomMetadata = 
Collections.emptyMap();
 
         CreateBuilderImpl(BookKeeper bk) {
@@ -261,11 +268,27 @@ public CreateBuilder 
withDigestType(org.apache.bookkeeper.client.api.DigestType
         }
 
         @Override
+        public CreateBuilder withLedgerType(LedgerType ledgerType) {
+            this.builderLedgerType = ledgerType;
+            return this;
+        }
+
+        @Override
         public CreateAdvBuilder makeAdv() {
             return new CreateAdvBuilderImpl(this);
         }
 
         private boolean validate() {
+            if (builderLedgerType == null) {
+                LOG.error("invalid null builderLedgerType");
+                return false;
+            }
+
+            if (bk.getConf().getUseV2WireProtocol() && 
!builderLedgerType.equals(LedgerType.FORCE_ON_JOURNAL)) {
+                LOG.error("invalid builderLedgerType {} while using v2 wire 
protocol");
+                return false;
+            }
+
             if (builderWriteQuorumSize > builderEnsembleSize) {
                 LOG.error("invalid writeQuorumSize {} > ensembleSize {}", 
builderWriteQuorumSize, builderEnsembleSize);
                 return false;
@@ -314,7 +337,7 @@ private void create(CreateCallback cb) {
             }
             LedgerCreateOp op = new LedgerCreateOp(bk, builderEnsembleSize,
                 builderWriteQuorumSize, builderAckQuorumSize, 
DigestType.fromApiDigestType(builderDigestType),
-                builderPassword, cb, null, builderCustomMetadata);
+                builderPassword, cb, null, builderCustomMetadata, 
builderLedgerType);
             ReentrantReadWriteLock closeLock = bk.getCloseLock();
             closeLock.readLock().lock();
             try {
@@ -371,7 +394,7 @@ private void create(CreateCallback cb) {
             LedgerCreateOp op = new LedgerCreateOp(parent.bk, 
parent.builderEnsembleSize,
                     parent.builderWriteQuorumSize, parent.builderAckQuorumSize,
                     DigestType.fromApiDigestType(parent.builderDigestType),
-                    parent.builderPassword, cb, null, 
parent.builderCustomMetadata);
+                    parent.builderPassword, cb, null, 
parent.builderCustomMetadata, parent.builderLedgerType);
             ReentrantReadWriteLock closeLock = parent.bk.getCloseLock();
             closeLock.readLock().lock();
             try {
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java
index 95c48d598..472aee8e1 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java
@@ -39,6 +39,7 @@
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.MultiCallback;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 import org.apache.bookkeeper.replication.ReplicationStats;
 import org.apache.bookkeeper.stats.Counter;
 import org.apache.bookkeeper.stats.NullStatsLogger;
@@ -261,6 +262,7 @@ private void recoverLedgerFragmentEntry(final Long entryId,
             final LedgerHandle lh,
             final AsyncCallback.VoidCallback ledgerFragmentEntryMcb,
             final Set<BookieSocketAddress> newBookies) throws 
InterruptedException {
+        final LedgerType ledgerType = lh.getLedgerMetadata().getLedgerType();
         final AtomicInteger numCompleted = new AtomicInteger(0);
         final AtomicBoolean completed = new AtomicBoolean(false);
         final WriteCallback multiWriteCallback = new WriteCallback() {
@@ -319,7 +321,7 @@ public void readComplete(int rc, LedgerHandle lh,
                 for (BookieSocketAddress newBookie : newBookies) {
                     bkc.getBookieClient().addEntry(newBookie, lh.getId(),
                             lh.getLedgerKey(), entryId, toSend.retainedSlice(),
-                            multiWriteCallback, dataLength, 
BookieProtocol.FLAG_RECOVERY_ADD);
+                            multiWriteCallback, dataLength, 
BookieProtocol.FLAG_RECOVERY_ADD, ledgerType);
                 }
                 toSend.release();
             }
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
index 5683105de..6f271eabe 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
@@ -44,6 +44,8 @@
 
 import com.google.common.base.Optional;
 import com.google.common.collect.Maps;
+import org.apache.bookkeeper.client.api.LedgerType;
+import org.apache.bookkeeper.proto.DataFormats;
 
 /**
  * This class encapsulates all the ledger metadata that is persistently stored
@@ -84,12 +86,14 @@
 
     private boolean hasPassword = false;
     private LedgerMetadataFormat.DigestType digestType;
+    private DataFormats.LedgerType ledgerType;
     private byte[] password;
 
     private Map<String, byte[]> customMetadata = Maps.newHashMap();
 
     public LedgerMetadata(int ensembleSize, int writeQuorumSize, int 
ackQuorumSize,
-                          BookKeeper.DigestType digestType, byte[] password, 
Map<String, byte[]> customMetadata) {
+                          BookKeeper.DigestType digestType, byte[] password, 
Map<String, byte[]> customMetadata,
+                          LedgerType ledgerType) {
         this.ensembleSize = ensembleSize;
         this.writeQuorumSize = writeQuorumSize;
         this.ackQuorumSize = ackQuorumSize;
@@ -106,6 +110,8 @@ public LedgerMetadata(int ensembleSize, int 
writeQuorumSize, int ackQuorumSize,
 
         this.digestType = digestType.equals(BookKeeper.DigestType.MAC) ?
             LedgerMetadataFormat.DigestType.HMAC : 
LedgerMetadataFormat.DigestType.CRC32;
+        this.ledgerType = 
ledgerType.equals(LedgerType.FORCE_DEFERRED_ON_JOURNAL) ?
+            DataFormats.LedgerType.FORCE_DEFERRED_ON_JOURNAL : 
DataFormats.LedgerType.FORCE_ON_JOURNAL;
         this.password = Arrays.copyOf(password, password.length);
         this.hasPassword = true;
         if (customMetadata != null) {
@@ -115,7 +121,7 @@ public LedgerMetadata(int ensembleSize, int 
writeQuorumSize, int ackQuorumSize,
 
     public LedgerMetadata(int ensembleSize, int writeQuorumSize, int 
ackQuorumSize,
             BookKeeper.DigestType digestType, byte[] password) {
-        this(ensembleSize, writeQuorumSize, ackQuorumSize, digestType, 
password, null);
+        this(ensembleSize, writeQuorumSize, ackQuorumSize, digestType, 
password, null, LedgerType.FORCE_ON_JOURNAL);
     }
 
     /**
@@ -133,6 +139,7 @@ public LedgerMetadata(int ensembleSize, int 
writeQuorumSize, int ackQuorumSize,
         this.version = other.version;
         this.hasPassword = other.hasPassword;
         this.digestType = other.digestType;
+        this.ledgerType = other.ledgerType;
         this.password = new byte[other.password.length];
         System.arraycopy(other.password, 0, this.password, 0, 
other.password.length);
         // copy the ensembles
@@ -207,6 +214,11 @@ boolean hasPassword() {
         }
     }
 
+    @VisibleForTesting
+    public DataFormats.LedgerType getLedgerType() {
+        return ledgerType;
+    }
+
     public long getLastEntryId() {
         return lastEntryId;
     }
@@ -300,6 +312,10 @@ void setCustomMetadata(Map<String, byte[]> customMetadata) 
{
             
builder.setDigestType(digestType).setPassword(ByteString.copyFrom(password));
         }
 
+        if (!ledgerType.equals(DataFormats.LedgerType.FORCE_ON_JOURNAL)) {
+            builder.setLedgerType(ledgerType);
+        }
+
         if (customMetadata != null) {
             LedgerMetadataFormat.cMetadataMapEntry.Builder cMetadataBuilder = 
LedgerMetadataFormat.cMetadataMapEntry.newBuilder();
             for (Map.Entry<String,byte[]> entry : customMetadata.entrySet()) {
@@ -436,6 +452,12 @@ public static LedgerMetadata parseConfig(byte[] bytes, 
Version version, Optional
             lc.hasPassword = true;
         }
 
+        if (data.hasLedgerType()) {
+            lc.ledgerType = data.getLedgerType();
+        } else {
+            lc.ledgerType = DataFormats.LedgerType.FORCE_ON_JOURNAL;
+        }
+
         for (LedgerMetadataFormat.Segment s : data.getSegmentList()) {
             ArrayList<BookieSocketAddress> addrs = new 
ArrayList<BookieSocketAddress>();
             for (String member : s.getEnsembleMemberList()) {
@@ -460,6 +482,7 @@ static LedgerMetadata parseVersion1Config(LedgerMetadata lc,
             lc.writeQuorumSize = lc.ackQuorumSize = 
Integer.parseInt(reader.readLine());
             lc.ensembleSize = Integer.parseInt(reader.readLine());
             lc.length = Long.parseLong(reader.readLine());
+            lc.ledgerType = DataFormats.LedgerType.FORCE_ON_JOURNAL;
 
             String line = reader.readLine();
             while (line != null) {
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java
index f4d05b77b..0b8dfa587 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/PendingAddOp.java
@@ -127,7 +127,7 @@ void sendWriteRequest(int bookieIndex) {
         int flags = isRecoveryAdd ? BookieProtocol.FLAG_RECOVERY_ADD : 
BookieProtocol.FLAG_NONE;
 
         
lh.bk.getBookieClient().addEntry(lh.metadata.currentEnsemble.get(bookieIndex), 
lh.ledgerId, lh.ledgerKey, entryId, toSend,
-                this, bookieIndex, flags);
+                this, bookieIndex, flags, lh.metadata.getLedgerType());
         ++pendingWriteRequests;
     }
 
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/CreateBuilder.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/CreateBuilder.java
index 6d7d1ee4e..0c6456f87 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/CreateBuilder.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/CreateBuilder.java
@@ -88,6 +88,15 @@
     CreateBuilder withDigestType(DigestType digestType);
 
     /**
+     * Set the Type of ledger. It defaults to {@link 
LedgerType#FORCE_ON_JOURNAL}
+     *
+     * @param ledgerType the type of ledger
+     *
+     * @return the builder itself
+     */
+    CreateBuilder withLedgerType(LedgerType ledgerType);
+
+    /**
      * Switch the ledger into 'Advanced' mode. A ledger used in Advanced mode 
will explicitly generate the sequence of
      * entry identifiers. Advanced ledgers can be created with a client side 
defined ledgerId
      *
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/LedgerType.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/LedgerType.java
new file mode 100644
index 000000000..71489feb0
--- /dev/null
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/LedgerType.java
@@ -0,0 +1,45 @@
+/**
+ *
+ * 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.client.api;
+
+/**
+ * Describes the type of ledger.
+ * LedgerTypes describes the behaviour of the ledger in respect to durability 
and provides
+ * hints to the storage of data on Bookies
+ *
+ * @since 4.6
+ */
+public enum LedgerType {
+    /**
+     * Persistent Durability, using Journal.<br>
+     * Each entry is persisted to the journal and every writes receives and 
acknowledgement only with the guarantee that
+     * it has been persisted durably to it (data is fsync'd to the disk)
+     */
+    FORCE_ON_JOURNAL,
+    /**
+     * Volatile Durability, using Journal.<br>
+     * Each entry is persisted to the journal and writes receive 
acknowledgement without guarantees of persistence (data
+     * is eventually fsync'd to disk).<br>
+     * For this kind of ledgers the client MUST explicitly call {@link 
ForceSupported#force()} in order
+     * to have guarantees of the durability of writes and in order to advance 
the LastAddConfirmed entry id
+     */
+    FORCE_DEFERRED_ON_JOURNAL
+}
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieClient.java 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieClient.java
index ae7f806ab..2d41aa8c2 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieClient.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieClient.java
@@ -64,6 +64,7 @@
 import io.netty.util.Recycler.Handle;
 import io.netty.util.Timeout;
 import io.netty.util.TimerTask;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 
 /**
  * Implements the client-side part of the BookKeeper protocol.
@@ -245,7 +246,8 @@ public void addEntry(final BookieSocketAddress addr,
                          final ByteBuf toSend,
                          final WriteCallback cb,
                          final Object ctx,
-                         final int options) {
+                         final int options,
+                         final LedgerType ledgerType) {
         closeLock.readLock().lock();
         try {
             final PerChannelBookieClientPool client = lookupClient(addr);
@@ -261,7 +263,7 @@ public void addEntry(final BookieSocketAddress addr,
 
             client.obtain(ChannelReadyForAddEntryCallback.create(
                                   this, toSend, ledgerId, entryId, addr,
-                                  ctx, cb, options, masterKey),
+                                  ctx, cb, options, masterKey, ledgerType),
                           ledgerId);
         } finally {
             closeLock.readLock().unlock();
@@ -300,11 +302,12 @@ public void safeRun() {
         private WriteCallback cb;
         private int options;
         private byte[] masterKey;
+        private LedgerType ledgerType;
 
         static ChannelReadyForAddEntryCallback create(
                 BookieClient bookieClient, ByteBuf toSend, long ledgerId,
                 long entryId, BookieSocketAddress addr, Object ctx,
-                WriteCallback cb, int options, byte[] masterKey) {
+                WriteCallback cb, int options, byte[] masterKey, LedgerType 
ledgerType) {
             ChannelReadyForAddEntryCallback callback = RECYCLER.get();
             callback.bookieClient = bookieClient;
             callback.toSend = toSend;
@@ -315,6 +318,7 @@ static ChannelReadyForAddEntryCallback create(
             callback.cb = cb;
             callback.options = options;
             callback.masterKey = masterKey;
+            callback.ledgerType = ledgerType;
             return callback;
         }
 
@@ -325,7 +329,7 @@ public void operationComplete(final int rc,
                 bookieClient.completeAdd(rc, ledgerId, entryId, addr, cb, ctx);
             } else {
                 pcbc.addEntry(ledgerId, masterKey, entryId,
-                              toSend, cb, ctx, options);
+                              toSend, cb, ctx, options, ledgerType);
             }
 
             toSend.release();
@@ -589,7 +593,8 @@ public void writeComplete(int rc, long ledger, long entry, 
BookieSocketAddress a
 
         for (int i = 0; i < 100000; i++) {
             counter.inc();
-            bc.addEntry(addr, ledger, new byte[0], i, 
Unpooled.wrappedBuffer(hello), cb, counter, 0);
+            bc.addEntry(addr, ledger, new byte[0], i, 
Unpooled.wrappedBuffer(hello), cb, counter, 0,
+                        LedgerType.FORCE_ON_JOURNAL);
         }
         counter.wait(0);
         System.out.println("Total = " + counter.total());
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtocol.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtocol.java
index 2c7a82835..adaeeec9e 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtocol.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtocol.java
@@ -48,11 +48,16 @@
     public static final byte CURRENT_PROTOCOL_VERSION = 2;
 
     /**
-     * Entry Entry ID. To be used when no valid entry id can be assigned.
+     * Invalid Entry ID. To be used when no valid entry id can be assigned.
      */
     public static final long INVALID_ENTRY_ID = -1;
 
     /**
+     * Invalid Ledger ID. To be used when no valid ledger id can be assigned.
+     */
+    public static final long INVALID_LEDGER_ID = -1;
+
+    /**
      * Entry identifier representing a request to obtain the last add entry 
confirmed
      */
     public static final long LAST_ADD_CONFIRMED = -1;
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieRequestProcessor.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieRequestProcessor.java
index 81208f3d1..2602c9fd4 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieRequestProcessor.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieRequestProcessor.java
@@ -60,7 +60,6 @@
 import static 
org.apache.bookkeeper.bookie.BookKeeperServerStats.READ_ENTRY_SCHEDULING_DELAY;
 import static 
org.apache.bookkeeper.bookie.BookKeeperServerStats.READ_LAC_REQUEST;
 import static 
org.apache.bookkeeper.bookie.BookKeeperServerStats.READ_LAST_ENTRY_NOENTRY_ERROR;
-import static org.apache.bookkeeper.bookie.BookKeeperServerStats.WRITE_LAC;
 import static org.apache.bookkeeper.bookie.BookKeeperServerStats.READ_LAC;
 import static org.apache.bookkeeper.bookie.BookKeeperServerStats.WRITE_LAC;
 import static 
org.apache.bookkeeper.bookie.BookKeeperServerStats.GET_BOOKIE_INFO;
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
index 0c8f25ad9..91edccafa 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java
@@ -20,16 +20,12 @@
 
 import static org.apache.bookkeeper.client.LedgerHandle.INVALID_ENTRY_ID;
 
-import com.google.common.collect.Sets;
 import com.google.common.base.Joiner;
 import com.google.protobuf.ByteString;
-import com.google.protobuf.ExtensionRegistry;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufAllocator;
 import io.netty.buffer.PooledByteBufAllocator;
 import io.netty.buffer.Unpooled;
-import io.netty.buffer.UnpooledByteBufAllocator;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import io.netty.channel.ChannelFutureListener;
@@ -60,19 +56,15 @@
 import io.netty.util.concurrent.GenericFutureListener;
 
 import java.io.IOException;
-import java.net.SocketAddress;
-import java.nio.channels.ClosedChannelException;
 import java.util.ArrayDeque;
 import java.util.Collections;
 import java.util.Collection;
-import java.util.Objects;
 import java.util.Queue;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
-import org.apache.bookkeeper.auth.BookKeeperPrincipal;
 import org.apache.bookkeeper.auth.ClientAuthProvider;
 import org.apache.bookkeeper.client.BKException;
 import org.apache.bookkeeper.client.BookKeeperClientStats;
@@ -119,7 +111,6 @@
 import com.google.protobuf.ExtensionRegistry;
 import io.netty.buffer.ByteBufAllocator;
 import io.netty.buffer.UnpooledByteBufAllocator;
-import java.net.SocketAddress;
 
 import java.net.SocketAddress;
 import java.security.cert.Certificate;
@@ -128,6 +119,7 @@
 import java.util.List;
 import javax.net.ssl.SSLPeerUnverifiedException;
 import org.apache.bookkeeper.auth.BookKeeperPrincipal;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 
 /**
  * This class manages all details of connection to a particular bookie. It also
@@ -528,7 +520,7 @@ void writeLac(final long ledgerId, final byte[] masterKey, 
final long lac, ByteB
      *          Add options
      */
     void addEntry(final long ledgerId, byte[] masterKey, final long entryId, 
ByteBuf toSend, WriteCallback cb,
-                  Object ctx, final int options) {
+                  Object ctx, final int options, final LedgerType ledgerType) {
         Object request = null;
         CompletionKey completionKey = null;
         if (useV2WireProtocol) {
@@ -558,6 +550,10 @@ void addEntry(final long ledgerId, byte[] masterKey, final 
long entryId, ByteBuf
                 addBuilder.setFlag(AddRequest.Flag.RECOVERY_ADD);
             }
 
+            if (ledgerType != DataFormats.LedgerType.FORCE_ON_JOURNAL) {
+                addBuilder.setLedgerType(ledgerType);
+            }
+
             request = Request.newBuilder()
                     .setHeader(headerBuilder)
                     .setAddRequest(addBuilder)
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/WriteEntryProcessor.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/WriteEntryProcessor.java
index 416a478e9..3c769b0ce 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/WriteEntryProcessor.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/WriteEntryProcessor.java
@@ -29,6 +29,7 @@
 import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.proto.BookieProtocol.Request;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 import org.apache.bookkeeper.util.MathUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -73,10 +74,11 @@ protected void processPacket() {
         int rc = BookieProtocol.EOK;
         ByteBuf addData = add.getData();
         try {
+            final LedgerType ledgerType = LedgerType.FORCE_ON_JOURNAL;
             if (add.isRecoveryAdd()) {
-                requestProcessor.bookie.recoveryAddEntry(addData, this, 
channel, add.getMasterKey());
+                requestProcessor.bookie.recoveryAddEntry(addData, ledgerType, 
this, channel, add.getMasterKey());
             } else {
-                requestProcessor.bookie.addEntry(addData, this, channel, 
add.getMasterKey());
+                requestProcessor.bookie.addEntry(addData, ledgerType, this, 
channel, add.getMasterKey());
             }
         } catch (IOException e) {
             LOG.error("Error writing " + add, e);
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/WriteEntryProcessorV3.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/WriteEntryProcessorV3.java
index b4e89f8c5..02c6b90ad 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/WriteEntryProcessorV3.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/WriteEntryProcessorV3.java
@@ -34,6 +34,7 @@
 import org.apache.bookkeeper.proto.BookkeeperProtocol.Request;
 import org.apache.bookkeeper.proto.BookkeeperProtocol.Response;
 import org.apache.bookkeeper.proto.BookkeeperProtocol.StatusCode;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 import org.apache.bookkeeper.util.MathUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -105,10 +106,11 @@ public void writeComplete(int rc, long ledgerId, long 
entryId,
         byte[] masterKey = addRequest.getMasterKey().toByteArray();
         ByteBuf entryToAdd = 
Unpooled.wrappedBuffer(addRequest.getBody().asReadOnlyByteBuffer());
         try {
+            LedgerType ledgerType = addRequest.hasLedgerType() ? 
addRequest.getLedgerType() : LedgerType.FORCE_ON_JOURNAL;
             if (addRequest.hasFlag() && 
addRequest.getFlag().equals(AddRequest.Flag.RECOVERY_ADD)) {
-                requestProcessor.bookie.recoveryAddEntry(entryToAdd, wcb, 
channel, masterKey);
+                requestProcessor.bookie.recoveryAddEntry(entryToAdd, 
ledgerType, wcb, channel, masterKey);
             } else {
-                requestProcessor.bookie.addEntry(entryToAdd, wcb, channel, 
masterKey);
+                requestProcessor.bookie.addEntry(entryToAdd, ledgerType, wcb, 
channel, masterKey);
             }
             status = StatusCode.EOK;
         } catch (IOException e) {
diff --git a/bookkeeper-server/src/main/proto/BookkeeperProtocol.proto 
b/bookkeeper-server/src/main/proto/BookkeeperProtocol.proto
index b43e69148..7cb72846b 100644
--- a/bookkeeper-server/src/main/proto/BookkeeperProtocol.proto
+++ b/bookkeeper-server/src/main/proto/BookkeeperProtocol.proto
@@ -15,6 +15,7 @@
  * limitations under the License.
  */
 syntax = "proto2";
+import "DataFormats.proto";
 
 option java_package = "org.apache.bookkeeper.proto";
 option optimize_for = SPEED;
@@ -111,6 +112,7 @@ message AddRequest {
     required int64 entryId = 2;
     required bytes masterKey = 3;
     required bytes body = 4;
+    optional LedgerType ledgerType = 5;
 }
 
 message StartTLSRequest {
@@ -192,4 +194,4 @@ message GetBookieInfoResponse {
 }
 
 message StartTLSResponse {
-}
+}
\ No newline at end of file
diff --git a/bookkeeper-server/src/main/proto/DataFormats.proto 
b/bookkeeper-server/src/main/proto/DataFormats.proto
index cdade9563..7fbdcce72 100644
--- a/bookkeeper-server/src/main/proto/DataFormats.proto
+++ b/bookkeeper-server/src/main/proto/DataFormats.proto
@@ -21,6 +21,14 @@ option java_package = "org.apache.bookkeeper.proto";
 option optimize_for = SPEED;
 
 /**
+ * Ledger Type
+ */
+enum LedgerType {
+    FORCE_ON_JOURNAL = 0;
+    FORCE_DEFERRED_ON_JOURNAL = 1;
+}
+
+/**
 * Metadata format for storing ledger information
 */
 message LedgerMetadataFormat {
@@ -58,6 +66,8 @@ message LedgerMetadataFormat {
         optional bytes value = 2;
     }
     repeated cMetadataMapEntry customMetadata = 11;
+
+    optional LedgerType ledgerType = 12 [default = FORCE_ON_JOURNAL];
 }
 
 message LedgerRereplicationLayoutFormat {
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java
index 5f62eccae..c2b9b8bd5 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java
@@ -43,6 +43,7 @@
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.ArrayList;
 import java.util.List;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 
 import org.apache.commons.io.FileUtils;
 import org.junit.After;
@@ -335,7 +336,7 @@ public void testIndexPageEvictionWriteOrder() throws 
Exception {
         b.start();
         for (int i = 1; i <= numLedgers; i++) {
             ByteBuf packet = generateEntry(i, 1);
-            b.addEntry(packet, new Bookie.NopWriteCallback(), null, 
"passwd".getBytes());
+            b.addEntry(packet, LedgerType.FORCE_ON_JOURNAL, new 
Bookie.NopWriteCallback(), null, "passwd".getBytes());
         }
 
         conf = TestBKConfiguration.newServerConfiguration()
@@ -514,7 +515,8 @@ public void testEntryMemTableFlushFailure() throws 
Exception {
 
         // this bookie.addEntry call is required. FileInfo for Ledger 1 would 
be created with this call.
         // without the fileinfo, 'flushTestSortedLedgerStorage.addEntry' calls 
will fail because of BOOKKEEPER-965 change.
-        bookie.addEntry(generateEntry(1, 1), new Bookie.NopWriteCallback(), 
null, "passwd".getBytes());
+        bookie.addEntry(generateEntry(1, 1), LedgerType.FORCE_ON_JOURNAL, new 
Bookie.NopWriteCallback(),
+                        null, "passwd".getBytes());
 
         flushTestSortedLedgerStorage.addEntry(generateEntry(1, 2));
         assertFalse("Bookie is expected to be in ReadWrite mode", 
bookie.isReadOnly());
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperCloseTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperCloseTest.java
index f415152c4..106d01652 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperCloseTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperCloseTest.java
@@ -20,14 +20,6 @@
  */
 package org.apache.bookkeeper.client;
 
-import com.google.common.util.concurrent.SettableFuture;
-import io.netty.buffer.ByteBuf;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.bookkeeper.bookie.Bookie;
 import org.apache.bookkeeper.bookie.BookieException;
 import org.apache.bookkeeper.client.AsyncCallback.AddCallback;
@@ -45,6 +37,16 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.util.concurrent.SettableFuture;
+import io.netty.buffer.ByteBuf;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
+
 import static org.junit.Assert.*;
 
 /**
@@ -70,7 +72,7 @@ private void restartBookieSlow() throws Exception{
 
         Bookie delayBookie = new Bookie(conf) {
                 @Override
-                public void recoveryAddEntry(ByteBuf entry, WriteCallback cb,
+                public void recoveryAddEntry(ByteBuf entry, LedgerType 
ledgerType, WriteCallback cb,
                                              Object ctx, byte[] masterKey)
                         throws IOException, BookieException {
                     try {
@@ -80,11 +82,11 @@ public void recoveryAddEntry(ByteBuf entry, WriteCallback 
cb,
                         // and an exception would spam the logs
                         Thread.currentThread().interrupt();
                     }
-                    super.recoveryAddEntry(entry, cb, ctx, masterKey);
+                    super.recoveryAddEntry(entry, ledgerType, cb, ctx, 
masterKey);
                 }
 
                 @Override
-                public void addEntry(ByteBuf entry, WriteCallback cb,
+                public void addEntry(ByteBuf entry, LedgerType ledgerType, 
WriteCallback cb,
                                      Object ctx, byte[] masterKey)
                         throws IOException, BookieException {
                     try {
@@ -94,7 +96,7 @@ public void addEntry(ByteBuf entry, WriteCallback cb,
                         // and an exception would spam the logs
                         Thread.currentThread().interrupt();
                     }
-                    super.addEntry(entry, cb, ctx, masterKey);
+                    super.addEntry(entry, ledgerType, cb, ctx, masterKey);
                 }
 
                 @Override
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
index e61100bbd..344bba1d4 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
@@ -46,6 +46,7 @@
 
 import static org.junit.Assert.*;
 import static com.google.common.base.Charsets.UTF_8;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 
 /**
  * This class tests the ledger close logic.
@@ -195,7 +196,7 @@ private void startUnauthorizedBookie(ServerConfiguration 
conf, final CountDownLa
             throws Exception {
         Bookie sBookie = new Bookie(conf) {
             @Override
-            public void addEntry(ByteBuf entry, WriteCallback cb, Object ctx, 
byte[] masterKey)
+            public void addEntry(ByteBuf entry, LedgerType ledgerType, 
WriteCallback cb, Object ctx, byte[] masterKey)
                     throws IOException, BookieException {
                 try {
                     latch.await();
@@ -205,7 +206,7 @@ public void addEntry(ByteBuf entry, WriteCallback cb, 
Object ctx, byte[] masterK
             }
 
             @Override
-            public void recoveryAddEntry(ByteBuf entry, WriteCallback cb, 
Object ctx, byte[] masterKey)
+            public void recoveryAddEntry(ByteBuf entry, LedgerType ledgerType, 
WriteCallback cb, Object ctx, byte[] masterKey)
                     throws IOException, BookieException {
                 throw new IOException("Dead bookie for recovery adds.");
             }
@@ -219,7 +220,7 @@ public void recoveryAddEntry(ByteBuf entry, WriteCallback 
cb, Object ctx, byte[]
     private void startDeadBookie(ServerConfiguration conf, final 
CountDownLatch latch) throws Exception {
         Bookie dBookie = new Bookie(conf) {
             @Override
-            public void addEntry(ByteBuf entry, WriteCallback cb, Object ctx, 
byte[] masterKey)
+            public void addEntry(ByteBuf entry, LedgerType ledgerType, 
WriteCallback cb, Object ctx, byte[] masterKey)
                     throws IOException, BookieException {
                 try {
                     latch.await();
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerRecoveryTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerRecoveryTest.java
index 73c38b9f0..cc6e7d951 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerRecoveryTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerRecoveryTest.java
@@ -37,6 +37,7 @@
 import org.apache.bookkeeper.proto.BookieProtocol;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -188,7 +189,7 @@ private void ledgerRecoveryWithSlowBookie(int ensembleSize, 
int writeQuorumSize,
 
         Bookie fakeBookie = new Bookie(conf) {
             @Override
-            public void addEntry(ByteBuf entry, WriteCallback cb, Object ctx, 
byte[] masterKey)
+            public void addEntry(ByteBuf entry, LedgerType ledgerType, 
WriteCallback cb, Object ctx, byte[] masterKey)
                     throws IOException, BookieException {
                 // drop request to simulate a slow and failed bookie
             }
@@ -247,7 +248,7 @@ public void testLedgerRecoveryWithRollingRestart() throws 
Exception {
         ServerConfiguration conf = newServerConfiguration();
         Bookie deadBookie1 = new Bookie(conf) {
             @Override
-            public void recoveryAddEntry(ByteBuf entry, WriteCallback cb, 
Object ctx, byte[] masterKey)
+            public void recoveryAddEntry(ByteBuf entry, LedgerType ledgerType, 
WriteCallback cb, Object ctx, byte[] masterKey)
                     throws IOException, BookieException {
                 // drop request to simulate a slow and failed bookie
                 throw new IOException("Couldn't write for some reason");
@@ -328,7 +329,7 @@ public void testBookieFailureDuringRecovery() throws 
Exception {
         ServerConfiguration conf = newServerConfiguration();
         Bookie deadBookie1 = new Bookie(conf) {
             @Override
-            public void recoveryAddEntry(ByteBuf entry, WriteCallback cb, 
Object ctx, byte[] masterKey)
+            public void recoveryAddEntry(ByteBuf entry, LedgerType ledgerType, 
WriteCallback cb, Object ctx, byte[] masterKey)
                     throws IOException, BookieException {
                 // drop request to simulate a slow and failed bookie
                 throw new IOException("Couldn't write for some reason");
@@ -412,7 +413,7 @@ public void addComplete(int rc, LedgerHandle lh, long 
entryId, Object ctx) {
     private void startDeadBookie(ServerConfiguration conf) throws Exception {
         Bookie rBookie = new Bookie(conf) {
             @Override
-            public void recoveryAddEntry(ByteBuf entry, WriteCallback cb, 
Object ctx, byte[] masterKey)
+            public void recoveryAddEntry(ByteBuf entry, LedgerType ledgerType, 
WriteCallback cb, Object ctx, byte[] masterKey)
                     throws IOException, BookieException {
                 // drop request to simulate a dead bookie
                 throw new IOException("Couldn't write entries for some 
reason");
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/MockBookKeeperTestCase.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/MockBookKeeperTestCase.java
index 6ef890154..0a7f3b7eb 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/MockBookKeeperTestCase.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/MockBookKeeperTestCase.java
@@ -24,7 +24,6 @@
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.Unpooled;
 import java.util.ArrayList;
-import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
@@ -44,6 +43,7 @@
 import org.apache.bookkeeper.proto.BookieClient;
 import org.apache.bookkeeper.proto.BookieProtocol;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 import org.apache.bookkeeper.stats.NullStatsLogger;
 import org.apache.bookkeeper.util.OrderedSafeExecutor;
 import org.junit.After;
@@ -51,7 +51,6 @@
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyInt;
 import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.ArgumentMatchers.eq;
 import org.mockito.Mockito;
 import static org.mockito.Mockito.doAnswer;
 import org.mockito.invocation.InvocationOnMock;
@@ -426,7 +425,7 @@ protected void setupBookieClientAddEntry() {
             anyLong(), any(byte[].class),
             anyLong(), any(ByteBuf.class),
             any(BookkeeperInternalCallbacks.WriteCallback.class),
-            any(), anyInt());
+            any(), anyInt(), any(LedgerType.class));
     }
 
 }
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ParallelLedgerRecoveryTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ParallelLedgerRecoveryTest.java
index a2a671a68..df1e3c113 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ParallelLedgerRecoveryTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ParallelLedgerRecoveryTest.java
@@ -58,6 +58,7 @@
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 
 public class ParallelLedgerRecoveryTest extends BookKeeperClusterTestCase {
 
@@ -368,7 +369,7 @@ public void writeComplete(int rc, long ledgerId, long 
entryId, BookieSocketAddre
                     addSuccess.set(BKException.Code.OK == rc);
                     addLatch.countDown();
                 }
-            }, 0, BookieProtocol.FLAG_NONE);
+            }, 0, BookieProtocol.FLAG_NONE, LedgerType.FORCE_ON_JOURNAL);
         addLatch.await();
         assertTrue("add entry 14 should succeed", addSuccess.get());
 
@@ -450,9 +451,9 @@ public DelayResponseBookie(ServerConfiguration conf)
         }
 
         @Override
-        public void addEntry(ByteBuf entry, final WriteCallback cb, Object 
ctx, byte[] masterKey)
+        public void addEntry(ByteBuf entry, LedgerType ledgerType, final 
WriteCallback cb, Object ctx, byte[] masterKey)
                 throws IOException, BookieException {
-            super.addEntry(entry, new WriteCallback() {
+            super.addEntry(entry, ledgerType, new WriteCallback() {
                 @Override
                 public void writeComplete(int rc, long ledgerId, long entryId,
                                           BookieSocketAddress addr, Object 
ctx) {
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/api/BookKeeperBuildersTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/api/BookKeeperBuildersTest.java
index 946ee4e1e..416644084 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/api/BookKeeperBuildersTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/api/BookKeeperBuildersTest.java
@@ -28,7 +28,6 @@
 import java.util.HashMap;
 import java.util.Map;
 import org.apache.bookkeeper.client.BKException.BKClientClosedException;
-import org.apache.bookkeeper.client.BKException.BKDigestMatchException;
 import org.apache.bookkeeper.client.BKException.BKIncorrectParameterException;
 import org.apache.bookkeeper.client.BKException.BKNoSuchLedgerExistsException;
 import org.apache.bookkeeper.client.BookKeeper;
@@ -37,6 +36,7 @@
 
 import org.apache.bookkeeper.conf.ClientConfiguration;
 import org.apache.bookkeeper.proto.BookieProtocol;
+import org.apache.bookkeeper.proto.DataFormats;
 
 import org.junit.Test;
 
@@ -46,7 +46,7 @@
 public class BookKeeperBuildersTest extends MockBookKeeperTestCase {
 
     private final static int ensembleSize = 3;
-    private final static int writeQuorumSize = 2;
+    private final static int writeQuorumSize = 3;
     private final static int ackQuorumSize = 1;
     private final static long ledgerId = 12342L;
     private final static Map<String, byte[]> customMetadata = new HashMap<>();
@@ -70,6 +70,65 @@ public void testCreateLedger() throws Exception {
         assertEquals(ackQuorumSize, metadata.getAckQuorumSize());
         assertEquals(writeQuorumSize, metadata.getWriteQuorumSize());
         assertArrayEquals(password, metadata.getPassword());
+        assertEquals(DataFormats.LedgerType.FORCE_ON_JOURNAL, 
metadata.getLedgerType());
+    }
+
+    @Test
+    public void testCreateLedgerLedgerTypeFORCE_DEFERRED_ON_JOURNAL() throws 
Exception {
+        setNewGeneratedLedgerId(ledgerId);
+        WriteHandle writer = newCreateLedgerOp()
+            .withAckQuorumSize(ackQuorumSize)
+            .withEnsembleSize(ensembleSize)
+            .withWriteQuorumSize(writeQuorumSize)
+            .withCustomMetadata(customMetadata)
+            .withLedgerType(LedgerType.FORCE_DEFERRED_ON_JOURNAL)
+            .withPassword(password)
+            .execute()
+            .get();
+        assertEquals(ledgerId, writer.getId());
+        LedgerMetadata metadata = getLedgerMetadata(ledgerId);
+        assertEquals(ensembleSize, metadata.getEnsembleSize());
+        assertEquals(ackQuorumSize, metadata.getAckQuorumSize());
+        assertEquals(writeQuorumSize, metadata.getWriteQuorumSize());
+        assertArrayEquals(password, metadata.getPassword());
+        assertEquals(DataFormats.LedgerType.FORCE_DEFERRED_ON_JOURNAL, 
metadata.getLedgerType());
+    }
+
+    @Test(expected = BKIncorrectParameterException.class)
+    public void 
testCreateLedgerLedgerTypeFORCE_DEFERRED_ON_JOURNALOnV2Protocol() throws 
Exception {
+        ClientConfiguration config = new ClientConfiguration();
+        config.setUseV2WireProtocol(true);
+        setBookkeeperConfig(config);
+        setNewGeneratedLedgerId(ledgerId);
+        result(newCreateLedgerOp()
+            .withAckQuorumSize(ackQuorumSize)
+            .withEnsembleSize(ensembleSize)
+            .withWriteQuorumSize(writeQuorumSize)
+            .withCustomMetadata(customMetadata)
+            .withLedgerType(LedgerType.FORCE_DEFERRED_ON_JOURNAL)
+            .withPassword(password)
+            .execute());
+    }
+
+    @Test
+    public void testCreateLedgerLedgerTypeExplicitFORCE_ON_JOURNAL() throws 
Exception {
+        setNewGeneratedLedgerId(ledgerId);
+        WriteHandle writer = newCreateLedgerOp()
+            .withAckQuorumSize(ackQuorumSize)
+            .withEnsembleSize(ensembleSize)
+            .withWriteQuorumSize(writeQuorumSize)
+            .withCustomMetadata(customMetadata)
+            .withLedgerType(LedgerType.FORCE_ON_JOURNAL)
+            .withPassword(password)
+            .execute()
+            .get();
+        assertEquals(ledgerId, writer.getId());
+        LedgerMetadata metadata = getLedgerMetadata(ledgerId);
+        assertEquals(ensembleSize, metadata.getEnsembleSize());
+        assertEquals(ackQuorumSize, metadata.getAckQuorumSize());
+        assertEquals(writeQuorumSize, metadata.getWriteQuorumSize());
+        assertArrayEquals(password, metadata.getPassword());
+        assertEquals(DataFormats.LedgerType.FORCE_ON_JOURNAL, 
metadata.getLedgerType());
     }
 
     @Test(expected = BKIncorrectParameterException.class)
@@ -141,6 +200,14 @@ public void testFailCustomMetadataNull() throws Exception {
     }
 
     @Test(expected = BKIncorrectParameterException.class)
+    public void testFailLedgerTypeNull() throws Exception {
+        result(newCreateLedgerOp()
+            .withLedgerType(null)
+            .withPassword(password)
+            .execute());
+    }
+
+    @Test(expected = BKIncorrectParameterException.class)
     public void testFailDigestTypeNullAndAutodetectionTrue() throws Exception {
         ClientConfiguration config = new ClientConfiguration();
         config.setEnableDigestTypeAutodetection(true);
@@ -310,7 +377,7 @@ protected LedgerMetadata generateLedgerMetadata(int 
ensembleSize,
         int writeQuorumSize, int ackQuorumSize, byte[] password,
         Map<String, byte[]> customMetadata) {
         LedgerMetadata ledgerMetadata = new LedgerMetadata(ensembleSize, 
writeQuorumSize,
-            ackQuorumSize, BookKeeper.DigestType.CRC32, password, 
customMetadata);
+            ackQuorumSize, BookKeeper.DigestType.CRC32, password, 
customMetadata, LedgerType.FORCE_ON_JOURNAL);
         ledgerMetadata.addEnsemble(0, generateNewEnsemble(ensembleSize));
         return ledgerMetadata;
     }
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorLedgerCheckerTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorLedgerCheckerTest.java
index 6627f8287..04ab5fd94 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorLedgerCheckerTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorLedgerCheckerTest.java
@@ -47,6 +47,7 @@
 import org.apache.bookkeeper.client.BookKeeper.DigestType;
 import org.apache.bookkeeper.client.LedgerHandle;
 import org.apache.bookkeeper.client.LedgerMetadata;
+import org.apache.bookkeeper.client.api.LedgerType;
 import org.apache.bookkeeper.conf.ServerConfiguration;
 import org.apache.bookkeeper.meta.LedgerManager;
 import org.apache.bookkeeper.meta.LedgerManagerFactory;
@@ -524,7 +525,7 @@ public void testTriggerAuditorWithNoPendingAuditTask() 
throws Exception {
         int numofledgers = 5;
         Random rand = new Random();
         for (int i = 0; i < numofledgers; i++) {
-            LedgerMetadata metadata = new LedgerMetadata(3, 2, 2, 
DigestType.CRC32, "passwd".getBytes(), null);
+            LedgerMetadata metadata = new LedgerMetadata(3, 2, 2, 
DigestType.CRC32, "passwd".getBytes(), null, LedgerType.FORCE_ON_JOURNAL);
             ArrayList<BookieSocketAddress> ensemble = new 
ArrayList<BookieSocketAddress>();
             ensemble.add(new BookieSocketAddress("99.99.99.99:9999"));
             ensemble.add(new BookieSocketAddress("11.11.11.11:1111"));
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
index 5bc34d61d..32c141d49 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
@@ -46,6 +46,7 @@
 import org.apache.bookkeeper.proto.BookkeeperProtocol;
 import 
org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.ReadEntryCallback;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 import org.apache.bookkeeper.util.OrderedSafeExecutor;
 import org.apache.bookkeeper.util.IOUtils;
 import org.junit.After;
@@ -145,7 +146,7 @@ public void testWriteGaps() throws Exception {
 
         BookieClient bc = new BookieClient(new ClientConfiguration(), 
eventLoopGroup, executor);
         ByteBuf bb = createByteBuffer(1, 1, 1);
-        bc.addEntry(addr, 1, passwd, 1, bb, wrcb, arc, 
BookieProtocol.FLAG_NONE);
+        bc.addEntry(addr, 1, passwd, 1, bb, wrcb, arc, 
BookieProtocol.FLAG_NONE, LedgerType.FORCE_ON_JOURNAL);
         synchronized (arc) {
             arc.wait(1000);
             assertEquals(0, arc.rc);
@@ -155,16 +156,16 @@ public void testWriteGaps() throws Exception {
             assertEquals(1, arc.entry.getInt());
         }
         bb = createByteBuffer(2, 1, 2);
-        bc.addEntry(addr, 1, passwd, 2, bb, wrcb, null, 
BookieProtocol.FLAG_NONE);
+        bc.addEntry(addr, 1, passwd, 2, bb, wrcb, null, 
BookieProtocol.FLAG_NONE, LedgerType.FORCE_ON_JOURNAL);
         bb = createByteBuffer(3, 1, 3);
-        bc.addEntry(addr, 1, passwd, 3, bb, wrcb, null, 
BookieProtocol.FLAG_NONE);
+        bc.addEntry(addr, 1, passwd, 3, bb, wrcb, null, 
BookieProtocol.FLAG_NONE, LedgerType.FORCE_ON_JOURNAL);
         bb = createByteBuffer(5, 1, 5);
-        bc.addEntry(addr, 1, passwd, 5, bb, wrcb, null, 
BookieProtocol.FLAG_NONE);
+        bc.addEntry(addr, 1, passwd, 5, bb, wrcb, null, 
BookieProtocol.FLAG_NONE, LedgerType.FORCE_ON_JOURNAL);
         bb = createByteBuffer(7, 1, 7);
-        bc.addEntry(addr, 1, passwd, 7, bb, wrcb, null, 
BookieProtocol.FLAG_NONE);
+        bc.addEntry(addr, 1, passwd, 7, bb, wrcb, null, 
BookieProtocol.FLAG_NONE, LedgerType.FORCE_ON_JOURNAL);
         synchronized (notifyObject) {
             bb = createByteBuffer(11, 1, 11);
-            bc.addEntry(addr, 1, passwd, 11, bb, wrcb, notifyObject, 
BookieProtocol.FLAG_NONE);
+            bc.addEntry(addr, 1, passwd, 11, bb, wrcb, notifyObject, 
BookieProtocol.FLAG_NONE, LedgerType.FORCE_ON_JOURNAL);
             notifyObject.wait();
         }
         synchronized (arc) {
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ConcurrentLedgerTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ConcurrentLedgerTest.java
index eb2ff0ee9..988c2cff0 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ConcurrentLedgerTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/ConcurrentLedgerTest.java
@@ -38,6 +38,7 @@
 import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.conf.TestBKConfiguration;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -187,7 +188,7 @@ public void writeComplete(int rc, long ledgerId, long 
entryId,
                 bytes.position(0);
                 bytes.limit(bytes.capacity());
                 throttle.acquire();
-                bookie.addEntry(Unpooled.wrappedBuffer(bytes), cb, counter, 
zeros);
+                bookie.addEntry(Unpooled.wrappedBuffer(bytes), 
LedgerType.FORCE_ON_JOURNAL, cb, counter, zeros);
             }
         }
         long finish = System.currentTimeMillis();
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/LoopbackClient.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/LoopbackClient.java
index 4aca80838..7e20fae0c 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/LoopbackClient.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/LoopbackClient.java
@@ -33,6 +33,7 @@
 import org.apache.bookkeeper.proto.BookieClient;
 import org.apache.bookkeeper.proto.BookieProtocol;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.WriteCallback;
+import org.apache.bookkeeper.proto.DataFormats.LedgerType;
 import org.apache.bookkeeper.util.OrderedSafeExecutor;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -76,7 +77,8 @@ void write(long ledgerId, long entry, byte[] data, 
BookieSocketAddress addr, Wri
         byte[] passwd = new byte[20];
         Arrays.fill(passwd, (byte) 'a');
 
-        client.addEntry(addr, ledgerId, passwd, entry, 
Unpooled.wrappedBuffer(data), cb, ctx, BookieProtocol.FLAG_NONE);
+        client.addEntry(addr, ledgerId, passwd, entry, 
Unpooled.wrappedBuffer(data), cb, ctx, BookieProtocol.FLAG_NONE,
+                        LedgerType.FORCE_ON_JOURNAL);
     }
 
     @Override
diff --git a/pom.xml b/pom.xml
index 2e1cc9569..080f045b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -204,7 +204,8 @@
           <target>1.8</target>
           <compilerArgs>
             <compilerArg>-Werror</compilerArg>
-            <compilerArg>-Xlint:deprecation</compilerArg>
+            <!-- protobuf generates deprecated code for top level enums -->
+            <!--<compilerArg>-Xlint:deprecation</compilerArg>-->
             <compilerArg>-Xlint:unchecked</compilerArg>
             <!-- https://issues.apache.org/jira/browse/MCOMPILER-205 -->
             <compilerArg>-Xpkginfo:always</compilerArg>


 

----------------------------------------------------------------
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