Add rate_limiter to string options

Summary: I want to be able to set this through mongo config.

Test Plan: added unit test

Reviewers: sdong

Reviewed By: sdong

Subscribers: dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D34599
main
Igor Canadi 10 years ago
parent e126e0da5b
commit 485ac0dbd0
  1. 2
      db/db_impl.cc
  2. 4
      util/options_helper.cc
  3. 3
      util/options_test.cc

@ -133,7 +133,7 @@ DBOptions SanitizeOptions(const std::string& dbname, const DBOptions& src) {
result.env->IncBackgroundThreadsIfNeeded(src.max_background_flushes,
Env::Priority::HIGH);
if (!result.rate_limiter) {
if (result.rate_limiter.get() != nullptr) {
if (result.bytes_per_sync == 0) {
result.bytes_per_sync = 1024 * 1024;
}

@ -9,6 +9,7 @@
#include "rocksdb/cache.h"
#include "rocksdb/filter_policy.h"
#include "rocksdb/options.h"
#include "rocksdb/rate_limiter.h"
#include "rocksdb/slice_transform.h"
#include "rocksdb/table.h"
#include "rocksdb/utilities/convenience.h"
@ -474,6 +475,9 @@ bool ParseDBOption(const std::string& name, const std::string& value,
new_options->error_if_exists = ParseBoolean(name, value);
} else if (name == "paranoid_checks") {
new_options->paranoid_checks = ParseBoolean(name, value);
} else if (name == "rate_limiter_bytes_per_sec") {
new_options->rate_limiter.reset(
NewGenericRateLimiter(static_cast<int64_t>(ParseUint64(value))));
} else if (name == "max_open_files") {
new_options->max_open_files = ParseInt(value);
} else if (name == "max_total_wal_size") {

@ -480,7 +480,7 @@ TEST(OptionsTest, GetOptionsFromStringTest) {
base_options,
"write_buffer_size=10;max_write_buffer_number=16;"
"block_based_table_factory={block_cache=1M;block_size=4;};"
"create_if_missing=true;max_open_files=1",
"create_if_missing=true;max_open_files=1;rate_limiter_bytes_per_sec=1024",
&new_options));
ASSERT_EQ(new_options.write_buffer_size, 10U);
@ -495,6 +495,7 @@ TEST(OptionsTest, GetOptionsFromStringTest) {
ASSERT_EQ(new_options.create_if_missing, true);
ASSERT_EQ(new_options.max_open_files, 1);
ASSERT_TRUE(new_options.rate_limiter.get() != nullptr);
}
#endif // !ROCKSDB_LITE

Loading…
Cancel
Save