summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2010-06-15 11:40:53 -0700
committerAaron <aaron@10gen.com>2010-06-15 11:40:53 -0700
commit1f9c1d6a3d88301f13f0e4db9cd368819833dad2 (patch)
treedec913869a32dc021a894ab046a9d32768e52cd1
parenta739b8df76503cb3a71d823791d3d859dbb6afda (diff)
parent19a0eca57a7e8907697a6c0a2acf67822ee55c07 (diff)
downloadmongo-1f9c1d6a3d88301f13f0e4db9cd368819833dad2.tar.gz
Merge branch 'master' of github.com:mongodb/mongo
-rw-r--r--SConstruct6
-rwxr-xr-xbuildscripts/smoke.py17
-rw-r--r--db/database.cpp54
-rw-r--r--db/database.h28
-rw-r--r--db/instance.cpp4
-rw-r--r--db/instance.h2
-rw-r--r--db/namespace.h3
-rw-r--r--jstests/rs/rs_basic.js15
-rw-r--r--jstests/rs/test_framework.js8
-rw-r--r--s/chunk.cpp2
-rw-r--r--s/shard.cpp11
-rw-r--r--s/shard.h18
-rw-r--r--shell/dbshell.cpp15
-rw-r--r--shell/msvc/mongo.vcxproj13
-rw-r--r--shell/msvc/mongo.vcxproj.filters3
15 files changed, 136 insertions, 63 deletions
diff --git a/SConstruct b/SConstruct
index b31d68f13bf..f39fb1eace3 100644
--- a/SConstruct
+++ b/SConstruct
@@ -641,6 +641,10 @@ elif "win32" == os.sys.platform:
env.Append( CPPFLAGS=' /Fd"mongod.pdb" ' )
env.Append( LINKFLAGS=" /debug " )
+ if os.path.exists("../readline/lib") :
+ env.Append( LIBPATH=["../readline/lib"] )
+ env.Append( CPPPATH=["../readline/include"] )
+
if force64 and os.path.exists( boostDir + "/lib/vs2010_64" ):
env.Append( LIBPATH=[ boostDir + "/lib/vs2010_64" ] )
elif not force64 and os.path.exists( boostDir + "/lib/vs2010_32" ):
@@ -988,7 +992,7 @@ def doConfigure( myenv , needPcre=True , shell=False ):
myCheckLib( "ncurses" , staticOnly=release )
myCheckLib( "tinfo" , staticOnly=release )
else:
- print( "warning: no readline, shell will be a bit ugly" )
+ print( "\n*** warning: no readline library, mongo shell will not have nice interactive line editing ***\n" )
if linux:
myCheckLib( "rt" , True )
diff --git a/buildscripts/smoke.py b/buildscripts/smoke.py
index ad577ce10c4..16707795f56 100755
--- a/buildscripts/smoke.py
+++ b/buildscripts/smoke.py
@@ -173,6 +173,8 @@ def checkDbHashes(master, slave):
ARB=10 # ARBITRARY
time.sleep(ARB)
while True:
+ # FIXME: it's probably better to do an empty insert and a
+ # getLastError() to force a sync.
argv = [shellExecutable, "--port", str(slave.port), "--quiet", "--eval", 'db.printSlaveReplicationInfo()']
res = Popen(argv, stdout=PIPE).communicate()[0]
m = re.search('(\d+)secs ', res)
@@ -180,6 +182,7 @@ def checkDbHashes(master, slave):
break
time.sleep(3)
+ # FIXME: maybe make this run dbhash on all databases?
for mongod in [master, slave]:
argv = [shellExecutable, "--port", str(mongod.port), "--quiet", "--eval", "x=db.runCommand('dbhash'); printjson(x.collections)"]
hashstr = Popen(argv, stdout=PIPE).communicate()[0]
@@ -253,8 +256,8 @@ def runTests(tests):
with mongod(slave=True) if oneMongodPerTest and smallOplog else nothing() as slave2:
runTest(test)
winners.append(test)
-# if isinstance(slave2, mongod):
-# checkDbHashes(master2, slave2)
+ if isinstance(slave2, mongod):
+ checkDbHashes(master2, slave2)
except TestFailure, f:
try:
print f
@@ -267,8 +270,8 @@ def runTests(tests):
except TestFailure, f:
if not continueOnFailure:
return 1
-# if isinstance(slave1, mongod):
-# checkDbHashes(master1, slave1)
+ if isinstance(slave1, mongod):
+ checkDbHashes(master1, slave1)
return 0
@@ -296,7 +299,7 @@ at the end of testing:"""
for db in screwy_in_slave.keys():
print "%s\t %s" % (db, screwy_in_slave[db])
if smallOplog and not (lost_in_master or lost_in_slave or screwy_in_slave):
- print "replication ok for %d databases" % (len(replicated_dbs))
+ print "replication ok for %d collections" % (len(replicated_dbs))
if (exit_bad or losers or lost_in_slave or lost_in_master or screwy_in_slave):
status = 1
else:
@@ -349,7 +352,9 @@ def expandSuites(suites):
if globstr:
globstr = mongoRepo+('jstests/' if globstr.endswith('.js') else '')+globstr
- tests += [(path, usedb) for path in glob.glob(globstr)]
+ paths = glob.glob(globstr)
+ paths.sort()
+ tests += [(path, usedb) for path in paths]
return tests
def main():
diff --git a/db/database.cpp b/db/database.cpp
index 8bf865b537f..d427a3a874f 100644
--- a/db/database.cpp
+++ b/db/database.cpp
@@ -19,11 +19,61 @@
#include "pch.h"
#include "pdfile.h"
#include "database.h"
+#include "instance.h"
namespace mongo {
bool Database::_openAllFiles = false;
+ Database::Database(const char *nm, bool& newDb, const string& _path )
+ : name(nm), path(_path), namespaceIndex( path, name ) {
+
+ { // check db name is valid
+ size_t L = strlen(nm);
+ uassert( 10028 , "db name is empty", L > 0 );
+ uassert( 10029 , "bad db name [1]", *nm != '.' );
+ uassert( 10030 , "bad db name [2]", nm[L-1] != '.' );
+ uassert( 10031 , "bad char(s) in db name", strchr(nm, ' ') == 0 );
+ uassert( 10032 , "db name too long", L < 64 );
+ }
+
+ newDb = namespaceIndex.exists();
+ profile = 0;
+ profileName = name + ".system.profile";
+
+ {
+ vector<string> others;
+ getDatabaseNames( others , path );
+
+ for ( unsigned i=0; i<others.size(); i++ ){
+
+ if ( strcasecmp( others[i].c_str() , nm ) )
+ continue;
+
+ if ( strcmp( others[i].c_str() , nm ) == 0 )
+ continue;
+
+ stringstream ss;
+ ss << "db already exists with different case: " << others[i];
+ uasserted( 13297 , ss.str() );
+ }
+ }
+
+
+ // If already exists, open. Otherwise behave as if empty until
+ // there's a write, then open.
+ if ( ! newDb || cmdLine.defaultProfile ) {
+ namespaceIndex.init();
+ if( _openAllFiles )
+ openAllFiles();
+
+ }
+
+
+ magic = 781231;
+ }
+
+
bool Database::setProfilingLevel( int newLevel , string& errmsg ){
if ( profile == newLevel )
return true;
@@ -62,7 +112,9 @@ namespace mongo {
}
bool Database::validDBName( const string& ns ){
- size_t good = strcspn( ns.c_str() , "/\\." );
+ if ( ns.size() == 0 || ns.size() > 64 )
+ return false;
+ size_t good = strcspn( ns.c_str() , "/\\. " );
return good == ns.size();
}
diff --git a/db/database.h b/db/database.h
index 88723f2b146..6378b2ebfa1 100644
--- a/db/database.h
+++ b/db/database.h
@@ -32,33 +32,7 @@ namespace mongo {
public:
static bool _openAllFiles;
- Database(const char *nm, bool& newDb, const string& _path = dbpath)
- : name(nm), path(_path), namespaceIndex( path, name ) {
-
- { // check db name is valid
- size_t L = strlen(nm);
- uassert( 10028 , "db name is empty", L > 0 );
- uassert( 10029 , "bad db name [1]", *nm != '.' );
- uassert( 10030 , "bad db name [2]", nm[L-1] != '.' );
- uassert( 10031 , "bad char(s) in db name", strchr(nm, ' ') == 0 );
- uassert( 10032 , "db name too long", L < 64 );
- }
-
- newDb = namespaceIndex.exists();
- profile = 0;
- profileName = name + ".system.profile";
-
- // If already exists, open. Otherwise behave as if empty until
- // there's a write, then open.
- if ( ! newDb || cmdLine.defaultProfile ) {
- namespaceIndex.init();
- if( _openAllFiles )
- openAllFiles();
-
- }
-
- magic = 781231;
- }
+ Database(const char *nm, bool& newDb, const string& _path = dbpath);
~Database() {
magic = 0;
diff --git a/db/instance.cpp b/db/instance.cpp
index 126c21efb81..457f3ccecee 100644
--- a/db/instance.cpp
+++ b/db/instance.cpp
@@ -563,8 +563,8 @@ namespace mongo {
Message & container;
};
- void getDatabaseNames( vector< string > &names ) {
- boost::filesystem::path path( dbpath );
+ void getDatabaseNames( vector< string > &names , const string& usePath ) {
+ boost::filesystem::path path( usePath );
for ( boost::filesystem::directory_iterator i( path );
i != boost::filesystem::directory_iterator(); ++i ) {
if ( directoryperdb ) {
diff --git a/db/instance.h b/db/instance.h
index 351726c7f0a..c5ab6a5fa0c 100644
--- a/db/instance.h
+++ b/db/instance.h
@@ -104,7 +104,7 @@ namespace mongo {
bool assembleResponse( Message &m, DbResponse &dbresponse, const SockAddr &client = unknownAddress );
- void getDatabaseNames( vector< string > &names );
+ void getDatabaseNames( vector< string > &names , const string& usePath = dbpath );
// --- local client ---
diff --git a/db/namespace.h b/db/namespace.h
index d132272d0fc..cc19c97720d 100644
--- a/db/namespace.h
+++ b/db/namespace.h
@@ -640,8 +640,9 @@ namespace mongo {
NamespaceDetails::Extra* newExtra(const char *ns, int n, NamespaceDetails *d);
- private:
boost::filesystem::path path() const;
+ private:
+
void maybeMkdir() const;
MMF f;
diff --git a/jstests/rs/rs_basic.js b/jstests/rs/rs_basic.js
index 8b0e3df6408..c6784fad442 100644
--- a/jstests/rs/rs_basic.js
+++ b/jstests/rs/rs_basic.js
@@ -7,9 +7,18 @@ function go() {
b = rs_mongod();
x = a.getDB("admin");
- y = b.getDB("admin");
-
- print("started 2");
+ y = b.getDB("admin");
+
+ print("rs_basic: started 2 servers");
+
+ assert(__nextPort == 27000);
+
+ var cfg = { _id: 'asdf', members: [] };
+ var hn = hostname();
+ cfg.members[0] = { _id: 0, host: hn };
+ cfg.members[1] = { _id: 1, host: hn + ":27001" };
+
+ print(tojson(cfg));
}
print("type go() to run");
diff --git a/jstests/rs/test_framework.js b/jstests/rs/test_framework.js
index ec8260b9123..d636da38cab 100644
--- a/jstests/rs/test_framework.js
+++ b/jstests/rs/test_framework.js
@@ -1,12 +1,10 @@
// test helpers
// load("test_framework.js")
-/* run mongod for a replica set member
- wipes data dir!
-*/
function rs_mongod() {
+ /* run mongod for a replica set member. wipes data dir! */
var port = __nextPort++;
- var not_me = (port == 27000 ? port+1 : port-1);
+ var not_me = (port == 27000 ? port + 1 : port - 1);
var f = startMongodEmpty;
var dir = "" + port; // e.g., data/db/27000
var conn = f.apply(null, [
@@ -17,7 +15,7 @@ function rs_mongod() {
smallfiles: "",
oplogSize: "2",
//nohttpinterface: ""
- rest: "",
+ rest: "", // --rest is best for replica set administration
replSet: "asdf/" + hostname() + ":" + not_me
}
]
diff --git a/s/chunk.cpp b/s/chunk.cpp
index 972558e2b29..b35ac776382 100644
--- a/s/chunk.cpp
+++ b/s/chunk.cpp
@@ -341,7 +341,7 @@ namespace mongo {
return 0;
}
- log() << "moving chunk (auto): " << toMove->toString() << " to: " << newLocation.toString() << " #objcets: " << toMove->countObjects() << endl;
+ log() << "moving chunk (auto): " << toMove->toString() << " to: " << newLocation.toString() << " #objects: " << toMove->countObjects() << endl;
string errmsg;
massert( 10412 , (string)"moveAndCommit failed: " + errmsg ,
diff --git a/s/shard.cpp b/s/shard.cpp
index c8ca41b884a..cec5ea53c4d 100644
--- a/s/shard.cpp
+++ b/s/shard.cpp
@@ -52,7 +52,13 @@ namespace mongo {
maxSize = maxSizeElem.numberLong();
}
- Shard s( name , host , maxSize );
+ bool isDraining = false;
+ BSONElement isDrainingElem = o["isDraining"];
+ if ( ! isDrainingElem.eoo() ){
+ isDraining = isDrainingElem.Bool();
+ }
+
+ Shard s( name , host , maxSize , isDraining );
_lookup[name] = s;
_lookup[host] = s;
}
@@ -118,6 +124,7 @@ namespace mongo {
_name = s._name;
_addr = s._addr;
_maxSize = s._maxSize;
+ _isDraining = s._isDraining;
}
void Shard::getAllShards( vector<Shard>& all ){
@@ -172,7 +179,7 @@ namespace mongo {
ShardStatus::ShardStatus( const Shard& shard , const BSONObj& obj )
: _shard( shard ) {
_mapped = obj.getFieldDotted( "mem.mapped" ).numberLong();
- _writeLock = 0; // TOOD
+ _writeLock = 0; // TODO
}
diff --git a/s/shard.h b/s/shard.h
index 2e6a054866c..f97ff300c52 100644
--- a/s/shard.h
+++ b/s/shard.h
@@ -29,10 +29,11 @@ namespace mongo {
class Shard {
public:
Shard()
- : _name(""), _addr(""), _maxSize(0){
+ : _name("") , _addr("") , _maxSize(0) , _isDraining( false ){
}
- Shard( const string& name , const string& addr, long long maxSize = 0)
- : _name(name), _addr( addr ), _maxSize( maxSize ){
+
+ Shard( const string& name , const string& addr, long long maxSize = 0 , bool isDraining = false )
+ : _name(name) , _addr( addr ) , _maxSize( maxSize ) , _isDraining( isDraining ){
}
Shard( const string& ident ){
@@ -40,11 +41,11 @@ namespace mongo {
}
Shard( const Shard& other )
- : _name( other._name ) , _addr( other._addr ), _maxSize( other._maxSize ){
+ : _name( other._name ) , _addr( other._addr ) , _maxSize( other._maxSize ) , _isDraining( other._isDraining ){
}
Shard( const Shard* other )
- : _name( other->_name ) ,_addr( other->_addr ), _maxSize( other->_maxSize ){
+ : _name( other->_name ) , _addr( other->_addr ), _maxSize( other->_maxSize ) , _isDraining( other->_isDraining ){
}
static Shard make( const string& ident ){
@@ -74,6 +75,10 @@ namespace mongo {
return _maxSize;
}
+ bool isDraining() const {
+ return _isDraining;
+ }
+
string toString() const {
return _name + ":" + _addr;
}
@@ -134,7 +139,8 @@ namespace mongo {
private:
string _name;
string _addr;
- long long _maxSize; // in MBytes, 0 is unlimited
+ long long _maxSize; // in MBytes, 0 is unlimited
+ bool _isDraining; // shard is currently being removed
};
class ShardStatus {
diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp
index 5d8946bfdc5..a91b93c7d18 100644
--- a/shell/dbshell.cpp
+++ b/shell/dbshell.cpp
@@ -18,6 +18,12 @@
#include "pch.h"
#include <stdio.h>
+#if defined(_WIN32)
+# if defined(USE_READLINE)
+# define USE_READLINE_STATIC
+# endif
+#endif
+
#ifdef USE_READLINE
#include <readline/readline.h>
#include <readline/history.h>
@@ -174,6 +180,13 @@ void quitNicely( int sig ){
shellHistoryDone();
exit(0);
}
+#else
+void quitNicely( int sig ){
+ mongo::goingAway = true;
+ //killOps();
+ shellHistoryDone();
+ exit(0);
+}
#endif
char * shellReadline( const char * prompt , int handlesigint = 0 ){
@@ -195,7 +208,7 @@ char * shellReadline( const char * prompt , int handlesigint = 0 ){
#endif
char * ret = readline( prompt );
- signal( SIGINT , quitNicely );
+ signal( SIGINT , quitNicely );
return ret;
#else
printf("%s", prompt); cout.flush();
diff --git a/shell/msvc/mongo.vcxproj b/shell/msvc/mongo.vcxproj
index cf258c072af..8b78a5257aa 100644
--- a/shell/msvc/mongo.vcxproj
+++ b/shell/msvc/mongo.vcxproj
@@ -41,10 +41,10 @@
<LinkIncremental>true</LinkIncremental>
<LibraryPath>\boost\lib\vs2010_32\;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>
<ExecutablePath>$(VCInstallDir)bin;$(WindowsSdkDir)bin\NETFX 4.0 Tools;$(WindowsSdkDir)bin;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;$(ProgramFiles)\HTML Help Workshop;$(FrameworkSDKDir)\bin;$(MSBuildToolsPath32);$(VSInstallDir);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
- <IncludePath>..\..\..\js\src\;..\..\pcre-7.4;..\..\;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;</IncludePath>
+ <IncludePath>..\..\..\readline\include;..\..\..\js\src\;..\..\pcre-7.4;..\..\;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <IncludePath>..\..\..\js\src\;..\..\pcre-7.4;..\..\;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include;</IncludePath>
+ <IncludePath>..\..\..\readline\include;..\..\..\js\src\;..\..\pcre-7.4;..\..\;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include</IncludePath>
<LinkIncremental>false</LinkIncremental>
<LibraryPath>\boost\lib\vs2010_32\;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib</LibraryPath>
</PropertyGroup>
@@ -53,7 +53,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
- <PreprocessorDefinitions>XP_WIN;PCRE_STATIC;HAVE_CONFIG_H;OLDJS;MONGO_EXPOSE_MACROS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>USE_READLINE;XP_WIN;PCRE_STATIC;HAVE_CONFIG_H;OLDJS;MONGO_EXPOSE_MACROS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>\boost\</AdditionalIncludeDirectories>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<DisableSpecificWarnings>4355;4800;4267;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
@@ -71,7 +71,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <PreprocessorDefinitions>XP_WIN;_WIN32;PCRE_STATIC;HAVE_CONFIG_H;OLDJS;MONGO_EXPOSE_MACROS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <PreprocessorDefinitions>USE_READLINE;XP_WIN;_WIN32;PCRE_STATIC;HAVE_CONFIG_H;OLDJS;MONGO_EXPOSE_MACROS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>\boost\</AdditionalIncludeDirectories>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
@@ -213,9 +213,11 @@
<ClCompile Include="..\dbshell.cpp" />
<ClCompile Include="..\mongo-server.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
- <ClCompile Include="..\mongo.cpp">
+ <ClCompile Include="..\mongo_vstudio.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\shell_utils.cpp" />
</ItemGroup>
@@ -237,6 +239,7 @@
<Library Include="..\..\..\js\js32r.lib">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
</Library>
+ <Library Include="..\..\..\readline\lib\readline.lib" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\db\lasterror.h" />
diff --git a/shell/msvc/mongo.vcxproj.filters b/shell/msvc/mongo.vcxproj.filters
index df87998b04a..762cd791dad 100644
--- a/shell/msvc/mongo.vcxproj.filters
+++ b/shell/msvc/mongo.vcxproj.filters
@@ -210,7 +210,7 @@
<ClCompile Include="..\..\db\common.cpp">
<Filter>db</Filter>
</ClCompile>
- <ClCompile Include="..\mongo.cpp">
+ <ClCompile Include="..\mongo_vstudio.cpp">
<Filter>shell\generated_from_js</Filter>
</ClCompile>
<ClCompile Include="..\mongo-server.cpp">
@@ -247,6 +247,7 @@
<ItemGroup>
<Library Include="..\..\..\js\js32d.lib" />
<Library Include="..\..\..\js\js32r.lib" />
+ <Library Include="..\..\..\readline\lib\readline.lib" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\db\lasterror.h">