本文整理汇总了C++中moe::Environment类的典型用法代码示例。如果您正苦于以下问题:C++ Environment类的具体用法?C++ Environment怎么用?C++ Environment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Environment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: storeMongoBridgeOptions
Status storeMongoBridgeOptions(const moe::Environment& params,
const std::vector<std::string>& args) {
if (!params.count("port")) {
return {ErrorCodes::BadValue, "Missing required option: --port"};
}
if (!params.count("dest")) {
return {ErrorCodes::BadValue, "Missing required option: --dest"};
}
mongoBridgeGlobalParams.port = params["port"].as<int>();
mongoBridgeGlobalParams.destUri = params["dest"].as<std::string>();
if (!params.count("seed")) {
std::unique_ptr<SecureRandom> seedSource{SecureRandom::create()};
mongoBridgeGlobalParams.seed = seedSource->nextInt64();
} else {
mongoBridgeGlobalParams.seed = static_cast<int64_t>(params["seed"].as<long>());
}
if (params.count("verbose")) {
std::string verbosity = params["verbose"].as<std::string>();
if (std::any_of(verbosity.cbegin(), verbosity.cend(), [](char ch) { return ch != 'v'; })) {
return {ErrorCodes::BadValue,
"The string for the --verbose option cannot contain characters other than 'v'"};
}
logger::globalLogDomain()->setMinimumLoggedSeverity(
logger::LogSeverity::Debug(verbosity.length()));
}
return Status::OK();
}
示例2: handlePreValidationMongoShellOptions
Status handlePreValidationMongoShellOptions(const moe::Environment& params,
const std::vector<std::string>& args) {
if (params.count("help")) {
std::cout << getMongoShellHelp(args[0], moe::startupOptions) << std::endl;
::_exit(EXIT_CLEAN);
}
if (params.count("version")) {
cout << "MongoDB shell version: " << mongo::versionString << endl;
::_exit(EXIT_CLEAN);
}
if (params.count("quiet")) {
mongo::serverGlobalParams.quiet = true;
}
#ifdef MONGO_SSL
Status ret = storeSSLClientOptions(params);
if (!ret.isOK()) {
return ret;
}
#endif
if (params.count("ipv6")) {
mongo::enableIPv6();
}
if (params.count("verbose")) {
logger::globalLogDomain()->setMinimumLoggedSeverity(logger::LogSeverity::Debug(1));
}
return Status::OK();
}
示例3: handlePreValidationMongodOptions
bool handlePreValidationMongodOptions(const moe::Environment& params,
const std::vector<std::string>& args) {
if (params.count("help") && params["help"].as<bool>() == true) {
printMongodHelp(moe::startupOptions);
return false;
}
if (params.count("version") && params["version"].as<bool>() == true) {
setPlainConsoleLogger();
auto&& vii = VersionInfoInterface::instance();
log() << mongodVersion(vii);
vii.logBuildInfo();
return false;
}
if (params.count("sysinfo") && params["sysinfo"].as<bool>() == true) {
setPlainConsoleLogger();
sysRuntimeInfo();
return false;
}
if (params.count("master") || params.count("slave")) {
severe() << "Master/slave replication is no longer supported";
return false;
}
return true;
}
示例4: validateSSLMongoShellOptions
Status validateSSLMongoShellOptions(const moe::Environment& params) {
// Users must specify either a CAFile or allowInvalidCertificates if ssl=true.
if (params.count("ssl") && params["ssl"].as<bool>() == true && !params.count("ssl.CAFile") &&
!params.count("ssl.allowInvalidCertificates")) {
return Status(ErrorCodes::BadValue,
"need to either provide sslCAFile or specify sslAllowInvalidCertificates");
}
return Status::OK();
}
示例5: store
Status WiredTigerGlobalOptions::store(const moe::Environment& params,
const std::vector<std::string>& args) {
// WiredTiger storage engine options
if (params.count("storage.wiredTiger.engineConfig.cacheSizeGB")) {
wiredTigerGlobalOptions.cacheSizeGB =
params["storage.wiredTiger.engineConfig.cacheSizeGB"].as<int>();
}
if (params.count("storage.syncPeriodSecs")) {
wiredTigerGlobalOptions.checkpointDelaySecs =
static_cast<size_t>(params["storage.syncPeriodSecs"].as<double>());
}
if (params.count("storage.wiredTiger.engineConfig.statisticsLogDelaySecs")) {
wiredTigerGlobalOptions.statisticsLogDelaySecs =
params["storage.wiredTiger.engineConfig.statisticsLogDelaySecs"].as<int>();
}
if (params.count("storage.wiredTiger.engineConfig.journalCompressor")) {
wiredTigerGlobalOptions.journalCompressor =
params["storage.wiredTiger.engineConfig.journalCompressor"].as<std::string>();
}
if (params.count("storage.wiredTiger.engineConfig.directoryForIndexes")) {
wiredTigerGlobalOptions.directoryForIndexes =
params["storage.wiredTiger.engineConfig.directoryForIndexes"].as<bool>();
}
if (params.count("storage.wiredTiger.engineConfig.configString")) {
wiredTigerGlobalOptions.engineConfig =
params["storage.wiredTiger.engineConfig.configString"].as<std::string>();
log() << "Engine custom option: " << wiredTigerGlobalOptions.engineConfig;
}
// WiredTiger collection options
if (params.count("storage.wiredTiger.collectionConfig.blockCompressor")) {
wiredTigerGlobalOptions.collectionBlockCompressor =
params["storage.wiredTiger.collectionConfig.blockCompressor"].as<std::string>();
}
if (params.count("storage.wiredTiger.collectionConfig.configString")) {
wiredTigerGlobalOptions.collectionConfig =
params["storage.wiredTiger.collectionConfig.configString"].as<std::string>();
log() << "Collection custom option: " << wiredTigerGlobalOptions.collectionConfig;
}
// WiredTiger index options
if (params.count("storage.wiredTiger.indexConfig.prefixCompression")) {
wiredTigerGlobalOptions.useIndexPrefixCompression =
params["storage.wiredTiger.indexConfig.prefixCompression"].as<bool>();
}
if (params.count("storage.wiredTiger.indexConfig.configString")) {
wiredTigerGlobalOptions.indexConfig =
params["storage.wiredTiger.indexConfig.configString"].as<std::string>();
log() << "Index custom option: " << wiredTigerGlobalOptions.indexConfig;
}
return Status::OK();
}
示例6: handlePreValidationMongoShellOptions
bool handlePreValidationMongoShellOptions(const moe::Environment& params,
const std::vector<std::string>& args) {
if (params.count("help")) {
std::cout << getMongoShellHelp(args[0], moe::startupOptions) << std::endl;
return false;
}
if (params.count("version")) {
cout << "MongoDB shell version: " << mongo::versionString << endl;
return false;
}
return true;
}
示例7: handlePreValidationMongosOptions
Status handlePreValidationMongosOptions(const moe::Environment& params,
const std::vector<std::string>& args) {
if (params.count("help")) {
printMongosHelp(serverOptions);
::_exit(EXIT_SUCCESS);
}
if (params.count("version")) {
printShardingVersionInfo(true);
::_exit(EXIT_SUCCESS);
}
return Status::OK();
}
示例8: storeSSLClientOptions
Status storeSSLClientOptions(const moe::Environment& params) {
if (params.count("ssl") && params["ssl"].as<bool>() == true) {
sslGlobalParams.sslMode.store(SSLGlobalParams::SSLMode_requireSSL);
}
if (params.count("ssl.PEMKeyFile")) {
sslGlobalParams.sslPEMKeyFile = params["ssl.PEMKeyFile"].as<std::string>();
}
if (params.count("ssl.PEMKeyPassword")) {
sslGlobalParams.sslPEMKeyPassword = params["ssl.PEMKeyPassword"].as<std::string>();
}
if (params.count("ssl.CAFile")) {
sslGlobalParams.sslCAFile = params["ssl.CAFile"].as<std::string>();
}
if (params.count("ssl.CRLFile")) {
sslGlobalParams.sslCRLFile = params["ssl.CRLFile"].as<std::string>();
}
if (params.count("net.ssl.allowInvalidHostnames")) {
sslGlobalParams.sslAllowInvalidHostnames =
params["net.ssl.allowInvalidHostnames"].as<bool>();
}
if (params.count("ssl.allowInvalidCertificates")) {
sslGlobalParams.sslAllowInvalidCertificates = true;
}
if (params.count("ssl.FIPSMode")) {
sslGlobalParams.sslFIPSMode = true;
}
return Status::OK();
}
示例9: storeSASLOptions
Status storeSASLOptions(const moe::Environment& params) {
bool haveAuthenticationMechanisms = false;
bool haveHostName = false;
bool haveServiceName = false;
bool haveAuthdPath = false;
// Check our setParameter options first so that these values can be properly overridden via
// the command line even though the options have different names.
if (params.count("setParameter")) {
std::map<std::string, std::string> parameters =
params["setParameter"].as<std::map<std::string, std::string> >();
for (std::map<std::string, std::string>::iterator parametersIt = parameters.begin();
parametersIt != parameters.end(); parametersIt++) {
if (parametersIt->first == "authenticationMechanisms") {
haveAuthenticationMechanisms = true;
}
else if (parametersIt->first == "saslHostName") {
haveHostName = true;
}
else if (parametersIt->first == "saslServiceName") {
haveServiceName = true;
}
else if (parametersIt->first == "saslauthdPath") {
haveAuthdPath = true;
}
}
}
if (params.count("security.authenticationMechanisms") &&
!haveAuthenticationMechanisms) {
saslGlobalParams.authenticationMechanisms =
params["security.authenticationMechanisms"].as<std::vector<std::string> >();
}
if (params.count("security.sasl.hostName") && !haveHostName) {
saslGlobalParams.hostName =
params["security.sasl.hostName"].as<std::string>();
}
if (params.count("security.sasl.serviceName") && !haveServiceName) {
saslGlobalParams.serviceName =
params["security.sasl.serviceName"].as<std::string>();
}
if (params.count("security.sasl.saslauthdSocketPath") && !haveAuthdPath) {
saslGlobalParams.authdPath =
params["security.sasl.saslauthdSocketPath"].as<std::string>();
}
return Status::OK();
}
示例10: handlePreValidationMongoShellOptions
bool handlePreValidationMongoShellOptions(const moe::Environment& params,
const std::vector<std::string>& args) {
auto&& vii = VersionInfoInterface::instance();
if (params.count("version") || params.count("help")) {
setPlainConsoleLogger();
log() << mongoShellVersion(vii);
if (params.count("help")) {
log() << getMongoShellHelp(args[0], moe::startupOptions);
} else {
vii.logBuildInfo();
}
return false;
}
return true;
}
示例11: handlePreValidationBSONDumpOptions
bool handlePreValidationBSONDumpOptions(const moe::Environment& params) {
if (params.count("help")) {
printBSONDumpHelp(&std::cout);
return false;
}
return true;
}
示例12: storeMongoRestoreOptions
Status storeMongoRestoreOptions(const moe::Environment& params,
const std::vector<std::string>& args) {
Status ret = storeGeneralToolOptions(params, args);
if (!ret.isOK()) {
return ret;
}
ret = storeBSONToolOptions(params, args);
if (!ret.isOK()) {
return ret;
}
mongoRestoreGlobalParams.restoreDirectory = getParam("dir");
mongoRestoreGlobalParams.drop = hasParam("drop");
mongoRestoreGlobalParams.keepIndexVersion = hasParam("keepIndexVersion");
mongoRestoreGlobalParams.restoreOptions = !hasParam("noOptionsRestore");
mongoRestoreGlobalParams.restoreIndexes = !hasParam("noIndexRestore");
mongoRestoreGlobalParams.w = getParam( "w" , 0 );
mongoRestoreGlobalParams.oplogReplay = hasParam("oplogReplay");
mongoRestoreGlobalParams.oplogLimit = getParam("oplogLimit", "");
// Make the default db "" if it was not explicitly set
if (!params.count("db")) {
toolGlobalParams.db = "";
}
return Status::OK();
}
示例13: handlePreValidationMongoImportOptions
bool handlePreValidationMongoImportOptions(const moe::Environment& params) {
if (params.count("help")) {
printMongoImportHelp(&std::cout);
return true;
}
return false;
}
示例14: storeBSONDumpOptions
Status storeBSONDumpOptions(const moe::Environment& params,
const std::vector<std::string>& args) {
Status ret = storeGeneralToolOptions(params, args);
if (!ret.isOK()) {
return ret;
}
ret = storeBSONToolOptions(params, args);
if (!ret.isOK()) {
return ret;
}
// BSONDump never has a db connection
toolGlobalParams.noconnection = true;
bsonDumpGlobalParams.type = getParam("type");
bsonDumpGlobalParams.file = getParam("file");
// Make the default db "" if it was not explicitly set
if (!params.count("db")) {
toolGlobalParams.db = "";
}
// bsondump always outputs data to stdout, so we can't send messages there
toolGlobalParams.canUseStdout = false;
return Status::OK();
}
示例15: handlePreValidationMongoTopOptions
Status handlePreValidationMongoTopOptions(const moe::Environment& params) {
if (params.count("help")) {
printMongoTopHelp(&std::cout);
::_exit(0);
}
return Status::OK();
}