Search in sources :

Example 51 with LedgerHandle

use of org.apache.bookkeeper.client.LedgerHandle in project pravega by pravega.

the class BookKeeperDetailsCommand method execute.

@Override
public void execute() throws Exception {
    ensureArgCount(1);
    int logId = getIntArg(0);
    @Cleanup val context = createContext();
    @Cleanup val log = context.logFactory.createDebugLogWrapper(logId);
    val m = log.fetchMetadata();
    outputLogSummary(logId, m);
    if (m == null) {
        // Nothing else to do.
        return;
    }
    if (m.getLedgers().size() == 0) {
        output("There are no ledgers for Log %s.", logId);
        return;
    }
    for (LedgerMetadata lm : m.getLedgers()) {
        LedgerHandle lh = null;
        try {
            lh = log.openLedgerNoFencing(lm);
            val bkLm = context.bkAdmin.getLedgerMetadata(lh);
            output("\tLedger %d: Seq=%d, Status=%s, LAC=%d, Length=%d, Bookies=%d, Frags=%d, E/W/A=%d/%d/%d, Ensembles=%s.", lm.getLedgerId(), lm.getSequence(), lm.getStatus(), lh.getLastAddConfirmed(), lh.getLength(), lh.getNumBookies(), lh.getNumFragments(), bkLm.getEnsembleSize(), bkLm.getWriteQuorumSize(), bkLm.getAckQuorumSize(), getEnsembleDescription(bkLm));
        } catch (Exception ex) {
            output("\tLedger %d: Seq = %d, Status = %s. BK: %s", lm.getLedgerId(), lm.getSequence(), lm.getStatus(), ex.getMessage());
        } finally {
            if (lh != null) {
                lh.close();
            }
        }
    }
}
Also used : lombok.val(lombok.val) LedgerMetadata(io.pravega.segmentstore.storage.impl.bookkeeper.LedgerMetadata) LedgerHandle(org.apache.bookkeeper.client.LedgerHandle) Cleanup(lombok.Cleanup)

Aggregations

LedgerHandle (org.apache.bookkeeper.client.LedgerHandle)51 Test (org.junit.Test)19 ZKTransaction (com.twitter.distributedlog.zk.ZKTransaction)13 LedgerEntry (org.apache.bookkeeper.client.LedgerEntry)12 ManagedLedgerException (org.apache.bookkeeper.mledger.ManagedLedgerException)12 CountDownLatch (java.util.concurrent.CountDownLatch)10 IOException (java.io.IOException)9 Entry (org.apache.bookkeeper.mledger.Entry)8 BKException (org.apache.bookkeeper.client.BKException)7 ReadEntriesCallback (org.apache.bookkeeper.mledger.AsyncCallbacks.ReadEntriesCallback)7 Test (org.testng.annotations.Test)7 List (java.util.List)6 BookKeeper (org.apache.bookkeeper.client.BookKeeper)6 ZKDistributedLock (com.twitter.distributedlog.lock.ZKDistributedLock)5 Future (com.twitter.util.Future)5 ArrayList (java.util.ArrayList)5 lombok.val (lombok.val)5 ZKException (com.twitter.distributedlog.exceptions.ZKException)4 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)3 Lists (com.google.common.collect.Lists)3