Remove unused methods in BKLogHandler
Project: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/commit/b7ae590e Tree: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/tree/b7ae590e Diff: http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/diff/b7ae590e Branch: refs/heads/merge/DL-98 Commit: b7ae590e8b819ae63c0139611320dcc0d27e39f7 Parents: f4f633f Author: Leigh Stewart <lstew...@twitter.com> Authored: Mon Dec 12 17:01:43 2016 -0800 Committer: Sijie Guo <sij...@twitter.com> Committed: Mon Dec 12 17:01:43 2016 -0800 ---------------------------------------------------------------------- .../twitter/distributedlog/BKLogHandler.java | 107 ------------------- 1 file changed, 107 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-distributedlog/blob/b7ae590e/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogHandler.java ---------------------------------------------------------------------- diff --git a/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogHandler.java b/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogHandler.java index 3b991e2..460de11 100644 --- a/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogHandler.java +++ b/distributedlog-core/src/main/java/com/twitter/distributedlog/BKLogHandler.java @@ -32,9 +32,7 @@ import com.twitter.distributedlog.io.AsyncCloseable; import com.twitter.distributedlog.logsegment.LogSegmentCache; import com.twitter.distributedlog.logsegment.LogSegmentFilter; import com.twitter.distributedlog.logsegment.LogSegmentMetadataStore; -import com.twitter.distributedlog.util.FutureUtils; import com.twitter.distributedlog.util.OrderedScheduler; -import com.twitter.distributedlog.util.Utils; import com.twitter.util.Function; import com.twitter.util.Future; import com.twitter.util.FutureEventListener; @@ -103,8 +101,6 @@ import java.util.concurrent.atomic.AtomicReference; public abstract class BKLogHandler implements Watcher, AsyncCloseable, AsyncAbortable { static final Logger LOG = LoggerFactory.getLogger(BKLogHandler.class); - private static final int LAYOUT_VERSION = -1; - protected final ZKLogMetadata logMetadata; protected final DistributedLogConfiguration conf; protected final ZooKeeperClient zooKeeperClient; @@ -458,57 +454,6 @@ public abstract class BKLogHandler implements Watcher, AsyncCloseable, AsyncAbor } } - public LogRecordWithDLSN getLastLogRecord(boolean recover, boolean includeEndOfStream) throws IOException { - checkLogStreamExists(); - List<LogSegmentMetadata> ledgerList = getFullLedgerListDesc(true, true); - - for (LogSegmentMetadata metadata: ledgerList) { - LogRecordWithDLSN record = recoverLastRecordInLedger(metadata, recover, false, includeEndOfStream); - - if (null != record) { - assert(!record.isControl()); - LOG.debug("{} getLastLogRecord Returned {}", getFullyQualifiedName(), record); - return record; - } - } - - throw new LogEmptyException("Log " + getFullyQualifiedName() + " has no records"); - } - - public long getLastTxId(boolean recover, - boolean includeEndOfStream) throws IOException { - checkLogStreamExists(); - return getLastLogRecord(recover, includeEndOfStream).getTransactionId(); - } - - public DLSN getLastDLSN(boolean recover, - boolean includeEndOfStream) throws IOException { - checkLogStreamExists(); - return getLastLogRecord(recover, includeEndOfStream).getDlsn(); - } - - public long getLogRecordCount() throws IOException { - try { - checkLogStreamExists(); - } catch (LogNotFoundException exc) { - return 0; - } - - List<LogSegmentMetadata> ledgerList = getFullLedgerList(true, false); - long count = 0; - for (LogSegmentMetadata l : ledgerList) { - if (l.isInProgress()) { - LogRecord record = recoverLastRecordInLedger(l, false, false, false); - if (null != record) { - count += record.getLastPositionWithinLogSegment(); - } - } else { - count += l.getRecordCount(); - } - } - return count; - } - private Future<LogRecordWithDLSN> asyncReadFirstUserRecord(LogSegmentMetadata ledger, DLSN beginDLSN) { final LedgerHandleCache handleCache = LedgerHandleCache.newBuilder().bkc(bookKeeperClient).conf(conf).build(); @@ -620,15 +565,6 @@ public abstract class BKLogHandler implements Watcher, AsyncCloseable, AsyncAbor return sum; } - public long getFirstTxId() throws IOException { - checkLogStreamExists(); - List<LogSegmentMetadata> ledgerList = getFullLedgerList(true, true); - - // The ledger list should at least have one element - // First TxId is populated even for in progress ledgers - return ledgerList.get(0).getFirstTxId(); - } - Future<Void> checkLogStreamExistsAsync() { final Promise<Void> promise = new Promise<Void>(); try { @@ -671,54 +607,11 @@ public abstract class BKLogHandler implements Watcher, AsyncCloseable, AsyncAbor return promise; } - private void checkLogStreamExists() throws IOException { - try { - if (null == Utils.sync(zooKeeperClient, logMetadata.getLogSegmentsPath()) - .exists(logMetadata.getLogSegmentsPath(), false)) { - throw new LogNotFoundException("Log " + getFullyQualifiedName() + " doesn't exist"); - } - } catch (InterruptedException ie) { - LOG.error("Interrupted while reading {}", logMetadata.getLogSegmentsPath(), ie); - throw new DLInterruptedException("Interrupted while checking " - + logMetadata.getLogSegmentsPath(), ie); - } catch (KeeperException ke) { - LOG.error("Error checking existence for {} : ", logMetadata.getLogSegmentsPath(), ke); - throw new ZKException("Error checking existence for " + getFullyQualifiedName() + " : ", ke); - } - } - @Override public Future<Void> asyncAbort() { return asyncClose(); } - /** - * Find the id of the last edit log transaction written to a edit log - * ledger. - */ - protected Pair<Long, DLSN> readLastTxIdInLedger(LogSegmentMetadata l) throws IOException { - LogRecordWithDLSN record = recoverLastRecordInLedger(l, false, false, true); - - if (null == record) { - return Pair.of(DistributedLogConstants.EMPTY_LOGSEGMENT_TX_ID, DLSN.InvalidDLSN); - } - else { - return Pair.of(record.getTransactionId(), record.getDlsn()); - } - } - - /** - * Find the id of the last edit log transaction written to a edit log - * ledger. - */ - protected LogRecordWithDLSN recoverLastRecordInLedger(LogSegmentMetadata l, - boolean fence, - boolean includeControl, - boolean includeEndOfStream) - throws IOException { - return FutureUtils.result(asyncReadLastRecord(l, fence, includeControl, includeEndOfStream)); - } - public Future<LogRecordWithDLSN> asyncReadLastUserRecord(final LogSegmentMetadata l) { return asyncReadLastRecord(l, false, false, false); }