Lines 161-167
Link Here
|
161 |
|
161 |
|
162 |
BSONObjBuilder dbsNextPassBuilder; |
162 |
BSONObjBuilder dbsNextPassBuilder; |
163 |
int n = 0; |
163 |
int n = 0; |
164 |
for (set<string>::iterator i = addDbNextPass.begin(); i != addDbNextPass.end(); i++) { |
164 |
for (set<std::string>::iterator i = addDbNextPass.begin(); i != addDbNextPass.end(); i++) { |
165 |
n++; |
165 |
n++; |
166 |
dbsNextPassBuilder.appendBool(*i, 1); |
166 |
dbsNextPassBuilder.appendBool(*i, 1); |
167 |
} |
167 |
} |
Lines 170-176
Link Here
|
170 |
|
170 |
|
171 |
BSONObjBuilder incompleteCloneDbsBuilder; |
171 |
BSONObjBuilder incompleteCloneDbsBuilder; |
172 |
n = 0; |
172 |
n = 0; |
173 |
for (set<string>::iterator i = incompleteCloneDbs.begin(); i != incompleteCloneDbs.end(); i++) { |
173 |
for (set<std::string>::iterator i = incompleteCloneDbs.begin(); i != incompleteCloneDbs.end(); i++) { |
174 |
n++; |
174 |
n++; |
175 |
incompleteCloneDbsBuilder.appendBool(*i, 1); |
175 |
incompleteCloneDbsBuilder.appendBool(*i, 1); |
176 |
} |
176 |
} |
Lines 181-187
Link Here
|
181 |
} |
181 |
} |
182 |
|
182 |
|
183 |
void ReplSource::ensureMe(OperationContext* txn) { |
183 |
void ReplSource::ensureMe(OperationContext* txn) { |
184 |
string myname = getHostName(); |
184 |
std::string myname = getHostName(); |
185 |
|
185 |
|
186 |
// local.me is an identifier for a server for getLastError w:2+ |
186 |
// local.me is an identifier for a server for getLastError w:2+ |
187 |
bool exists = Helpers::getSingleton(txn, "local.me", _me); |
187 |
bool exists = Helpers::getSingleton(txn, "local.me", _me); |
Lines 373-382
Link Here
|
373 |
} |
373 |
} |
374 |
|
374 |
|
375 |
virtual bool run(OperationContext* txn, |
375 |
virtual bool run(OperationContext* txn, |
376 |
const string& ns, |
376 |
const std::string& ns, |
377 |
BSONObj& cmdObj, |
377 |
BSONObj& cmdObj, |
378 |
int options, |
378 |
int options, |
379 |
string& errmsg, |
379 |
std::string& errmsg, |
380 |
BSONObjBuilder& result) { |
380 |
BSONObjBuilder& result) { |
381 |
HandshakeArgs handshake; |
381 |
HandshakeArgs handshake; |
382 |
Status status = handshake.initialize(cmdObj); |
382 |
Status status = handshake.initialize(cmdObj); |
Lines 393-399
Link Here
|
393 |
} handshakeCmd; |
393 |
} handshakeCmd; |
394 |
|
394 |
|
395 |
bool replHandshake(DBClientConnection* conn, const OID& myRID) { |
395 |
bool replHandshake(DBClientConnection* conn, const OID& myRID) { |
396 |
string myname = getHostName(); |
396 |
std::string myname = getHostName(); |
397 |
|
397 |
|
398 |
BSONObjBuilder cmd; |
398 |
BSONObjBuilder cmd; |
399 |
cmd.append("handshake", myRID); |
399 |
cmd.append("handshake", myRID); |
Lines 445-451
Link Here
|
445 |
BSONElement e = i.next(); |
445 |
BSONElement e = i.next(); |
446 |
if (e.eoo()) |
446 |
if (e.eoo()) |
447 |
break; |
447 |
break; |
448 |
string name = e.embeddedObject().getField("name").valuestr(); |
448 |
std::string name = e.embeddedObject().getField("name").valuestr(); |
449 |
if (!e.embeddedObject().getBoolField("empty")) { |
449 |
if (!e.embeddedObject().getBoolField("empty")) { |
450 |
if (name != "local") { |
450 |
if (name != "local") { |
451 |
if (only.empty() || only == name) { |
451 |
if (only.empty() || only == name) { |
Lines 459-465
Link Here
|
459 |
save(txn); |
459 |
save(txn); |
460 |
} |
460 |
} |
461 |
|
461 |
|
462 |
void ReplSource::resyncDrop(OperationContext* txn, const string& db) { |
462 |
void ReplSource::resyncDrop(OperationContext* txn, const std::string& db) { |
463 |
log() << "resync: dropping database " << db; |
463 |
log() << "resync: dropping database " << db; |
464 |
OldClientContext ctx(txn, db); |
464 |
OldClientContext ctx(txn, db); |
465 |
dropDatabase(txn, ctx.db()); |
465 |
dropDatabase(txn, ctx.db()); |
Lines 502-514
Link Here
|
502 |
|
502 |
|
503 |
static DatabaseIgnorer ___databaseIgnorer; |
503 |
static DatabaseIgnorer ___databaseIgnorer; |
504 |
|
504 |
|
505 |
void DatabaseIgnorer::doIgnoreUntilAfter(const string& db, const Timestamp& futureOplogTime) { |
505 |
void DatabaseIgnorer::doIgnoreUntilAfter(const std::string& db, const Timestamp& futureOplogTime) { |
506 |
if (futureOplogTime > _ignores[db]) { |
506 |
if (futureOplogTime > _ignores[db]) { |
507 |
_ignores[db] = futureOplogTime; |
507 |
_ignores[db] = futureOplogTime; |
508 |
} |
508 |
} |
509 |
} |
509 |
} |
510 |
|
510 |
|
511 |
bool DatabaseIgnorer::ignoreAt(const string& db, const Timestamp& currentOplogTime) { |
511 |
bool DatabaseIgnorer::ignoreAt(const std::string& db, const Timestamp& currentOplogTime) { |
512 |
if (_ignores[db].isNull()) { |
512 |
if (_ignores[db].isNull()) { |
513 |
return false; |
513 |
return false; |
514 |
} |
514 |
} |
Lines 598-604
Link Here
|
598 |
|
598 |
|
599 |
// The database is present on the master and no conflicting databases |
599 |
// The database is present on the master and no conflicting databases |
600 |
// are present on the master. Drop any local conflicts. |
600 |
// are present on the master. Drop any local conflicts. |
601 |
for (set<string>::const_iterator i = duplicates.begin(); i != duplicates.end(); ++i) { |
601 |
for (set<std::string>::const_iterator i = duplicates.begin(); i != duplicates.end(); ++i) { |
602 |
___databaseIgnorer.doIgnoreUntilAfter(*i, lastTime); |
602 |
___databaseIgnorer.doIgnoreUntilAfter(*i, lastTime); |
603 |
incompleteCloneDbs.erase(*i); |
603 |
incompleteCloneDbs.erase(*i); |
604 |
addDbNextPass.erase(*i); |
604 |
addDbNextPass.erase(*i); |
Lines 793-802
Link Here
|
793 |
} |
793 |
} |
794 |
|
794 |
|
795 |
void ReplSource::syncToTailOfRemoteLog() { |
795 |
void ReplSource::syncToTailOfRemoteLog() { |
796 |
string _ns = ns(); |
796 |
std::string _ns = ns(); |
797 |
BSONObjBuilder b; |
797 |
BSONObjBuilder b; |
798 |
if (!only.empty()) { |
798 |
if (!only.empty()) { |
799 |
b.appendRegex("ns", string("^") + pcrecpp::RE::QuoteMeta(only)); |
799 |
b.appendRegex("ns", std::string("^") + pcrecpp::RE::QuoteMeta(only)); |
800 |
} |
800 |
} |
801 |
BSONObj last = oplogReader.findOne(_ns.c_str(), Query(b.done()).sort(BSON("$natural" << -1))); |
801 |
BSONObj last = oplogReader.findOne(_ns.c_str(), Query(b.done()).sort(BSON("$natural" << -1))); |
802 |
if (!last.isEmpty()) { |
802 |
if (!last.isEmpty()) { |
Lines 844-850
Link Here
|
844 |
*/ |
844 |
*/ |
845 |
int ReplSource::_sync_pullOpLog(OperationContext* txn, int& nApplied) { |
845 |
int ReplSource::_sync_pullOpLog(OperationContext* txn, int& nApplied) { |
846 |
int okResultCode = 1; |
846 |
int okResultCode = 1; |
847 |
string ns = string("local.oplog.$") + sourceName(); |
847 |
std::string ns = std::string("local.oplog.$") + sourceName(); |
848 |
LOG(2) << "sync_pullOpLog " << ns << " syncedTo:" << syncedTo.toStringLong() << '\n'; |
848 |
LOG(2) << "sync_pullOpLog " << ns << " syncedTo:" << syncedTo.toStringLong() << '\n'; |
849 |
|
849 |
|
850 |
bool tailing = true; |
850 |
bool tailing = true; |
Lines 864-870
Link Here
|
864 |
BSONElement e = i.next(); |
864 |
BSONElement e = i.next(); |
865 |
if (e.eoo()) |
865 |
if (e.eoo()) |
866 |
break; |
866 |
break; |
867 |
string name = e.embeddedObject().getField("name").valuestr(); |
867 |
std::string name = e.embeddedObject().getField("name").valuestr(); |
868 |
if (!e.embeddedObject().getBoolField("empty")) { |
868 |
if (!e.embeddedObject().getBoolField("empty")) { |
869 |
if (name != "local") { |
869 |
if (name != "local") { |
870 |
if (only.empty() || only == name) { |
870 |
if (only.empty() || only == name) { |
Lines 888-894
Link Here
|
888 |
if (!only.empty()) { |
888 |
if (!only.empty()) { |
889 |
// note we may here skip a LOT of data table scanning, a lot of work for the master. |
889 |
// note we may here skip a LOT of data table scanning, a lot of work for the master. |
890 |
// maybe append "\\." here? |
890 |
// maybe append "\\." here? |
891 |
query.appendRegex("ns", string("^") + pcrecpp::RE::QuoteMeta(only)); |
891 |
query.appendRegex("ns", std::string("^") + pcrecpp::RE::QuoteMeta(only)); |
892 |
} |
892 |
} |
893 |
BSONObj queryObj = query.done(); |
893 |
BSONObj queryObj = query.done(); |
894 |
// e.g. queryObj = { ts: { $gte: syncedTo } } |
894 |
// e.g. queryObj = { ts: { $gte: syncedTo } } |
Lines 907-913
Link Here
|
907 |
|
907 |
|
908 |
// show any deferred database creates from a previous pass |
908 |
// show any deferred database creates from a previous pass |
909 |
{ |
909 |
{ |
910 |
set<string>::iterator i = addDbNextPass.begin(); |
910 |
set<std::string>::iterator i = addDbNextPass.begin(); |
911 |
if (i != addDbNextPass.end()) { |
911 |
if (i != addDbNextPass.end()) { |
912 |
BSONObjBuilder b; |
912 |
BSONObjBuilder b; |
913 |
b.append("ns", *i + '.'); |
913 |
b.append("ns", *i + '.'); |
Lines 938-944
Link Here
|
938 |
BSONObj op = oplogReader.next(); |
938 |
BSONObj op = oplogReader.next(); |
939 |
BSONElement ts = op.getField("ts"); |
939 |
BSONElement ts = op.getField("ts"); |
940 |
if (ts.type() != Date && ts.type() != bsonTimestamp) { |
940 |
if (ts.type() != Date && ts.type() != bsonTimestamp) { |
941 |
string err = op.getStringField("$err"); |
941 |
std::string err = op.getStringField("$err"); |
942 |
if (!err.empty()) { |
942 |
if (!err.empty()) { |
943 |
// 13051 is "tailable cursor requested on non capped collection" |
943 |
// 13051 is "tailable cursor requested on non capped collection" |
944 |
if (op.getIntField("code") == 13051) { |
944 |
if (op.getIntField("code") == 13051) { |
Lines 1106-1112
Link Here
|
1106 |
|
1106 |
|
1107 |
// FIXME Handle cases where this db isn't on default port, or default port is spec'd in |
1107 |
// FIXME Handle cases where this db isn't on default port, or default port is spec'd in |
1108 |
// hostName. |
1108 |
// hostName. |
1109 |
if ((string("localhost") == hostName || string("127.0.0.1") == hostName) && |
1109 |
if ((std::string("localhost") == hostName || std::string("127.0.0.1") == hostName) && |
1110 |
serverGlobalParams.port == ServerGlobalParams::DefaultDBPort) { |
1110 |
serverGlobalParams.port == ServerGlobalParams::DefaultDBPort) { |
1111 |
log() << "can't sync from self (localhost). sources configuration may be wrong." << endl; |
1111 |
log() << "can't sync from self (localhost). sources configuration may be wrong." << endl; |
1112 |
sleepsecs(5); |
1112 |
sleepsecs(5); |
Lines 1251-1257
Link Here
|
1251 |
if (s) { |
1251 |
if (s) { |
1252 |
stringstream ss; |
1252 |
stringstream ss; |
1253 |
ss << "sleep " << s << " sec before next pass"; |
1253 |
ss << "sleep " << s << " sec before next pass"; |
1254 |
string msg = ss.str(); |
1254 |
std::string msg = ss.str(); |
1255 |
if (!serverGlobalParams.quiet) |
1255 |
if (!serverGlobalParams.quiet) |
1256 |
log() << msg << endl; |
1256 |
log() << msg << endl; |
1257 |
ReplInfo r(msg.c_str()); |
1257 |
ReplInfo r(msg.c_str()); |