00001
00017 #pragma once
00018
00019 #include "../pch.h"
00020 #include "jsobj.h"
00021
00022 namespace mongo {
00023
00024
00025
00026
00027 struct CmdLine {
00028
00029 CmdLine() :
00030 port(DefaultDBPort), rest(false), jsonp(false), quiet(false), noTableScan(false), prealloc(true), smallfiles(sizeof(int*) == 4),
00031 quota(false), quotaFiles(8), cpu(false), durOptions(0), oplogSize(0), defaultProfile(0), slowMS(100), pretouch(0), moveParanoia( true ),
00032 syncdelay(60), socket("/tmp") {
00033
00034 #if defined(_DURABLEDEFAULTON)
00035 dur = true;
00036 #else
00037 dur = false;
00038 #endif
00039 }
00040
00041 string binaryName;
00042 string cwd;
00043
00044 int port;
00045 enum {
00046 DefaultDBPort = 27017,
00047 ConfigServerPort = 27019,
00048 ShardServerPort = 27018
00049 };
00050 bool isDefaultPort() const { return port == DefaultDBPort; }
00051
00052 string bind_ip;
00053 bool rest;
00054 bool jsonp;
00055
00056 string _replSet;
00057 string ourSetName() const {
00058 string setname;
00059 size_t sl = _replSet.find('/');
00060 if( sl == string::npos )
00061 return _replSet;
00062 return _replSet.substr(0, sl);
00063 }
00064 bool usingReplSets() const { return !_replSet.empty(); }
00065
00066
00067 string source;
00068 string only;
00069
00070 bool quiet;
00071 bool noTableScan;
00072 bool prealloc;
00073 bool smallfiles;
00074
00075 bool quota;
00076 int quotaFiles;
00077 bool cpu;
00078
00079 bool dur;
00080
00084 enum {
00085 DurDumpJournal = 1,
00086 DurScanOnly = 2,
00087 DurRecoverOnly = 4,
00088 DurParanoid = 8,
00089 DurAlwaysCommit = 16
00090 };
00091 int durOptions;
00092
00093 long long oplogSize;
00094 int defaultProfile;
00095 int slowMS;
00096
00097 int pretouch;
00098 bool moveParanoia;
00099 double syncdelay;
00100
00101 string socket;
00102
00103 static void addGlobalOptions( boost::program_options::options_description& general ,
00104 boost::program_options::options_description& hidden );
00105
00106 static void addWindowsOptions( boost::program_options::options_description& windows ,
00107 boost::program_options::options_description& hidden );
00108
00109
00113 static bool store( int argc , char ** argv ,
00114 boost::program_options::options_description& visible,
00115 boost::program_options::options_description& hidden,
00116 boost::program_options::positional_options_description& positional,
00117 boost::program_options::variables_map &output );
00118 };
00119
00120 extern CmdLine cmdLine;
00121
00122 void setupCoreSignals();
00123
00124 string prettyHostName();
00125
00126
00134 class ParameterValidator {
00135 public:
00136 ParameterValidator( const string& name );
00137 virtual ~ParameterValidator() {}
00138
00139 virtual bool isValid( BSONElement e , string& errmsg ) = 0;
00140
00141 static ParameterValidator * get( const string& name );
00142
00143 private:
00144 string _name;
00145
00146
00147 static map<string,ParameterValidator*> * _all;
00148 };
00149
00150 }