BSONObj BalanceChunkRequest::serializeToRebalanceCommandForConfig(const ChunkType& chunk) { invariantOK(chunk.validate()); BSONObjBuilder cmdBuilder; cmdBuilder.append(kConfigSvrMoveChunk, 1); cmdBuilder.appendElements(chunk.toBSON()); return cmdBuilder.obj(); }
BSONObj BalanceChunkRequest::serializeToMoveCommandForConfig( const ChunkType& chunk, const ShardId& newShardId, int64_t maxChunkSizeBytes, const MigrationSecondaryThrottleOptions& secondaryThrottle, bool waitForDelete) { invariantOK(chunk.validate()); BSONObjBuilder cmdBuilder; cmdBuilder.append(kConfigSvrMoveChunk, 1); cmdBuilder.appendElements(chunk.toBSON()); cmdBuilder.append(kToShardId, newShardId); cmdBuilder.append(kMaxChunkSizeBytes, static_cast<long long>(maxChunkSizeBytes)); { BSONObjBuilder secondaryThrottleBuilder(cmdBuilder.subobjStart(kSecondaryThrottle)); secondaryThrottle.append(&secondaryThrottleBuilder); secondaryThrottleBuilder.doneFast(); } cmdBuilder.append(kWaitForDelete, waitForDelete); return cmdBuilder.obj(); }