public BdbStorageConfiguration(VoldemortConfig config) {
    this.voldemortConfig = config;
    environmentConfig = new EnvironmentConfig();
    environmentConfig.setTransactional(true);
    environmentConfig.setCacheSize(config.getBdbCacheSize());
    if (config.isBdbWriteTransactionsEnabled() && config.isBdbFlushTransactionsEnabled()) {
      environmentConfig.setTxnNoSync(false);
      environmentConfig.setTxnWriteNoSync(false);
    } else if (config.isBdbWriteTransactionsEnabled() && !config.isBdbFlushTransactionsEnabled()) {
      environmentConfig.setTxnNoSync(false);
      environmentConfig.setTxnWriteNoSync(true);
    } else {
      environmentConfig.setTxnNoSync(true);
    }
    environmentConfig.setAllowCreate(true);
    environmentConfig.setConfigParam(
        EnvironmentConfig.LOG_FILE_MAX, Long.toString(config.getBdbMaxLogFileSize()));
    environmentConfig.setConfigParam(
        EnvironmentConfig.CHECKPOINTER_BYTES_INTERVAL,
        Long.toString(config.getBdbCheckpointBytes()));
    environmentConfig.setConfigParam(
        EnvironmentConfig.CHECKPOINTER_WAKEUP_INTERVAL,
        Long.toString(config.getBdbCheckpointMs() * Time.US_PER_MS));
    environmentConfig.setConfigParam(
        EnvironmentConfig.CLEANER_MIN_FILE_UTILIZATION,
        Integer.toString(config.getBdbCleanerMinFileUtilization()));
    environmentConfig.setConfigParam(
        EnvironmentConfig.CLEANER_MIN_UTILIZATION,
        Integer.toString(config.getBdbCleanerMinUtilization()));
    environmentConfig.setConfigParam(
        EnvironmentConfig.CLEANER_THREADS, Integer.toString(config.getBdbCleanerThreads()));
    environmentConfig.setConfigParam(
        EnvironmentConfig.CLEANER_LOOK_AHEAD_CACHE_SIZE,
        Integer.toString(config.getBdbCleanerLookAheadCacheSize()));
    environmentConfig.setConfigParam(
        EnvironmentConfig.LOCK_N_LOCK_TABLES, Integer.toString(config.getBdbLockNLockTables()));
    environmentConfig.setConfigParam(
        EnvironmentConfig.ENV_FAIR_LATCHES, Boolean.toString(config.getBdbFairLatches()));
    environmentConfig.setConfigParam(
        EnvironmentConfig.CHECKPOINTER_HIGH_PRIORITY,
        Boolean.toString(config.getBdbCheckpointerHighPriority()));
    environmentConfig.setConfigParam(
        EnvironmentConfig.CLEANER_MAX_BATCH_FILES,
        Integer.toString(config.getBdbCleanerMaxBatchFiles()));

    environmentConfig.setLockTimeout(config.getBdbLockTimeoutMs(), TimeUnit.MILLISECONDS);
    databaseConfig = new DatabaseConfig();
    databaseConfig.setAllowCreate(true);
    databaseConfig.setSortedDuplicates(config.isBdbSortedDuplicatesEnabled());
    databaseConfig.setNodeMaxEntries(config.getBdbBtreeFanout());
    databaseConfig.setTransactional(true);
    bdbMasterDir = config.getBdbDataDirectory();
    useOneEnvPerStore = config.isBdbOneEnvPerStore();
    if (useOneEnvPerStore) environmentConfig.setSharedCache(true);
  }
Esempio n. 2
0
 static {
   envConfig.setConfigParam(EnvironmentParams.ENV_CHECK_LEAKS.getName(), "false");
   envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "6");
   envConfig.setTxnNoSync(Boolean.getBoolean(TestUtils.NO_SYNC));
   envConfig.setLockTimeout(1); // to speed up intentional deadlocks
   envConfig.setAllowCreate(true);
 }