/** * Creates a new DebugLogWrapper that can be used for debugging purposes. This should not be used for regular operations. * * @param logId Id of the Log to create a wrapper for. * @return A new instance of the DebugLogWrapper class. */ public DebugLogWrapper createDebugLogWrapper(int logId) { Preconditions.checkState(this.bookKeeper.get() != null, "BookKeeperLogFactory is not initialized."); return new DebugLogWrapper(logId, this.zkClient, this.bookKeeper.get(), this.config, this.executor); }
private void checkForExtraLogs(Context context) throws Exception { val maxLogId = context.serviceConfig.getContainerCount() * 10; for (int logId = context.serviceConfig.getContainerCount(); logId < maxLogId; logId++) { @Cleanup DebugLogWrapper log = context.logFactory.createDebugLogWrapper(logId); val m = log.fetchMetadata(); if (m != null) { throw new Exception(String.format("Discovered BookKeeperLog %d which is beyond the maximum log id (%d) as specified in the configuration.", logId, context.serviceConfig.getContainerCount() - 1)); } } }
/** * Open-Fences the BookKeeperLog (initializes it), then updates the Metadata for it in ZooKeeper by setting its * Enabled flag to false. * @throws DurableDataLogException If an exception occurred. */ public void disable() throws DurableDataLogException { initialize(); this.log.disable(); }
val m = log.fetchMetadata(); outputLogSummary(logId, m); if (m == null) { log.disable(); output("BookKeeperLog '%s' has been disabled.", logId); return null; val m2 = log.fetchMetadata(); outputLogSummary(logId, m2);
val m = log.fetchMetadata(); outputLogSummary(logId, m); if (m == null) { log.enable(); output("BookKeeperLog '%s' has been enabled. It may take a few minutes for its SegmentContainer to resume operations.", logId); } catch (Exception ex) { val m2 = log.fetchMetadata(); outputLogSummary(logId, m2);
@Cleanup val log = context.logFactory.createDebugLogWrapper(logId); val m = log.fetchMetadata(); outputLogSummary(logId, m); if (m == null) { 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.",
val bkLog = log.asReadOnly();
private void collectAllReferencedLedgerIds(Collection<Long> referencedLedgerIds, Context context) throws Exception { referencedLedgerIds.clear(); for (int logId = 0; logId < context.serviceConfig.getContainerCount(); logId++) { @Cleanup DebugLogWrapper log = context.logFactory.createDebugLogWrapper(logId); val m = log.fetchMetadata(); if (m == null) { continue; } for (val lm : m.getLedgers()) { referencedLedgerIds.add(lm.getLedgerId()); } } }
@Override public void execute() throws Exception { ensureArgCount(0); // Loop through all known log ids and fetch their metadata. @Cleanup val context = createContext(); for (int logId = 0; logId < context.serviceConfig.getContainerCount(); logId++) { @Cleanup DebugLogWrapper log = context.logFactory.createDebugLogWrapper(logId); val m = log.fetchMetadata(); outputLogSummary(logId, m); } }