本文整理汇总了C++中DBClientConnection::port方法的典型用法代码示例。如果您正苦于以下问题:C++ DBClientConnection::port方法的具体用法?C++ DBClientConnection::port怎么用?C++ DBClientConnection::port使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBClientConnection
的用法示例。
在下文中一共展示了DBClientConnection::port方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
void operator()() const {
DBClientConnection dest;
string errmsg;
while (!dest.connect(mongoBridgeGlobalParams.destUri, errmsg))
sleepmillis( 500 );
Message m;
while( 1 ) {
try {
m.reset();
if ( !mp_.recv( m ) ) {
cout << "end connection " << mp_.psock->remoteString() << endl;
mp_.shutdown();
break;
}
sleepmillis(mongoBridgeGlobalParams.delay);
int oldId = m.header()->id;
if ( m.operation() == dbQuery || m.operation() == dbMsg || m.operation() == dbGetMore ) {
bool exhaust = false;
if ( m.operation() == dbQuery ) {
DbMessage d( m );
QueryMessage q( d );
exhaust = q.queryOptions & QueryOption_Exhaust;
}
Message response;
dest.port().call( m, response );
// nothing to reply with?
if ( response.empty() ) cleanup(0);
mp_.reply( m, response, oldId );
while ( exhaust ) {
MsgData *header = response.header();
QueryResult *qr = (QueryResult *) header;
if ( qr->cursorId ) {
response.reset();
dest.port().recv( response );
mp_.reply( m, response ); // m argument is ignored anyway
}
else {
exhaust = false;
}
}
}
else {
dest.port().say( m, oldId );
}
}
catch ( ... ) {
log() << "caught exception in Forwarder, continuing" << endl;
}
}
}
示例2: operator
void operator()() const {
DBClientConnection dest;
string errmsg;
while( !dest.connect( destUri, errmsg ) )
sleepmillis( 500 );
Message m;
while( 1 ) {
m.reset();
if ( !mp_.recv( m ) ) {
cout << "end connection " << mp_.farEnd.toString() << endl;
mp_.shutdown();
break;
}
int oldId = m.data->id;
if ( m.data->operation() == dbQuery || m.data->operation() == dbMsg || m.data->operation() == dbGetMore ) {
Message response;
dest.port().call( m, response );
mp_.reply( m, response, oldId );
} else {
dest.port().say( m, oldId );
}
}
}
示例3: operator
void operator()() const {
DBClientConnection dest;
string errmsg;
Timer connectTimer;
while (!dest.connect(HostAndPort(mongoBridgeGlobalParams.destUri), errmsg)) {
// If we can't connect for the configured timeout, give up
//
if (connectTimer.seconds() >= mongoBridgeGlobalParams.connectTimeoutSec) {
cout << "Unable to establish connection from " << mp_.psock->remoteString()
<< " to " << mongoBridgeGlobalParams.destUri
<< " after " << connectTimer.seconds() << " seconds. Giving up." << endl;
mp_.shutdown();
return;
}
sleepmillis(500);
}
Message m;
while( 1 ) {
try {
m.reset();
if ( !mp_.recv( m ) ) {
cout << "end connection " << mp_.psock->remoteString() << endl;
mp_.shutdown();
break;
}
sleepmillis(mongoBridgeGlobalParams.delay);
int oldId = m.header()->id;
if ( m.operation() == dbQuery || m.operation() == dbMsg || m.operation() == dbGetMore ) {
bool exhaust = false;
if ( m.operation() == dbQuery ) {
DbMessage d( m );
QueryMessage q( d );
exhaust = q.queryOptions & QueryOption_Exhaust;
}
Message response;
dest.port().call( m, response );
// nothing to reply with?
if ( response.empty() ) cleanup(0);
mp_.reply( m, response, oldId );
while ( exhaust ) {
MsgData *header = response.header();
QueryResult *qr = (QueryResult *) header;
if ( qr->cursorId ) {
response.reset();
dest.port().recv( response );
mp_.reply( m, response ); // m argument is ignored anyway
}
else {
exhaust = false;
}
}
}
else {
dest.port().say( m, oldId );
}
}
catch ( ... ) {
log() << "caught exception in Forwarder, continuing" << endl;
}
}
}