use of org.apache.bookkeeper.util.DiskChecker in project bookkeeper by apache.
the class DbLedgerStorage method readLedgerIndexEntries.
/**
* Reads ledger index entries to get list of entry-logger that contains given ledgerId.
*
* @param ledgerId
* @param serverConf
* @param processor
* @throws IOException
*/
public static void readLedgerIndexEntries(long ledgerId, ServerConfiguration serverConf, LedgerLoggerProcessor processor) throws IOException {
checkNotNull(serverConf, "ServerConfiguration can't be null");
checkNotNull(processor, "LedgerLoggger info processor can't null");
LedgerDirsManager ledgerDirsManager = new LedgerDirsManager(serverConf, serverConf.getLedgerDirs(), new DiskChecker(serverConf.getDiskUsageThreshold(), serverConf.getDiskUsageWarnThreshold()));
String ledgerBasePath = ledgerDirsManager.getAllLedgerDirs().get(0).toString();
EntryLocationIndex entryLocationIndex = new EntryLocationIndex(serverConf, (path, dbConfigType, conf1) -> new KeyValueStorageRocksDB(path, DbConfigType.Small, conf1, true), ledgerBasePath, NullStatsLogger.INSTANCE);
try {
long lastEntryId = entryLocationIndex.getLastEntryInLedger(ledgerId);
for (long currentEntry = 0; currentEntry <= lastEntryId; currentEntry++) {
long offset = entryLocationIndex.getLocation(ledgerId, currentEntry);
if (offset <= 0) {
// entry not found in this bookie
continue;
}
long entryLogId = offset >> 32L;
long position = offset & 0xffffffffL;
processor.process(currentEntry, entryLogId, position);
}
} finally {
entryLocationIndex.close();
}
}
Aggregations