Search in sources :

Example 1 with GarbageCollectorThread

use of org.apache.bookkeeper.bookie.GarbageCollectorThread in project bookkeeper by apache.

the class DbLedgerStorage method initialize.

@Override
public void initialize(ServerConfiguration conf, LedgerManager ledgerManager, LedgerDirsManager ledgerDirsManager, LedgerDirsManager indexDirsManager, StateManager stateManager, CheckpointSource checkpointSource, Checkpointer checkpointer, StatsLogger statsLogger) throws IOException {
    checkArgument(ledgerDirsManager.getAllLedgerDirs().size() == 1, "Db implementation only allows for one storage dir");
    String baseDir = ledgerDirsManager.getAllLedgerDirs().get(0).toString();
    writeCacheMaxSize = conf.getLong(WRITE_CACHE_MAX_SIZE_MB, DEFAULT_WRITE_CACHE_MAX_SIZE_MB) * MB;
    writeCache = new WriteCache(writeCacheMaxSize / 2);
    writeCacheBeingFlushed = new WriteCache(writeCacheMaxSize / 2);
    this.checkpointSource = checkpointSource;
    readCacheMaxSize = conf.getLong(READ_AHEAD_CACHE_MAX_SIZE_MB, DEFAULT_READ_CACHE_MAX_SIZE_MB) * MB;
    readAheadCacheBatchSize = conf.getInt(READ_AHEAD_CACHE_BATCH_SIZE, DEFAULT_READ_AHEAD_CACHE_BATCH_SIZE);
    long maxThrottleTimeMillis = conf.getLong(MAX_THROTTLE_TIME_MILLIS, DEFAUL_MAX_THROTTLE_TIME_MILLIS);
    maxThrottleTimeNanos = TimeUnit.MILLISECONDS.toNanos(maxThrottleTimeMillis);
    readCache = new ReadCache(readCacheMaxSize);
    this.stats = statsLogger;
    log.info("Started Db Ledger Storage");
    log.info(" - Write cache size: {} MB", writeCacheMaxSize / MB);
    log.info(" - Read Cache: {} MB", readCacheMaxSize / MB);
    log.info(" - Read Ahead Batch size: : {}", readAheadCacheBatchSize);
    ledgerIndex = new LedgerMetadataIndex(conf, KeyValueStorageRocksDB.factory, baseDir, stats);
    entryLocationIndex = new EntryLocationIndex(conf, KeyValueStorageRocksDB.factory, baseDir, stats);
    transientLedgerInfoCache = new ConcurrentLongHashMap<>(16 * 1024, Runtime.getRuntime().availableProcessors() * 2);
    cleanupExecutor.scheduleAtFixedRate(this::cleanupStaleTransientLedgerInfo, LEDGER_INFO_CACHING_TIME_MINUTES, LEDGER_INFO_CACHING_TIME_MINUTES, TimeUnit.MINUTES);
    entryLogger = new EntryLogger(conf, ledgerDirsManager);
    gcThread = new GarbageCollectorThread(conf, ledgerManager, this, statsLogger);
    registerStats();
}
Also used : GarbageCollectorThread(org.apache.bookkeeper.bookie.GarbageCollectorThread) ByteString(com.google.protobuf.ByteString) EntryLogger(org.apache.bookkeeper.bookie.EntryLogger)

Aggregations

ByteString (com.google.protobuf.ByteString)1 EntryLogger (org.apache.bookkeeper.bookie.EntryLogger)1 GarbageCollectorThread (org.apache.bookkeeper.bookie.GarbageCollectorThread)1