0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

--profile command line option SERVER-456

This commit is contained in:
Eliot Horowitz 2009-12-29 12:27:27 -05:00
parent 3b37c3fbd4
commit 7d65d20f5a
5 changed files with 25 additions and 6 deletions

View File

@ -37,7 +37,8 @@ namespace mongo {
bool cpu; // --cpu show cpu time periodically
long long oplogSize; // --oplogSize
int defaultProfile; // --profile
enum {
DefaultDBPort = 27017,
ConfigServerPort = 27019,
@ -46,7 +47,7 @@ namespace mongo {
CmdLine() :
port(DefaultDBPort), quiet(false), notablescan(false), prealloc(true), smallfiles(false),
quota(false), quotaFiles(8), cpu(false), oplogSize(0)
quota(false), quotaFiles(8), cpu(false), oplogSize(0), defaultProfile(0)
{ }
};

View File

@ -40,7 +40,8 @@ namespace mongo {
assert( cc().database() == this );
if ( ! nsdetails( profileName.c_str() ) ){
if ( ! namespaceIndex.details( profileName.c_str() ) ){
log(1) << "creating profile ns: " << profileName << endl;
BSONObjBuilder spec;
spec.appendBool( "capped", true );
spec.append( "size", 131072.0 );
@ -52,4 +53,12 @@ namespace mongo {
return true;
}
void Database::finishInit(){
if ( cmdLine.defaultProfile == profile )
return;
string errmsg;
massert( 12506 , errmsg , setProfilingLevel( cmdLine.defaultProfile , errmsg ) );
}
} // namespace mongo

View File

@ -18,6 +18,8 @@
#pragma once
#include "cmdline.h"
/* Database represents a database database
Each database database has its own set of files -- dbname.ns, dbname.0, dbname.1, ...
*/
@ -48,11 +50,13 @@ namespace mongo {
// If already exists, open. Otherwise behave as if empty until
// there's a write, then open.
if ( !newDb ) {
if ( ! newDb || cmdLine.defaultProfile ) {
namespaceIndex.init();
if( _openAllFiles )
openAllFiles();
}
}
~Database() {
@ -170,6 +174,8 @@ namespace mongo {
*/
bool setProfilingLevel( int newLevel , string& errmsg );
void finishInit();
vector<MongoDataFile*> files;
string name; // "alleyinsider"
string path;

View File

@ -584,6 +584,7 @@ int main(int argc, char* argv[], char *envp[] )
("repair", "run repair on all dbs")
("notablescan", "do not allow table scans")
("syncdelay",po::value<double>(&dataFileSync._sleepsecs)->default_value(60), "seconds between disk syncs (0 for never)")
("profile",po::value<int>(), "0=off 1=slow, 2=all")
#if defined(_WIN32)
("install", "install mongodb service")
("remove", "remove mongodb service")
@ -868,7 +869,8 @@ int main(int argc, char* argv[], char *envp[] )
if ( params.count("configsvr" ) && params.count( "diaglog" ) == 0 ){
_diaglog.level = 1;
}
if ( params.count( "profile" ) )
cmdLine.defaultProfile = params["profile"].as<int>();
Module::configAll( params );
dataFileSync.go();

View File

@ -101,9 +101,10 @@ namespace mongo {
bool justCreated;
Database *newdb = new Database(cl, justCreated, path);
databases[key] = newdb;
//newdb->finishInit();
cc().setns(ns, newdb);
newdb->finishInit();
return justCreated;
}