diff options
Diffstat (limited to 'src/mongo/s/d_migrate.cpp')
-rw-r--r-- | src/mongo/s/d_migrate.cpp | 73 |
1 files changed, 37 insertions, 36 deletions
diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp index 4f9eb259ae0..52c8e8690c8 100644 --- a/src/mongo/s/d_migrate.cpp +++ b/src/mongo/s/d_migrate.cpp @@ -63,6 +63,7 @@ #include "d_logic.h" #include "config.h" #include "chunk.h" +#include "mongo/s/type_chunk.h" using namespace std; @@ -1000,12 +1001,12 @@ namespace mongo { BSONObj x; BSONObj currChunk; try{ - x = conn->get()->findOne(ConfigNS::chunk, - Query(BSON(ChunkFields::ns(ns))) - .sort(BSON(ChunkFields::lastmod() << -1))); + x = conn->get()->findOne(ChunkType::ConfigNS, + Query(BSON(ChunkType::ns(ns))) + .sort(BSON(ChunkType::DEPRECATED_lastmod() << -1))); - currChunk = conn->get()->findOne(ConfigNS::chunk, - shardId.wrap(ChunkFields::name().c_str())); + currChunk = conn->get()->findOne(ChunkType::ConfigNS, + shardId.wrap(ChunkType::name().c_str())); } catch( DBException& e ){ errmsg = str::stream() << "aborted moveChunk because could not get chunk data from config server " << shardingState.getConfigServer() << causedBy( e ); @@ -1013,15 +1014,15 @@ namespace mongo { return false; } - maxVersion = ShardChunkVersion::fromBSON(x, ChunkFields::lastmod()); - verify(currChunk[ChunkFields::shard()].type()); - verify(currChunk[ChunkFields::min()].type()); - verify(currChunk[ChunkFields::max()].type()); - myOldShard = currChunk[ChunkFields::shard()].String(); + maxVersion = ShardChunkVersion::fromBSON(x, ChunkType::DEPRECATED_lastmod()); + verify(currChunk[ChunkType::shard()].type()); + verify(currChunk[ChunkType::min()].type()); + verify(currChunk[ChunkType::max()].type()); + myOldShard = currChunk[ChunkType::shard()].String(); conn->done(); - BSONObj currMin = currChunk[ChunkFields::min()].Obj(); - BSONObj currMax = currChunk[ChunkFields::max()].Obj(); + BSONObj currMin = currChunk[ChunkType::min()].Obj(); + BSONObj currMax = currChunk[ChunkType::max()].Obj(); if ( currMin.woCompare( min ) || currMax.woCompare( max ) ) { errmsg = "boundaries are outdated (likely a split occurred)"; result.append( "currMin" , currMin ); @@ -1266,19 +1267,19 @@ namespace mongo { BSONObjBuilder op; op.append( "op" , "u" ); op.appendBool( "b" , false /* no upserting */ ); - op.append( "ns" , ConfigNS::chunk ); + op.append( "ns" , ChunkType::ConfigNS ); BSONObjBuilder n( op.subobjStart( "o" ) ); - n.append(ChunkFields::name(), Chunk::genID(ns, min)); - myVersion.addToBSON(n, ChunkFields::lastmod()); - n.append(ChunkFields::ns(), ns); - n.append(ChunkFields::min(), min); - n.append(ChunkFields::max(), max); - n.append(ChunkFields::shard(), toShard.getName()); + n.append(ChunkType::name(), Chunk::genID(ns, min)); + myVersion.addToBSON(n, ChunkType::DEPRECATED_lastmod()); + n.append(ChunkType::ns(), ns); + n.append(ChunkType::min(), min); + n.append(ChunkType::max(), max); + n.append(ChunkType::shard(), toShard.getName()); n.done(); BSONObjBuilder q( op.subobjStart( "o2" ) ); - q.append(ChunkFields::name(), Chunk::genID(ns, min)); + q.append(ChunkType::name(), Chunk::genID(ns, min)); q.done(); updates.append( op.obj() ); @@ -1305,20 +1306,20 @@ namespace mongo { BSONObjBuilder op; op.append( "op" , "u" ); op.appendBool( "b" , false ); - op.append( "ns" , ConfigNS::chunk ); + op.append( "ns" , ChunkType::ConfigNS ); nextVersion.incMinor(); // same as used on donateChunk BSONObjBuilder n( op.subobjStart( "o" ) ); - n.append(ChunkFields::name(), Chunk::genID(ns, bumpMin)); - nextVersion.addToBSON(n, ChunkFields::lastmod()); - n.append(ChunkFields::ns(), ns); - n.append(ChunkFields::min(), bumpMin); - n.append(ChunkFields::max(), bumpMax); - n.append(ChunkFields::shard(), fromShard.getName()); + n.append(ChunkType::name(), Chunk::genID(ns, bumpMin)); + nextVersion.addToBSON(n, ChunkType::DEPRECATED_lastmod()); + n.append(ChunkType::ns(), ns); + n.append(ChunkType::min(), bumpMin); + n.append(ChunkType::max(), bumpMax); + n.append(ChunkType::shard(), fromShard.getName()); n.done(); BSONObjBuilder q( op.subobjStart( "o2" ) ); - q.append(ChunkFields::name(), Chunk::genID(ns, bumpMin)); + q.append(ChunkType::name(), Chunk::genID(ns, bumpMin)); q.done(); updates.append( op.obj() ); @@ -1337,13 +1338,13 @@ namespace mongo { BSONArrayBuilder preCond( cmdBuilder.subarrayStart( "preCondition" ) ); { BSONObjBuilder b; - b.append("ns", ConfigNS::chunk); - b.append("q", BSON("query" << BSON(ChunkFields::ns(ns)) << - "orderby" << BSON(ChunkFields::lastmod() << -1))); + b.append("ns", ChunkType::ConfigNS); + b.append("q", BSON("query" << BSON(ChunkType::ns(ns)) << + "orderby" << BSON(ChunkType::DEPRECATED_lastmod() << -1))); { BSONObjBuilder bb( b.subobjStart( "res" ) ); // TODO: For backwards compatibility, we can't yet require an epoch here - bb.appendTimestamp(ChunkFields::lastmod(), maxVersion.toLong()); + bb.appendTimestamp(ChunkType::DEPRECATED_lastmod(), maxVersion.toLong()); bb.done(); } preCond.append( b.obj() ); @@ -1392,12 +1393,12 @@ namespace mongo { // look for the chunk in this shard whose version got bumped // we assume that if that mod made it to the config, the applyOps was successful - BSONObj doc = conn->get()->findOne(ConfigNS::chunk, - Query(BSON(ChunkFields::ns(ns))) - .sort(BSON(ChunkFields::lastmod() << -1))); + BSONObj doc = conn->get()->findOne(ChunkType::ConfigNS, + Query(BSON(ChunkType::ns(ns))) + .sort(BSON(ChunkType::DEPRECATED_lastmod() << -1))); ShardChunkVersion checkVersion = - ShardChunkVersion::fromBSON(doc[ChunkFields::lastmod()]); + ShardChunkVersion::fromBSON(doc[ChunkType::DEPRECATED_lastmod()]); if ( checkVersion.isEquivalentTo( nextVersion ) ) { log() << "moveChunk commit confirmed" << migrateLog; |