distributedlog-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject [18/31] incubator-distributedlog git commit: DL-161: Rename ledger id to log segment id
Date Fri, 30 Dec 2016 00:07:32 GMT
DL-161: Rename ledger id to log segment id

Along with providing log segment store related interfaces, clean up the naming from 'ledger id' to 'log segment id'. So it would become clear when we can plugin different log segment store.


Project: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/commit/47622a6e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/tree/47622a6e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/diff/47622a6e

Branch: refs/heads/master
Commit: 47622a6e45a34492ec50fcae79fb052dba06c6a4
Parents: c775180
Author: Sijie Guo <sijieg@twitter.com>
Authored: Wed Dec 28 16:48:47 2016 -0800
Committer: Sijie Guo <sijieg@twitter.com>
Committed: Thu Dec 29 02:12:25 2016 -0800

----------------------------------------------------------------------
 .../benchmark/stream/LedgerReadBenchmark.java   |  2 +-
 .../distributedlog/BKLogWriteHandler.java       | 42 +++++-----
 .../distributedlog/LedgerHandleCache.java       |  2 +-
 .../distributedlog/LogSegmentMetadata.java      | 85 ++++++++++----------
 .../distributedlog/auditor/DLAuditor.java       | 16 ++--
 .../bk/SimpleLedgerAllocator.java               |  4 +-
 .../logsegment/BKLogSegmentEntryReader.java     |  2 +-
 .../impl/logsegment/BKLogSegmentEntryStore.java |  4 +-
 .../logsegment/PerStreamLogSegmentCache.java    | 10 +--
 .../readahead/ReadAheadWorker.java              |  4 +-
 .../tools/DistributedLogTool.java               | 10 +--
 .../twitter/distributedlog/util/DLUtils.java    | 20 ++---
 .../com/twitter/distributedlog/DLMTestUtil.java |  2 +-
 .../distributedlog/TestAsyncReaderWriter.java   |  4 +-
 .../distributedlog/TestLogSegmentMetadata.java  |  7 +-
 .../TestZKLogStreamMetadataStoreUtils.java      |  2 +-
 .../TestLogSegmentMetadataStoreUpdater.java     |  4 +-
 .../distributedlog/util/TestDLUtils.java        |  6 +-
 18 files changed, 110 insertions(+), 116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-benchmark/src/main/java/com/twitter/distributedlog/benchmark/stream/LedgerReadBenchmark.java
----------------------------------------------------------------------
diff --git a/distributedlog-benchmark/src/main/java/com/twitter/distributedlog/benchmark/stream/LedgerReadBenchmark.java b/distributedlog-benchmark/src/main/java/com/twitter/distributedlog/benchmark/stream/LedgerReadBenchmark.java
index d5ef5b2..0f4d3d4 100644
--- a/distributedlog-benchmark/src/main/java/com/twitter/distributedlog/benchmark/stream/LedgerReadBenchmark.java
+++ b/distributedlog-benchmark/src/main/java/com/twitter/distributedlog/benchmark/stream/LedgerReadBenchmark.java
@@ -118,7 +118,7 @@ public class LedgerReadBenchmark extends AbstractReaderBenchmark {
         try {
             for (LogSegmentMetadata segment : segments) {
                 Stopwatch stopwatch = Stopwatch.createStarted();
-                long lid = segment.getLedgerId();
+                long lid = segment.getLogSegmentId();
                 LedgerHandle lh = bk.openLedgerNoRecovery(
                         lid, BookKeeper.DigestType.CRC32, conf.getBKDigestPW().getBytes(UTF_8));
                 logger.info("It took {} ms to open log segment {}",

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogWriteHandler.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogWriteHandler.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogWriteHandler.java
index 16c0111..3f06700 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogWriteHandler.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogWriteHandler.java
@@ -707,13 +707,13 @@ class BKLogWriteHandler extends BKLogHandler {
 
     @VisibleForTesting
     LogSegmentMetadata completeAndCloseLogSegment(long logSegmentSeqNo,
-                                                  long ledgerId,
+                                                  long logSegmentId,
                                                   long firstTxId,
                                                   long lastTxId,
                                                   int recordCount)
         throws IOException {
-        return completeAndCloseLogSegment(inprogressZNodeName(ledgerId, firstTxId, logSegmentSeqNo), logSegmentSeqNo,
-            ledgerId, firstTxId, lastTxId, recordCount, -1, -1);
+        return completeAndCloseLogSegment(inprogressZNodeName(logSegmentId, firstTxId, logSegmentSeqNo), logSegmentSeqNo,
+            logSegmentId, firstTxId, lastTxId, recordCount, -1, -1);
     }
 
     /**
@@ -726,7 +726,7 @@ class BKLogWriteHandler extends BKLogHandler {
      * trying to finalize.
      */
     LogSegmentMetadata completeAndCloseLogSegment(String inprogressZnodeName, long logSegmentSeqNo,
-                                                  long ledgerId, long firstTxId, long lastTxId,
+                                                  long logSegmentId, long firstTxId, long lastTxId,
                                                   int recordCount, long lastEntryId, long lastSlotId)
             throws IOException {
         Stopwatch stopwatch = Stopwatch.createStarted();
@@ -734,7 +734,7 @@ class BKLogWriteHandler extends BKLogHandler {
         try {
             LogSegmentMetadata completedLogSegment =
                     doCompleteAndCloseLogSegment(inprogressZnodeName, logSegmentSeqNo,
-                            ledgerId, firstTxId, lastTxId, recordCount,
+                            logSegmentId, firstTxId, lastTxId, recordCount,
                             lastEntryId, lastSlotId);
             success = true;
             return completedLogSegment;
@@ -770,7 +770,7 @@ class BKLogWriteHandler extends BKLogHandler {
      *
      * @param inprogressZnodeName
      * @param logSegmentSeqNo
-     * @param ledgerId
+     * @param logSegmentId
      * @param firstTxId
      * @param lastTxId
      * @param recordCount
@@ -781,7 +781,7 @@ class BKLogWriteHandler extends BKLogHandler {
     protected LogSegmentMetadata doCompleteAndCloseLogSegment(
             String inprogressZnodeName,
             long logSegmentSeqNo,
-            long ledgerId,
+            long logSegmentId,
             long firstTxId,
             long lastTxId,
             int recordCount,
@@ -791,7 +791,7 @@ class BKLogWriteHandler extends BKLogHandler {
         doCompleteAndCloseLogSegment(
                 inprogressZnodeName,
                 logSegmentSeqNo,
-                ledgerId,
+                logSegmentId,
                 firstTxId,
                 lastTxId,
                 recordCount,
@@ -803,7 +803,7 @@ class BKLogWriteHandler extends BKLogHandler {
 
     protected void doCompleteAndCloseLogSegment(final String inprogressZnodeName,
                                                 final long logSegmentSeqNo,
-                                                final long ledgerId,
+                                                final long logSegmentId,
                                                 final long firstTxId,
                                                 final long lastTxId,
                                                 final int recordCount,
@@ -821,7 +821,7 @@ class BKLogWriteHandler extends BKLogHandler {
                 doCompleteAndCloseLogSegmentAfterLogSegmentListFetched(
                         inprogressZnodeName,
                         logSegmentSeqNo,
-                        ledgerId,
+                        logSegmentId,
                         firstTxId,
                         lastTxId,
                         recordCount,
@@ -835,7 +835,7 @@ class BKLogWriteHandler extends BKLogHandler {
     private void doCompleteAndCloseLogSegmentAfterLogSegmentListFetched(
             final String inprogressZnodeName,
             long logSegmentSeqNo,
-            long ledgerId,
+            long logSegmentId,
             long firstTxId,
             long lastTxId,
             int recordCount,
@@ -853,11 +853,11 @@ class BKLogWriteHandler extends BKLogHandler {
         LogSegmentMetadata inprogressLogSegment = readLogSegmentFromCache(inprogressZnodeName);
 
         // validate log segment
-        if (inprogressLogSegment.getLedgerId() != ledgerId) {
+        if (inprogressLogSegment.getLogSegmentId() != logSegmentId) {
             FutureUtils.setException(promise, new IOException(
                 "Active ledger has different ID to inprogress. "
-                    + inprogressLogSegment.getLedgerId() + " found, "
-                    + ledgerId + " expected"));
+                    + inprogressLogSegment.getLogSegmentId() + " found, "
+                    + logSegmentId + " expected"));
             return;
         }
         // validate the transaction id
@@ -1016,7 +1016,7 @@ class BKLogWriteHandler extends BKLogHandler {
             doCompleteAndCloseLogSegment(
                     l.getZNodeName(),
                     l.getLogSegmentSequenceNumber(),
-                    l.getLedgerId(),
+                    l.getLogSegmentId(),
                     l.getFirstTxId(),
                     endTxId,
                     recordCount,
@@ -1223,17 +1223,17 @@ class BKLogWriteHandler extends BKLogHandler {
             }
         });
         try {
-            bookKeeperClient.get().asyncDeleteLedger(ledgerMetadata.getLedgerId(), new AsyncCallback.DeleteCallback() {
+            bookKeeperClient.get().asyncDeleteLedger(ledgerMetadata.getLogSegmentId(), new AsyncCallback.DeleteCallback() {
                 @Override
                 public void deleteComplete(int rc, Object ctx) {
                     if (BKException.Code.NoSuchLedgerExistsException == rc) {
                         LOG.warn("No ledger {} found to delete for {} : {}.",
-                                new Object[]{ledgerMetadata.getLedgerId(), getFullyQualifiedName(),
+                                new Object[]{ledgerMetadata.getLogSegmentId(), getFullyQualifiedName(),
                                         ledgerMetadata});
                     } else if (BKException.Code.OK != rc) {
                         BKException bke = BKException.create(rc);
                         LOG.error("Couldn't delete ledger {} from bookkeeper for {} : ",
-                                new Object[]{ledgerMetadata.getLedgerId(), getFullyQualifiedName(), bke});
+                                new Object[]{ledgerMetadata.getLogSegmentId(), getFullyQualifiedName(), bke});
                         promise.setException(bke);
                         return;
                     }
@@ -1315,7 +1315,7 @@ class BKLogWriteHandler extends BKLogHandler {
      *
      * @return name of the inprogress znode.
      */
-    String inprogressZNodeName(long ledgerId, long firstTxId, long logSegmentSeqNo) {
+    String inprogressZNodeName(long logSegmentId, long firstTxId, long logSegmentSeqNo) {
         if (DistributedLogConstants.LOGSEGMENT_NAME_VERSION == conf.getLogSegmentNameVersion()) {
             // Lots of the problems are introduced due to different inprogress names with same ledger sequence number.
             return String.format("%s_%018d", DistributedLogConstants.INPROGRESS_LOGSEGMENT_PREFIX, logSegmentSeqNo);
@@ -1327,8 +1327,8 @@ class BKLogWriteHandler extends BKLogHandler {
     /**
      * Get the znode path for the inprogressZNode
      */
-    String inprogressZNode(long ledgerId, long firstTxId, long logSegmentSeqNo) {
-        return logMetadata.getLogSegmentsPath() + "/" + inprogressZNodeName(ledgerId, firstTxId, logSegmentSeqNo);
+    String inprogressZNode(long logSegmentId, long firstTxId, long logSegmentSeqNo) {
+        return logMetadata.getLogSegmentsPath() + "/" + inprogressZNodeName(logSegmentId, firstTxId, logSegmentSeqNo);
     }
 
     String inprogressZNode(String inprogressZNodeName) {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/main/java/com/twitter/distributedlog/LedgerHandleCache.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/LedgerHandleCache.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/LedgerHandleCache.java
index 33e8c7d..49896fd 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/LedgerHandleCache.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/LedgerHandleCache.java
@@ -141,7 +141,7 @@ public class LedgerHandleCache {
         final Stopwatch stopwatch = Stopwatch.createStarted();
         final OpStatsLogger openStatsLogger = fence ? openStats : openNoRecoveryStats;
         final Promise<LedgerDescriptor> promise = new Promise<LedgerDescriptor>();
-        final LedgerDescriptor ledgerDesc = new LedgerDescriptor(metadata.getLedgerId(), metadata.getLogSegmentSequenceNumber(), fence);
+        final LedgerDescriptor ledgerDesc = new LedgerDescriptor(metadata.getLogSegmentId(), metadata.getLogSegmentSequenceNumber(), fence);
         RefCountedLedgerHandle refhandle = handlesMap.get(ledgerDesc);
         if (null == refhandle) {
             asyncOpenLedger(ledgerDesc, new AsyncCallback.OpenCallback() {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/main/java/com/twitter/distributedlog/LogSegmentMetadata.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/LogSegmentMetadata.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/LogSegmentMetadata.java
index 2297579..a8d9e6d 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/LogSegmentMetadata.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/LogSegmentMetadata.java
@@ -23,7 +23,9 @@ import java.util.Comparator;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Objects;
+import com.twitter.distributedlog.exceptions.DLInterruptedException;
 import com.twitter.distributedlog.exceptions.LogSegmentNotFoundException;
+import com.twitter.distributedlog.exceptions.UnsupportedMetadataVersionException;
 import com.twitter.distributedlog.exceptions.ZKException;
 import com.twitter.distributedlog.util.FutureUtils;
 import com.twitter.distributedlog.util.Utils;
@@ -36,9 +38,6 @@ import org.apache.zookeeper.data.Stat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.twitter.distributedlog.exceptions.DLInterruptedException;
-import com.twitter.distributedlog.exceptions.UnsupportedMetadataVersionException;
-
 import static com.google.common.base.Charsets.UTF_8;
 
 /**
@@ -93,7 +92,7 @@ public class LogSegmentMetadata {
 
     public static class LogSegmentMetadataBuilder {
         protected String zkPath;
-        protected long ledgerId;
+        protected long logSegmentId;
         protected LogSegmentMetadataVersion version;
         protected long firstTxId;
         protected int regionId;
@@ -118,20 +117,20 @@ public class LogSegmentMetadata {
 
         LogSegmentMetadataBuilder(String zkPath,
                                   LogSegmentMetadataVersion version,
-                                  long ledgerId,
+                                  long logSegmentId,
                                   long firstTxId) {
             initialize();
             this.zkPath = zkPath;
             this.version = version;
-            this.ledgerId = ledgerId;
+            this.logSegmentId = logSegmentId;
             this.firstTxId = firstTxId;
         }
 
         LogSegmentMetadataBuilder(String zkPath,
                                   int version,
-                                  long ledgerId,
+                                  long logSegmentId,
                                   long firstTxId) {
-            this(zkPath, LogSegmentMetadataVersion.values()[version], ledgerId, firstTxId);
+            this(zkPath, LogSegmentMetadataVersion.values()[version], logSegmentId, firstTxId);
         }
 
         private void initialize() {
@@ -222,7 +221,7 @@ public class LogSegmentMetadata {
             return new LogSegmentMetadata(
                 zkPath,
                 version,
-                ledgerId,
+                    logSegmentId,
                 firstTxId,
                 lastTxId,
                 completionTime,
@@ -249,7 +248,7 @@ public class LogSegmentMetadata {
     public static class Mutator extends LogSegmentMetadataBuilder {
 
         Mutator(LogSegmentMetadata original) {
-            super(original.getZkPath(), original.getVersion(), original.getLedgerId(), original.getFirstTxId());
+            super(original.getZkPath(), original.getVersion(), original.getLogSegmentId(), original.getFirstTxId());
             this.inprogress = original.isInProgress();
             this.logSegmentSequenceNo = original.getLogSegmentSequenceNumber();
             this.lastEntryId = original.getLastEntryId();
@@ -310,7 +309,7 @@ public class LogSegmentMetadata {
     }
 
     private final String zkPath;
-    private final long ledgerId;
+    private final long logSegmentId;
     private final LogSegmentMetadataVersion version;
     private final long firstTxId;
     private final int regionId;
@@ -418,7 +417,7 @@ public class LogSegmentMetadata {
 
     private LogSegmentMetadata(String zkPath,
                                LogSegmentMetadataVersion version,
-                               long ledgerId,
+                               long logSegmentId,
                                long firstTxId,
                                long lastTxId,
                                long completionTime,
@@ -434,7 +433,7 @@ public class LogSegmentMetadata {
                                long startSequenceId,
                                boolean envelopeEntries) {
         this.zkPath = zkPath;
-        this.ledgerId = ledgerId;
+        this.logSegmentId = logSegmentId;
         this.version = version;
         this.firstTxId = firstTxId;
         this.lastTxId = lastTxId;
@@ -469,8 +468,8 @@ public class LogSegmentMetadata {
         return completionTime;
     }
 
-    public long getLedgerId() {
-        return ledgerId;
+    public long getLogSegmentId() {
+        return logSegmentId;
     }
 
     public long getLogSegmentSequenceNumber() {
@@ -645,9 +644,9 @@ public class LogSegmentMetadata {
         assert (status >= 0 && status <= METADATA_STATUS_BIT_MAX);
 
         if (parts.length == 3) {
-            long ledgerId = Long.parseLong(parts[1]);
+            long logSegmentId = Long.parseLong(parts[1]);
             long txId = Long.parseLong(parts[2]);
-            return new LogSegmentMetadataBuilder(path, llmv, ledgerId, txId)
+            return new LogSegmentMetadataBuilder(path, llmv, logSegmentId, txId)
                     .setRegionId(regionId)
                     .setStatus(status)
                     .build();
@@ -655,11 +654,11 @@ public class LogSegmentMetadata {
             long recordCount = (versionStatusCount & LOGRECORD_COUNT_MASK) >> LOGRECORD_COUNT_SHIFT;
             assert (recordCount >= Integer.MIN_VALUE && recordCount <= Integer.MAX_VALUE);
 
-            long ledgerId = Long.parseLong(parts[1]);
+            long logSegmentId = Long.parseLong(parts[1]);
             long firstTxId = Long.parseLong(parts[2]);
             long lastTxId = Long.parseLong(parts[3]);
             long completionTime = Long.parseLong(parts[4]);
-            return new LogSegmentMetadataBuilder(path, llmv, ledgerId, firstTxId)
+            return new LogSegmentMetadataBuilder(path, llmv, logSegmentId, firstTxId)
                 .setInprogress(false)
                 .setLastTxId(lastTxId)
                 .setCompletionTime(completionTime)
@@ -690,10 +689,10 @@ public class LogSegmentMetadata {
         assert (status >= 0 && status <= METADATA_STATUS_BIT_MAX);
 
         if (parts.length == 4) {
-            long ledgerId = Long.parseLong(parts[1]);
+            long logSegmentId = Long.parseLong(parts[1]);
             long txId = Long.parseLong(parts[2]);
             long logSegmentSequenceNumber = Long.parseLong(parts[3]);
-            return new LogSegmentMetadataBuilder(path, llmv, ledgerId, txId)
+            return new LogSegmentMetadataBuilder(path, llmv, logSegmentId, txId)
                 .setLogSegmentSequenceNo(logSegmentSequenceNumber)
                 .setRegionId(regionId)
                 .setStatus(status)
@@ -702,14 +701,14 @@ public class LogSegmentMetadata {
             long recordCount = (versionStatusCount & LOGRECORD_COUNT_MASK) >> LOGRECORD_COUNT_SHIFT;
             assert (recordCount >= Integer.MIN_VALUE && recordCount <= Integer.MAX_VALUE);
 
-            long ledgerId = Long.parseLong(parts[1]);
+            long logSegmentId = Long.parseLong(parts[1]);
             long firstTxId = Long.parseLong(parts[2]);
             long lastTxId = Long.parseLong(parts[3]);
             long completionTime = Long.parseLong(parts[4]);
             long logSegmentSequenceNumber = Long.parseLong(parts[5]);
             long lastEntryId = Long.parseLong(parts[6]);
             long lastSlotId = Long.parseLong(parts[7]);
-            return new LogSegmentMetadataBuilder(path, llmv, ledgerId, firstTxId)
+            return new LogSegmentMetadataBuilder(path, llmv, logSegmentId, firstTxId)
                 .setInprogress(false)
                 .setLastTxId(lastTxId)
                 .setCompletionTime(completionTime)
@@ -745,13 +744,13 @@ public class LogSegmentMetadata {
         assert (status >= 0 && status <= METADATA_STATUS_BIT_MAX);
 
         if (parts.length == 6) {
-            long ledgerId = Long.parseLong(parts[1]);
+            long logSegmentId = Long.parseLong(parts[1]);
             long txId = Long.parseLong(parts[2]);
             long logSegmentSequenceNumber = Long.parseLong(parts[3]);
             long minActiveEntryId = Long.parseLong(parts[4]);
             long minActiveSlotId = Long.parseLong(parts[5]);
 
-            LogSegmentMetadataBuilder builder = new LogSegmentMetadataBuilder(path, llmv, ledgerId, txId)
+            LogSegmentMetadataBuilder builder = new LogSegmentMetadataBuilder(path, llmv, logSegmentId, txId)
                 .setLogSegmentSequenceNo(logSegmentSequenceNumber)
                 .setMinActiveEntryId(minActiveEntryId)
                 .setMinActiveSlotId(minActiveSlotId)
@@ -765,7 +764,7 @@ public class LogSegmentMetadata {
             long recordCount = (versionStatusCount & LOGRECORD_COUNT_MASK) >> LOGRECORD_COUNT_SHIFT;
             assert (recordCount >= Integer.MIN_VALUE && recordCount <= Integer.MAX_VALUE);
 
-            long ledgerId = Long.parseLong(parts[1]);
+            long logSegmentId = Long.parseLong(parts[1]);
             long firstTxId = Long.parseLong(parts[2]);
             long lastTxId = Long.parseLong(parts[3]);
             long completionTime = Long.parseLong(parts[4]);
@@ -774,7 +773,7 @@ public class LogSegmentMetadata {
             long lastSlotId = Long.parseLong(parts[7]);
             long minActiveEntryId = Long.parseLong(parts[8]);
             long minActiveSlotId = Long.parseLong(parts[9]);
-            LogSegmentMetadataBuilder builder = new LogSegmentMetadataBuilder(path, llmv, ledgerId, firstTxId)
+            LogSegmentMetadataBuilder builder = new LogSegmentMetadataBuilder(path, llmv, logSegmentId, firstTxId)
                 .setInprogress(false)
                 .setLastTxId(lastTxId)
                 .setCompletionTime(completionTime)
@@ -815,14 +814,14 @@ public class LogSegmentMetadata {
         assert (status >= 0 && status <= METADATA_STATUS_BIT_MAX);
 
         if (parts.length == 7) {
-            long ledgerId = Long.parseLong(parts[1]);
+            long logSegmentId = Long.parseLong(parts[1]);
             long txId = Long.parseLong(parts[2]);
             long logSegmentSequenceNumber = Long.parseLong(parts[3]);
             long minActiveEntryId = Long.parseLong(parts[4]);
             long minActiveSlotId = Long.parseLong(parts[5]);
             long startSequenceId = Long.parseLong(parts[6]);
 
-            LogSegmentMetadataBuilder builder = new LogSegmentMetadataBuilder(path, llmv, ledgerId, txId)
+            LogSegmentMetadataBuilder builder = new LogSegmentMetadataBuilder(path, llmv, logSegmentId, txId)
                     .setLogSegmentSequenceNo(logSegmentSequenceNumber)
                     .setMinActiveEntryId(minActiveEntryId)
                     .setMinActiveSlotId(minActiveSlotId)
@@ -835,7 +834,7 @@ public class LogSegmentMetadata {
             long recordCount = (versionStatusCount & LOGRECORD_COUNT_MASK) >> LOGRECORD_COUNT_SHIFT;
             assert (recordCount >= Integer.MIN_VALUE && recordCount <= Integer.MAX_VALUE);
 
-            long ledgerId = Long.parseLong(parts[1]);
+            long logSegmentId = Long.parseLong(parts[1]);
             long firstTxId = Long.parseLong(parts[2]);
             long lastTxId = Long.parseLong(parts[3]);
             long completionTime = Long.parseLong(parts[4]);
@@ -845,7 +844,7 @@ public class LogSegmentMetadata {
             long minActiveEntryId = Long.parseLong(parts[8]);
             long minActiveSlotId = Long.parseLong(parts[9]);
             long startSequenceId = Long.parseLong(parts[10]);
-            LogSegmentMetadataBuilder builder = new LogSegmentMetadataBuilder(path, llmv, ledgerId, firstTxId)
+            LogSegmentMetadataBuilder builder = new LogSegmentMetadataBuilder(path, llmv, logSegmentId, firstTxId)
                     .setInprogress(false)
                     .setLastTxId(lastTxId)
                     .setCompletionTime(completionTime)
@@ -919,11 +918,11 @@ public class LogSegmentMetadata {
         if (LogSegmentMetadataVersion.VERSION_V1_ORIGINAL == version) {
             if (inprogress) {
                 finalisedData = String.format("%d;%d;%d",
-                    version.value, ledgerId, firstTxId);
+                    version.value, logSegmentId, firstTxId);
             } else {
                 long versionAndCount = ((long) version.value) | ((long)recordCount << LOGRECORD_COUNT_SHIFT);
                 finalisedData = String.format("%d;%d;%d;%d;%d",
-                    versionAndCount, ledgerId, firstTxId, lastTxId, completionTime);
+                    versionAndCount, logSegmentId, firstTxId, lastTxId, completionTime);
             }
         } else {
             long versionStatusCount = ((long) version.value);
@@ -935,30 +934,30 @@ public class LogSegmentMetadata {
             if (LogSegmentMetadataVersion.VERSION_V2_LEDGER_SEQNO == version) {
                 if (inprogress) {
                     finalisedData = String.format("%d;%d;%d;%d",
-                        versionStatusCount, ledgerId, firstTxId, logSegmentSeqNo);
+                        versionStatusCount, logSegmentId, firstTxId, logSegmentSeqNo);
                 } else {
                     finalisedData = String.format("%d;%d;%d;%d;%d;%d;%d;%d",
-                        versionStatusCount, ledgerId, firstTxId, lastTxId, completionTime,
+                        versionStatusCount, logSegmentId, firstTxId, lastTxId, completionTime,
                         logSegmentSeqNo, lastEntryId, lastSlotId);
                 }
             } else if (LogSegmentMetadataVersion.VERSION_V4_ENVELOPED_ENTRIES.value >= version.value &&
                         LogSegmentMetadataVersion.VERSION_V3_MIN_ACTIVE_DLSN.value <= version.value) {
                 if (inprogress) {
                     finalisedData = String.format("%d;%d;%d;%d;%d;%d",
-                        versionStatusCount, ledgerId, firstTxId, logSegmentSeqNo, minActiveEntryId, minActiveSlotId);
+                        versionStatusCount, logSegmentId, firstTxId, logSegmentSeqNo, minActiveEntryId, minActiveSlotId);
                 } else {
                     finalisedData = String.format("%d;%d;%d;%d;%d;%d;%d;%d;%d;%d",
-                        versionStatusCount, ledgerId, firstTxId, lastTxId, completionTime,
+                        versionStatusCount, logSegmentId, firstTxId, lastTxId, completionTime,
                         logSegmentSeqNo, lastEntryId, lastSlotId, minActiveEntryId, minActiveSlotId);
                 }
             } else if (LogSegmentMetadataVersion.VERSION_V5_SEQUENCE_ID.value <= version.value &&
                         LogSegmentMetadata.LEDGER_METADATA_CURRENT_LAYOUT_VERSION >= version.value) {
                 if (inprogress) {
                     finalisedData = String.format("%d;%d;%d;%d;%d;%d;%d",
-                        versionStatusCount, ledgerId, firstTxId, logSegmentSeqNo, minActiveEntryId, minActiveSlotId, startSequenceId);
+                        versionStatusCount, logSegmentId, firstTxId, logSegmentSeqNo, minActiveEntryId, minActiveSlotId, startSequenceId);
                 } else {
                     finalisedData = String.format("%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d",
-                        versionStatusCount, ledgerId, firstTxId, lastTxId, completionTime,
+                        versionStatusCount, logSegmentId, firstTxId, lastTxId, completionTime,
                         logSegmentSeqNo, lastEntryId, lastSlotId, minActiveEntryId, minActiveSlotId, startSequenceId);
                 }
             } else {
@@ -1007,7 +1006,7 @@ public class LogSegmentMetadata {
             // cannot be compared
             // if the node is inprogress, don't compare the lastTxId either
             if (this.getLogSegmentSequenceNumber() != other.getLogSegmentSequenceNumber() ||
-                this.ledgerId != other.ledgerId ||
+                this.logSegmentId != other.logSegmentId ||
                 this.firstTxId != other.firstTxId) {
                 retVal = false;
             } else if (this.inprogress) {
@@ -1033,7 +1032,7 @@ public class LogSegmentMetadata {
         }
         LogSegmentMetadata ol = (LogSegmentMetadata) o;
         return getLogSegmentSequenceNumber() == ol.getLogSegmentSequenceNumber()
-            && ledgerId == ol.ledgerId
+            && logSegmentId == ol.logSegmentId
             && firstTxId == ol.firstTxId
             && lastTxId == ol.lastTxId
             && version == ol.version
@@ -1046,7 +1045,7 @@ public class LogSegmentMetadata {
 
     public int hashCode() {
         int hash = 1;
-        hash = hash * 31 + (int) ledgerId;
+        hash = hash * 31 + (int) logSegmentId;
         hash = hash * 31 + (int) firstTxId;
         hash = hash * 31 + (int) lastTxId;
         hash = hash * 31 + version.value;
@@ -1056,7 +1055,7 @@ public class LogSegmentMetadata {
     }
 
     public String toString() {
-        return "[LedgerId:" + ledgerId +
+        return "[LogSegmentId:" + logSegmentId +
             ", firstTxId:" + firstTxId +
             ", lastTxId:" + lastTxId +
             ", version:" + version +

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/main/java/com/twitter/distributedlog/auditor/DLAuditor.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/auditor/DLAuditor.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/auditor/DLAuditor.java
index 289afd6..e551c22 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/auditor/DLAuditor.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/auditor/DLAuditor.java
@@ -325,7 +325,7 @@ public class DLAuditor {
                     byte[] data = getZooKeeperClient(factory).get().getData(allocatorPath, false, new Stat());
                     if (null != data && data.length > 0) {
                         try {
-                            long ledgerId = DLUtils.bytes2LedgerId(data);
+                            long ledgerId = DLUtils.bytes2LogSegmentId(data);
                             synchronized (ledgers) {
                                 ledgers.add(ledgerId);
                             }
@@ -370,9 +370,9 @@ public class DLAuditor {
             List<Long> sLedgers = new ArrayList<Long>();
             for (LogSegmentMetadata segment : segments) {
                 synchronized (ledgers) {
-                    ledgers.add(segment.getLedgerId());
+                    ledgers.add(segment.getLogSegmentId());
                 }
-                sLedgers.add(segment.getLedgerId());
+                sLedgers.add(segment.getLogSegmentId());
             }
             return sLedgers;
         } finally {
@@ -431,17 +431,17 @@ public class DLAuditor {
             List<LogSegmentMetadata> segments = dlm.getLogSegments();
             for (LogSegmentMetadata segment : segments) {
                 try {
-                    LedgerHandle lh = getBookKeeperClient(factory).get().openLedgerNoRecovery(segment.getLedgerId(),
+                    LedgerHandle lh = getBookKeeperClient(factory).get().openLedgerNoRecovery(segment.getLogSegmentId(),
                             BookKeeper.DigestType.CRC32, conf.getBKDigestPW().getBytes(UTF_8));
                     totalBytes += lh.getLength();
                     lh.close();
                 } catch (BKException e) {
-                    logger.error("Failed to open ledger {} : ", segment.getLedgerId(), e);
-                    throw new IOException("Failed to open ledger " + segment.getLedgerId(), e);
+                    logger.error("Failed to open ledger {} : ", segment.getLogSegmentId(), e);
+                    throw new IOException("Failed to open ledger " + segment.getLogSegmentId(), e);
                 } catch (InterruptedException e) {
-                    logger.warn("Interrupted on opening ledger {} : ", segment.getLedgerId(), e);
+                    logger.warn("Interrupted on opening ledger {} : ", segment.getLogSegmentId(), e);
                     Thread.currentThread().interrupt();
-                    throw new DLInterruptedException("Interrupted on opening ledger " + segment.getLedgerId(), e);
+                    throw new DLInterruptedException("Interrupted on opening ledger " + segment.getLogSegmentId(), e);
                 }
             }
         } finally {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/main/java/com/twitter/distributedlog/bk/SimpleLedgerAllocator.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/bk/SimpleLedgerAllocator.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/bk/SimpleLedgerAllocator.java
index dbabdc5..ab5976e 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/bk/SimpleLedgerAllocator.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/bk/SimpleLedgerAllocator.java
@@ -212,7 +212,7 @@ public class SimpleLedgerAllocator implements LedgerAllocator, FutureEventListen
         if (null != data && data.length > 0) {
             // delete the allocated ledger since this is left by last allocation.
             try {
-                ledgerIdLeftFromPrevAllocation = DLUtils.bytes2LedgerId(data);
+                ledgerIdLeftFromPrevAllocation = DLUtils.bytes2LogSegmentId(data);
             } catch (NumberFormatException nfe) {
                 LOG.warn("Invalid data found in allocator path {} : ", allocatePath, nfe);
             }
@@ -384,7 +384,7 @@ public class SimpleLedgerAllocator implements LedgerAllocator, FutureEventListen
     }
 
     private void markAsAllocated(final LedgerHandle lh) {
-        byte[] data = DLUtils.ledgerId2Bytes(lh.getId());
+        byte[] data = DLUtils.logSegmentId2Bytes(lh.getId());
         Utils.zkSetData(zkc, allocatePath, data, getVersion())
             .addEventListener(new FutureEventListener<ZkVersion>() {
                 @Override

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/main/java/com/twitter/distributedlog/impl/logsegment/BKLogSegmentEntryReader.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/impl/logsegment/BKLogSegmentEntryReader.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/impl/logsegment/BKLogSegmentEntryReader.java
index be8e1b5..dc382d2 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/impl/logsegment/BKLogSegmentEntryReader.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/impl/logsegment/BKLogSegmentEntryReader.java
@@ -387,7 +387,7 @@ public class BKLogSegmentEntryReader implements Runnable, LogSegmentEntryReader,
         }
         // segment is closed from inprogress, then re-open the log segment
         bk.asyncOpenLedger(
-                segment.getLedgerId(),
+                segment.getLogSegmentId(),
                 BookKeeper.DigestType.CRC32,
                 conf.getBKDigestPW().getBytes(UTF_8),
                 this,

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/main/java/com/twitter/distributedlog/impl/logsegment/BKLogSegmentEntryStore.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/impl/logsegment/BKLogSegmentEntryStore.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/impl/logsegment/BKLogSegmentEntryStore.java
index dc96a80..4650949 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/impl/logsegment/BKLogSegmentEntryStore.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/impl/logsegment/BKLogSegmentEntryStore.java
@@ -87,14 +87,14 @@ public class BKLogSegmentEntryStore implements LogSegmentEntryStore, AsyncCallba
         OpenReaderRequest request = new OpenReaderRequest(segment, startEntryId);
         if (segment.isInProgress()) {
             bk.asyncOpenLedgerNoRecovery(
-                    segment.getLedgerId(),
+                    segment.getLogSegmentId(),
                     BookKeeper.DigestType.CRC32,
                     passwd,
                     this,
                     request);
         } else {
             bk.asyncOpenLedger(
-                    segment.getLedgerId(),
+                    segment.getLogSegmentId(),
                     BookKeeper.DigestType.CRC32,
                     passwd,
                     this,

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/main/java/com/twitter/distributedlog/logsegment/PerStreamLogSegmentCache.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/logsegment/PerStreamLogSegmentCache.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/logsegment/PerStreamLogSegmentCache.java
index f242941..5f88c5a 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/logsegment/PerStreamLogSegmentCache.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/logsegment/PerStreamLogSegmentCache.java
@@ -157,14 +157,14 @@ public class PerStreamLogSegmentCache {
                 LOG.info("{} added log segment ({} : {}) to cache.",
                         new Object[]{ streamName, name, metadata });
             }
-            LogSegmentMetadata oldMetadata = lid2LogSegments.remove(metadata.getLedgerId());
+            LogSegmentMetadata oldMetadata = lid2LogSegments.remove(metadata.getLogSegmentId());
             if (null == oldMetadata) {
-                lid2LogSegments.put(metadata.getLedgerId(), metadata);
+                lid2LogSegments.put(metadata.getLogSegmentId(), metadata);
             } else {
                 if (oldMetadata.isInProgress() && !metadata.isInProgress()) {
-                    lid2LogSegments.put(metadata.getLedgerId(), metadata);
+                    lid2LogSegments.put(metadata.getLogSegmentId(), metadata);
                 } else {
-                    lid2LogSegments.put(oldMetadata.getLedgerId(), oldMetadata);
+                    lid2LogSegments.put(oldMetadata.getLogSegmentId(), oldMetadata);
                 }
             }
         }
@@ -232,7 +232,7 @@ public class PerStreamLogSegmentCache {
         synchronized (logSegments) {
             LogSegmentMetadata metadata = logSegments.remove(name);
             if (null != metadata) {
-                lid2LogSegments.remove(metadata.getLedgerId(), metadata);
+                lid2LogSegments.remove(metadata.getLogSegmentId(), metadata);
                 LOG.debug("Removed log segment ({} : {}) from cache.", name, metadata);
             }
             return metadata;

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/main/java/com/twitter/distributedlog/readahead/ReadAheadWorker.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/readahead/ReadAheadWorker.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/readahead/ReadAheadWorker.java
index 5161b91..8529281 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/readahead/ReadAheadWorker.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/readahead/ReadAheadWorker.java
@@ -707,7 +707,7 @@ public class ReadAheadWorker implements ReadAheadCallback, Runnable, AsyncClosea
                                 }
                             }
 
-                            nextReadAheadPosition = new LedgerReadPosition(l.getLedgerId(), l.getLogSegmentSequenceNumber(), startBKEntry);
+                            nextReadAheadPosition = new LedgerReadPosition(l.getLogSegmentId(), l.getLogSegmentSequenceNumber(), startBKEntry);
                             if (conf.getTraceReadAheadMetadataChanges()) {
                                 LOG.info("Moved read position to {} for stream {} at {}.",
                                          new Object[] {nextReadAheadPosition, logMetadata.getFullyQualifiedName(), System.currentTimeMillis() });
@@ -1028,7 +1028,7 @@ public class ReadAheadWorker implements ReadAheadCallback, Runnable, AsyncClosea
                                                     LOG.trace("Moving read position to a new ledger {} for {}.",
                                                         currentMetadata, fullyQualifiedName);
                                                 }
-                                                nextReadAheadPosition.positionOnNewLogSegment(currentMetadata.getLedgerId(), currentMetadata.getLogSegmentSequenceNumber());
+                                                nextReadAheadPosition.positionOnNewLogSegment(currentMetadata.getLogSegmentId(), currentMetadata.getLogSegmentSequenceNumber());
                                             }
                                         }
                                     }

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/main/java/com/twitter/distributedlog/tools/DistributedLogTool.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/tools/DistributedLogTool.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/tools/DistributedLogTool.java
index 23d8e40..30d6908 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/tools/DistributedLogTool.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/tools/DistributedLogTool.java
@@ -703,7 +703,7 @@ public class DistributedLogTool extends Tool {
                             LogSegmentMetadata segment = seg;
                             List<String> dumpedEntries = new ArrayList<String>();
                             if (segment.isInProgress()) {
-                                LedgerHandle lh = bkc.get().openLedgerNoRecovery(segment.getLedgerId(), BookKeeper.DigestType.CRC32,
+                                LedgerHandle lh = bkc.get().openLedgerNoRecovery(segment.getLogSegmentId(), BookKeeper.DigestType.CRC32,
                                                                                  dlConf.getBKDigestPW().getBytes(UTF_8));
                                 try {
                                     long lac = lh.readLastConfirmed();
@@ -1011,7 +1011,7 @@ public class DistributedLogTool extends Tool {
 
         private Map<BookieSocketAddress, Integer> getBookieStats(LogSegmentMetadata segment) throws Exception {
             Map<BookieSocketAddress, Integer> stats = new HashMap<BookieSocketAddress, Integer>();
-            LedgerHandle lh = bkc.client().get().openLedgerNoRecovery(segment.getLedgerId(), BookKeeper.DigestType.CRC32,
+            LedgerHandle lh = bkc.client().get().openLedgerNoRecovery(segment.getLogSegmentId(), BookKeeper.DigestType.CRC32,
                     getConf().getBKDigestPW().getBytes(UTF_8));
             long eidFirst = 0;
             for (SortedMap.Entry<Long, ArrayList<BookieSocketAddress>> entry : LedgerReader.bookiesForLedger(lh).entrySet()) {
@@ -1601,7 +1601,7 @@ public class DistributedLogTool extends Tool {
                 System.out.println("Skip inprogress log segment " + metadata);
                 return true;
             }
-            long ledgerId = metadata.getLedgerId();
+            long ledgerId = metadata.getLogSegmentId();
             LedgerHandle lh = bkc.get().openLedger(ledgerId, BookKeeper.DigestType.CRC32,
                     getConf().getBKDigestPW().getBytes(UTF_8));
             LedgerHandle readLh = bkc.get().openLedger(ledgerId, BookKeeper.DigestType.CRC32,
@@ -1667,7 +1667,7 @@ public class DistributedLogTool extends Tool {
                 System.out.println("Skip inprogress log segment " + segment);
                 return;
             }
-            LedgerHandle lh = bkAdmin.openLedger(segment.getLedgerId(), true);
+            LedgerHandle lh = bkAdmin.openLedger(segment.getLogSegmentId(), true);
             long lac = lh.getLastAddConfirmed();
             Enumeration<LedgerEntry> entries = lh.readEntries(lac, lac);
             if (!entries.hasMoreElements()) {
@@ -2129,7 +2129,7 @@ public class DistributedLogTool extends Tool {
             try {
                 List<LogSegmentMetadata> segments = dlm.getLogSegments();
                 for (LogSegmentMetadata segment : segments) {
-                    if (getLedgerID() == segment.getLedgerId()) {
+                    if (getLedgerID() == segment.getLogSegmentId()) {
                         System.out.println("Found ledger " + getLedgerID() + " at log segment "
                                 + segment + " for stream '" + logName + "'");
                         return true;

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/main/java/com/twitter/distributedlog/util/DLUtils.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/util/DLUtils.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/util/DLUtils.java
index 803db90..63db1fe 100644
--- a/distributedlog-core/src/main/java/com/twitter/distributedlog/util/DLUtils.java
+++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/util/DLUtils.java
@@ -204,24 +204,24 @@ public class DLUtils {
     }
 
     /**
-     * Serialize ledger id into bytes.
+     * Serialize log segment id into bytes.
      *
-     * @param ledgerId
-     *          ledger id
-     * @return bytes representation of ledger id
+     * @param logSegmentId
+     *          log segment id
+     * @return bytes representation of log segment id
      */
-    public static byte[] ledgerId2Bytes(long ledgerId) {
-        return Long.toString(ledgerId).getBytes(UTF_8);
+    public static byte[] logSegmentId2Bytes(long logSegmentId) {
+        return Long.toString(logSegmentId).getBytes(UTF_8);
     }
 
     /**
-     * Deserialize bytes into ledger id.
+     * Deserialize bytes into log segment id.
      *
      * @param data
-     *          bytes representation of ledger id
-     * @return ledger id
+     *          bytes representation of log segment id
+     * @return log segment id
      */
-    public static long bytes2LedgerId(byte[] data) {
+    public static long bytes2LogSegmentId(byte[] data) {
         return Long.parseLong(new String(data, UTF_8));
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/test/java/com/twitter/distributedlog/DLMTestUtil.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/test/java/com/twitter/distributedlog/DLMTestUtil.java b/distributedlog-core/src/test/java/com/twitter/distributedlog/DLMTestUtil.java
index 588c366..b0a38cf 100644
--- a/distributedlog-core/src/test/java/com/twitter/distributedlog/DLMTestUtil.java
+++ b/distributedlog-core/src/test/java/com/twitter/distributedlog/DLMTestUtil.java
@@ -195,7 +195,7 @@ public class DLMTestUtil {
             ).getValue();
             LogSegmentMetadata lastSegment = ledgerList.get(ledgerList.size() - 1);
             BookKeeperClient bkc = dlm.getWriterBKC();
-            LedgerHandle lh = bkc.get().openLedger(lastSegment.getLedgerId(),
+            LedgerHandle lh = bkc.get().openLedger(lastSegment.getLogSegmentId(),
                     BookKeeper.DigestType.CRC32, conf.getBKDigestPW().getBytes(UTF_8));
             lh.close();
         } finally {

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/test/java/com/twitter/distributedlog/TestAsyncReaderWriter.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/test/java/com/twitter/distributedlog/TestAsyncReaderWriter.java b/distributedlog-core/src/test/java/com/twitter/distributedlog/TestAsyncReaderWriter.java
index 65507ac..41adbb9 100644
--- a/distributedlog-core/src/test/java/com/twitter/distributedlog/TestAsyncReaderWriter.java
+++ b/distributedlog-core/src/test/java/com/twitter/distributedlog/TestAsyncReaderWriter.java
@@ -1975,7 +1975,7 @@ public class TestAsyncReaderWriter extends TestDistributedLogBase {
         FutureUtils.result(writer.write(DLMTestUtil.getLogRecordInstance(1L)));
         List<LogSegmentMetadata> segments = dlm.getLogSegments();
         assertEquals(1, segments.size());
-        long ledgerId = segments.get(0).getLedgerId();
+        long ledgerId = segments.get(0).getLogSegmentId();
         LedgerHandle lh = ((BKDistributedLogNamespace) namespace).getReaderBKC()
                 .get().openLedgerNoRecovery(ledgerId, BookKeeper.DigestType.CRC32, confLocal.getBKDigestPW().getBytes(UTF_8));
         LedgerMetadata metadata = BookKeeperAccessor.getLedgerMetadata(lh);
@@ -1994,7 +1994,7 @@ public class TestAsyncReaderWriter extends TestDistributedLogBase {
         FutureUtils.result(writer.write(DLMTestUtil.getLogRecordInstance(1L)));
         segments = dlm.getLogSegments();
         assertEquals(1, segments.size());
-        ledgerId = segments.get(0).getLedgerId();
+        ledgerId = segments.get(0).getLogSegmentId();
         lh = ((BKDistributedLogNamespace) namespace).getReaderBKC()
                 .get().openLedgerNoRecovery(ledgerId, BookKeeper.DigestType.CRC32, confLocal.getBKDigestPW().getBytes(UTF_8));
         metadata = BookKeeperAccessor.getLedgerMetadata(lh);

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/test/java/com/twitter/distributedlog/TestLogSegmentMetadata.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/test/java/com/twitter/distributedlog/TestLogSegmentMetadata.java b/distributedlog-core/src/test/java/com/twitter/distributedlog/TestLogSegmentMetadata.java
index f652d96..9e2c22e 100644
--- a/distributedlog-core/src/test/java/com/twitter/distributedlog/TestLogSegmentMetadata.java
+++ b/distributedlog-core/src/test/java/com/twitter/distributedlog/TestLogSegmentMetadata.java
@@ -23,9 +23,6 @@ import com.twitter.distributedlog.LogSegmentMetadata.TruncationStatus;
 import com.twitter.distributedlog.exceptions.UnsupportedMetadataVersionException;
 
 import com.twitter.distributedlog.util.FutureUtils;
-import org.apache.bookkeeper.client.BKException;
-import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks;
-import org.apache.zookeeper.KeeperException;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -33,8 +30,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicReference;
 
 import static com.google.common.base.Charsets.UTF_8;
 import static org.junit.Assert.assertEquals;
@@ -81,7 +76,7 @@ public class TestLogSegmentMetadata extends ZooKeeperClusterTestCase {
         metadata1.write(zkc);
         // synchronous read
         LogSegmentMetadata read1 = FutureUtils.result(LogSegmentMetadata.read(zkc, "/metadata2", true));
-        assertEquals(read1.getLedgerId(), metadata1.getLedgerId());
+        assertEquals(read1.getLogSegmentId(), metadata1.getLogSegmentId());
         assertEquals(read1.getFirstTxId(), metadata1.getFirstTxId());
         assertEquals(read1.getLastTxId(), metadata1.getLastTxId());
         assertEquals(read1.getLogSegmentSequenceNumber(), metadata1.getLogSegmentSequenceNumber());

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/test/java/com/twitter/distributedlog/impl/metadata/TestZKLogStreamMetadataStoreUtils.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/test/java/com/twitter/distributedlog/impl/metadata/TestZKLogStreamMetadataStoreUtils.java b/distributedlog-core/src/test/java/com/twitter/distributedlog/impl/metadata/TestZKLogStreamMetadataStoreUtils.java
index 9f29ebe..eb9174f 100644
--- a/distributedlog-core/src/test/java/com/twitter/distributedlog/impl/metadata/TestZKLogStreamMetadataStoreUtils.java
+++ b/distributedlog-core/src/test/java/com/twitter/distributedlog/impl/metadata/TestZKLogStreamMetadataStoreUtils.java
@@ -188,7 +188,7 @@ public class TestZKLogStreamMetadataStoreUtils {
         Versioned<byte[]> logSegmentsData =
                 new Versioned<byte[]>(DLUtils.serializeLogSegmentSequenceNumber(1L), new ZkVersion(1));
         Versioned<byte[]> allocationData =
-                new Versioned<byte[]>(DLUtils.ledgerId2Bytes(1L), new ZkVersion(1));
+                new Versioned<byte[]>(DLUtils.logSegmentId2Bytes(1L), new ZkVersion(1));
         List<Versioned<byte[]>> metadatas = Lists.newArrayList(
                 new Versioned<byte[]>(null, null),
                 new Versioned<byte[]>(null, null),

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/test/java/com/twitter/distributedlog/metadata/TestLogSegmentMetadataStoreUpdater.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/test/java/com/twitter/distributedlog/metadata/TestLogSegmentMetadataStoreUpdater.java b/distributedlog-core/src/test/java/com/twitter/distributedlog/metadata/TestLogSegmentMetadataStoreUpdater.java
index 82fbc69..51bdaa5 100644
--- a/distributedlog-core/src/test/java/com/twitter/distributedlog/metadata/TestLogSegmentMetadataStoreUpdater.java
+++ b/distributedlog-core/src/test/java/com/twitter/distributedlog/metadata/TestLogSegmentMetadataStoreUpdater.java
@@ -131,7 +131,7 @@ public class TestLogSegmentMetadataStoreUpdater extends ZooKeeperClusterTestCase
         assertEquals(6L, segmentChanged.getLogSegmentSequenceNumber());
         assertTrue(segmentChanged.isInProgress());
         assertEquals(5 * 100, segmentChanged.getFirstTxId());
-        assertEquals(3L, segmentChanged.getLedgerId());
+        assertEquals(3L, segmentChanged.getLogSegmentId());
     }
 
     @Test(timeout = 60000)
@@ -214,7 +214,7 @@ public class TestLogSegmentMetadataStoreUpdater extends ZooKeeperClusterTestCase
         assertEquals(updatedCompletedLogSegment, readCompletedLogSegment);
         assertEquals(completedLogSegment.getCompletionTime(), readCompletedLogSegment.getCompletionTime());
         assertEquals(completedLogSegment.getFirstTxId(), readCompletedLogSegment.getFirstTxId());
-        assertEquals(completedLogSegment.getLedgerId(), readCompletedLogSegment.getLedgerId());
+        assertEquals(completedLogSegment.getLogSegmentId(), readCompletedLogSegment.getLogSegmentId());
         assertEquals(completedLogSegment.getLogSegmentSequenceNumber(), readCompletedLogSegment.getLogSegmentSequenceNumber());
         assertEquals(completedLogSegment.getRegionId(), readCompletedLogSegment.getRegionId());
         assertEquals(completedLogSegment.getZkPath(), readCompletedLogSegment.getZkPath());

http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/47622a6e/distributedlog-core/src/test/java/com/twitter/distributedlog/util/TestDLUtils.java
----------------------------------------------------------------------
diff --git a/distributedlog-core/src/test/java/com/twitter/distributedlog/util/TestDLUtils.java b/distributedlog-core/src/test/java/com/twitter/distributedlog/util/TestDLUtils.java
index c60d4d2..8869a57 100644
--- a/distributedlog-core/src/test/java/com/twitter/distributedlog/util/TestDLUtils.java
+++ b/distributedlog-core/src/test/java/com/twitter/distributedlog/util/TestDLUtils.java
@@ -259,15 +259,15 @@ public class TestDLUtils {
         long ledgerId = 123456L;
         byte[] ledgerIdData = Long.toString(ledgerId).getBytes(UTF_8);
         assertEquals("Deserialization should succeed",
-                ledgerId, DLUtils.bytes2LedgerId(ledgerIdData));
+                ledgerId, DLUtils.bytes2LogSegmentId(ledgerIdData));
         assertArrayEquals("Serialization should succeed",
-                ledgerIdData, DLUtils.ledgerId2Bytes(ledgerId));
+                ledgerIdData, DLUtils.logSegmentId2Bytes(ledgerId));
     }
 
     @Test(timeout = 60000, expected = NumberFormatException.class)
     public void testDeserializeInvalidLedgerId() throws Exception {
         byte[] corruptedData = "corrupted-ledger-id".getBytes(UTF_8);
-        DLUtils.bytes2LedgerId(corruptedData);
+        DLUtils.bytes2LogSegmentId(corruptedData);
     }
 
 }


Mime
View raw message