summaryrefslogtreecommitdiff
path: root/src/mongo/db/dbwebserver.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2014-05-01 15:09:02 -0400
committerMathias Stearn <mathias@10gen.com>2014-05-14 13:58:01 -0400
commit6378da06b637dbf86f916274c8f0457d925af6a9 (patch)
treeb07693c3b786ad9eef3e17fe1a6a670f9229cd44 /src/mongo/db/dbwebserver.cpp
parent304534f11a265d8c18d788623185340c001cc26e (diff)
downloadmongo-6378da06b637dbf86f916274c8f0457d925af6a9.tar.gz
SERVER-13641 Pull TransactionExperiment up to top level request processor
Diffstat (limited to 'src/mongo/db/dbwebserver.cpp')
-rw-r--r--src/mongo/db/dbwebserver.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/mongo/db/dbwebserver.cpp b/src/mongo/db/dbwebserver.cpp
index cfd6c747e38..e63ad58f0d8 100644
--- a/src/mongo/db/dbwebserver.cpp
+++ b/src/mongo/db/dbwebserver.cpp
@@ -50,6 +50,7 @@
#include "mongo/db/db.h"
#include "mongo/db/instance.h"
#include "mongo/db/stats/snapshots.h"
+#include "mongo/db/storage/mmap_v1/dur_transaction.h"
#include "mongo/util/admin_access.h"
#include "mongo/util/md5.hpp"
#include "mongo/util/mongoutils/html.h"
@@ -73,13 +74,20 @@ namespace mongo {
class DbWebServer : public MiniWebServer {
public:
- DbWebServer(const string& ip, int port, const AdminAccess* webUsers)
- : MiniWebServer("admin web console", ip, port), _webUsers(webUsers) {
+ DbWebServer(const string& ip,
+ int port,
+ const AdminAccess* webUsers,
+ TransactionExperiment::Factory transactionFactory)
+ : MiniWebServer("admin web console", ip, port),
+ _webUsers(webUsers),
+ _transactionFactory(transactionFactory) {
+
WebStatusPlugin::initAll();
}
private:
const AdminAccess* _webUsers; // not owned here
+ const TransactionExperiment::Factory _transactionFactory;
void doUnlockedStuff(stringstream& ss) {
/* this is in the header already ss << "port: " << port << '\n'; */
@@ -179,6 +187,9 @@ namespace mongo {
vector<string>& headers, // if completely empty, content-type: text/html will be added
const SockAddr &from
) {
+
+ boost::scoped_ptr<TransactionExperiment> txn(_transactionFactory()); // XXX SERVER-13931
+
if ( url.size() > 1 ) {
if ( ! allowed( rq , headers, from ) ) {
@@ -206,7 +217,7 @@ namespace mongo {
uassert(13453, "server not started with --jsonp",
callback.empty() || serverGlobalParams.jsonp);
- handler->handle( rq , url , params , responseMsg , responseCode , headers , from );
+ handler->handle( txn.get(), rq , url , params , responseMsg , responseCode , headers , from );
if (responseCode == 200 && !callback.empty()) {
responseMsg = callback + '(' + responseMsg + ')';
@@ -410,7 +421,8 @@ namespace mongo {
public:
FavIconHandler() : DbWebHandler( "favicon.ico" , 0 , false ) {}
- virtual void handle( const char *rq, const std::string& url, BSONObj params,
+ virtual void handle( TransactionExperiment* txn,
+ const char *rq, const std::string& url, BSONObj params,
string& responseMsg, int& responseCode,
vector<string>& headers, const SockAddr &from ) {
responseCode = 404;
@@ -424,7 +436,8 @@ namespace mongo {
public:
StatusHandler() : DbWebHandler( "_status" , 1 , false ) {}
- virtual void handle( const char *rq, const std::string& url, BSONObj params,
+ virtual void handle( TransactionExperiment* txn,
+ const char *rq, const std::string& url, BSONObj params,
string& responseMsg, int& responseCode,
vector<string>& headers, const SockAddr &from ) {
headers.push_back( "Content-Type: application/json;charset=utf-8" );
@@ -459,7 +472,7 @@ namespace mongo {
string errmsg;
BSONObjBuilder sub;
- if ( ! c->run( "admin.$cmd" , co , 0, errmsg , sub , false ) )
+ if ( ! c->newRun( txn, "admin.$cmd" , co , 0, errmsg , sub , false ) )
buf.append( cmd , errmsg );
else
buf.append( cmd , sub.obj() );
@@ -475,7 +488,8 @@ namespace mongo {
public:
CommandListHandler() : DbWebHandler( "_commands" , 1 , true ) {}
- virtual void handle( const char *rq, const std::string& url, BSONObj params,
+ virtual void handle( TransactionExperiment* txn,
+ const char *rq, const std::string& url, BSONObj params,
string& responseMsg, int& responseCode,
vector<string>& headers, const SockAddr &from ) {
headers.push_back( "Content-Type: text/html;charset=utf-8" );
@@ -527,7 +541,8 @@ namespace mongo {
return _cmd(cmd) != 0;
}
- virtual void handle( const char *rq, const std::string& url, BSONObj params,
+ virtual void handle( TransactionExperiment* txn,
+ const char *rq, const std::string& url, BSONObj params,
string& responseMsg, int& responseCode,
vector<string>& headers, const SockAddr &from ) {
string cmd;
@@ -540,7 +555,7 @@ namespace mongo {
Client& client = cc();
BSONObjBuilder result;
- Command::execCommand(c, client, 0, "admin.", cmdObj , result, false);
+ Command::execCommand(txn, c, client, 0, "admin.", cmdObj , result, false);
responseCode = 200;
@@ -561,11 +576,12 @@ namespace mongo {
// --- external ----
- void webServerThread(const AdminAccess* adminAccess) {
+ void webServerThread(const AdminAccess* adminAccess,
+ TransactionExperiment::Factory transactionFactory) {
boost::scoped_ptr<const AdminAccess> adminAccessPtr(adminAccess); // adminAccess is owned here
Client::initThread("websvr");
const int p = serverGlobalParams.port + 1000;
- DbWebServer mini(serverGlobalParams.bind_ip, p, adminAccessPtr.get());
+ DbWebServer mini(serverGlobalParams.bind_ip, p, adminAccessPtr.get(), transactionFactory);
mini.setupSockets();
mini.initAndListen();
cc().shutdown();