bool Shard::moveIfShould( Shard * newShard ){ Shard * toMove = 0; if ( newShard->countObjects() <= 1 ){ toMove = newShard; } else if ( this->countObjects() <= 1 ){ toMove = this; } else { log(1) << "don't know how to decide if i should move inner shard" << endl; } if ( ! toMove ) return false; string newLocation = grid.pickServerForNewDB(); if ( newLocation == getServer() ){ // if this is the best server, then we shouldn't do anything! log(1) << "not moving shard: " << toString() << " b/c would move to same place " << newLocation << " -> " << getServer() << endl; return 0; } log() << "moving shard (auto): " << toMove->toString() << " to: " << newLocation << " #objcets: " << toMove->countObjects() << endl; string errmsg; massert( (string)"moveAndCommit failed: " + errmsg , toMove->moveAndCommit( newLocation , errmsg ) ); return true; }