diff options
author | Shaun Verch <shaun.verch@mongodb.com> | 2014-06-04 12:00:36 -0400 |
---|---|---|
committer | Shaun Verch <shaun.verch@mongodb.com> | 2014-06-06 20:22:32 -0700 |
commit | b13b6d94618848579855da4114025fabee85cb6d (patch) | |
tree | acdd6a889928503da95e3922c280b7f2aba4178a /src/mongo/db/storage_options.cpp | |
parent | 616461d294bd9f5054ca38b302b6fc5d70fde20c (diff) | |
download | mongo-b13b6d94618848579855da4114025fabee85cb6d.tar.gz |
SERVER-10515 Convert special cased parameters to proper ServerParameters
Diffstat (limited to 'src/mongo/db/storage_options.cpp')
-rw-r--r-- | src/mongo/db/storage_options.cpp | 59 |
1 files changed, 53 insertions, 6 deletions
diff --git a/src/mongo/db/storage_options.cpp b/src/mongo/db/storage_options.cpp index 23516baf85d..2d99896aef1 100644 --- a/src/mongo/db/storage_options.cpp +++ b/src/mongo/db/storage_options.cpp @@ -39,13 +39,60 @@ namespace mongo { return storageGlobalParams.dur; } - void setJournalCommitInterval(unsigned newValue) { - storageGlobalParams.journalCommitInterval = newValue; - } + class JournalCommitIntervalSetting : public ServerParameter { + public: + JournalCommitIntervalSetting() : + ServerParameter(ServerParameterSet::getGlobal(), "journalCommitInterval", + false, // allowedToChangeAtStartup + true // allowedToChangeAtRuntime + ) {} - unsigned getJournalCommitInterval() { - return storageGlobalParams.journalCommitInterval; - } + virtual void append(OperationContext* txn, BSONObjBuilder& b, const std::string& name) { + b << name << storageGlobalParams.journalCommitInterval; + } + + virtual Status set(const BSONElement& newValueElement) { + long long newValue; + if (!newValueElement.isNumber()) { + StringBuilder sb; + sb << "Expected number type for journalCommitInterval via setParameter command: " + << newValueElement; + return Status(ErrorCodes::BadValue, sb.str()); + } + if (newValueElement.type() == NumberDouble && + (newValueElement.numberDouble() - newValueElement.numberLong()) > 0) { + StringBuilder sb; + sb << "journalCommitInterval must be a whole number: " + << newValueElement; + return Status(ErrorCodes::BadValue, sb.str()); + } + newValue = newValueElement.numberLong(); + if (newValue <= 1 || newValue >= 500) { + StringBuilder sb; + sb << "journalCommitInterval must be between 1 and 500, but attempted to set to: " + << newValue; + return Status(ErrorCodes::BadValue, sb.str()); + } + storageGlobalParams.journalCommitInterval = static_cast<unsigned>(newValue); + return Status::OK(); + } + + virtual Status setFromString(const std::string& str) { + unsigned newValue; + Status status = parseNumberFromString(str, &newValue); + if (!status.isOK()) { + return status; + } + if (newValue <= 1 || newValue >= 500) { + StringBuilder sb; + sb << "journalCommitInterval must be between 1 and 500, but attempted to set to: " + << newValue; + return Status(ErrorCodes::BadValue, sb.str()); + } + storageGlobalParams.journalCommitInterval = newValue; + return Status::OK(); + } + } journalCommitIntervalSetting; ExportedServerParameter<bool> NoTableScanSetting(ServerParameterSet::getGlobal(), "notablescan", |