2009-02-06 20:11:31 +01:00
|
|
|
// request.h
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2009-02-06 20:25:06 +01:00
|
|
|
#include "../stdafx.h"
|
2009-02-06 20:11:31 +01:00
|
|
|
#include "../util/message.h"
|
|
|
|
#include "../db/dbmessage.h"
|
2009-02-13 03:03:46 +01:00
|
|
|
#include "config.h"
|
2009-02-06 20:11:31 +01:00
|
|
|
|
|
|
|
namespace mongo {
|
|
|
|
|
2009-02-20 16:46:42 +01:00
|
|
|
class Request : boost::noncopyable {
|
2009-02-06 20:11:31 +01:00
|
|
|
public:
|
2009-02-06 21:44:21 +01:00
|
|
|
Request( Message& m, MessagingPort& p );
|
2009-02-06 20:11:31 +01:00
|
|
|
|
2009-02-19 19:26:25 +01:00
|
|
|
// ---- message info -----
|
|
|
|
|
|
|
|
|
2009-02-06 20:11:31 +01:00
|
|
|
const char * getns(){
|
|
|
|
return _d.getns();
|
|
|
|
}
|
2009-02-19 18:55:01 +01:00
|
|
|
int op(){
|
|
|
|
return _m.data->operation();
|
|
|
|
}
|
|
|
|
bool expectResponse(){
|
|
|
|
return op() == dbQuery || op() == dbGetMore;
|
|
|
|
}
|
2009-02-06 20:11:31 +01:00
|
|
|
|
|
|
|
MSGID id(){
|
|
|
|
return _id;
|
|
|
|
}
|
|
|
|
|
2009-02-06 21:44:21 +01:00
|
|
|
DBConfig * getConfig(){
|
|
|
|
return _config;
|
|
|
|
}
|
2009-02-19 19:26:25 +01:00
|
|
|
|
2009-02-20 16:46:42 +01:00
|
|
|
ShardInfo * getShardInfo(){
|
|
|
|
return _shardInfo;
|
|
|
|
}
|
|
|
|
|
2009-02-19 19:26:25 +01:00
|
|
|
// ---- remote location info -----
|
2009-02-06 21:44:21 +01:00
|
|
|
|
2009-02-19 19:26:25 +01:00
|
|
|
|
|
|
|
string singleServerName();
|
|
|
|
|
2009-02-06 21:44:21 +01:00
|
|
|
const char * primaryName(){
|
2009-02-08 20:36:01 +01:00
|
|
|
return _config->getPrimary().c_str();
|
2009-02-06 21:44:21 +01:00
|
|
|
}
|
|
|
|
|
2009-02-19 19:26:25 +01:00
|
|
|
// ---- low level access ----
|
2009-02-17 17:41:34 +01:00
|
|
|
|
2009-02-06 20:11:31 +01:00
|
|
|
void reply( Message & response ){
|
|
|
|
_p.reply( _m , response , _id );
|
|
|
|
}
|
|
|
|
|
|
|
|
Message& m(){ return _m; }
|
|
|
|
DbMessage& d(){ return _d; }
|
|
|
|
MessagingPort& p(){ return _p; }
|
|
|
|
|
2009-02-19 18:55:01 +01:00
|
|
|
void process();
|
|
|
|
|
2009-02-06 20:11:31 +01:00
|
|
|
private:
|
|
|
|
Message& _m;
|
|
|
|
DbMessage _d;
|
|
|
|
MessagingPort& _p;
|
2009-02-19 19:26:25 +01:00
|
|
|
|
2009-02-06 20:11:31 +01:00
|
|
|
MSGID _id;
|
2009-02-06 21:44:21 +01:00
|
|
|
DBConfig * _config;
|
2009-02-19 19:26:25 +01:00
|
|
|
ShardInfo * _shardInfo;
|
2009-02-06 20:11:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2009-02-23 19:56:54 +01:00
|
|
|
|
|
|
|
#include "strategy.h"
|