本文整理汇总了C++中ShardType::toBSON方法的典型用法代码示例。如果您正苦于以下问题:C++ ShardType::toBSON方法的具体用法?C++ ShardType::toBSON怎么用?C++ ShardType::toBSON使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShardType
的用法示例。
在下文中一共展示了ShardType::toBSON方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: storeShardsAndPings
/**
* Stores sample shard and ping information at the current version.
*/
void storeShardsAndPings(int numShards, int numPings) {
DBDirectClient client(&_txn);
for (int i = 0; i < numShards; i++) {
ShardType shard;
shard.setName(OID::gen().toString());
shard.setHost((string) (str::stream() << "$dummyShard:" << (i + 1) << "0000"));
client.insert(ShardType::ConfigNS, shard.toBSON());
}
for (int i = 0; i < numPings; i++) {
MongosType ping;
ping.setName((string) (str::stream() << "$dummyMongos:" << (i + 1) << "0000"));
ping.setPing(jsTime());
ping.setMongoVersion(versionString);
ping.setConfigVersion(CURRENT_CONFIG_VERSION);
if (i % 2 == 0) {
ping.setPing(ping.getPing() - Minutes(10));
}
client.insert(MongosType::ConfigNS, ping.toBSON());
}
}
示例2: storeLegacyConfigVersion
/**
* Stores a legacy { version : X } config server entry
*/
void storeLegacyConfigVersion(int version) {
if (version == 0) return;
if (version == 1) {
ShardType shard;
shard.setName("test");
shard.setHost("$dummy:10000");
client().insert(ShardType::ConfigNS, shard.toBSON());
return;
}
client().insert(VersionType::ConfigNS, BSON("_id" << 1 << "version" << version));
}