/** * 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()); } }
/** * 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)); }