Skip to content

Commit b4cafb4

Browse files
committed
SERVER-13635 SERVER-1153: can choose heap1 at startup, but doesn't remotely work yet
1 parent 7ce2ffd commit b4cafb4

35 files changed

+344
-152
lines changed

src/mongo/SConscript

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ serverOnlyFiles = [ "db/curop.cpp",
560560
"db/storage/mmap_v1/mmap_v1_database_catalog_entry.cpp",
561561
"db/storage/mmap_v1/mmap_v1_engine.cpp",
562562
"db/storage/mmap_v1/repair_database.cpp",
563+
"db/storage/storage_engine.cpp",
563564
"db/operation_context_impl.cpp",
564565
"db/storage/mmap_v1/mmap_v1_extent_manager.cpp",
565566
"db/introspect.cpp",
@@ -917,6 +918,7 @@ env.Library("serveronly", serverOnlyFiles,
917918
"db/repl/repl_settings",
918919
"db/repl/replication_executor",
919920
'db/storage/extent',
921+
'db/storage/heap1/storage_heap1',
920922
'db/structure/record_store',
921923
'db/structure/record_store_v1',
922924
'db/structure/btree/btree',

src/mongo/db/catalog/database.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ namespace mongo {
104104

105105
Database::Database(OperationContext* txn,
106106
const std::string& name,
107-
bool& newDb,
108107
DatabaseCatalogEntry* dbEntry )
109108
: _name(name),
110109
_dbEntry( dbEntry ),
@@ -120,7 +119,6 @@ namespace mongo {
120119
}
121120

122121
_profile = serverGlobalParams.defaultProfile;
123-
newDb = !_dbEntry->exists();
124122
}
125123

126124

src/mongo/db/catalog/database.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ namespace mongo {
5858
// you probably need to be in dbHolderMutex when constructing this
5959
Database(OperationContext* txn,
6060
const std::string& name,
61-
bool& newDb, /* out */
6261
DatabaseCatalogEntry* dbEntry );
6362

6463
/* you must use this to close - there is essential code in this method that is not in the ~Database destructor.

src/mongo/db/catalog/database_holder.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,13 @@ namespace mongo {
9494
cc().writeHappened();
9595

9696
// this locks _m for defensive checks, so we don't want to be locked right here :
97+
invariant( globalStorageEngine );
98+
DatabaseCatalogEntry* entry = globalStorageEngine->getDatabaseCatalogEntry( txn, dbname );
99+
invariant( entry );
100+
justCreated = !entry->exists();
97101
Database *db = new Database(txn,
98102
dbname,
99-
justCreated,
100-
globalStorageEngine->getDatabaseCatalogEntry( txn, dbname ) );
103+
entry );
101104

102105
{
103106
SimpleMutex::scoped_lock lk(_m);

src/mongo/db/commands/apply_ops.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ namespace mongo {
9191
while ( i.more() ) {
9292
BSONObj f = i.next().Obj();
9393

94+
DBDirectClient db( txn );
9495
BSONObj realres = db.findOne( f["ns"].String() , f["q"].Obj() );
9596

9697
// Apply-ops would never have a $where matcher, so use the default callback,
@@ -172,8 +173,6 @@ namespace mongo {
172173
return errors == 0;
173174
}
174175

175-
DBDirectClient db;
176-
177176
} applyOpsCmd;
178177

179178
}

src/mongo/db/commands/drop_indexes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ namespace mongo {
215215
}
216216

217217
bool run(OperationContext* txn, const string& dbname , BSONObj& jsobj, int, string& errmsg, BSONObjBuilder& result, bool /*fromRepl*/) {
218-
static DBDirectClient db;
218+
DBDirectClient db;
219219

220220
BSONElement e = jsobj.firstElement();
221221
string toDeleteNs = dbname + '.' + e.valuestr();

src/mongo/db/instance.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#include "mongo/db/storage/mmap_v1/dur_commitjob.h"
5757
#include "mongo/db/storage/mmap_v1/dur_journal.h"
5858
#include "mongo/db/storage/mmap_v1/dur_recover.h"
59-
#include "mongo/db/storage/mmap_v1/mmap_v1_engine.h"
6059
#include "mongo/db/operation_context_impl.h"
6160
#include "mongo/db/global_optime.h"
6261
#include "mongo/db/global_environment_experiment.h"
@@ -115,8 +114,6 @@ namespace mongo {
115114
HANDLE lockFileHandle;
116115
#endif
117116

118-
StorageEngine* globalStorageEngine = new MMAPV1Engine(); // TODO: put this somewhere else
119-
120117
MONGO_FP_DECLARE(rsStopGetMore);
121118

122119
void inProgCmd( Message &m, DbResponse &dbresponse ) {
@@ -551,7 +548,8 @@ namespace mongo {
551548
invariant(txn->lockState()->isW());
552549

553550
Database* database = dbHolder().get(txn, db);
554-
invariant(database != NULL);
551+
if ( !database )
552+
return;
555553

556554
repl::oplogCheckCloseDatabase(txn, database); // oplog caches some things, dirty its caches
557555

@@ -1020,7 +1018,9 @@ namespace {
10201018
return new DBDirectClient();
10211019
}
10221020

1023-
MONGO_INITIALIZER(CreateJSDirectClient)
1021+
MONGO_INITIALIZER_GENERAL(CreateJSDirectClient,
1022+
("StorageEngineInit"),
1023+
MONGO_NO_DEPENDENTS)
10241024
(InitializerContext* context) {
10251025

10261026
directDBClient = createDirectClient();

src/mongo/db/mongod_options.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ namespace mongo {
155155

156156
// Storage Options
157157

158+
general_options.addOptionChaining("storage.engine", "storageEngine", moe::String,
159+
"what storage engine to use")
160+
.setDefault(moe::Value(std::string("mmapv1")));
161+
162+
158163
#ifdef _WIN32
159164
boost::filesystem::path currentPath = boost::filesystem::current_path();
160165

@@ -859,6 +864,8 @@ namespace mongo {
859864
"files");
860865
}
861866

867+
storageGlobalParams.engine = params["storage.engine"].as<string>();
868+
862869
if (params.count("storage.dbPath")) {
863870
storageGlobalParams.dbpath = params["storage.dbPath"].as<string>();
864871
if (params.count("processManagement.fork") && storageGlobalParams.dbpath[0] != '/') {

src/mongo/db/operation_context_impl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@
3434
#include "mongo/db/namespace_string.h"
3535
#include "mongo/db/repl/is_master.h"
3636
#include "mongo/db/repl/repl_coordinator_global.h"
37-
#include "mongo/db/storage/mmap_v1/dur_recovery_unit.h"
37+
#include "mongo/db/storage/storage_engine.h"
3838
#include "mongo/platform/random.h"
3939
#include "mongo/util/fail_point_service.h"
4040

4141
namespace mongo {
4242

4343
OperationContextImpl::OperationContextImpl() {
44-
_recovery.reset(new DurRecoveryUnit(this));
44+
invariant( globalStorageEngine );
45+
_recovery.reset(globalStorageEngine->newRecoveryUnit(this));
4546
}
4647

4748
RecoveryUnit* OperationContextImpl::recoveryUnit() const {

src/mongo/db/restapi.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ namespace mongo {
7070
string& responseMsg, int& responseCode,
7171
vector<string>& headers, const SockAddr &from ) {
7272

73+
DBDirectClient db( txn );
74+
7375
string::size_type first = url.find( "/" , 1 );
7476
if ( first == string::npos ) {
7577
responseCode = 400;
@@ -106,11 +108,11 @@ namespace mongo {
106108

107109
if ( method == "GET" ) {
108110
responseCode = 200;
109-
html = handleRESTQuery( fullns , action , params , responseCode , ss );
111+
html = handleRESTQuery( db, fullns, action, params, responseCode, ss );
110112
}
111113
else if ( method == "POST" ) {
112114
responseCode = 201;
113-
handlePost( fullns , MiniWebServer::body( rq ) , params , responseCode , ss );
115+
handlePost( db, fullns, MiniWebServer::body( rq ), params, responseCode, ss );
114116
}
115117
else {
116118
responseCode = 400;
@@ -127,7 +129,8 @@ namespace mongo {
127129
responseMsg = ss.str();
128130
}
129131

130-
bool handleRESTQuery( const std::string& ns,
132+
bool handleRESTQuery( DBDirectClient& db,
133+
const std::string& ns,
131134
const std::string& action,
132135
BSONObj & params,
133136
int & responseCode,
@@ -229,7 +232,8 @@ namespace mongo {
229232
}
230233

231234
// TODO Generate id and revision per couch POST spec
232-
void handlePost( const std::string& ns,
235+
void handlePost( DBDirectClient& db,
236+
const std::string& ns,
233237
const char *body,
234238
BSONObj& params,
235239
int & responseCode,
@@ -256,8 +260,6 @@ namespace mongo {
256260
return def;
257261
}
258262

259-
DBDirectClient db;
260-
261263
} restHandler;
262264

263265
bool RestAdminAccess::haveAdminUsers(OperationContext* txn) const {

0 commit comments

Comments
 (0)