forked from mongodb/mongo
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SERVER-17331 RocksDB configuring and monitoring
- Loading branch information
1 parent
e191b45
commit b7fb7c4
Showing
12 changed files
with
408 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* Copyright (C) 2014 MongoDB Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* As a special exception, the copyright holders give permission to link the | ||
* code of portions of this program with the OpenSSL library under certain | ||
* conditions as described in each individual source file and distribute | ||
* linked combinations including the program with the OpenSSL library. You | ||
* must comply with the GNU Affero General Public License in all respects for | ||
* all of the code used other than as permitted herein. If you modify file(s) | ||
* with this exception, you may extend this exception to your version of the | ||
* file(s), but you are not obligated to do so. If you do not wish to do so, | ||
* delete this exception statement from your version. If you delete this | ||
* exception statement from all source files in the program, then also delete | ||
* it in the license file. | ||
*/ | ||
|
||
#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kStorage | ||
|
||
#include "mongo/platform/basic.h" | ||
|
||
#include "mongo/base/status.h" | ||
#include "mongo/db/storage/rocks/rocks_global_options.h" | ||
#include "mongo/util/log.h" | ||
#include "mongo/util/options_parser/constraints.h" | ||
|
||
namespace mongo { | ||
|
||
RocksGlobalOptions rocksGlobalOptions; | ||
|
||
Status RocksGlobalOptions::add(moe::OptionSection* options) { | ||
moe::OptionSection rocksOptions("RocksDB options"); | ||
|
||
rocksOptions.addOptionChaining("storage.rocksdb.cacheSizeGB", "rocksdbCacheSizeGB", | ||
moe::Int, | ||
"maximum amount of memory to allocate for cache; " | ||
"defaults to 1/2 of physical RAM").validRange(1, 10000); | ||
rocksOptions.addOptionChaining("storage.rocksdb.compression", "rocksdbCompression", | ||
moe::String, | ||
"block compression algorithm for collection data " | ||
"[none|snappy|zlib]") | ||
.format("(:?none)|(:?snappy)|(:?zlib)", "(none/snappy/zlib)") | ||
.setDefault(moe::Value(std::string("snappy"))); | ||
rocksOptions.addOptionChaining("storage.rocksdb.configString", "rocksdbConfigString", | ||
moe::String, | ||
"RocksDB storage engine custom " | ||
"configuration settings").hidden(); | ||
|
||
return options->addSection(rocksOptions); | ||
} | ||
|
||
Status RocksGlobalOptions::store(const moe::Environment& params, | ||
const std::vector<std::string>& args) { | ||
if (params.count("storage.rocksdb.cacheSizeGB")) { | ||
rocksGlobalOptions.cacheSizeGB = params["storage.rocksdb.cacheSizeGB"].as<int>(); | ||
log() << "Block Cache Size GB: " << rocksGlobalOptions.cacheSizeGB; | ||
} | ||
if (params.count("storage.rocksdb.compression")) { | ||
rocksGlobalOptions.compression = | ||
params["storage.rocksdb.compression"].as<std::string>(); | ||
log() << "Compression: " << rocksGlobalOptions.compression; | ||
} | ||
if (params.count("storage.rocksdb.configString")) { | ||
rocksGlobalOptions.configString = | ||
params["storage.rocksdb.configString"].as<std::string>(); | ||
log() << "Engine custom option: " << rocksGlobalOptions.configString; | ||
} | ||
|
||
return Status::OK(); | ||
} | ||
|
||
} // namespace mongo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (C) 2014 MongoDB Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* As a special exception, the copyright holders give permission to link the | ||
* code of portions of this program with the OpenSSL library under certain | ||
* conditions as described in each individual source file and distribute | ||
* linked combinations including the program with the OpenSSL library. You | ||
* must comply with the GNU Affero General Public License in all respects for | ||
* all of the code used other than as permitted herein. If you modify file(s) | ||
* with this exception, you may extend this exception to your version of the | ||
* file(s), but you are not obligated to do so. If you do not wish to do so, | ||
* delete this exception statement from your version. If you delete this | ||
* exception statement from all source files in the program, then also delete | ||
* it in the license file. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "mongo/util/options_parser/startup_option_init.h" | ||
#include "mongo/util/options_parser/startup_options.h" | ||
|
||
namespace mongo { | ||
|
||
namespace moe = mongo::optionenvironment; | ||
|
||
class RocksGlobalOptions { | ||
public: | ||
RocksGlobalOptions() : cacheSizeGB(0) {} | ||
|
||
Status add(moe::OptionSection* options); | ||
Status store(const moe::Environment& params, const std::vector<std::string>& args); | ||
|
||
size_t cacheSizeGB; | ||
|
||
std::string compression; | ||
std::string configString; | ||
}; | ||
|
||
extern RocksGlobalOptions rocksGlobalOptions; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Copyright (C) 2014 MongoDB Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, version 3, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* As a special exception, the copyright holders give permission to link the | ||
* code of portions of this program with the OpenSSL library under certain | ||
* conditions as described in each individual source file and distribute | ||
* linked combinations including the program with the OpenSSL library. You | ||
* must comply with the GNU Affero General Public License in all respects for | ||
* all of the code used other than as permitted herein. If you modify file(s) | ||
* with this exception, you may extend this exception to your version of the | ||
* file(s), but you are not obligated to do so. If you do not wish to do so, | ||
* delete this exception statement from your version. If you delete this | ||
* exception statement from all source files in the program, then also delete | ||
* it in the license file. | ||
*/ | ||
|
||
#include "mongo/util/options_parser/startup_option_init.h" | ||
|
||
#include <iostream> | ||
|
||
#include "mongo/util/options_parser/startup_options.h" | ||
#include "mongo/db/storage/rocks/rocks_global_options.h" | ||
|
||
namespace mongo { | ||
|
||
MONGO_MODULE_STARTUP_OPTIONS_REGISTER(RocksOptions)(InitializerContext* context) { | ||
return rocksGlobalOptions.add(&moe::startupOptions); | ||
} | ||
|
||
MONGO_STARTUP_OPTIONS_VALIDATE(RocksOptions)(InitializerContext* context) { | ||
return Status::OK(); | ||
} | ||
|
||
MONGO_STARTUP_OPTIONS_STORE(RocksOptions)(InitializerContext* context) { | ||
Status ret = rocksGlobalOptions.store(moe::startupOptionsParsed, context->args()); | ||
if (!ret.isOK()) { | ||
std::cerr << ret.toString() << std::endl; | ||
std::cerr << "try '" << context->args()[0] << " --help' for more information" | ||
<< std::endl; | ||
::_exit(EXIT_BADOPTIONS); | ||
} | ||
return Status::OK(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.