0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00
mongodb/s/request.h

97 lines
2.1 KiB
C
Raw Normal View History

// request.h
#pragma once
2009-02-06 20:25:06 +01:00
#include "../stdafx.h"
#include "../util/message.h"
#include "../db/dbmessage.h"
2009-02-13 03:03:46 +01:00
#include "config.h"
namespace mongo {
2009-02-20 16:46:42 +01:00
class Request : boost::noncopyable {
public:
2009-03-02 05:43:00 +01:00
Request( Message& m, AbstractMessagingPort* p );
// ---- message info -----
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;
}
MSGID id(){
return _id;
}
2009-02-06 21:44:21 +01:00
DBConfig * getConfig(){
return _config;
}
bool isShardingEnabled(){
return _config->isShardingEnabled();
}
ChunkManager * getChunkManager(){
return _chunkManager;
2009-02-20 16:46:42 +01:00
}
// ---- remote location info -----
2009-02-06 21:44:21 +01:00
string singleServerName();
2009-02-06 21:44:21 +01:00
const char * primaryName(){
return _config->getPrimary().c_str();
2009-02-06 21:44:21 +01:00
}
// ---- low level access ----
2009-02-17 17:41:34 +01:00
void reply( Message & response ){
2009-03-02 05:43:00 +01:00
_p->reply( _m , response , _id );
}
Message& m(){ return _m; }
DbMessage& d(){ return _d; }
2009-03-02 05:43:00 +01:00
AbstractMessagingPort* p(){ return _p; }
2009-04-07 21:19:27 +02:00
void process( int attempt = 0 );
private:
2009-04-07 21:19:27 +02:00
void reset( bool reload=false );
2009-04-07 21:19:27 +02:00
Message& _m;
DbMessage _d;
2009-03-02 05:43:00 +01:00
AbstractMessagingPort* _p;
MSGID _id;
2009-02-06 21:44:21 +01:00
DBConfig * _config;
ChunkManager * _chunkManager;
};
2009-04-07 21:19:27 +02:00
class StaleConfigException : public std::exception {
public:
StaleConfigException( const string& ns , const string& msg){
stringstream s;
s << "StaleConfigException ns: " << ns << " " << msg;
_msg = s.str();
}
virtual ~StaleConfigException() throw(){}
2009-04-07 21:19:27 +02:00
virtual const char* what() const throw(){
return _msg.c_str();
}
private:
string _msg;
2009-04-07 21:19:27 +02:00
};
}
2009-02-23 19:56:54 +01:00
#include "strategy.h"