本文整理汇总了C++中CurOp::setExpectedLatencyMs方法的典型用法代码示例。如果您正苦于以下问题:C++ CurOp::setExpectedLatencyMs方法的具体用法?C++ CurOp::setExpectedLatencyMs怎么用?C++ CurOp::setExpectedLatencyMs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CurOp
的用法示例。
在下文中一共展示了CurOp::setExpectedLatencyMs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: receivedGetMore
bool receivedGetMore(DbResponse& dbresponse, Message& m, CurOp& curop ) {
bool ok = true;
DbMessage d(m);
const char *ns = d.getns();
int ntoreturn = d.pullInt();
long long cursorid = d.pullInt64();
curop.debug().ns = ns;
curop.debug().ntoreturn = ntoreturn;
curop.debug().cursorid = cursorid;
shared_ptr<AssertionException> ex;
scoped_ptr<Timer> timer;
int pass = 0;
bool exhaust = false;
QueryResult* msgdata = 0;
OpTime last;
while( 1 ) {
try {
const NamespaceString nsString( ns );
uassert( 16258, str::stream() << "Invalid ns [" << ns << "]", nsString.isValid() );
if (str::startsWith(ns, "local.oplog.")){
if (pass == 0) {
mutex::scoped_lock lk(OpTime::m);
last = OpTime::getLast(lk);
}
else {
last.waitForDifferent(1000/*ms*/);
}
}
Client::ReadContext ctx(ns);
// call this readlocked so state can't change
replVerifyReadsOk();
msgdata = processGetMore(ns, ntoreturn, cursorid, curop, pass, exhaust);
}
catch ( AssertionException& e ) {
ex.reset( new AssertionException( e.getInfo().msg, e.getCode() ) );
ok = false;
break;
}
if (msgdata == 0) {
// this should only happen with QueryOption_AwaitData
exhaust = false;
massert(13073, "shutting down", !inShutdown() );
if ( ! timer ) {
timer.reset( new Timer() );
}
else {
if ( timer->seconds() >= 4 ) {
// after about 4 seconds, return. pass stops at 1000 normally.
// we want to return occasionally so slave can checkpoint.
pass = 10000;
}
}
pass++;
if (debug)
sleepmillis(20);
else
sleepmillis(2);
// note: the 1100 is beacuse of the waitForDifferent above
// should eventually clean this up a bit
curop.setExpectedLatencyMs( 1100 + timer->millis() );
continue;
}
break;
};
if (ex) {
exhaust = false;
BSONObjBuilder err;
ex->getInfo().append( err );
BSONObj errObj = err.done();
log() << errObj << endl;
curop.debug().exceptionInfo = ex->getInfo();
if (ex->getCode() == 13436) {
replyToQuery(ResultFlag_ErrSet, m, dbresponse, errObj);
curop.debug().responseLength = dbresponse.response->header()->dataLen();
curop.debug().nreturned = 1;
return ok;
}
msgdata = emptyMoreResult(cursorid);
}
Message *resp = new Message();
resp->setData(msgdata, true);
curop.debug().responseLength = resp->header()->dataLen();
curop.debug().nreturned = msgdata->nReturned;
//.........这里部分代码省略.........
示例2: receivedGetMore
bool receivedGetMore(DbResponse& dbresponse, Message& m, CurOp& curop ) {
bool ok = true;
DbMessage d(m);
const char *ns = d.getns();
int ntoreturn = d.pullInt();
long long cursorid = d.pullInt64();
curop.debug().ns = ns;
curop.debug().ntoreturn = ntoreturn;
curop.debug().cursorid = cursorid;
shared_ptr<AssertionException> ex;
scoped_ptr<Timer> timer;
int pass = 0;
bool exhaust = false;
QueryResult* msgdata = 0;
OpTime last;
while( 1 ) {
bool isCursorAuthorized = false;
try {
const NamespaceString nsString( ns );
uassert( 16258, str::stream() << "Invalid ns [" << ns << "]", nsString.isValid() );
Status status = cc().getAuthorizationManager()->checkAuthForGetMore(ns);
uassert(16543, status.reason(), status.isOK());
if (str::startsWith(ns, "local.oplog.")){
while (MONGO_FAIL_POINT(rsStopGetMore)) {
sleepmillis(0);
}
if (pass == 0) {
mutex::scoped_lock lk(OpTime::m);
last = OpTime::getLast(lk);
}
else {
last.waitForDifferent(1000/*ms*/);
}
}
msgdata = processGetMore(ns,
ntoreturn,
cursorid,
curop,
pass,
exhaust,
&isCursorAuthorized);
}
catch ( AssertionException& e ) {
if ( isCursorAuthorized ) {
// If a cursor with id 'cursorid' was authorized, it may have been advanced
// before an exception terminated processGetMore. Erase the ClientCursor
// because it may now be out of sync with the client's iteration state.
// SERVER-7952
// TODO Temporary code, see SERVER-4563 for a cleanup overview.
ClientCursor::erase( cursorid );
}
ex.reset( new AssertionException( e.getInfo().msg, e.getCode() ) );
ok = false;
break;
}
if (msgdata == 0) {
// this should only happen with QueryOption_AwaitData
exhaust = false;
massert(13073, "shutting down", !inShutdown() );
if ( ! timer ) {
timer.reset( new Timer() );
}
else {
if ( timer->seconds() >= 4 ) {
// after about 4 seconds, return. pass stops at 1000 normally.
// we want to return occasionally so slave can checkpoint.
pass = 10000;
}
}
pass++;
if (debug)
sleepmillis(20);
else
sleepmillis(2);
// note: the 1100 is beacuse of the waitForDifferent above
// should eventually clean this up a bit
curop.setExpectedLatencyMs( 1100 + timer->millis() );
continue;
}
break;
};
if (ex) {
exhaust = false;
BSONObjBuilder err;
ex->getInfo().append( err );
BSONObj errObj = err.done();
//.........这里部分代码省略.........
示例3: receivedGetMore
//.........这里部分代码省略.........
&isCursorAuthorized);
}
catch ( AssertionException& e ) {
if ( isCursorAuthorized ) {
// If a cursor with id 'cursorid' was authorized, it may have been advanced
// before an exception terminated processGetMore. Erase the ClientCursor
// because it may now be out of sync with the client's iteration state.
// SERVER-7952
// TODO Temporary code, see SERVER-4563 for a cleanup overview.
ClientCursor::erase( cursorid );
}
ex.reset( new AssertionException( e.getInfo().msg, e.getCode() ) );
ok = false;
break;
}
pass++;
if (msgdata == 0) {
// this should only happen with QueryOption_AwaitData
exhaust = false;
massert(13073, "shutting down", !inShutdown() );
if (!isOplog) {
if ( ! timer ) {
timer.reset( new Timer() );
}
else {
if ( timer->seconds() >= 4 ) {
// after about 4 seconds, return. pass stops at 1000 normally.
// we want to return occasionally so slave can checkpoint.
pass = 10000;
}
}
if (debug) {
sleepmillis(20);
}
else {
sleepmillis(2);
}
}
else {
// in the case where we are the oplog, using
// waitForDifferentMinLive is sufficient. That
// waits for 4 seconds, as the timer above does.
// So, we we don't need more than 2 passes.
if (pass > 1) {
pass = 10000;
}
}
// should eventually clean this up a bit
if (isOplog) {
curop.setExpectedLatencyMs( 4100 );
}
else {
// not sure if this 1100 is still wise.
curop.setExpectedLatencyMs( 1100 + timer->millis() );
}
continue;
}
break;
};
if (ex) {
exhaust = false;
BSONObjBuilder err;
ex->getInfo().append( err );
BSONObj errObj = err.done();
if (!ex->interrupted()) {
log() << errObj << endl;
}
curop.debug().exceptionInfo = ex->getInfo();
if (ex->getCode() == 13436) {
replyToQuery(ResultFlag_ErrSet, m, dbresponse, errObj);
curop.debug().responseLength = dbresponse.response->header()->dataLen();
curop.debug().nreturned = 1;
return ok;
}
msgdata = emptyMoreResult(cursorid);
}
Message *resp = new Message();
resp->setData(msgdata, true);
curop.debug().responseLength = resp->header()->dataLen();
curop.debug().nreturned = msgdata->nReturned;
dbresponse.response = resp;
dbresponse.responseTo = m.header()->id;
if( exhaust ) {
curop.debug().exhaust = true;
dbresponse.exhaustNS = ns;
}
return ok;
}