本文整理汇总了C++中scoped_ptr::asDate方法的典型用法代码示例。如果您正苦于以下问题:C++ scoped_ptr::asDate方法的具体用法?C++ scoped_ptr::asDate怎么用?C++ scoped_ptr::asDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scoped_ptr
的用法示例。
在下文中一共展示了scoped_ptr::asDate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doRun
virtual int doRun() {
// authenticate
enum Auth::Level authLevel = Auth::NONE;
auth("", &authLevel);
uassert(15935, "user does not have write access", authLevel == Auth::WRITE);
boost::filesystem::path root = getParam("dir");
// check if we're actually talking to a machine that can write
if (!isMaster()) {
return -1;
}
if (isMongos() && _db == "" && exists(root / "config")) {
log() << "Cannot do a full restore on a sharded system" << endl;
return -1;
}
_drop = hasParam( "drop" );
_keepIndexVersion = hasParam("keepIndexVersion");
_restoreOptions = !hasParam("noOptionsRestore");
_restoreIndexes = !hasParam("noIndexRestore");
_w = getParam( "w" , 1 );
bool doOplog = hasParam( "oplogReplay" );
if (doOplog) {
// fail early if errors
if (_db != "") {
log() << "Can only replay oplog on full restore" << endl;
return -1;
}
if ( ! exists(root / "oplog.bson") ) {
log() << "No oplog file to replay. Make sure you run mongodump with --oplog." << endl;
return -1;
}
BSONObj out;
if (! conn().simpleCommand("admin", &out, "buildinfo")) {
log() << "buildinfo command failed: " << out["errmsg"].String() << endl;
return -1;
}
StringData version = out["version"].valuestr();
if (versionCmp(version, "1.7.4-pre-") < 0) {
log() << "Can only replay oplog to server version >= 1.7.4" << endl;
return -1;
}
string oplogLimit = getParam( "oplogLimit", "" );
string oplogInc = "0";
if(!oplogLimit.empty()) {
size_t i = oplogLimit.find_first_of(':');
if ( i != string::npos ) {
if ( i + 1 < oplogLimit.length() ) {
oplogInc = oplogLimit.substr(i + 1);
}
oplogLimit = oplogLimit.substr(0, i);
}
try {
_oplogLimitTS.reset(new OpTime(
boost::lexical_cast<unsigned long>(oplogLimit.c_str()),
boost::lexical_cast<unsigned long>(oplogInc.c_str())));
} catch( const boost::bad_lexical_cast& error) {
log() << "Could not parse oplogLimit into Timestamp from values ( "
<< oplogLimit << " , " << oplogInc << " )"
<< endl;
return -1;
}
if (!oplogLimit.empty()) {
// Only for a replica set as master will have no-op entries so we would need to
// skip them all to find the real op
scoped_ptr<DBClientCursor> cursor(
conn().query("local.oplog.rs", Query().sort(BSON("$natural" << -1)),
1 /*return first*/));
OpTime tsOptime;
// get newest oplog entry and make sure it is older than the limit to apply.
if (cursor->more()) {
tsOptime = cursor->next().getField("ts")._opTime();
if (tsOptime > *_oplogLimitTS.get()) {
log() << "The oplogLimit is not newer than"
<< " the last oplog entry on the server."
<< endl;
return -1;
}
}
BSONObjBuilder tsRestrictBldr;
if (!tsOptime.isNull())
tsRestrictBldr.appendTimestamp("$gt", tsOptime.asDate());
tsRestrictBldr.appendTimestamp("$lt", _oplogLimitTS->asDate());
//.........这里部分代码省略.........