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

149 lines
5.3 KiB
C
Raw Normal View History

2009-08-25 16:24:44 +02:00
/**
* Copyright (C) 2008 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
2010-04-27 21:27:52 +02:00
#include "../pch.h"
#include "jsobj.h"
2009-08-25 16:24:44 +02:00
namespace mongo {
2009-10-08 22:29:04 +02:00
2009-08-25 20:35:22 +02:00
/* command line options
*/
/* concurrency: OK/READ */
2009-08-25 16:24:44 +02:00
struct CmdLine {
CmdLine() :
port(DefaultDBPort), rest(false), jsonp(false), quiet(false), noTableScan(false), prealloc(true), smallfiles(false),
2010-12-13 20:47:11 +01:00
quota(false), quotaFiles(8), cpu(false), durOptions(0), oplogSize(0), defaultProfile(0), slowMS(100), pretouch(0), moveParanoia( true ),
syncdelay(60)
{
// default may change for this later.
#if defined(_DURABLEDEFAULTON)
dur = true;
#else
dur = false;
#endif
}
2010-10-14 20:07:36 +02:00
2010-09-10 22:20:50 +02:00
string binaryName; // mongod or mongos
2009-08-25 20:35:22 +02:00
int port; // --port
2010-10-14 20:06:39 +02:00
enum {
DefaultDBPort = 27017,
ConfigServerPort = 27019,
ShardServerPort = 27018
};
bool isDefaultPort() const { return port == DefaultDBPort; }
2010-07-27 15:59:34 +02:00
string bind_ip; // --bind_ip
bool rest; // --rest
2010-11-27 00:18:24 +01:00
bool jsonp; // --jsonp
2009-10-08 22:29:04 +02:00
2010-08-02 21:21:26 +02:00
string _replSet; // --replSet[/<seedlist>]
string ourSetName() const {
string setname;
size_t sl = _replSet.find('/');
if( sl == string::npos )
return _replSet;
return _replSet.substr(0, sl);
}
bool usingReplSets() const { return !_replSet.empty(); }
2010-08-02 21:21:26 +02:00
2010-11-27 00:18:24 +01:00
// for master/slave replication
2009-08-25 20:35:22 +02:00
string source; // --source
string only; // --only
2009-10-20 19:29:05 +02:00
2009-08-25 20:35:22 +02:00
bool quiet; // --quiet
2010-11-27 00:18:24 +01:00
bool noTableScan; // --notablescan no table scans allowed
bool prealloc; // --noprealloc no preallocation of data files
bool smallfiles; // --smallfiles allocate smaller data files
2009-10-16 17:36:38 +02:00
bool quota; // --quota
2009-10-20 19:29:05 +02:00
int quotaFiles; // --quotaFiles
2009-10-16 17:36:38 +02:00
bool cpu; // --cpu show cpu time periodically
2010-11-28 16:13:01 +01:00
bool dur; // --dur durability
2010-12-08 14:16:29 +01:00
2010-12-13 20:47:11 +01:00
/** --durOptions 7 dump journal and terminate without doing anything further
--durOptions 4 recover and terminate without listening
2010-12-08 14:16:29 +01:00
*/
enum { // bits to be ORed
2010-11-27 00:18:24 +01:00
DurDumpJournal = 1, // dump diagnostics on the journal during recovery
DurScanOnly = 2, // don't do any real work, just scan and dump if dump specified
DurRecoverOnly = 4, // terminate after recovery step
DurParanoid = 8, // paranoid mode enables extra checks
DurAlwaysCommit = 16 // do a group commit every time the writelock is released
2010-11-27 00:18:24 +01:00
};
2010-12-13 20:47:11 +01:00
int durOptions; // --durOptions <n> for debugging
2010-11-27 00:18:24 +01:00
2009-10-17 05:32:34 +02:00
long long oplogSize; // --oplogSize
int defaultProfile; // --profile
int slowMS; // --time in ms that is "slow"
2010-07-04 15:48:34 +02:00
int pretouch; // --pretouch for replication application (experimental)
bool moveParanoia; // for move chunk paranoia
double syncdelay; // seconds between fsyncs
static void addGlobalOptions( boost::program_options::options_description& general ,
boost::program_options::options_description& hidden );
static void addWindowsOptions( boost::program_options::options_description& windows ,
boost::program_options::options_description& hidden );
/**
* @return true if should run program, false if should exit
*/
static bool store( int argc , char ** argv ,
boost::program_options::options_description& visible,
boost::program_options::options_description& hidden,
boost::program_options::positional_options_description& positional,
boost::program_options::variables_map &output );
2009-08-25 16:24:44 +02:00
};
2009-08-25 16:24:44 +02:00
extern CmdLine cmdLine;
2010-11-28 16:13:01 +01:00
void setupCoreSignals();
string prettyHostName();
/**
* used for setParameter
* so you can write validation code that lives with code using it
* rather than all in the command place
* also lets you have mongos or mongod specific code
* without pulling it all sorts of things
*/
class ParameterValidator {
public:
ParameterValidator( const string& name );
virtual ~ParameterValidator(){}
virtual bool isValid( BSONElement e , string& errmsg ) = 0;
static ParameterValidator * get( const string& name );
private:
string _name;
// don't need to lock since this is all done in static init
static map<string,ParameterValidator*> * _all;
};
2009-08-25 16:24:44 +02:00
}