Lines 168-174
Link Here
|
168 |
|
168 |
|
169 |
BSONObjBuilder dbsNextPassBuilder; |
169 |
BSONObjBuilder dbsNextPassBuilder; |
170 |
int n = 0; |
170 |
int n = 0; |
171 |
for (set<string>::iterator i = addDbNextPass.begin(); i != addDbNextPass.end(); i++) { |
171 |
for (set<std::string>::iterator i = addDbNextPass.begin(); i != addDbNextPass.end(); i++) { |
172 |
n++; |
172 |
n++; |
173 |
dbsNextPassBuilder.appendBool(*i, 1); |
173 |
dbsNextPassBuilder.appendBool(*i, 1); |
174 |
} |
174 |
} |
Lines 177-183
Link Here
|
177 |
|
177 |
|
178 |
BSONObjBuilder incompleteCloneDbsBuilder; |
178 |
BSONObjBuilder incompleteCloneDbsBuilder; |
179 |
n = 0; |
179 |
n = 0; |
180 |
for (set<string>::iterator i = incompleteCloneDbs.begin(); i != incompleteCloneDbs.end(); i++) { |
180 |
for (set<std::string>::iterator i = incompleteCloneDbs.begin(); i != incompleteCloneDbs.end(); i++) { |
181 |
n++; |
181 |
n++; |
182 |
incompleteCloneDbsBuilder.appendBool(*i, 1); |
182 |
incompleteCloneDbsBuilder.appendBool(*i, 1); |
183 |
} |
183 |
} |
Lines 188-194
Link Here
|
188 |
} |
188 |
} |
189 |
|
189 |
|
190 |
void ReplSource::ensureMe(OperationContext* txn) { |
190 |
void ReplSource::ensureMe(OperationContext* txn) { |
191 |
string myname = getHostName(); |
191 |
std::string myname = getHostName(); |
192 |
|
192 |
|
193 |
// local.me is an identifier for a server for getLastError w:2+ |
193 |
// local.me is an identifier for a server for getLastError w:2+ |
194 |
bool exists = Helpers::getSingleton(txn, "local.me", _me); |
194 |
bool exists = Helpers::getSingleton(txn, "local.me", _me); |
Lines 378-387
Link Here
|
378 |
} |
378 |
} |
379 |
|
379 |
|
380 |
virtual bool run(OperationContext* txn, |
380 |
virtual bool run(OperationContext* txn, |
381 |
const string& ns, |
381 |
const std::string& ns, |
382 |
BSONObj& cmdObj, |
382 |
BSONObj& cmdObj, |
383 |
int options, |
383 |
int options, |
384 |
string& errmsg, |
384 |
std::string& errmsg, |
385 |
BSONObjBuilder& result) { |
385 |
BSONObjBuilder& result) { |
386 |
HandshakeArgs handshake; |
386 |
HandshakeArgs handshake; |
387 |
Status status = handshake.initialize(cmdObj); |
387 |
Status status = handshake.initialize(cmdObj); |
Lines 398-404
Link Here
|
398 |
} handshakeCmd; |
398 |
} handshakeCmd; |
399 |
|
399 |
|
400 |
bool replHandshake(DBClientConnection* conn, const OID& myRID) { |
400 |
bool replHandshake(DBClientConnection* conn, const OID& myRID) { |
401 |
string myname = getHostName(); |
401 |
std::string myname = getHostName(); |
402 |
|
402 |
|
403 |
BSONObjBuilder cmd; |
403 |
BSONObjBuilder cmd; |
404 |
cmd.append("handshake", myRID); |
404 |
cmd.append("handshake", myRID); |
Lines 450-456
Link Here
|
450 |
BSONElement e = i.next(); |
450 |
BSONElement e = i.next(); |
451 |
if (e.eoo()) |
451 |
if (e.eoo()) |
452 |
break; |
452 |
break; |
453 |
string name = e.embeddedObject().getField("name").valuestr(); |
453 |
std::string name = e.embeddedObject().getField("name").valuestr(); |
454 |
if (!e.embeddedObject().getBoolField("empty")) { |
454 |
if (!e.embeddedObject().getBoolField("empty")) { |
455 |
if (name != "local") { |
455 |
if (name != "local") { |
456 |
if (only.empty() || only == name) { |
456 |
if (only.empty() || only == name) { |
Lines 481-487
Link Here
|
481 |
return Status::OK(); |
481 |
return Status::OK(); |
482 |
} |
482 |
} |
483 |
|
483 |
|
484 |
void ReplSource::resyncDrop(OperationContext* txn, const string& dbName) { |
484 |
void ReplSource::resyncDrop(OperationContext* txn, const std::string& dbName) { |
485 |
log() << "resync: dropping database " << dbName; |
485 |
log() << "resync: dropping database " << dbName; |
486 |
invariant(txn->lockState()->isW()); |
486 |
invariant(txn->lockState()->isW()); |
487 |
|
487 |
|
Lines 531-543
Link Here
|
531 |
|
531 |
|
532 |
static DatabaseIgnorer ___databaseIgnorer; |
532 |
static DatabaseIgnorer ___databaseIgnorer; |
533 |
|
533 |
|
534 |
void DatabaseIgnorer::doIgnoreUntilAfter(const string& db, const Timestamp& futureOplogTime) { |
534 |
void DatabaseIgnorer::doIgnoreUntilAfter(const std::string& db, const Timestamp& futureOplogTime) { |
535 |
if (futureOplogTime > _ignores[db]) { |
535 |
if (futureOplogTime > _ignores[db]) { |
536 |
_ignores[db] = futureOplogTime; |
536 |
_ignores[db] = futureOplogTime; |
537 |
} |
537 |
} |
538 |
} |
538 |
} |
539 |
|
539 |
|
540 |
bool DatabaseIgnorer::ignoreAt(const string& db, const Timestamp& currentOplogTime) { |
540 |
bool DatabaseIgnorer::ignoreAt(const std::string& db, const Timestamp& currentOplogTime) { |
541 |
if (_ignores[db].isNull()) { |
541 |
if (_ignores[db].isNull()) { |
542 |
return false; |
542 |
return false; |
543 |
} |
543 |
} |
Lines 627-633
Link Here
|
627 |
|
627 |
|
628 |
// The database is present on the master and no conflicting databases |
628 |
// The database is present on the master and no conflicting databases |
629 |
// are present on the master. Drop any local conflicts. |
629 |
// are present on the master. Drop any local conflicts. |
630 |
for (set<string>::const_iterator i = duplicates.begin(); i != duplicates.end(); ++i) { |
630 |
for (set<std::string>::const_iterator i = duplicates.begin(); i != duplicates.end(); ++i) { |
631 |
___databaseIgnorer.doIgnoreUntilAfter(*i, lastTime); |
631 |
___databaseIgnorer.doIgnoreUntilAfter(*i, lastTime); |
632 |
incompleteCloneDbs.erase(*i); |
632 |
incompleteCloneDbs.erase(*i); |
633 |
addDbNextPass.erase(*i); |
633 |
addDbNextPass.erase(*i); |
Lines 826-835
Link Here
|
826 |
} |
826 |
} |
827 |
|
827 |
|
828 |
void ReplSource::syncToTailOfRemoteLog() { |
828 |
void ReplSource::syncToTailOfRemoteLog() { |
829 |
string _ns = ns(); |
829 |
std::string _ns = ns(); |
830 |
BSONObjBuilder b; |
830 |
BSONObjBuilder b; |
831 |
if (!only.empty()) { |
831 |
if (!only.empty()) { |
832 |
b.appendRegex("ns", string("^") + pcrecpp::RE::QuoteMeta(only)); |
832 |
b.appendRegex("ns", std::string("^") + pcrecpp::RE::QuoteMeta(only)); |
833 |
} |
833 |
} |
834 |
BSONObj last = oplogReader.findOne(_ns.c_str(), Query(b.done()).sort(BSON("$natural" << -1))); |
834 |
BSONObj last = oplogReader.findOne(_ns.c_str(), Query(b.done()).sort(BSON("$natural" << -1))); |
835 |
if (!last.isEmpty()) { |
835 |
if (!last.isEmpty()) { |
Lines 877-883
Link Here
|
877 |
*/ |
877 |
*/ |
878 |
int ReplSource::_sync_pullOpLog(OperationContext* txn, int& nApplied) { |
878 |
int ReplSource::_sync_pullOpLog(OperationContext* txn, int& nApplied) { |
879 |
int okResultCode = restartSyncAfterSleep; |
879 |
int okResultCode = restartSyncAfterSleep; |
880 |
string ns = string("local.oplog.$") + sourceName(); |
880 |
std::string ns = std::string("local.oplog.$") + sourceName(); |
881 |
LOG(2) << "sync_pullOpLog " << ns << " syncedTo:" << syncedTo.toStringLong() << '\n'; |
881 |
LOG(2) << "sync_pullOpLog " << ns << " syncedTo:" << syncedTo.toStringLong() << '\n'; |
882 |
|
882 |
|
883 |
bool tailing = true; |
883 |
bool tailing = true; |
Lines 897-903
Link Here
|
897 |
BSONElement e = i.next(); |
897 |
BSONElement e = i.next(); |
898 |
if (e.eoo()) |
898 |
if (e.eoo()) |
899 |
break; |
899 |
break; |
900 |
string name = e.embeddedObject().getField("name").valuestr(); |
900 |
std::string name = e.embeddedObject().getField("name").valuestr(); |
901 |
if (!e.embeddedObject().getBoolField("empty")) { |
901 |
if (!e.embeddedObject().getBoolField("empty")) { |
902 |
if (name != "local") { |
902 |
if (name != "local") { |
903 |
if (only.empty() || only == name) { |
903 |
if (only.empty() || only == name) { |
Lines 921-927
Link Here
|
921 |
if (!only.empty()) { |
921 |
if (!only.empty()) { |
922 |
// note we may here skip a LOT of data table scanning, a lot of work for the master. |
922 |
// note we may here skip a LOT of data table scanning, a lot of work for the master. |
923 |
// maybe append "\\." here? |
923 |
// maybe append "\\." here? |
924 |
query.appendRegex("ns", string("^") + pcrecpp::RE::QuoteMeta(only)); |
924 |
query.appendRegex("ns", std::string("^") + pcrecpp::RE::QuoteMeta(only)); |
925 |
} |
925 |
} |
926 |
BSONObj queryObj = query.done(); |
926 |
BSONObj queryObj = query.done(); |
927 |
// e.g. queryObj = { ts: { $gte: syncedTo } } |
927 |
// e.g. queryObj = { ts: { $gte: syncedTo } } |
Lines 940-946
Link Here
|
940 |
|
940 |
|
941 |
// show any deferred database creates from a previous pass |
941 |
// show any deferred database creates from a previous pass |
942 |
{ |
942 |
{ |
943 |
set<string>::iterator i = addDbNextPass.begin(); |
943 |
set<std::string>::iterator i = addDbNextPass.begin(); |
944 |
if (i != addDbNextPass.end()) { |
944 |
if (i != addDbNextPass.end()) { |
945 |
BSONObjBuilder b; |
945 |
BSONObjBuilder b; |
946 |
b.append("ns", *i + '.'); |
946 |
b.append("ns", *i + '.'); |
Lines 984-990
Link Here
|
984 |
BSONObj op = oplogReader.nextSafe(); |
984 |
BSONObj op = oplogReader.nextSafe(); |
985 |
BSONElement ts = op.getField("ts"); |
985 |
BSONElement ts = op.getField("ts"); |
986 |
if (ts.type() != Date && ts.type() != bsonTimestamp) { |
986 |
if (ts.type() != Date && ts.type() != bsonTimestamp) { |
987 |
string err = op.getStringField("$err"); |
987 |
std::string err = op.getStringField("$err"); |
988 |
if (!err.empty()) { |
988 |
if (!err.empty()) { |
989 |
// 13051 is "tailable cursor requested on non capped collection" |
989 |
// 13051 is "tailable cursor requested on non capped collection" |
990 |
if (op.getIntField("code") == 13051) { |
990 |
if (op.getIntField("code") == 13051) { |
Lines 1152-1158
Link Here
|
1152 |
|
1152 |
|
1153 |
// FIXME Handle cases where this db isn't on default port, or default port is spec'd in |
1153 |
// FIXME Handle cases where this db isn't on default port, or default port is spec'd in |
1154 |
// hostName. |
1154 |
// hostName. |
1155 |
if ((string("localhost") == hostName || string("127.0.0.1") == hostName) && |
1155 |
if ((std::string("localhost") == hostName || std::string("127.0.0.1") == hostName) && |
1156 |
serverGlobalParams.port == ServerGlobalParams::DefaultDBPort) { |
1156 |
serverGlobalParams.port == ServerGlobalParams::DefaultDBPort) { |
1157 |
log() << "can't sync from self (localhost). sources configuration may be wrong." << endl; |
1157 |
log() << "can't sync from self (localhost). sources configuration may be wrong." << endl; |
1158 |
sleepsecs(5); |
1158 |
sleepsecs(5); |
Lines 1297-1303
Link Here
|
1297 |
if (s) { |
1297 |
if (s) { |
1298 |
stringstream ss; |
1298 |
stringstream ss; |
1299 |
ss << "sleep " << s << " sec before next pass"; |
1299 |
ss << "sleep " << s << " sec before next pass"; |
1300 |
string msg = ss.str(); |
1300 |
std::string msg = ss.str(); |
1301 |
if (!serverGlobalParams.quiet) |
1301 |
if (!serverGlobalParams.quiet) |
1302 |
log() << msg << endl; |
1302 |
log() << msg << endl; |
1303 |
ReplInfo r(msg.c_str()); |
1303 |
ReplInfo r(msg.c_str()); |