Compare commits
105 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22c7c88d01 | ||
|
|
5bd47701aa | ||
|
|
5ab9c9b6a9 | ||
|
|
672fda4244 | ||
|
|
c0acb04e0f | ||
|
|
2fd67aca84 | ||
|
|
fca1962ce4 | ||
|
|
84eab5e950 | ||
|
|
6e44c36341 | ||
|
|
639c39189f | ||
|
|
7c4cd36d0a | ||
|
|
dee49ac080 | ||
|
|
bec48b040a | ||
|
|
dfe8582685 | ||
|
|
06279cde9a | ||
|
|
677a095c22 | ||
|
|
b2973e7cc3 | ||
|
|
447c9df927 | ||
|
|
063f651c6b | ||
|
|
97515db5b8 | ||
|
|
b90ccb6652 | ||
|
|
c0a685292a | ||
|
|
cc206ecdf6 | ||
|
|
084eb0c7f2 | ||
|
|
5cf582d3d9 | ||
|
|
4a7c73f5e2 | ||
|
|
ee388151a7 | ||
|
|
8e3d106320 | ||
|
|
76d4703561 | ||
|
|
1d82d20390 | ||
|
|
de365ac8eb | ||
|
|
a05b907fc4 | ||
|
|
fcb6a16b48 | ||
|
|
074553298d | ||
|
|
92b27770be | ||
|
|
c62aa841a2 | ||
|
|
5ded448a90 | ||
|
|
d498124c60 | ||
|
|
8d182e1639 | ||
|
|
90f5b501f2 | ||
|
|
67f8e66058 | ||
|
|
3895bcd00b | ||
|
|
8cd3f5b5d4 | ||
|
|
c75c00cfa8 | ||
|
|
bf7640dfa8 | ||
|
|
d95fa41f50 | ||
|
|
e987a94c7c | ||
|
|
b790e13761 | ||
|
|
b83c5efe35 | ||
|
|
e07cbe6088 | ||
|
|
899328a8cf | ||
|
|
fc3d3acafc | ||
|
|
30c0576b8b | ||
|
|
ba32baba1c | ||
|
|
a71dbfc15a | ||
|
|
a2bc5e3269 | ||
|
|
efb769e3b6 | ||
|
|
ec1550c63d | ||
|
|
2dc3d5b577 | ||
|
|
188436f8c9 | ||
|
|
48ba6d2991 | ||
|
|
ba4cdb7b4c | ||
|
|
38a924346d | ||
|
|
be98c677cc | ||
|
|
bda359e9a1 | ||
|
|
a6d7b21ccd | ||
|
|
8a4fb8b1c7 | ||
|
|
a6d37a6d3e | ||
|
|
41232b6557 | ||
|
|
a4f9e4bc12 | ||
|
|
6a324b4a98 | ||
|
|
04aabf6194 | ||
|
|
5a2da6b86f | ||
|
|
c461be6e17 | ||
|
|
7907050da3 | ||
|
|
2ce38e3376 | ||
|
|
5b36ef5cfa | ||
|
|
56b803b9f2 | ||
|
|
48c7684617 | ||
|
|
17a2a93bb5 | ||
|
|
2b59b7f0c5 | ||
|
|
dc1ebc586e | ||
|
|
1c4843d497 | ||
|
|
054917e5c4 | ||
|
|
209968640d | ||
|
|
45992de574 | ||
|
|
961d3ab8b2 | ||
|
|
f8f12e8d13 | ||
|
|
720eecdc01 | ||
|
|
5dc18ddb3b | ||
|
|
9280f63a83 | ||
|
|
007da4fdc7 | ||
|
|
a0d90a4478 | ||
|
|
697c07f8c9 | ||
|
|
2add01f37d | ||
|
|
0775d99ea1 | ||
|
|
d6d9ce8ffe | ||
|
|
306c8c6b98 | ||
|
|
87f324edf8 | ||
|
|
89b0957a41 | ||
|
|
05c32be539 | ||
|
|
c0b78e37b5 | ||
|
|
cb39613c0f | ||
|
|
ad7fc89083 | ||
|
|
3c6a8cf7b7 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -88,7 +88,8 @@ clientTest
|
||||
build-stamp
|
||||
configure-stamp
|
||||
debian/mongodb
|
||||
debian/mongodb.*
|
||||
# This was inserted 2009-08-16, nobody knows why.
|
||||
#debian/mongodb.*
|
||||
|
||||
#osx
|
||||
.DS_Store
|
||||
|
||||
76
SConstruct
76
SConstruct
@ -483,7 +483,7 @@ elif "win32" == os.sys.platform:
|
||||
|
||||
env.Append( CPPFLAGS=" /EHsc /W3 " )
|
||||
env.Append( CPPFLAGS=" /wd4355 /wd4800 " ) #some warnings we don't like
|
||||
env.Append( CPPDEFINES=["WIN32","_CONSOLE","_CRT_SECURE_NO_WARNINGS","HAVE_CONFIG_H","PCRE_STATIC","_UNICODE","UNICODE","SUPPORT_UCP","SUPPORT_UTF8" ] )
|
||||
env.Append( CPPDEFINES=["WIN32","_CONSOLE","_CRT_SECURE_NO_WARNINGS","HAVE_CONFIG_H","PCRE_STATIC","_UNICODE","UNICODE","SUPPORT_UCP","SUPPORT_UTF8,PSAPI_VERSION=1" ] )
|
||||
|
||||
#env.Append( CPPFLAGS=' /Yu"stdafx.h" ' ) # this would be for pre-compiled headers, could play with it later
|
||||
|
||||
@ -524,12 +524,14 @@ elif "win32" == os.sys.platform:
|
||||
commonFiles += pcreFiles
|
||||
allClientFiles += pcreFiles
|
||||
|
||||
winLibString = "ws2_32.lib kernel32.lib advapi32.lib"
|
||||
winLibString = "ws2_32.lib kernel32.lib advapi32.lib Psapi.lib"
|
||||
|
||||
if force64:
|
||||
winLibString += " LIBCMT LIBCPMT "
|
||||
else:
|
||||
winLibString += " user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib "
|
||||
winLibString += " odbc32.lib odbccp32.lib uuid.lib "
|
||||
|
||||
env.Append( LIBS=Split(winLibString) )
|
||||
|
||||
if force64:
|
||||
@ -604,6 +606,29 @@ except OSError:
|
||||
|
||||
# --- check system ---
|
||||
|
||||
def getGitBranch():
|
||||
if not os.path.exists( ".git" ):
|
||||
return None
|
||||
|
||||
version = open( ".git/HEAD" ,'r' ).read().strip()
|
||||
if not version.startswith( "ref: " ):
|
||||
return version
|
||||
version = version.split( "/" )
|
||||
version = version[len(version)-1]
|
||||
return version
|
||||
|
||||
def getGitBranchString( prefix="" , postfix="" ):
|
||||
t = re.compile( '[/\\\]' ).split( os.getcwd() )
|
||||
if len(t) > 2 and t[len(t)-1] == "mongo":
|
||||
t = re.compile( ".*_([vV]\d+\.\d+)$" ).match( t[len(t)-2] )
|
||||
if t is not None:
|
||||
return prefix + t.group(1).lower() + postfix
|
||||
|
||||
b = getGitBranch()
|
||||
if b == None or b == "master":
|
||||
return ""
|
||||
return prefix + b + postfix
|
||||
|
||||
def getGitVersion():
|
||||
if not os.path.exists( ".git" ):
|
||||
return "nogitversion"
|
||||
@ -818,6 +843,8 @@ def concatjs(target, source, env):
|
||||
|
||||
fullSource = ""
|
||||
|
||||
first = True
|
||||
|
||||
for s in source:
|
||||
f = open( str(s) , 'r' )
|
||||
for l in f:
|
||||
@ -825,8 +852,21 @@ def concatjs(target, source, env):
|
||||
if len ( l ) == 0:
|
||||
continue
|
||||
|
||||
fullSource += l + "\n"
|
||||
if l == "}":
|
||||
fullSource += "}"
|
||||
continue
|
||||
|
||||
if first:
|
||||
first = False
|
||||
else:
|
||||
fullSource += "\n"
|
||||
|
||||
fullSource += l
|
||||
|
||||
fullSource += "\n"
|
||||
|
||||
fullSource = re.compile( r'/\*\*.*?\*/' , re.M | re.S ).sub( "" , fullSource )
|
||||
|
||||
out = open( outFile , 'w' )
|
||||
out.write( fullSource )
|
||||
|
||||
@ -1055,7 +1095,8 @@ def jsSpec( suffix ):
|
||||
return apply( os.path.join, args )
|
||||
|
||||
def jsDirTestSpec( dir ):
|
||||
return mongo[0].abspath + " --nodb " + jsSpec( [ dir, "*.js" ] )
|
||||
tests = Glob( jsSpec( [ dir, "*.js" ] ) )
|
||||
return [ mongo[0].abspath + " --nodb " + test.abspath for test in tests ]
|
||||
|
||||
def runShellTest( env, target, source ):
|
||||
global mongodForTestsPort
|
||||
@ -1077,13 +1118,17 @@ def runShellTest( env, target, source ):
|
||||
# These tests require the mongo shell
|
||||
if not onlyServer and not noshell:
|
||||
addSmoketest( "smokeJs", [add_exe("mongo")], runShellTest )
|
||||
addSmoketest( "smokeClone", [ "mongo", "mongod" ], [ jsDirTestSpec( "clone" ) ] )
|
||||
addSmoketest( "smokeRepl", [ "mongo", "mongod", "mongobridge" ], [ jsDirTestSpec( "repl" ) ] )
|
||||
addSmoketest( "smokeDisk", [ add_exe( "mongo" ), add_exe( "mongod" ) ], [ jsDirTestSpec( "disk" ) ] )
|
||||
addSmoketest( "smokeSharding", [ "mongo", "mongod", "mongos" ], [ jsDirTestSpec( "sharding" ) ] )
|
||||
addSmoketest( "smokeClone", [ "mongo", "mongod" ], jsDirTestSpec( "clone" ) )
|
||||
addSmoketest( "smokeRepl", [ "mongo", "mongod", "mongobridge" ], jsDirTestSpec( "repl" ) )
|
||||
addSmoketest( "smokeDisk", [ add_exe( "mongo" ), add_exe( "mongod" ) ], jsDirTestSpec( "disk" ) )
|
||||
addSmoketest( "smokeAuth", [ add_exe( "mongo" ), add_exe( "mongod" ) ], jsDirTestSpec( "auth" ) )
|
||||
addSmoketest( "smokeSharding", [ "mongo", "mongod", "mongos" ], jsDirTestSpec( "sharding" ) )
|
||||
addSmoketest( "smokeJsPerf", [ "mongo" ], runShellTest )
|
||||
addSmoketest( "smokeQuota", [ "mongo" ], runShellTest )
|
||||
addSmoketest( "smokeTool", [ add_exe( "mongo" ) ], [ jsDirTestSpec( "tool" ) ] )
|
||||
if windows: # this test doesn't work on windows in v1.2.x
|
||||
addSmoketest( "smokeTool", [ add_exe( "mongo" ) ], [] )
|
||||
else:
|
||||
addSmoketest( "smokeTool", [ add_exe( "mongo" ) ], jsDirTestSpec( "tool" ) )
|
||||
|
||||
mongodForTests = None
|
||||
mongodForTestsPort = "27017"
|
||||
@ -1094,7 +1139,7 @@ def startMongodForTests( env, target, source ):
|
||||
global mongod
|
||||
if mongodForTests:
|
||||
return
|
||||
mongodForTestsPort = "40000"
|
||||
mongodForTestsPort = "32000"
|
||||
import os
|
||||
ensureTestDirs()
|
||||
dirName = "/data/db/sconsTests/"
|
||||
@ -1133,6 +1178,11 @@ testEnv.Alias( "startMongod", [add_exe("mongod")], [startMongodForTests] );
|
||||
testEnv.AlwaysBuild( "startMongod" );
|
||||
testEnv.SideEffect( "dummySmokeSideEffect", "startMongod" )
|
||||
|
||||
testEnv.Alias( "startMongodSmallOplog", [add_exe("mongod")], [startMongodForTests] );
|
||||
testEnv.AlwaysBuild( "startMongodSmallOplog" );
|
||||
testEnv.SideEffect( "dummySmokeSideEffect", "startMongodSmallOplog" )
|
||||
|
||||
|
||||
def addMongodReqTargets( env, target, source ):
|
||||
mongodReqTargets = [ "smokeClient", "smokeJs", "smokeQuota" ]
|
||||
for target in mongodReqTargets:
|
||||
@ -1240,7 +1290,9 @@ def getDistName( sofar ):
|
||||
distName = version
|
||||
return version
|
||||
|
||||
return today.strftime( "%Y-%m-%d" )
|
||||
|
||||
return getGitBranchString( "" , "-" ) + today.strftime( "%Y-%m-%d" )
|
||||
|
||||
|
||||
if distBuild:
|
||||
from datetime import date
|
||||
@ -1361,7 +1413,7 @@ def s3push( localName , remoteName=None , remotePrefix=None , fixName=True , pla
|
||||
|
||||
if remotePrefix is None:
|
||||
if distName is None:
|
||||
remotePrefix = "-latest"
|
||||
remotePrefix = getGitBranchString( "-" ) + "-latest"
|
||||
else:
|
||||
remotePrefix = "-" + distName
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ import os;
|
||||
|
||||
def findHacks( un ):
|
||||
if un[0] == 'Linux' and (os.path.exists("/etc/debian_version") or
|
||||
os.path.exists("/etc/arch-release") or
|
||||
un[3].find("Ubuntu") >= 0):
|
||||
return hacks_ubuntu
|
||||
return None
|
||||
|
||||
43
buildscripts/cleanbb.py
Normal file
43
buildscripts/cleanbb.py
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
import sys
|
||||
import os
|
||||
import utils
|
||||
import time
|
||||
|
||||
def killprocs( signal="" ):
|
||||
cwd = os.getcwd();
|
||||
if cwd.find("buildscripts" ) > 0 :
|
||||
cwd = cwd.partition( "buildscripts" )[0]
|
||||
|
||||
killed = 0
|
||||
|
||||
for x in utils.getprocesslist():
|
||||
x = x.lstrip()
|
||||
if x.find( cwd ) < 0:
|
||||
continue
|
||||
|
||||
pid = x.partition( " " )[0]
|
||||
print( "killing: " + x )
|
||||
utils.execsys( "/bin/kill " + signal + " " + pid )
|
||||
killed = killed + 1
|
||||
|
||||
return killed
|
||||
|
||||
|
||||
def cleanup( root ):
|
||||
|
||||
# delete all regular files, directories can stay
|
||||
# NOTE: if we delete directories later, we can't delete diskfulltest
|
||||
for ( dirpath , dirnames , filenames ) in os.walk( root , topdown=False ):
|
||||
for x in filenames:
|
||||
os.remove( dirpath + "/" + x )
|
||||
|
||||
if killprocs() > 0:
|
||||
time.sleep(3)
|
||||
killprocs("-9")
|
||||
|
||||
if __name__ == "__main__":
|
||||
root = "/data/db/"
|
||||
if len( sys.argv ) > 1:
|
||||
root = sys.argv[1]
|
||||
cleanup( root )
|
||||
69
buildscripts/frob_version.py
Normal file
69
buildscripts/frob_version.py
Normal file
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from __future__ import with_statement
|
||||
import tempfile
|
||||
import sys
|
||||
import re
|
||||
import os
|
||||
|
||||
def opentemp(basename):
|
||||
# The following doesn't work in python before 2.6
|
||||
# return tempfile.NamedTemporaryFile('w', -1, ".XXXXXX", basename, '.', False)
|
||||
fname = basename +".TMP"
|
||||
if os.path.exists(fname):
|
||||
raise "not clobbering file %s" % fname
|
||||
return open(fname, 'w')
|
||||
|
||||
def frob_debian_changelog(version):
|
||||
fname = 'debian/changelog'
|
||||
with opentemp(fname) as o:
|
||||
with open(fname) as i:
|
||||
lineno = 0
|
||||
for line in i:
|
||||
if lineno == 0:
|
||||
newline = re.sub(r'\([^)]*\)', '('+version+')', line)
|
||||
o.write(newline)
|
||||
else:
|
||||
o.write(line)
|
||||
os.rename(o.name, fname)
|
||||
|
||||
def frob_rpm_spec(version):
|
||||
fname = 'rpm/mongo.spec'
|
||||
with opentemp(fname) as o:
|
||||
with open(fname) as i:
|
||||
frobbed = False
|
||||
for line in i:
|
||||
if frobbed:
|
||||
o.write(line)
|
||||
else:
|
||||
if line.find('Version:') == 0:
|
||||
print >> o, 'Version: ' + version
|
||||
frobbed = True
|
||||
else:
|
||||
o.write(line)
|
||||
os.rename(o.name, fname)
|
||||
|
||||
def frob_stdafx_cpp(version):
|
||||
fname = 'stdafx.cpp'
|
||||
with opentemp(fname) as o:
|
||||
with open(fname) as i:
|
||||
frobbed = False
|
||||
for line in i:
|
||||
if frobbed:
|
||||
o.write(line)
|
||||
else:
|
||||
if re.search(r'const.*char.*versionString\[\].*=', line):
|
||||
o.write(' const char versionString[] = "%s";' % version)
|
||||
else:
|
||||
o.write(line)
|
||||
os.rename(o.name, fname)
|
||||
|
||||
(progname, version) = sys.argv
|
||||
if version is None:
|
||||
print >> sys.stderr, 'usage: %s VERSION' % progname
|
||||
sys.exit(1)
|
||||
frob_debian_changelog(version)
|
||||
frob_rpm_spec(version)
|
||||
## I don't yet know what-all cares about the versionString inside the
|
||||
## mongo code, so I'm not actually calling this yet.
|
||||
# frob_stdafx_cpp(version)
|
||||
@ -39,9 +39,11 @@ def foundxulrunner( env , options ):
|
||||
env.Prepend( RPATH=[ libroot ] )
|
||||
|
||||
env.Prepend( CPPPATH=[ incroot + "stable/" ,
|
||||
incroot + "unstable/" ] )
|
||||
incroot + "unstable/" ,
|
||||
incroot ] )
|
||||
env.Prepend( CPPPATH=[ "/usr/include/nspr/" ] )
|
||||
|
||||
env.Append( CPPDEFINES=[ "XULRUNNER" , "OLDJS" ] )
|
||||
if best.find( "1.9.0" ) >= 0:
|
||||
if best.find( "1.9.0" ) >= 0 or best.endswith("1.9"):
|
||||
env.Append( CPPDEFINES=[ "XULRUNNER190" ] )
|
||||
return True
|
||||
|
||||
23
buildscripts/utils.py
Normal file
23
buildscripts/utils.py
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
import re
|
||||
|
||||
# various utilities that are handy
|
||||
|
||||
def execsys( args ):
|
||||
import subprocess
|
||||
if isinstance( args , str ):
|
||||
r = re.compile( "\s+" )
|
||||
args = r.split( args )
|
||||
p = subprocess.Popen( args , stdout=subprocess.PIPE , stderr=subprocess.PIPE )
|
||||
r = p.communicate()
|
||||
return r;
|
||||
|
||||
def getprocesslist():
|
||||
raw = ""
|
||||
try:
|
||||
raw = execsys( "/bin/ps -ax" )[0]
|
||||
except Exception,e:
|
||||
print( "can't get processlist: " + str( e ) )
|
||||
|
||||
r = re.compile( "[\r\n]+" )
|
||||
return r.split( raw )
|
||||
@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
#include "../stdafx.h"
|
||||
#include "../db/cmdline.h"
|
||||
|
||||
namespace mongo {
|
||||
|
||||
@ -23,6 +24,8 @@ namespace mongo {
|
||||
|
||||
bool quiet = false;
|
||||
|
||||
CmdLine cmdLine;
|
||||
|
||||
// Database* database = 0;
|
||||
|
||||
bool dbexitCalled = false;
|
||||
|
||||
23
db/btree.cpp
23
db/btree.cpp
@ -465,6 +465,10 @@ namespace mongo {
|
||||
assert(false);
|
||||
}
|
||||
found:
|
||||
deallocBucket( thisLoc );
|
||||
}
|
||||
|
||||
void BtreeBucket::deallocBucket(const DiskLoc &thisLoc) {
|
||||
#if 1
|
||||
/* as a temporary defensive measure, we zap the whole bucket, AND don't truly delete
|
||||
it (meaning it is ineligible for reuse).
|
||||
@ -1003,20 +1007,27 @@ namespace mongo {
|
||||
BSONObj k;
|
||||
DiskLoc r;
|
||||
x->popBack(r,k);
|
||||
if( x->n == 0 )
|
||||
log() << "warning: empty bucket on BtreeBuild " << k.toString() << endl;
|
||||
bool keepX = ( x->n != 0 );
|
||||
DiskLoc keepLoc = keepX ? xloc : x->nextChild;
|
||||
|
||||
if ( ! up->_pushBack(r, k, order, xloc) ){
|
||||
if ( ! up->_pushBack(r, k, order, keepLoc) ){
|
||||
// current bucket full
|
||||
DiskLoc n = BtreeBucket::addBucket(idx);
|
||||
up->tempNext() = n;
|
||||
upLoc = n;
|
||||
up = upLoc.btreemod();
|
||||
up->pushBack(r, k, order, xloc);
|
||||
up->pushBack(r, k, order, keepLoc);
|
||||
}
|
||||
|
||||
xloc = x->tempNext(); /* get next in chain at current level */
|
||||
x->parent = upLoc;
|
||||
DiskLoc nextLoc = x->tempNext(); /* get next in chain at current level */
|
||||
if ( keepX ) {
|
||||
x->parent = upLoc;
|
||||
} else {
|
||||
if ( !x->nextChild.isNull() )
|
||||
x->nextChild.btreemod()->parent = upLoc;
|
||||
x->deallocBucket( xloc );
|
||||
}
|
||||
xloc = nextLoc;
|
||||
}
|
||||
|
||||
loc = upStart;
|
||||
|
||||
@ -88,7 +88,9 @@ namespace mongo {
|
||||
protected:
|
||||
void modified(const DiskLoc& thisLoc);
|
||||
KeyNode keyNode(int i) const {
|
||||
assert( i < n );
|
||||
if ( i >= n ){
|
||||
massert( (string)"invalid keyNode: " + BSON( "i" << i << "n" << n ).jsonString() , i < n );
|
||||
}
|
||||
return KeyNode(*this, k(i));
|
||||
}
|
||||
|
||||
@ -185,6 +187,7 @@ namespace mongo {
|
||||
bool exists(const IndexDetails& idx, DiskLoc thisLoc, const BSONObj& key, BSONObj order);
|
||||
|
||||
static DiskLoc addBucket(IndexDetails&); /* start a new index off, empty */
|
||||
void deallocBucket(const DiskLoc &thisLoc); // clear bucket memory, placeholder for deallocation
|
||||
|
||||
static void renameIndexNamespace(const char *oldNs, const char *newNs);
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ namespace mongo {
|
||||
/* must call when a btree bucket going away.
|
||||
note this is potentially slow
|
||||
*/
|
||||
inline void ClientCursor::informAboutToDeleteBucket(const DiskLoc& b) {
|
||||
void ClientCursor::informAboutToDeleteBucket(const DiskLoc& b) {
|
||||
recursive_boostlock lock(ccmutex);
|
||||
RARELY if ( byLoc.size() > 70 ) {
|
||||
log() << "perf warning: byLoc.size=" << byLoc.size() << " in aboutToDeleteBucket\n";
|
||||
|
||||
@ -216,7 +216,7 @@ namespace mongo {
|
||||
|
||||
if( strstr(from_name, ".system.") ) {
|
||||
/* system.users is cloned -- but nothing else from system. */
|
||||
if( strstr(from_name, ".system.users") == 0 ){
|
||||
if( legalClientSystemNS( from_name , true ) == 0 ){
|
||||
log(2) << "\t\t not cloning because system collection" << endl;
|
||||
continue;
|
||||
}
|
||||
|
||||
29
db/db.cpp
29
db/db.cpp
@ -65,6 +65,8 @@ namespace mongo {
|
||||
void pairWith(const char *remoteEnd, const char *arb);
|
||||
void setRecCacheSize(unsigned MB);
|
||||
|
||||
void exitCleanly( ExitCode code );
|
||||
|
||||
const char *ourgetns() {
|
||||
Client *c = currentClient.get();
|
||||
return c ? c->ns() : "";
|
||||
@ -113,9 +115,16 @@ namespace mongo {
|
||||
virtual void accepted(MessagingPort *mp) {
|
||||
assert( grab == 0 );
|
||||
grab = mp;
|
||||
boost::thread thr(connThread);
|
||||
while ( grab )
|
||||
sleepmillis(1);
|
||||
try {
|
||||
boost::thread thr(connThread);
|
||||
while ( grab )
|
||||
sleepmillis(1);
|
||||
}
|
||||
catch ( boost::thread_resource_error& e ){
|
||||
log() << "can't create new thread, closing connection" << endl;
|
||||
mp->shutdown();
|
||||
grab = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -217,6 +226,9 @@ namespace mongo {
|
||||
problem() << "SocketException in connThread, closing client connection" << endl;
|
||||
dbMsgPort.shutdown();
|
||||
}
|
||||
catch ( const ClockSkewException &e ) {
|
||||
exitCleanly( EXIT_CLOCK_SKEW );
|
||||
}
|
||||
catch ( std::exception &e ) {
|
||||
problem() << "Uncaught std::exception: " << e.what() << ", terminating" << endl;
|
||||
dbexit( EXIT_UNCAUGHT );
|
||||
@ -283,7 +295,7 @@ namespace mongo {
|
||||
bool doDBUpgrade( const string& dbName , string errmsg , MDFHeader * h ){
|
||||
static DBDirectClient db;
|
||||
|
||||
if ( h->version == 4 && h->versionMinor == 4 ){
|
||||
if ( forceRepair == false && h->version == 4 && h->versionMinor == 4 ){
|
||||
assert( VERSION == 4 );
|
||||
assert( VERSION_MINOR == 5 );
|
||||
|
||||
@ -347,6 +359,7 @@ namespace mongo {
|
||||
|
||||
if ( shouldRepairDatabases ){
|
||||
log() << "finished checking dbs" << endl;
|
||||
cc().shutdown();
|
||||
dbexit( EXIT_CLEAN );
|
||||
}
|
||||
}
|
||||
@ -935,13 +948,13 @@ namespace mongo {
|
||||
|
||||
#undef out
|
||||
|
||||
void exitCleanly() {
|
||||
void exitCleanly( ExitCode code ) {
|
||||
goingAway = true;
|
||||
killCurrentOp = 1;
|
||||
{
|
||||
dblock lk;
|
||||
log() << "now exiting" << endl;
|
||||
dbexit( EXIT_KILL );
|
||||
dbexit( code );
|
||||
}
|
||||
}
|
||||
|
||||
@ -987,7 +1000,7 @@ namespace mongo {
|
||||
int x;
|
||||
sigwait( &asyncSignals, &x );
|
||||
log() << "got kill or ctrl c signal " << x << " (" << strsignal( x ) << "), will terminate after current cmd ends" << endl;
|
||||
exitCleanly();
|
||||
exitCleanly( EXIT_KILL );
|
||||
}
|
||||
|
||||
void setupSignals() {
|
||||
@ -1010,7 +1023,7 @@ namespace mongo {
|
||||
#else
|
||||
void ctrlCTerminate() {
|
||||
log() << "got kill or ctrl c signal, will terminate after current cmd ends" << endl;
|
||||
exitCleanly();
|
||||
exitCleanly( EXIT_KILL );
|
||||
}
|
||||
BOOL CtrlHandler( DWORD fdwCtrlType )
|
||||
{
|
||||
|
||||
@ -308,18 +308,24 @@ namespace mongo {
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
BSONObjBuilder t( result.subobjStart( "mem" ) );
|
||||
|
||||
ProcessInfo p;
|
||||
if ( p.supported() ){
|
||||
BSONObjBuilder t;
|
||||
t.append( "resident" , p.getResidentSize() );
|
||||
t.append( "virtual" , p.getVirtualMemorySize() );
|
||||
t.append( "mapped" , MemoryMappedFile::totalMappedLength() / ( 1024 * 1024 ) );
|
||||
result.append( "mem" , t.obj() );
|
||||
t.appendBool( "supported" , true );
|
||||
}
|
||||
else {
|
||||
result.append( "mem" , "not support on this platform" );
|
||||
result.append( "note" , "not all mem info support on this platform" );
|
||||
t.appendBool( "supported" , false );
|
||||
}
|
||||
|
||||
t.append( "mapped" , MemoryMappedFile::totalMappedLength() / ( 1024 * 1024 ) );
|
||||
|
||||
t.done();
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -1275,7 +1281,32 @@ namespace mongo {
|
||||
|
||||
} distinctCmd;
|
||||
|
||||
|
||||
/* For testing only, not for general use */
|
||||
class GodInsert : public Command {
|
||||
public:
|
||||
GodInsert() : Command( "godinsert" ) { }
|
||||
virtual bool logTheOp() {
|
||||
return true;
|
||||
}
|
||||
virtual bool slaveOk() {
|
||||
return false;
|
||||
}
|
||||
virtual bool requiresAuth() {
|
||||
return true;
|
||||
}
|
||||
virtual void help( stringstream &help ) const {
|
||||
help << "[for testing only]";
|
||||
}
|
||||
virtual bool run(const char *dbname, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool) {
|
||||
string coll = cmdObj[ "godinsert" ].valuestrsafe();
|
||||
uassert( "godinsert must specify a collection", !coll.empty() );
|
||||
string ns = nsToClient( dbname ) + "." + coll;
|
||||
BSONObj obj = cmdObj[ "obj" ].embeddedObjectUserCheck();
|
||||
DiskLoc loc = theDataFileMgr.insert( ns.c_str(), obj, true );
|
||||
return true;
|
||||
}
|
||||
} cmdGodInsert;
|
||||
|
||||
extern map<string,Command*> *commands;
|
||||
|
||||
/* TODO make these all command objects -- legacy stuff here
|
||||
|
||||
@ -104,13 +104,13 @@ namespace mongo {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Helpers::findById(const char *ns, BSONObj query, BSONObj& result ){
|
||||
int Helpers::findById(const char *ns, BSONObj query, BSONObj& result ){
|
||||
NamespaceDetails *d = nsdetails(ns);
|
||||
if ( ! d )
|
||||
return false;
|
||||
return -1;
|
||||
int idxNo = d->findIdIndex();
|
||||
if ( idxNo < 0 )
|
||||
return false;
|
||||
return -1;
|
||||
IndexDetails& i = d->idx( idxNo );
|
||||
|
||||
BSONObj key = i.getKeyFromQuery( query );
|
||||
|
||||
@ -49,7 +49,12 @@ namespace mongo {
|
||||
*/
|
||||
static bool findOne(const char *ns, BSONObj query, BSONObj& result, bool requireIndex = false);
|
||||
|
||||
static bool findById(const char *ns, BSONObj query, BSONObj& result );
|
||||
/**
|
||||
-1 no index
|
||||
0 not found
|
||||
1 found
|
||||
*/
|
||||
static int findById(const char *ns, BSONObj query, BSONObj& result );
|
||||
|
||||
/* Get/put the first object from a collection. Generally only useful if the collection
|
||||
only ever has a single object -- which is a "singleton collection".
|
||||
|
||||
@ -88,10 +88,20 @@ namespace mongo {
|
||||
_cur = new InMemory();
|
||||
}
|
||||
|
||||
_cur->push_back( pair<BSONObj,DiskLoc>( o.getOwned() , loc ) );
|
||||
BSONObj toadd = o;
|
||||
if ( toadd.isOwned() ){
|
||||
// hack to handle buffer problems
|
||||
if ( toadd.objsize() < 100 )
|
||||
toadd = toadd.copy();
|
||||
}
|
||||
else {
|
||||
toadd = toadd.getOwned();
|
||||
}
|
||||
|
||||
_cur->push_back( pair<BSONObj,DiskLoc>( o , loc ) );
|
||||
|
||||
long size = o.objsize();
|
||||
_curSizeSoFar += size + sizeof( DiskLoc );
|
||||
_curSizeSoFar += size + sizeof( DiskLoc ) + sizeof( BSONObj );
|
||||
|
||||
if ( _curSizeSoFar > _maxFilesize )
|
||||
finishMap();
|
||||
@ -204,7 +214,8 @@ namespace mongo {
|
||||
|
||||
BSONObjExternalSorter::FileIterator::FileIterator( string file ){
|
||||
long length;
|
||||
_buf = (char*)_file.map( file.c_str() , length );
|
||||
_buf = (char*)_file.map( file.c_str() , length , MemoryMappedFile::SEQUENTIAL );
|
||||
massert( "mmap failed" , _buf );
|
||||
assert( (unsigned long)length == file_size( file ) );
|
||||
_end = _buf + length;
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ namespace mongo {
|
||||
if ( ! f && level ){
|
||||
log() << "diagLogging = " << level << endl;
|
||||
stringstream ss;
|
||||
ss << "diaglog." << hex << time(0);
|
||||
ss << dbpath << "/diaglog." << hex << time(0);
|
||||
string name = ss.str();
|
||||
f = new ofstream(name.c_str(), ios::out | ios::binary);
|
||||
if ( ! f->good() ) {
|
||||
|
||||
12
db/jsobj.cpp
12
db/jsobj.cpp
@ -608,11 +608,15 @@ namespace mongo {
|
||||
case DBRef:
|
||||
case Code:
|
||||
case Symbol:
|
||||
case String:
|
||||
massert( "Invalid dbref/code/string/symbol size",
|
||||
valuestrsize() > 0 &&
|
||||
valuestrsize() - 1 == strnlen( valuestr(), valuestrsize() ) );
|
||||
case String: {
|
||||
int x = valuestrsize();
|
||||
if ( x > 0 && valuestr()[x-1] == 0 )
|
||||
return;
|
||||
stringstream buf;
|
||||
buf << "Invalid dbref/code/string/symbol size: " << x;
|
||||
massert( buf.str() , 0 );
|
||||
break;
|
||||
}
|
||||
case CodeWScope: {
|
||||
int totalSize = *( int * )( value() );
|
||||
massert( "Invalid CodeWScope size", totalSize >= 8 );
|
||||
|
||||
11
db/jsobj.h
11
db/jsobj.h
@ -714,8 +714,15 @@ namespace mongo {
|
||||
_holder.reset( new Holder( data ) );
|
||||
_objdata = data;
|
||||
if ( ! isValid() ){
|
||||
log() << "invalid object size: " << objsize() << endl;
|
||||
massert( "Invalid BSONObj spec size" , 0 );
|
||||
stringstream ss;
|
||||
ss << "Invalid BSONObj spec size: " << objsize();
|
||||
try {
|
||||
BSONElement e = firstElement();
|
||||
ss << " first element:" << e.toString() << " ";
|
||||
}
|
||||
catch ( ... ){}
|
||||
string s = ss.str();
|
||||
massert( s , 0 );
|
||||
}
|
||||
}
|
||||
#pragma pack(1)
|
||||
|
||||
@ -103,7 +103,6 @@ namespace mongo {
|
||||
if ( ! _needRecord ){
|
||||
return true;
|
||||
}
|
||||
|
||||
return _recordMatcher.matches(recLoc.rec());
|
||||
}
|
||||
|
||||
|
||||
@ -205,7 +205,13 @@ namespace mongo {
|
||||
scope->localConnect( setup.dbname.c_str() );
|
||||
|
||||
map = scope->createFunction( setup.mapCode.c_str() );
|
||||
if ( ! map )
|
||||
throw UserException( (string)"map compile failed: " + scope->getError() );
|
||||
|
||||
reduce = scope->createFunction( setup.reduceCode.c_str() );
|
||||
if ( ! reduce )
|
||||
throw UserException( (string)"reduce compile failed: " + scope->getError() );
|
||||
|
||||
if ( setup.finalizeCode.size() )
|
||||
finalize = scope->createFunction( setup.finalizeCode.c_str() );
|
||||
else
|
||||
|
||||
@ -445,9 +445,14 @@ namespace mongo {
|
||||
// signal done allocating new extents.
|
||||
if ( !deletedList[ 1 ].isValid() )
|
||||
deletedList[ 1 ] = DiskLoc();
|
||||
|
||||
|
||||
assert( len < 400000000 );
|
||||
int passes = 0;
|
||||
int maxPasses = ( len / 30 ) + 2; // 30 is about the smallest entry that could go in the oplog
|
||||
if ( maxPasses < 5000 ){
|
||||
// this is for bacwards safety since 5000 was the old value
|
||||
maxPasses = 5000;
|
||||
}
|
||||
DiskLoc loc;
|
||||
|
||||
// delete records until we have room and the max # objects limit achieved.
|
||||
@ -496,10 +501,10 @@ namespace mongo {
|
||||
DiskLoc fr = theCapExtent()->firstRecord;
|
||||
theDataFileMgr.deleteRecord(ns, fr.rec(), fr, true);
|
||||
compact();
|
||||
if( ++passes >= 5000 ) {
|
||||
log() << "passes ns:" << ns << " len:" << len << '\n';
|
||||
if( ++passes > maxPasses ) {
|
||||
log() << "passes ns:" << ns << " len:" << len << " maxPasses: " << maxPasses << '\n';
|
||||
log() << "passes max:" << max << " nrecords:" << nrecords << " datasize: " << datasize << endl;
|
||||
massert( "passes >= 5000 in capped collection alloc", false );
|
||||
massert( "passes >= maxPasses in capped collection alloc", false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -774,9 +774,9 @@ namespace mongo {
|
||||
try {
|
||||
ok = id.head.btree()->unindex(id.head, id, j, dl);
|
||||
}
|
||||
catch (AssertionException&) {
|
||||
catch (AssertionException& e) {
|
||||
problem() << "Assertion failure: _unindex failed " << id.indexNamespace() << endl;
|
||||
out() << "Assertion failure: _unindex failed" << '\n';
|
||||
out() << "Assertion failure: _unindex failed: " << e.what() << '\n';
|
||||
out() << " obj:" << obj.toString() << '\n';
|
||||
out() << " key:" << j.toString() << '\n';
|
||||
out() << " dl:" << dl.toString() << endl;
|
||||
|
||||
46
db/query.cpp
46
db/query.cpp
@ -481,12 +481,17 @@ namespace mongo {
|
||||
findingStartCursor_ = new ClientCursor();
|
||||
findingStartCursor_->c = qp().newReverseCursor();
|
||||
findingStartCursor_->ns = qp().ns();
|
||||
BSONElement tsElt = qp().query()[ "ts" ];
|
||||
massert( "no ts field in query", !tsElt.eoo() );
|
||||
BSONObjBuilder b;
|
||||
b.append( tsElt );
|
||||
BSONObj tsQuery = b.obj();
|
||||
matcher_.reset(new KeyValJSMatcher(tsQuery, qp().indexKey()));
|
||||
} else {
|
||||
c_ = qp().newCursor();
|
||||
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
|
||||
}
|
||||
|
||||
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
|
||||
|
||||
if ( qp().scanAndOrderRequired() ) {
|
||||
ordering_ = true;
|
||||
so_.reset( new ScanAndOrder( ntoskip_, ntoreturn_, order_ ) );
|
||||
@ -498,9 +503,11 @@ namespace mongo {
|
||||
if ( !findingStartCursor_ || !findingStartCursor_->c->ok() ) {
|
||||
findingStart_ = false;
|
||||
c_ = qp().newCursor();
|
||||
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
|
||||
} else if ( !matcher_->matches( findingStartCursor_->c->currKey(), findingStartCursor_->c->currLoc() ) ) {
|
||||
findingStart_ = false;
|
||||
c_ = qp().newCursor( findingStartCursor_->c->currLoc() );
|
||||
matcher_.reset(new KeyValJSMatcher(qp().query(), qp().indexKey()));
|
||||
} else {
|
||||
findingStartCursor_->c->advance();
|
||||
RARELY {
|
||||
@ -771,26 +778,31 @@ namespace mongo {
|
||||
uassert("bad query object", false);
|
||||
}
|
||||
|
||||
int idxHackWorked = false;
|
||||
if ( strcmp( query.firstElement().fieldName() , "_id" ) == 0 && query.nFields() == 1 && query.firstElement().isSimpleType() ){
|
||||
nscanned = 1;
|
||||
|
||||
BSONObj resObject;
|
||||
bool found = Helpers::findById( ns , query , resObject );
|
||||
if ( found ){
|
||||
n = 1;
|
||||
fillQueryResultFromObj( bb , filter.get() , resObject );
|
||||
}
|
||||
qr.reset( (QueryResult *) bb.buf() );
|
||||
bb.decouple();
|
||||
qr->resultFlags() = 0;
|
||||
qr->len = bb.len();
|
||||
ss << " reslen:" << bb.len();
|
||||
qr->setOperation(opReply);
|
||||
qr->cursorId = cursorid;
|
||||
qr->startingFrom = 0;
|
||||
qr->nReturned = n;
|
||||
int found = Helpers::findById( ns , query , resObject );
|
||||
if ( found >= 0 ){
|
||||
idxHackWorked = true;
|
||||
if ( found ){
|
||||
n = 1;
|
||||
fillQueryResultFromObj( bb , filter.get() , resObject );
|
||||
}
|
||||
qr.reset( (QueryResult *) bb.buf() );
|
||||
bb.decouple();
|
||||
qr->resultFlags() = 0;
|
||||
qr->len = bb.len();
|
||||
ss << " reslen:" << bb.len();
|
||||
qr->setOperation(opReply);
|
||||
qr->cursorId = cursorid;
|
||||
qr->startingFrom = 0;
|
||||
qr->nReturned = n;
|
||||
}
|
||||
}
|
||||
else { // non-simple _id lookup
|
||||
|
||||
if ( ! idxHackWorked ){
|
||||
BSONObj oldPlan;
|
||||
if ( explain && hint.eoo() && min.isEmpty() && max.isEmpty() ) {
|
||||
QueryPlanSet qps( ns, query, order );
|
||||
|
||||
19
db/repl.cpp
19
db/repl.cpp
@ -860,7 +860,7 @@ namespace mongo {
|
||||
|
||||
if ( replAllDead ) {
|
||||
// hmmm why is this check here and not at top of this function? does it get set between top and here?
|
||||
log() << "replAllDead, throwing SyncException\n";
|
||||
log() << "replAllDead, throwing SyncException: " << replAllDead << endl;
|
||||
throw SyncException();
|
||||
}
|
||||
|
||||
@ -981,7 +981,11 @@ namespace mongo {
|
||||
|
||||
void ReplSource::syncToTailOfRemoteLog() {
|
||||
string _ns = ns();
|
||||
BSONObj last = conn->findOne( _ns.c_str(), Query().sort( BSON( "$natural" << -1 ) ) );
|
||||
BSONObjBuilder b;
|
||||
if ( !only.empty() ) {
|
||||
b.appendRegex("ns", string("^") + only);
|
||||
}
|
||||
BSONObj last = conn->findOne( _ns.c_str(), Query( b.done() ).sort( BSON( "$natural" << -1 ) ) );
|
||||
if ( !last.isEmpty() ) {
|
||||
BSONElement ts = last.findElement( "ts" );
|
||||
massert( "non Date ts found", ts.type() == Date || ts.type() == Timestamp );
|
||||
@ -1585,7 +1589,8 @@ namespace mongo {
|
||||
stringstream ss;
|
||||
ss << "repl: sleep " << s << "sec before next pass";
|
||||
string msg = ss.str();
|
||||
log() << msg << endl;
|
||||
if ( ! cmdLine.quiet )
|
||||
log() << msg << endl;
|
||||
ReplInfo r(msg.c_str());
|
||||
sleepsecs(s);
|
||||
}
|
||||
@ -1639,8 +1644,14 @@ namespace mongo {
|
||||
const char * ns = "local.oplog.$main";
|
||||
setClient(ns);
|
||||
|
||||
if ( nsdetails( ns ) )
|
||||
if ( nsdetails( ns ) ) {
|
||||
DBDirectClient c;
|
||||
BSONObj lastOp = c.findOne( ns, Query().sort( BSON( "$natural" << -1 ) ) );
|
||||
if ( !lastOp.isEmpty() ) {
|
||||
OpTime::setLast( lastOp[ "ts" ].date() );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* create an oplog collection, if it doesn't yet exist. */
|
||||
BSONObjBuilder b;
|
||||
|
||||
@ -97,11 +97,17 @@ namespace mongo {
|
||||
stringstream digestBuilder;
|
||||
|
||||
{
|
||||
bool reject = false;
|
||||
nonce *ln = lastNonce.release();
|
||||
digestBuilder << hex << *ln;
|
||||
|
||||
if( ln == 0 || digestBuilder.str() != received_nonce ) {
|
||||
log() << "auth: bad nonce received. could be a driver bug or a security attack. db:" << cc().database()->name << '\n';
|
||||
if ( ln == 0 ) {
|
||||
reject = true;
|
||||
} else {
|
||||
digestBuilder << hex << *ln;
|
||||
reject = digestBuilder.str() != received_nonce;
|
||||
}
|
||||
|
||||
if ( reject ) {
|
||||
log() << "auth: bad nonce received or getnonce not called. could be a driver bug or a security attack. db:" << cc().database()->name << '\n';
|
||||
errmsg = "auth fails";
|
||||
sleepmillis(30);
|
||||
return false;
|
||||
|
||||
@ -248,6 +248,8 @@ namespace mongo {
|
||||
if ( !( e.isNumber() && m.elt.isNumber() ) &&
|
||||
m.elt.valuesize() != e.valuesize() )
|
||||
inPlacePossible = false;
|
||||
if ( e.type() != m.elt.type() )
|
||||
inPlacePossible = false;
|
||||
break;
|
||||
case Mod::PUSH:
|
||||
case Mod::PUSH_ALL:
|
||||
|
||||
@ -110,6 +110,27 @@ namespace BasicTests {
|
||||
roundTrip( y , 40 );
|
||||
}
|
||||
};
|
||||
|
||||
class sleeptest {
|
||||
public:
|
||||
void run(){
|
||||
Timer t;
|
||||
sleepsecs( 1 );
|
||||
ASSERT_EQUALS( 1 , t.seconds() );
|
||||
|
||||
t.reset();
|
||||
sleepmicros( 1527123 );
|
||||
ASSERT( t.micros() > 1000000 );
|
||||
ASSERT( t.micros() < 2000000 );
|
||||
|
||||
t.reset();
|
||||
sleepmillis( 1727 );
|
||||
ASSERT( t.millis() >= 1000 );
|
||||
ASSERT( t.millis() <= 2000 );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class All : public Suite {
|
||||
public:
|
||||
@ -119,6 +140,8 @@ namespace BasicTests {
|
||||
void setupTests(){
|
||||
add< Rarely >();
|
||||
add< Base64Tests >();
|
||||
|
||||
add< sleeptest >();
|
||||
}
|
||||
} myall;
|
||||
|
||||
|
||||
@ -82,6 +82,20 @@ namespace ClientTests {
|
||||
|
||||
};
|
||||
|
||||
class CS_10 : public Base {
|
||||
public:
|
||||
CS_10() : Base( "CS_10" ) {}
|
||||
void run() {
|
||||
string longs( 770, 'c' );
|
||||
for( int i = 0; i < 11; ++i )
|
||||
db.insert( ns(), BSON( "a" << i << "b" << longs ) );
|
||||
db.ensureIndex( ns(), BSON( "a" << 1 << "b" << 1 ) );
|
||||
|
||||
auto_ptr< DBClientCursor > c = db.query( ns(), Query().sort( BSON( "a" << 1 << "b" << 1 ) ), 2 );
|
||||
ASSERT_EQUALS( 11, c->itcount() );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class All : public Suite {
|
||||
public:
|
||||
@ -92,6 +106,7 @@ namespace ClientTests {
|
||||
add<DropIndex>();
|
||||
add<ReIndex>();
|
||||
add<ReIndex2>();
|
||||
add<CS_10>();
|
||||
}
|
||||
|
||||
} all;
|
||||
|
||||
@ -112,7 +112,7 @@ namespace CursorTests {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace MultiBtreeCursorTests
|
||||
} // namespace BtreeCursorTests
|
||||
|
||||
class All : public Suite {
|
||||
public:
|
||||
|
||||
@ -339,8 +339,9 @@ namespace JsobjTests {
|
||||
}
|
||||
BSONObj invalid() const {
|
||||
BSONObj ret = valid();
|
||||
set( ret, 0, get( ret, 0 ) + 1 );
|
||||
set( ret, 7, get( ret, 7 ) + 1 );
|
||||
ASSERT_EQUALS( ret.firstElement().valuestr()[0] , 'b' );
|
||||
ASSERT_EQUALS( ret.firstElement().valuestr()[1] , 0 );
|
||||
((char*)ret.firstElement().valuestr())[1] = 1;
|
||||
return ret.copy();
|
||||
}
|
||||
};
|
||||
@ -391,32 +392,6 @@ namespace JsobjTests {
|
||||
};
|
||||
};
|
||||
|
||||
class WrongSymbolSize : public Base {
|
||||
BSONObj valid() const {
|
||||
return fromjson( "{\"a\":\"b\"}" );
|
||||
}
|
||||
BSONObj invalid() const {
|
||||
BSONObj ret = valid();
|
||||
set( ret, 4, Symbol );
|
||||
set( ret, 0, get( ret, 0 ) + 1 );
|
||||
set( ret, 7, get( ret, 7 ) + 1 );
|
||||
return ret.copy();
|
||||
}
|
||||
};
|
||||
|
||||
class WrongCodeSize : public Base {
|
||||
BSONObj valid() const {
|
||||
return fromjson( "{\"a\":\"b\"}" );
|
||||
}
|
||||
BSONObj invalid() const {
|
||||
BSONObj ret = valid();
|
||||
set( ret, 4, Code );
|
||||
set( ret, 0, get( ret, 0 ) + 1 );
|
||||
set( ret, 7, get( ret, 7 ) + 1 );
|
||||
return ret.copy();
|
||||
}
|
||||
};
|
||||
|
||||
class NoFieldNameEnd : public Base {
|
||||
BSONObj valid() const {
|
||||
return fromjson( "{\"a\":1}" );
|
||||
@ -1185,6 +1160,40 @@ namespace JsobjTests {
|
||||
}
|
||||
};
|
||||
|
||||
class InvalidIDFind {
|
||||
public:
|
||||
void run(){
|
||||
BSONObj x = BSON( "_id" << 5 << "t" << 2 );
|
||||
{
|
||||
char * crap = (char*)malloc( x.objsize() );
|
||||
memcpy( crap , x.objdata() , x.objsize() );
|
||||
BSONObj y( crap , false );
|
||||
ASSERT_EQUALS( x , y );
|
||||
free( crap );
|
||||
}
|
||||
|
||||
{
|
||||
char * crap = (char*)malloc( x.objsize() );
|
||||
memcpy( crap , x.objdata() , x.objsize() );
|
||||
int * foo = (int*)crap;
|
||||
foo[0] = 123123123;
|
||||
int state = 0;
|
||||
try {
|
||||
BSONObj y( crap , false );
|
||||
state = 1;
|
||||
}
|
||||
catch ( std::exception& e ){
|
||||
state = 2;
|
||||
ASSERT( strstr( e.what() , "_id: 5" ) > 0 );
|
||||
}
|
||||
free( crap );
|
||||
ASSERT_EQUALS( 2 , state );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
class All : public Suite {
|
||||
public:
|
||||
All() : Suite( "jsobj" ){
|
||||
@ -1214,8 +1223,6 @@ namespace JsobjTests {
|
||||
add< BSONObjTests::Validation::NegativeStringSize >();
|
||||
add< BSONObjTests::Validation::WrongSubobjectSize >();
|
||||
add< BSONObjTests::Validation::WrongDbrefNsSize >();
|
||||
add< BSONObjTests::Validation::WrongSymbolSize >();
|
||||
add< BSONObjTests::Validation::WrongCodeSize >();
|
||||
add< BSONObjTests::Validation::NoFieldNameEnd >();
|
||||
add< BSONObjTests::Validation::BadRegex >();
|
||||
add< BSONObjTests::Validation::BadRegexOptions >();
|
||||
@ -1269,6 +1276,7 @@ namespace JsobjTests {
|
||||
add< BSONArrayBuilderTest >();
|
||||
add< ArrayMacroTest >();
|
||||
add< NumberParsing >();
|
||||
add< InvalidIDFind >();
|
||||
}
|
||||
} myall;
|
||||
|
||||
|
||||
@ -288,13 +288,13 @@ namespace QueryTests {
|
||||
}
|
||||
void run() {
|
||||
const char *ns = "unittests.querytests.OplogReplayMode";
|
||||
insert( ns, BSON( "a" << 3 ) );
|
||||
insert( ns, BSON( "a" << 0 ) );
|
||||
insert( ns, BSON( "a" << 1 ) );
|
||||
insert( ns, BSON( "a" << 2 ) );
|
||||
auto_ptr< DBClientCursor > c = client().query( ns, QUERY( "a" << GT << 1 ).hint( BSON( "$natural" << 1 ) ), 0, 0, 0, Option_OplogReplay );
|
||||
insert( ns, BSON( "ts" << 3 ) );
|
||||
insert( ns, BSON( "ts" << 0 ) );
|
||||
insert( ns, BSON( "ts" << 1 ) );
|
||||
insert( ns, BSON( "ts" << 2 ) );
|
||||
auto_ptr< DBClientCursor > c = client().query( ns, QUERY( "ts" << GT << 1 ).hint( BSON( "$natural" << 1 ) ), 0, 0, 0, Option_OplogReplay );
|
||||
ASSERT( c->more() );
|
||||
ASSERT_EQUALS( 2, c->next().getIntField( "a" ) );
|
||||
ASSERT_EQUALS( 2, c->next().getIntField( "ts" ) );
|
||||
ASSERT( !c->more() );
|
||||
}
|
||||
};
|
||||
|
||||
22
debian/changelog
vendored
22
debian/changelog
vendored
@ -1,4 +1,24 @@
|
||||
mongodb (1.1.3) unstable; urgency=low
|
||||
mongodb (1.2.5) unsable; urgency=low
|
||||
|
||||
* replication clock skew fix
|
||||
|
||||
-- Richard Kreuter <richard@10gen.com> Fri, 05 Feb 2010 16:56:28 -0500
|
||||
|
||||
mongodb (1.2.4) unsable; urgency=low
|
||||
|
||||
* shell fix
|
||||
* replication only fix
|
||||
|
||||
-- Richard Kreuter <richard@10gen.com> Fri, 05 Feb 2010 16:56:28 -0500
|
||||
|
||||
|
||||
mongodb (1.2.3) unsable; urgency=low
|
||||
|
||||
* munged debian files
|
||||
|
||||
-- Richard Kreuter <richard@10gen.com> Fri, 05 Feb 2010 16:56:28 -0500
|
||||
|
||||
mongodb (1.2.2) unstable; urgency=low
|
||||
|
||||
* Initial release
|
||||
|
||||
|
||||
6
debian/control
vendored
6
debian/control
vendored
@ -1,14 +1,14 @@
|
||||
Source: mongodb
|
||||
Section: devel
|
||||
Priority: optional
|
||||
Maintainer: Kristina Chodorow <kristina@10gen.com>
|
||||
Build-Depends: debhelper (>= 7), libboost-dev, libpcre3, libpcre3-dev, scons, xulrunner-1.9-dev, libboost-thread-dev, libboost-filesystem-dev, libboost-program-options-dev, libboost-date-time-dev
|
||||
Maintainer: Richard Kreuter <richard@10gen.com>
|
||||
Build-Depends: debhelper (>= 7), libpcre3, libpcre3-dev, scons, xulrunner-dev, libboost1.35-dev | libboost1.37-dev | libboost1.38-dev | libboost1.40-dev, libboost-thread1.35-dev | libboost-thread1.37-dev | libboost-thread1.38-dev | libboost-thread1.40-dev, libboost-filesystem1.35-dev | libboost-filesystem1.37-dev | libboost-filesystem1.38-dev | libboost-filesystem1.40-dev, libboost-program-options1.35-dev | libboost-program-options1.37-dev | libboost-program-options1.38-dev | libboost-program-options1.40-dev, libboost-date-time1.35-dev | libboost-date-time1.37-dev | libboost-date-time1.38-dev | libboost-date-time1.40-dev, libpcap-dev, libreadline-dev
|
||||
Standards-Version: 3.8.0
|
||||
Homepage: http://www.mongodb.org
|
||||
|
||||
Package: mongodb
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, xulrunner-1.9-dev
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends}, xulrunner-dev
|
||||
Description: An object/document-oriented database
|
||||
MongoDB is a high-performance, open source, schema-free
|
||||
document-oriented data store that's easy to deploy, manage
|
||||
|
||||
102
debian/init.d
vendored
102
debian/init.d
vendored
@ -21,8 +21,8 @@
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: mongodb
|
||||
# Required-Start: $network $local_fs
|
||||
# Required-Stop:
|
||||
# Required-Start: $network $local_fs $remote_fs
|
||||
# Required-Stop: $network $local_fs $remote_fs
|
||||
# Should-Start: $named
|
||||
# Should-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
@ -48,50 +48,45 @@
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
DAEMON=/usr/bin/mongod
|
||||
DATA=/var/lib/mongodb
|
||||
NAME=MongoDB
|
||||
DESC=database
|
||||
|
||||
# Default defaults. Can be overridden by the /etc/default/$NAME
|
||||
NAME=mongodb
|
||||
CONF=/etc/mongodb.conf
|
||||
DATA=/var/lib/mongodb
|
||||
LOGDIR=/var/log/mongodb
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
LOGFILE=$LOGDIR/$NAME.log # Server logfile
|
||||
|
||||
# Include mongodb defaults if available
|
||||
if [ -f /etc/default/$NAME ] ; then
|
||||
. /etc/default/$NAME
|
||||
fi
|
||||
|
||||
if test ! -x $DAEMON; then
|
||||
echo "Could not find $DAEMON"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test "x$ENABLE_MONGODB" != "xyes"; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test ! -x $DATA; then
|
||||
mkdir $DATA || exit 0
|
||||
fi
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
LOGDIR=/var/log/mongodb
|
||||
PIDFILE=/var/run/$NAME.pid
|
||||
STARTTIME=1
|
||||
DIETIME=10 # Time to wait for the server to die, in seconds
|
||||
# If this value is set too low you might not
|
||||
# let some servers to die gracefully and
|
||||
# 'restart' will not work
|
||||
|
||||
LOGFILE=$LOGDIR/$NAME.log # Server logfile
|
||||
DAEMON_OPTS="--dbpath $DATA --logpath $LOGFILE run"
|
||||
|
||||
|
||||
# Include mongodb defaults if available
|
||||
if [ -f /etc/default/$NAME ] ; then
|
||||
. /etc/default/$NAME
|
||||
fi
|
||||
|
||||
DAEMONUSER=mongodb
|
||||
# Check that the user exists (if we set a user)
|
||||
# Does the user exist?
|
||||
if [ -n "$DAEMONUSER" ] ; then
|
||||
if getent passwd | grep -q "^$DAEMONUSER:"; then
|
||||
# Obtain the uid and gid
|
||||
DAEMONUID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $3}'`
|
||||
DAEMONGID=`getent passwd |grep "^$DAEMONUSER:" | awk -F : '{print $4}'`
|
||||
else
|
||||
log_failure_msg "The user $DAEMONUSER, required to run $NAME does not exist."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
DAEMONUSER=${DAEMONUSER:-mongodb}
|
||||
DAEMON_OPTS=${DAEMON_OPTS:-"--dbpath $DATA --logpath $LOGFILE run"}
|
||||
DAEMON_OPTS="$DAEMON_OPTS --config $CONF"
|
||||
|
||||
set -e
|
||||
|
||||
@ -121,45 +116,22 @@ running() {
|
||||
|
||||
start_server() {
|
||||
# Start the process using the wrapper
|
||||
if [ -z "$DAEMONUSER" ] ; then
|
||||
start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
|
||||
--make-pidfile --exec $DAEMON -- $DAEMON_OPTS
|
||||
errcode=$?
|
||||
else
|
||||
# if we are using a daemonuser then change the user id
|
||||
start-stop-daemon --background --start --quiet --pidfile $PIDFILE \
|
||||
--make-pidfile --chuid $DAEMONUSER \
|
||||
--exec $DAEMON -- $DAEMON_OPTS
|
||||
errcode=$?
|
||||
fi
|
||||
return $errcode
|
||||
}
|
||||
|
||||
stop_server() {
|
||||
# Stop the process using the wrapper
|
||||
if [ -z "$DAEMONUSER" ] ; then
|
||||
start-stop-daemon --stop --quiet --pidfile $PIDFILE
|
||||
rm $PIDFILE
|
||||
errcode=$?
|
||||
else
|
||||
# if we are using a daemonuser then look for process that match
|
||||
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
|
||||
--user $DAEMONUSER \
|
||||
--exec $DAEMON
|
||||
errcode=$?
|
||||
fi
|
||||
|
||||
return $errcode
|
||||
}
|
||||
|
||||
reload_server() {
|
||||
[ ! -f "$PIDFILE" ] && return 1
|
||||
pid=pidofproc $PIDFILE # This is the daemon's pid
|
||||
# Send a SIGHUP
|
||||
kill -USR1 $pid
|
||||
return $?
|
||||
}
|
||||
|
||||
force_stop() {
|
||||
# Force the process to die killing it manually
|
||||
[ ! -e "$PIDFILE" ] && return
|
||||
@ -182,7 +154,7 @@ force_stop() {
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
log_daemon_msg "Starting $DESC $NAME"
|
||||
log_daemon_msg "Starting $DESC" "$NAME"
|
||||
# Check if it's running first
|
||||
if running ; then
|
||||
log_progress_msg "apparently already running"
|
||||
@ -254,35 +226,11 @@ case "$1" in
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
# Use this if the daemon cannot reload
|
||||
# MongoDB can't reload its configuration.
|
||||
reload)
|
||||
log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon"
|
||||
log_warning_msg "cannot re-read the config file (use restart)."
|
||||
;;
|
||||
# And this if it cann
|
||||
#reload)
|
||||
#
|
||||
# If the daemon can reload its config files on the fly
|
||||
# for example by sending it SIGHUP, do it here.
|
||||
#
|
||||
# If the daemon responds to changes in its config file
|
||||
# directly anyway, make this a do-nothing entry.
|
||||
#
|
||||
# log_daemon_msg "Reloading $DESC configuration files" "$NAME"
|
||||
# if running ; then
|
||||
# reload_server
|
||||
# if ! running ; then
|
||||
# Process died after we tried to reload
|
||||
# log_progress_msg "died on reload"
|
||||
# log_end_msg 1
|
||||
# exit 1
|
||||
# fi
|
||||
# else
|
||||
# log_progress_msg "server is not running"
|
||||
# log_end_msg 1
|
||||
# exit 1
|
||||
# fi
|
||||
#;;
|
||||
|
||||
*)
|
||||
N=/etc/init.d/$NAME
|
||||
|
||||
11
debian/lintian-overrides
vendored
Normal file
11
debian/lintian-overrides
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# Agreed with upstream, that redefining rpath is necessary as xulrunner used to
|
||||
# change API without changing so-name
|
||||
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongo /usr/lib64/xulrunner-1.9.1
|
||||
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongod /usr/lib64/xulrunner-1.9.1
|
||||
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongodump /usr/lib64/xulrunner-1.9.1
|
||||
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongoexport /usr/lib64/xulrunner-1.9.1
|
||||
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongofiles /usr/lib64/xulrunner-1.9.1
|
||||
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongoimport /usr/lib64/xulrunner-1.9.1
|
||||
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongorestore /usr/lib64/xulrunner-1.9.1
|
||||
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongos /usr/lib64/xulrunner-1.9.1
|
||||
mongodb: binary-or-shlib-defines-rpath ./usr/bin/mongosniff /usr/lib64/xulrunner-1.9.1
|
||||
16
debian/mongod.1
vendored
Normal file
16
debian/mongod.1
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
.\" Documentation for the MongoDB shell
|
||||
.TH MONGOD "1" "June 2009" "10gen" "Mongo Database"
|
||||
.SH "NAME"
|
||||
mongod \- the Mongo Daemon
|
||||
.SH "SYNOPSIS"
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
\fBmongod\fR
|
||||
is a core MongoDB daemon. You are not supposed to call it directly, please refer to the wiki if necessary.
|
||||
.SH "COPYRIGHT"
|
||||
.PP
|
||||
Copyright 2007\-2009 10gen
|
||||
.SH "SEE ALSO"
|
||||
For more information, please refer to the MongoDB wiki, available at http://www.mongodb.org.
|
||||
.SH "AUTHOR"
|
||||
Antonin Kral
|
||||
95
debian/mongodb.conf
vendored
Normal file
95
debian/mongodb.conf
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
# mongodb.conf
|
||||
|
||||
# Where to store the data.
|
||||
|
||||
# Note: if you run mongodb as a non-root user (recommended) you may
|
||||
# need to create and set permissions for this directory manually,
|
||||
# e.g., if the parent directory isn't mutable by the mongodb user.
|
||||
dbpath=/var/lib/mongodb
|
||||
|
||||
#where to log
|
||||
logpath=/var/log/mongodb/mongodb.log
|
||||
|
||||
logappend=true
|
||||
|
||||
#port = 27017
|
||||
|
||||
|
||||
|
||||
# Enables periodic logging of CPU utilization and I/O wait
|
||||
#cpu = true
|
||||
|
||||
# Turn on/off security. Off is currently the default
|
||||
#noauth = true
|
||||
#auth = true
|
||||
|
||||
# Verbose logging output.
|
||||
#verbose = true
|
||||
|
||||
# Inspect all client data for validity on receipt (useful for
|
||||
# developing drivers)
|
||||
#objcheck = true
|
||||
|
||||
# Enable db quota management
|
||||
#quota = true
|
||||
|
||||
# Set oplogging level where n is
|
||||
# 0=off (default)
|
||||
# 1=W
|
||||
# 2=R
|
||||
# 3=both
|
||||
# 7=W+some reads
|
||||
#oplog = 0
|
||||
|
||||
# Diagnostic/debugging option
|
||||
#nocursors = true
|
||||
|
||||
# Ignore query hints
|
||||
#nohints = true
|
||||
|
||||
# Disable the HTTP interface (Defaults to localhost:27018).
|
||||
#nohttpinterface = true
|
||||
|
||||
# Turns off server-side scripting. This will result in greatly limited
|
||||
# functionality
|
||||
#noscripting = true
|
||||
|
||||
# Turns off table scans. Any query that would do a table scan fails.
|
||||
#notablescan = true
|
||||
|
||||
# Disable data file preallocation.
|
||||
#noprealloc = true
|
||||
|
||||
# Specify .ns file size for new databases.
|
||||
# nssize = <size>
|
||||
|
||||
# Accout token for Mongo monitoring server.
|
||||
#mms-token = <token>
|
||||
|
||||
# Server name for Mongo monitoring server.
|
||||
#mms-name = <server-name>
|
||||
|
||||
# Ping interval for Mongo monitoring server.
|
||||
#mms-interval = <seconds>
|
||||
|
||||
# Replication Options
|
||||
|
||||
# in replicated mongo databases, specify here whether this is a slave or master
|
||||
#slave = true
|
||||
#source = master.example.com
|
||||
# Slave only: specify a single database to replicate
|
||||
#only = master.example.com
|
||||
# or
|
||||
#master = true
|
||||
#source = slave.example.com
|
||||
|
||||
# Address of a server to pair with.
|
||||
#pairwith = <server:port>
|
||||
# Address of arbiter server.
|
||||
#arbiter = <server:port>
|
||||
# Automatically resync if slave data is stale
|
||||
#autoresync
|
||||
# Custom size for replication operation log.
|
||||
#oplogSize = <MB>
|
||||
# Size limit for in-memory storage of op ids.
|
||||
#opIdMem = <bytes>
|
||||
15
debian/mongodb.upstart
vendored
Normal file
15
debian/mongodb.upstart
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Ubuntu upstart file at /etc/init/mongodb.conf
|
||||
|
||||
pre-start script
|
||||
mkdir -p /var/lib/mongodb/
|
||||
mkdir -p /var/log/mongodb/
|
||||
end script
|
||||
|
||||
start on runlevel [2345]
|
||||
stop on runlevel [06]
|
||||
|
||||
script
|
||||
ENABLE_MONGODB="yes"
|
||||
if [ -f /etc/default/mongodb ]; then . /etc/default/mongodb; fi
|
||||
if [ "x$ENABLE_MONGODB" = "xyes" ]; then exec start-stop-daemon --start --quiet --chuid mongodb --exec /usr/bin/mongod -- --config /etc/mongodb.conf; fi
|
||||
end script
|
||||
63
debian/mongoimport.1
vendored
Normal file
63
debian/mongoimport.1
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||
.TH MONGOIMPORT "1" "January 2010" "10gen" "Mongo Database"
|
||||
.SH "NAME"
|
||||
mongoimport \- the Mongo import tool
|
||||
.SH "SYNOPSIS"
|
||||
\fBmongoimport [\fIOPTIONS\fR]\fR
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
\fBmongoimport\fR
|
||||
is a tool to import a MongoDB collection from JSON, CSV, or TSV. The query can be filtered or a list of fields to input can be given.
|
||||
.\".SH "EXAMPLES"
|
||||
.\".TP
|
||||
.\".B mongoimport -d test -c test1 --csv -f "name,num"
|
||||
.\"import documents from test.test1 in CSV format
|
||||
.SS "OPTIONS"
|
||||
.TP
|
||||
\fB\-\-help\fR
|
||||
show usage information
|
||||
.TP
|
||||
.B \-h, \-\-host HOST
|
||||
server to connect to (default HOST=localhost)
|
||||
.TP
|
||||
.B \-d, \-\-db DATABASE
|
||||
database to use
|
||||
.TP
|
||||
.B \-c, \-\-c COLLECTION
|
||||
collection to use (some commands)
|
||||
.TP
|
||||
.B \-\-dbpath PATH
|
||||
directly access mongod data files in this path,
|
||||
instead of connecting to a mongod instance
|
||||
.TP
|
||||
.B \-v, \-\-verbose
|
||||
be more verbose (include multiple times for more
|
||||
verbosity e.g. \fB\-vvvvv\fR)
|
||||
.TP
|
||||
.B \-f, \-\-fields NAMES
|
||||
comma seperated list of field names e.g. \fB\-f\fR name,age
|
||||
.TP
|
||||
.B \-\-fieldFile FILE
|
||||
file with fields names \- 1 per line
|
||||
.TP
|
||||
.B \-\-ignoreBlanks
|
||||
if given, empty fields in csv and tsv will be ignored
|
||||
.TP
|
||||
.B \-\-type TYPE
|
||||
type of file to import. default: json (json,csv,tsv)
|
||||
.TP
|
||||
.B \-\-file FILE
|
||||
file to import from; if not specified stdin is used
|
||||
.TP
|
||||
.B \-\-drop
|
||||
drop collection first
|
||||
.TP
|
||||
.B \-\-headerline
|
||||
CSV,TSV only \- use first line as headers
|
||||
.SH "COPYRIGHT"
|
||||
.PP
|
||||
Copyright 2007\-2009 10gen
|
||||
.SH "SEE ALSO"
|
||||
For more information, please refer to the MongoDB wiki, available at http://www.mongodb.org.
|
||||
.SH "AUTHOR"
|
||||
Kristina Chodorow
|
||||
45
debian/mongoimportjson.1
vendored
45
debian/mongoimportjson.1
vendored
@ -1,45 +0,0 @@
|
||||
.\" Documentation for the MongoDB shell
|
||||
.TH MONGOIMPORTJSON "1" "June 2009" "10gen" "Mongo Database"
|
||||
.SH "NAME"
|
||||
mongoimportjson \- the Mongo import tool
|
||||
.SH "SYNOPSIS"
|
||||
\fBmongoimportjson [\fIOPTIONS\fR]\fR
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
\fBmongoimportjson\fR
|
||||
is a tool to import JSON documents into MongoDB. This utility takes a single file that contains one JSON string per line and inserts it. A databaase and collection must be specified.
|
||||
.SH "OPTIONS"
|
||||
.TP
|
||||
.B \-\-help
|
||||
show usage information
|
||||
.TP
|
||||
.B \-h, \-\-host HOST
|
||||
server to connect to (default HOST=localhost)
|
||||
.TP
|
||||
.B \-d, \-\-db DATABASE
|
||||
database to use
|
||||
.TP
|
||||
.B \-c, \-\-c COLLECTION
|
||||
collection to use
|
||||
.TP
|
||||
.B \-\-file FILE
|
||||
file from which to import
|
||||
.TP
|
||||
.B \-\-dbpath PATH
|
||||
directly access mongod data files in this path, instead of connecting to a mongod instance
|
||||
.TP
|
||||
.B \-\-idbefore
|
||||
create id index before importing
|
||||
.TP
|
||||
.B \-\-id
|
||||
create id index after importing (recommended)
|
||||
.TP
|
||||
.B \-\-drop
|
||||
drop collection before importing
|
||||
.SH "COPYRIGHT"
|
||||
.PP
|
||||
Copyright 2007\-2009 10gen
|
||||
.SH "SEE ALSO"
|
||||
For more information, please refer to the MongoDB wiki, available at http://www.mongodb.org.
|
||||
.SH "AUTHOR"
|
||||
Kristina Chodorow
|
||||
30
debian/mongosniff.1
vendored
Normal file
30
debian/mongosniff.1
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
.TH MONGOSNIFF "1" "Jan 2010" "10gen" "Mongo Database"
|
||||
.SH "NAME"
|
||||
mongosniff \- the Mongo packet analyzer
|
||||
.SH "SYNOPSIS"
|
||||
\fBmongosniff [\fIOPTIONS\fR] [\fI<port0> <port1> ...\fR]
|
||||
.SH "DESCRIPTION"
|
||||
.PP
|
||||
\fBmongosniff\fR
|
||||
is a analyzer tool for analyzing packets coming to your database.
|
||||
.PP
|
||||
.SH "OPTIONS"
|
||||
.TP
|
||||
.B \-\-forward
|
||||
Forward all parsed request messages to mongod instance at specified host:port
|
||||
.TP
|
||||
.B \-\-source
|
||||
Source of traffic to sniff, either a network interface or a file containing previously captured packets, in pcap format. If no source is specified, mongosniff will attempt to sniff from one of the machine's network interfaces.
|
||||
.TP
|
||||
.B \-\-help
|
||||
print a short help message.
|
||||
.TP
|
||||
.B <port0>
|
||||
These parameters are used to filter sniffing. By default, only port 27017 is sniffed.
|
||||
.SH "COPYRIGHT"
|
||||
.PP
|
||||
Copyright 2007\-2009 10gen
|
||||
.SH "SEE ALSO"
|
||||
For more information, please refer to the MongoDB wiki, available at http://www.mongodb.org.
|
||||
.SH "AUTHOR"
|
||||
Antonin Kral
|
||||
10
debian/postinst
vendored
10
debian/postinst
vendored
@ -22,18 +22,18 @@ case "$1" in
|
||||
configure)
|
||||
# create a mongodb group and user
|
||||
if ! grep -q mongodb /etc/passwd; then
|
||||
adduser --system mongodb
|
||||
adduser --system --no-create-home mongodb
|
||||
addgroup --system mongodb
|
||||
adduser mongodb mongodb
|
||||
fi
|
||||
|
||||
# create db
|
||||
# create db -- note: this should agree with dbpath in mongodb.conf
|
||||
mkdir -p /var/lib/mongodb
|
||||
chown mongodb:mongodb /var/lib/mongodb
|
||||
chown -R mongodb:mongodb /var/lib/mongodb
|
||||
|
||||
# create logdir
|
||||
# create logdir -- note: this should agree with logpath in mongodb.conf
|
||||
mkdir -p /var/log/mongodb
|
||||
chown mongodb:mongodb /var/log/mongodb
|
||||
chown -R mongodb:mongodb /var/log/mongodb
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
|
||||
18
debian/rules
vendored
18
debian/rules
vendored
@ -26,6 +26,7 @@ build-stamp: configure-stamp
|
||||
# Add here commands to compile the package.
|
||||
scons
|
||||
#docbook-to-man debian/mongodb.sgml > mongodb.1
|
||||
ls debian/*.1 > debian/mongodb.manpages
|
||||
|
||||
touch $@
|
||||
|
||||
@ -34,7 +35,10 @@ clean:
|
||||
dh_testroot
|
||||
rm -f build-stamp configure-stamp
|
||||
|
||||
scons -c
|
||||
# FIXME: scons freaks out at the presence of target files
|
||||
# under debian/mongodb.
|
||||
#scons -c
|
||||
rm -rf $(CURDIR)/debian/mongodb
|
||||
rm -f config.log
|
||||
rm -f mongo
|
||||
rm -f mongod
|
||||
@ -49,16 +53,24 @@ clean:
|
||||
rm -rf tools/*.o
|
||||
rm -rf shell/*.o
|
||||
rm -rf .sconf_temp
|
||||
dh_clean
|
||||
rm -f buildscripts/*.pyc
|
||||
rm -f *.pyc
|
||||
rm -f buildinfo.cpp
|
||||
dh_clean debian/files
|
||||
|
||||
install: build
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_clean -k
|
||||
dh_prep
|
||||
dh_installdirs
|
||||
|
||||
scons --prefix=$(CURDIR)/debian/mongodb/usr install
|
||||
mkdir -p $(CURDIR)/debian/mongodb/etc
|
||||
cp $(CURDIR)/debian/mongodb.conf $(CURDIR)/debian/mongodb/etc/mongodb.conf
|
||||
|
||||
mkdir -p $(CURDIR)/debian/mongodb/usr/share/lintian/overrides/
|
||||
install -m 644 $(CURDIR)/debian/lintian-overrides \
|
||||
$(CURDIR)/debian/mongodb/usr/share/lintian/overrides/mongodb
|
||||
|
||||
# Build architecture-independent files here.
|
||||
binary-indep: build install
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = MongoDB
|
||||
PROJECT_NUMBER = 1.1.3
|
||||
PROJECT_NUMBER = 1.2.5
|
||||
OUTPUT_DIRECTORY = docs
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
|
||||
0
jstests/auth/dummy.js
Normal file
0
jstests/auth/dummy.js
Normal file
11
jstests/auth2.js
Normal file
11
jstests/auth2.js
Normal file
@ -0,0 +1,11 @@
|
||||
db2 = new Mongo( db.getMongo().host ).getDB( db.getName() );
|
||||
|
||||
users = db2.getCollection( "system.users" );
|
||||
users.remove( {} );
|
||||
|
||||
pass = "a" + Math.random();
|
||||
//print( "password [" + pass + "]" );
|
||||
|
||||
db2.addUser( "eliot" , pass );
|
||||
|
||||
assert.commandFailed( db2.runCommand( { authenticate: 1, user: "eliot", nonce: "foo", key: "bar" } ) );
|
||||
@ -134,7 +134,7 @@ if ( true ){
|
||||
print( "t1: " + Date.timeFunc(
|
||||
function(){
|
||||
var out = db.runCommand( { mapreduce : "mr1" , map : m , reduce : r } );
|
||||
if ( ks == "_id" ) assert( out.ok , "XXX" );
|
||||
if ( ks == "_id" ) assert( out.ok , "XXX : " + tojson( out ) );
|
||||
db[out.result].drop();
|
||||
} , 10 ) + " (~500 on 2.8ghz) - itcount: " + Date.timeFunc( function(){ db.mr1.find().itcount(); } , 10 ) );
|
||||
|
||||
|
||||
47
jstests/mr_errorhandling.js
Normal file
47
jstests/mr_errorhandling.js
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
t = db.mr_errorhandling;
|
||||
t.drop();
|
||||
|
||||
t.save( { a : [ 1 , 2 , 3 ] } )
|
||||
t.save( { a : [ 2 , 3 , 4 ] } )
|
||||
|
||||
m_good = function(){
|
||||
for ( var i=0; i<this.a.length; i++ ){
|
||||
emit( this.a[i] , 1 );
|
||||
}
|
||||
}
|
||||
|
||||
m_bad = function(){
|
||||
for ( var i=0; i<this.a.length; i++ ){
|
||||
emit( this.a[i] );
|
||||
}
|
||||
}
|
||||
|
||||
r = function( k , v ){
|
||||
var total = 0;
|
||||
for ( var i=0; i<v.length; i++ )
|
||||
total += v[i];
|
||||
return total;
|
||||
}
|
||||
|
||||
res = t.mapReduce( m_good , r );
|
||||
assert.eq( { 1 : 1 , 2 : 2 , 3 : 2 , 4 : 1 } , res.convertToSingleObject() , "A" );
|
||||
res.drop()
|
||||
|
||||
res = null;
|
||||
|
||||
theerror = null;
|
||||
try {
|
||||
res = t.mapReduce( m_bad , r );
|
||||
}
|
||||
catch ( e ){
|
||||
theerror = e.toString();
|
||||
}
|
||||
assert.isnull( res , "B1" );
|
||||
assert( theerror , "B2" );
|
||||
assert( theerror.indexOf( "emit" ) >= 0 , "B3" );
|
||||
|
||||
// test things are still in an ok state
|
||||
res = t.mapReduce( m_good , r );
|
||||
assert.eq( { 1 : 1 , 2 : 2 , 3 : 2 , 4 : 1 } , res.convertToSingleObject() , "A" );
|
||||
res.drop()
|
||||
53
jstests/repl/master1.js
Normal file
53
jstests/repl/master1.js
Normal file
@ -0,0 +1,53 @@
|
||||
// Test handling of clock skew and optimes across mongod instances
|
||||
|
||||
if ( typeof( BinData ) != "undefined" ) { // don't run in v8
|
||||
|
||||
var baseName = "jstests_repl_master1test";
|
||||
|
||||
oplog = function() {
|
||||
return m.getDB( "local" ).oplog.$main;
|
||||
}
|
||||
|
||||
lastop = function() {
|
||||
return oplog().find().sort( {$natural:-1} ).next();
|
||||
}
|
||||
|
||||
am = function() {
|
||||
return m.getDB( baseName ).a;
|
||||
}
|
||||
|
||||
rt = new ReplTest( baseName );
|
||||
|
||||
m = rt.start( true );
|
||||
|
||||
am().save( {} );
|
||||
assert.eq( "i", lastop().op );
|
||||
|
||||
op = lastop();
|
||||
printjson( op );
|
||||
op.ts.t = op.ts.t + 600000 // 10 minutes
|
||||
m.getDB( "local" ).runCommand( {godinsert:"oplog.$main", obj:op} );
|
||||
|
||||
rt.stop( true );
|
||||
m = rt.start( true, null, true );
|
||||
|
||||
assert.eq( op.ts.t, lastop().ts.t );
|
||||
am().save( {} );
|
||||
assert.eq( op.ts.t, lastop().ts.t );
|
||||
assert.eq( op.ts.i + 1, lastop().ts.i );
|
||||
|
||||
op = lastop();
|
||||
printjson( op );
|
||||
op.ts.i = Math.pow(2,31);
|
||||
printjson( op );
|
||||
m.getDB( "local" ).runCommand( {godinsert:"oplog.$main", obj:op} );
|
||||
|
||||
rt.stop( true );
|
||||
m = rt.start( true, null, true );
|
||||
assert.eq( op.ts.i, lastop().ts.i );
|
||||
am().save( {} );
|
||||
sleep( 3000 ); // make sure dies on its own before stop() called
|
||||
|
||||
assert.eq( 47 /*EXIT_CLOCK_SKEW*/, rt.stop( true ) );
|
||||
|
||||
}
|
||||
@ -226,6 +226,8 @@ doTest4 = function( signal ) {
|
||||
// now can only talk to arbiter
|
||||
pair.start( true );
|
||||
pair.waitForSteadyState( [ 1, 1 ], null, true );
|
||||
|
||||
ports.forEach( function( x ) { stopMongoProgram( x ); } );
|
||||
}
|
||||
|
||||
doTest1();
|
||||
|
||||
@ -28,6 +28,14 @@ doTest = function() {
|
||||
printjson( s.getDBNames() );
|
||||
assert.eq( -1, s.getDBNames().indexOf( "b" ) );
|
||||
assert.eq( 0, s.getDB( "b" ).b.find().count() );
|
||||
|
||||
stopMongod( ports[ 1 ] );
|
||||
|
||||
cm.save( { x:3 } );
|
||||
bm.save( { x:4 } );
|
||||
|
||||
s = startMongoProgram( "mongod", "--port", ports[ 1 ], "--dbpath", "/data/db/" + baseName + "-slave", "--slave", "--source", "127.0.0.1:" + ports[ 0 ], "--only", "c", "--nohttpinterface", "--noprealloc", "--bind_ip", "127.0.0.1" );
|
||||
soonCount( "c", "c", 2 );
|
||||
}
|
||||
|
||||
doTest();
|
||||
|
||||
@ -12,6 +12,8 @@ assert.eq( 0 , s.count() , "setup - D" );
|
||||
s.save( { _id : "x" , value : "4" } );
|
||||
assert.eq( 1 , s.count() , "setup - E" );
|
||||
|
||||
assert.eq( 4 , s.findOne( { _id : "x" } ).value , "E2 " );
|
||||
|
||||
assert.eq( 4 , s.findOne().value , "setup - F" );
|
||||
s.update( { _id : "x" } , { $set : { value : 5 } } );
|
||||
assert.eq( 1 , s.count() , "setup - G" );
|
||||
@ -29,3 +31,5 @@ assert.eq( 6 , db.eval( "return x" ) , "exec - 2 " );
|
||||
|
||||
s.insert( { _id : "bar" , value : function( z ){ return 17 + z; } } );
|
||||
assert.eq( 22 , db.eval( "return bar(5);" ) , "exec - 3 " );
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
72
rpm/init.d-mongod
Normal file
72
rpm/init.d-mongod
Normal file
@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
|
||||
# mongod - Startup script for mongod
|
||||
|
||||
# chkconfig: 35 85 15
|
||||
# description: Mongo is a scalable, document-oriented database.
|
||||
# processname: mongod
|
||||
# config: /etc/mongod.conf
|
||||
# pidfile: /var/run/mongo/mongo.pid
|
||||
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
# things from mongod.conf get there by mongod reading it
|
||||
|
||||
|
||||
|
||||
OPTIONS=" -f /etc/mongod.conf"
|
||||
SYSCONFIG="/etc/sysconfig/mongod"
|
||||
|
||||
mongod=${MONGOD-/usr/bin/mongod}
|
||||
|
||||
MONGO_USER=mongod
|
||||
MONGO_GROUP=mongod
|
||||
|
||||
. "$SYSCONFIG" || true
|
||||
|
||||
start()
|
||||
{
|
||||
echo -n $"Starting mongod: "
|
||||
daemon --user "$MONGO_USER" $mongod $OPTIONS
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod && success
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
echo -n $"Stopping mongod: "
|
||||
killproc -p /var/lib/mongo/mongod.lock -t30 -TERM /usr/bin/mongod
|
||||
RETVAL=$?
|
||||
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod && success
|
||||
}
|
||||
|
||||
restart () {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
ulimit -n 12000
|
||||
RETVAL=0
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart|reload|force-reload)
|
||||
restart
|
||||
;;
|
||||
condrestart)
|
||||
[ -f /var/lock/subsys/mongodb ] && restart || :
|
||||
;;
|
||||
status)
|
||||
status $mongod
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
|
||||
RETVAL=1
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
136
rpm/mongo.spec
Normal file
136
rpm/mongo.spec
Normal file
@ -0,0 +1,136 @@
|
||||
Name: mongo
|
||||
Version: 1.2.5
|
||||
Release: mongodb_1%{?dist}
|
||||
Summary: mongo client shell and tools
|
||||
License: AGPL 3.0
|
||||
URL: http://www.mongodb.org
|
||||
Group: Applications/Databases
|
||||
|
||||
Source0: %{name}-%{version}.tar.gz
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||
BuildRequires: js-devel, readline-devel, boost-devel, pcre-devel
|
||||
BuildRequires: gcc-c++, scons
|
||||
|
||||
%description
|
||||
Mongo (from "huMONGOus") is a schema-free document-oriented database.
|
||||
It features dynamic profileable queries, full indexing, replication
|
||||
and fail-over support, efficient storage of large binary data objects,
|
||||
and auto-sharding.
|
||||
|
||||
This package provides the mongo shell, import/export tools, and other
|
||||
client utilities.
|
||||
|
||||
%package server
|
||||
Summary: mongo server, sharding server, and support scripts
|
||||
Group: Applications/Databases
|
||||
Requires: mongo
|
||||
|
||||
%description server
|
||||
Mongo (from "huMONGOus") is a schema-free document-oriented database.
|
||||
|
||||
This package provides the mongo server software, mongo sharding server
|
||||
softwware, default configuration files, and init.d scripts.
|
||||
|
||||
%package devel
|
||||
Summary: Headers and libraries for mongo development.
|
||||
Group: Applications/Databases
|
||||
|
||||
%description devel
|
||||
Mongo (from "huMONGOus") is a schema-free document-oriented database.
|
||||
|
||||
This package provides the mongo static library and header files needed
|
||||
to develop mongo client software.
|
||||
|
||||
%prep
|
||||
%setup
|
||||
|
||||
%build
|
||||
scons --prefix=$RPM_BUILD_ROOT/usr all
|
||||
# XXX really should have shared library here
|
||||
|
||||
%install
|
||||
scons --prefix=$RPM_BUILD_ROOT/usr install
|
||||
mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1
|
||||
cp debian/*.1 $RPM_BUILD_ROOT/usr/share/man/man1/
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/rc.d/init.d
|
||||
cp rpm/init.d-mongod $RPM_BUILD_ROOT/etc/rc.d/init.d/mongod
|
||||
chmod a+x $RPM_BUILD_ROOT/etc/rc.d/init.d/mongod
|
||||
mkdir -p $RPM_BUILD_ROOT/etc
|
||||
cp rpm/mongod.conf $RPM_BUILD_ROOT/etc/mongod.conf
|
||||
mkdir -p $RPM_BUILD_ROOT/etc/sysconfig
|
||||
cp rpm/mongod.sysconfig $RPM_BUILD_ROOT/etc/sysconfig/mongod
|
||||
mkdir -p $RPM_BUILD_ROOT/var/lib/mongo
|
||||
mkdir -p $RPM_BUILD_ROOT/var/log/mongo
|
||||
touch $RPM_BUILD_ROOT/var/log/mongo/mongod.log
|
||||
|
||||
%clean
|
||||
scons -c
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%pre server
|
||||
/usr/sbin/useradd -M -r -U -d /var/lib/mongo -s /bin/false \
|
||||
-c mongod mongod > /dev/null 2>&1
|
||||
|
||||
%post server
|
||||
if test $1 = 1
|
||||
then
|
||||
/sbin/chkconfig --add mongod
|
||||
fi
|
||||
|
||||
%preun server
|
||||
if test $1 = 0
|
||||
then
|
||||
/sbin/chkconfig --del mongod
|
||||
fi
|
||||
|
||||
%postun server
|
||||
if test $1 -ge 1
|
||||
then
|
||||
/sbin/service mongod stop >/dev/null 2>&1 || :
|
||||
fi
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%doc README GNU-AGPL-3.0.txt
|
||||
|
||||
%{_bindir}/mongo
|
||||
%{_bindir}/mongodump
|
||||
%{_bindir}/mongoexport
|
||||
%{_bindir}/mongofiles
|
||||
%{_bindir}/mongoimport
|
||||
%{_bindir}/mongorestore
|
||||
|
||||
%{_mandir}/man1/mongo.1*
|
||||
%{_mandir}/man1/mongod.1*
|
||||
%{_mandir}/man1/mongodump.1*
|
||||
%{_mandir}/man1/mongoexport.1*
|
||||
%{_mandir}/man1/mongofiles.1*
|
||||
%{_mandir}/man1/mongoimport.1*
|
||||
%{_mandir}/man1/mongosniff.1*
|
||||
%{_mandir}/man1/mongorestore.1*
|
||||
|
||||
%files server
|
||||
%defattr(-,root,root,-)
|
||||
%config(noreplace) /etc/mongod.conf
|
||||
%{_bindir}/mongod
|
||||
%{_bindir}/mongos
|
||||
#%{_mandir}/man1/mongod.1*
|
||||
%{_mandir}/man1/mongos.1*
|
||||
/etc/rc.d/init.d/mongod
|
||||
/etc/sysconfig/mongod
|
||||
#/etc/rc.d/init.d/mongos
|
||||
%attr(0755,mongod,mongod) %dir /var/lib/mongo
|
||||
%attr(0755,mongod,mongod) %dir /var/log/mongo
|
||||
%attr(0640,mongod,mongod) %config(noreplace) %verify(not md5 size mtime) /var/log/mongo/mongod.log
|
||||
|
||||
%files devel
|
||||
/usr/include/mongo
|
||||
%{_libdir}/libmongoclient.a
|
||||
#%{_libdir}/libmongotestfiles.a
|
||||
|
||||
%changelog
|
||||
* Thu Jan 28 2010 Richard M Kreuter <richard@10gen.com>
|
||||
- Minor fixes.
|
||||
|
||||
* Sat Oct 24 2009 Joe Miklojcik <jmiklojcik@shopwiki.com> -
|
||||
- Wrote mongo.spec.
|
||||
89
rpm/mongod.conf
Normal file
89
rpm/mongod.conf
Normal file
@ -0,0 +1,89 @@
|
||||
# mongo.conf
|
||||
|
||||
#where to log
|
||||
logpath=/var/log/mongo/mongod.log
|
||||
|
||||
# fork and run in background
|
||||
fork = true
|
||||
|
||||
#port = 27017
|
||||
|
||||
dbpath=/var/lib/mongo
|
||||
|
||||
# Enables periodic logging of CPU utilization and I/O wait
|
||||
#cpu = true
|
||||
|
||||
# Turn on/off security. Off is currently the default
|
||||
#noauth = true
|
||||
#auth = true
|
||||
|
||||
# Verbose logging output.
|
||||
#verbose = true
|
||||
|
||||
# Inspect all client data for validity on receipt (useful for
|
||||
# developing drivers)
|
||||
#objcheck = true
|
||||
|
||||
# Enable db quota management
|
||||
#quota = true
|
||||
|
||||
# Set oplogging level where n is
|
||||
# 0=off (default)
|
||||
# 1=W
|
||||
# 2=R
|
||||
# 3=both
|
||||
# 7=W+some reads
|
||||
#oplog = 0
|
||||
|
||||
# Diagnostic/debugging option
|
||||
#nocursors = true
|
||||
|
||||
# Ignore query hints
|
||||
#nohints = true
|
||||
|
||||
# Disable the HTTP interface (Defaults to localhost:27018).
|
||||
#nohttpinterface = true
|
||||
|
||||
# Turns off server-side scripting. This will result in greatly limited
|
||||
# functionality
|
||||
#noscripting = true
|
||||
|
||||
# Turns off table scans. Any query that would do a table scan fails.
|
||||
#notablescan = true
|
||||
|
||||
# Disable data file preallocation.
|
||||
#noprealloc = true
|
||||
|
||||
# Specify .ns file size for new databases.
|
||||
# nssize = <size>
|
||||
|
||||
# Accout token for Mongo monitoring server.
|
||||
#mms-token = <token>
|
||||
|
||||
# Server name for Mongo monitoring server.
|
||||
#mms-name = <server-name>
|
||||
|
||||
# Ping interval for Mongo monitoring server.
|
||||
#mms-interval = <seconds>
|
||||
|
||||
# Replication Options
|
||||
|
||||
# in replicated mongo databases, specify here whether this is a slave or master
|
||||
#slave = true
|
||||
#source = master.example.com
|
||||
# Slave only: specify a single database to replicate
|
||||
#only = master.example.com
|
||||
# or
|
||||
#master = true
|
||||
#source = slave.example.com
|
||||
|
||||
# Address of a server to pair with.
|
||||
#pairwith = <server:port>
|
||||
# Address of arbiter server.
|
||||
#arbiter = <server:port>
|
||||
# Automatically resync if slave data is stale
|
||||
#autoresync
|
||||
# Custom size for replication operation log.
|
||||
#oplogSize = <MB>
|
||||
# Size limit for in-memory storage of op ids.
|
||||
#opIdMem = <bytes>
|
||||
1
rpm/mongod.sysconfig
Normal file
1
rpm/mongod.sysconfig
Normal file
@ -0,0 +1 @@
|
||||
# TODO: add relevant configuration stuff here.
|
||||
@ -171,7 +171,7 @@ int main(int argc, char* argv[], char *envp[] ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
log() << argv[0] << " v0.3- (alpha 3r) starting (--help for usage)" << endl;
|
||||
log() << argv[0] << " v0.2.6 (alpha 2f) starting (--help for usage)" << endl;
|
||||
printGitVersion();
|
||||
printSysInfo();
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
boost::thread_specific_ptr<SMScope> currentScope( dontDeleteScope );
|
||||
boost::recursive_mutex smmutex;
|
||||
boost::recursive_mutex &smmutex = *( new boost::recursive_mutex );
|
||||
#define smlock recursive_boostlock ___lk( smmutex );
|
||||
|
||||
#define GETHOLDER(x,o) ((BSONHolder*)JS_GetPrivate( x , o ))
|
||||
@ -818,7 +818,15 @@ namespace mongo {
|
||||
|
||||
a = args.obj();
|
||||
}
|
||||
BSONObj out = func( a );
|
||||
|
||||
BSONObj out;
|
||||
try {
|
||||
out = func( a );
|
||||
}
|
||||
catch ( std::exception& e ){
|
||||
JS_ReportError( cx , e.what() );
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if ( out.isEmpty() ){
|
||||
*rval = JSVAL_VOID;
|
||||
|
||||
@ -42,6 +42,7 @@
|
||||
#endif
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jsobj.h"
|
||||
#include "jsdate.h"
|
||||
#include "jsregexp.h"
|
||||
|
||||
|
||||
@ -124,7 +124,7 @@ namespace mongo {
|
||||
case mongo::Timestamp: {
|
||||
Local<v8::Object> sub = v8::Object::New();
|
||||
|
||||
sub->Set( v8::String::New( "time" ) , v8::Date::New( f.timestampTime() ) );
|
||||
sub->Set( v8::String::New( "t" ) , v8::Number::New( f.timestampTime() ) );
|
||||
sub->Set( v8::String::New( "i" ) , v8::Number::New( f.timestampInc() ) );
|
||||
|
||||
o->Set( v8::String::New( f.fieldName() ) , sub );
|
||||
@ -213,7 +213,7 @@ namespace mongo {
|
||||
case mongo::Timestamp: {
|
||||
Local<v8::Object> sub = v8::Object::New();
|
||||
|
||||
sub->Set( v8::String::New( "time" ) , v8::Date::New( f.timestampTime() ) );
|
||||
sub->Set( v8::String::New( "t" ) , v8::Number::New( f.timestampTime() ) );
|
||||
sub->Set( v8::String::New( "i" ) , v8::Number::New( f.timestampInc() ) );
|
||||
|
||||
return sub;
|
||||
|
||||
@ -113,7 +113,7 @@ ShardingTest = function( testName , numServers , verboseLevel , numMongos ){
|
||||
|
||||
for ( var i=0; i<numServers; i++){
|
||||
var conn = startMongod( { port : 30000 + i , dbpath : "/data/db/" + testName + i ,
|
||||
noprealloc : "" , smallfiles : "" , oplogSize : "2" } );
|
||||
noprealloc : "" , smallfiles : "" , oplogSize : "2" , "nohttpinterface" : ""} );
|
||||
conn.name = "localhost:" + ( 30000 + i );
|
||||
|
||||
this._connections.push( conn );
|
||||
@ -124,7 +124,7 @@ ShardingTest = function( testName , numServers , verboseLevel , numMongos ){
|
||||
|
||||
|
||||
this._mongos = [];
|
||||
var startMongosPort = 39999;
|
||||
var startMongosPort = 31000;
|
||||
for ( var i=0; i<(numMongos||1); i++ ){
|
||||
var myPort = startMongosPort - i;
|
||||
var conn = startMongos( { port : startMongosPort - i , v : verboseLevel || 0 , configdb : this._configDB } );
|
||||
@ -173,7 +173,7 @@ ShardingTest.prototype.getOther = function( one ){
|
||||
|
||||
ShardingTest.prototype.stop = function(){
|
||||
for ( var i=0; i<this._mongos.length; i++ ){
|
||||
stopMongoProgram( 39999 - i );
|
||||
stopMongoProgram( 31000 - i );
|
||||
}
|
||||
for ( var i=0; i<this._connections.length; i++){
|
||||
stopMongod( 30000 + i );
|
||||
@ -599,5 +599,12 @@ ReplTest.prototype.stop = function( master , signal ){
|
||||
this.stop( false );
|
||||
return;
|
||||
}
|
||||
stopMongod( this.getPort( master ) , signal || 15 );
|
||||
return stopMongod( this.getPort( master ) , signal || 15 );
|
||||
}
|
||||
|
||||
allocatePorts = function( n ) {
|
||||
var ret = [];
|
||||
for( var i = 31000; i < 31000 + n; ++i )
|
||||
ret.push( i );
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -139,42 +139,6 @@ namespace mongo {
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
BSONObj AllocatePorts( const BSONObj &args ) {
|
||||
uassert( "allocatePorts takes exactly 1 argument", args.nFields() == 1 );
|
||||
uassert( "allocatePorts needs to be passed an integer", args.firstElement().isNumber() );
|
||||
|
||||
int n = int( args.firstElement().number() );
|
||||
|
||||
vector< int > ports;
|
||||
vector< int > sockets;
|
||||
for( int i = 0; i < n; ++i ) {
|
||||
int s = socket( AF_INET, SOCK_STREAM, 0 );
|
||||
assert( s );
|
||||
|
||||
sockaddr_in address;
|
||||
memset(address.sin_zero, 0, sizeof(address.sin_zero));
|
||||
address.sin_family = AF_INET;
|
||||
address.sin_port = 0;
|
||||
address.sin_addr.s_addr = inet_addr( "127.0.0.1" );
|
||||
assert( 0 == ::bind( s, (sockaddr*)&address, sizeof( address ) ) );
|
||||
|
||||
sockaddr_in newAddress;
|
||||
socklen_t len = sizeof( newAddress );
|
||||
assert( 0 == getsockname( s, (sockaddr*)&newAddress, &len ) );
|
||||
ports.push_back( ntohs( newAddress.sin_port ) );
|
||||
sockets.push_back( s );
|
||||
}
|
||||
for( vector< int >::const_iterator i = sockets.begin(); i != sockets.end(); ++i )
|
||||
assert( 0 == close( *i ) );
|
||||
|
||||
sort( ports.begin(), ports.end() );
|
||||
for( unsigned i = 1; i < ports.size(); ++i )
|
||||
massert( "duplicate ports allocated", ports[ i - 1 ] != ports[ i ] );
|
||||
BSONObjBuilder b;
|
||||
b.append( "", ports );
|
||||
return b.obj();
|
||||
}
|
||||
|
||||
map< int, pair< pid_t, int > > dbs;
|
||||
map< pid_t, int > shells;
|
||||
@ -357,12 +321,13 @@ namespace mongo {
|
||||
return undefined_;
|
||||
}
|
||||
|
||||
void killDb( int port, pid_t _pid, int signal ) {
|
||||
int killDb( int port, pid_t _pid, int signal ) {
|
||||
pid_t pid;
|
||||
int exitCode = 0;
|
||||
if ( port > 0 ) {
|
||||
if( dbs.count( port ) != 1 ) {
|
||||
cout << "No db started on port: " << port << endl;
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
pid = dbs[ port ].first;
|
||||
} else {
|
||||
@ -382,6 +347,7 @@ namespace mongo {
|
||||
}
|
||||
int temp;
|
||||
int ret = waitpid( pid, &temp, WNOHANG );
|
||||
exitCode = WEXITSTATUS( temp );
|
||||
if ( ret == pid )
|
||||
break;
|
||||
sleepms( 1000 );
|
||||
@ -404,6 +370,8 @@ namespace mongo {
|
||||
if ( i > 4 || signal == SIGKILL ) {
|
||||
sleepms( 4000 ); // allow operating system to reclaim resources
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
int getSignal( const BSONObj &a ) {
|
||||
@ -422,18 +390,18 @@ namespace mongo {
|
||||
assert( a.nFields() == 1 || a.nFields() == 2 );
|
||||
assert( a.firstElement().isNumber() );
|
||||
int port = int( a.firstElement().number() );
|
||||
killDb( port, 0, getSignal( a ) );
|
||||
int code = killDb( port, 0, getSignal( a ) );
|
||||
cout << "shell: stopped mongo program on port " << port << endl;
|
||||
return undefined_;
|
||||
return BSON( "" << code );
|
||||
}
|
||||
|
||||
BSONObj StopMongoProgramByPid( const BSONObj &a ) {
|
||||
assert( a.nFields() == 1 || a.nFields() == 2 );
|
||||
assert( a.firstElement().isNumber() );
|
||||
int pid = int( a.firstElement().number() );
|
||||
killDb( 0, pid, getSignal( a ) );
|
||||
int code = killDb( 0, pid, getSignal( a ) );
|
||||
cout << "shell: stopped mongo program on pid " << pid << endl;
|
||||
return undefined_;
|
||||
return BSON( "" << code );
|
||||
}
|
||||
|
||||
void KillMongoProgramInstances() {
|
||||
@ -483,7 +451,6 @@ namespace mongo {
|
||||
scope.injectNative( "version" , JSVersion );
|
||||
scope.injectNative( "hex_md5" , jsmd5 );
|
||||
#if !defined(_WIN32)
|
||||
scope.injectNative( "allocatePorts", AllocatePorts );
|
||||
scope.injectNative( "_startMongoProgram", StartMongoProgram );
|
||||
scope.injectNative( "runMongoProgram", RunMongoProgram );
|
||||
scope.injectNative( "stopMongod", StopMongoProgram );
|
||||
|
||||
@ -32,6 +32,6 @@
|
||||
|
||||
namespace mongo {
|
||||
|
||||
const char versionString[] = "1.1.4-";
|
||||
const char versionString[] = "1.2.6-pre-";
|
||||
|
||||
} // namespace mongo
|
||||
|
||||
1
stdafx.h
1
stdafx.h
@ -53,6 +53,7 @@ namespace mongo {
|
||||
EXIT_OOM_MALLOC = 42 ,
|
||||
EXIT_OOM_REALLOC = 43 ,
|
||||
EXIT_FS = 45 ,
|
||||
EXIT_CLOCK_SKEW = 47 ,
|
||||
EXIT_POSSIBLE_CORRUPTION = 60 , // this means we detected a possible corruption situation, like a buf overflow
|
||||
EXIT_UNCAUGHT = 100 , // top level exception that wasn't caught
|
||||
EXIT_TEST = 101 ,
|
||||
|
||||
@ -198,13 +198,14 @@ public:
|
||||
log(1) << "filesize: " << fileSize << endl;
|
||||
ProgressMeter pm( fileSize );
|
||||
const int BUF_SIZE = 1024 * 1024 * 4;
|
||||
char line[ (1024 * 1024 * 4) + 128];
|
||||
boost::scoped_array<char> line (new char[BUF_SIZE]);
|
||||
while ( *in ){
|
||||
in->getline( line , BUF_SIZE );
|
||||
uassert( "unknown error reading file" , ( in->rdstate() & ios_base::badbit ) == 0 );
|
||||
log(1) << "got line:" << line << endl;
|
||||
char * buf = line.get();
|
||||
|
||||
in->getline( buf , BUF_SIZE );
|
||||
uassert( "unknown error reading file" , ( in->rdstate() & ios_base::badbit ) == 0 );
|
||||
log(1) << "got line:" << buf << endl;
|
||||
|
||||
char * buf = line;
|
||||
while( isspace( buf[0] ) ) buf++;
|
||||
|
||||
int len = strlen( buf );
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
|
||||
namespace mongo {
|
||||
|
||||
#if !defined(_WIN32) && !defined(NOEXECINFO)
|
||||
#if !defined(_WIN32) && !defined(NOEXECINFO) && !defined(__freebsd__)
|
||||
|
||||
} // namespace mongo
|
||||
|
||||
@ -180,6 +180,7 @@ namespace mongo {
|
||||
#define localtime _localtime_not_threadsafe_
|
||||
#define ctime _ctime_is_not_threadsafe_
|
||||
|
||||
#if defined(_WIN32) || defined(__sunos__)
|
||||
inline void sleepsecs(int s) {
|
||||
boost::xtime xt;
|
||||
boost::xtime_get(&xt, boost::TIME_UTC);
|
||||
@ -208,6 +209,28 @@ namespace mongo {
|
||||
}
|
||||
boost::thread::sleep(xt);
|
||||
}
|
||||
#else
|
||||
inline void sleepsecs(int s) {
|
||||
struct timespec t;
|
||||
t.tv_sec = s;
|
||||
t.tv_nsec = 0;
|
||||
if ( nanosleep( &t , 0 ) ){
|
||||
cout << "nanosleep failed" << endl;
|
||||
}
|
||||
}
|
||||
inline void sleepmicros(int s) {
|
||||
struct timespec t;
|
||||
t.tv_sec = (int)(s / 1000000);
|
||||
t.tv_nsec = s % 1000000;
|
||||
if ( nanosleep( &t , 0 ) ){
|
||||
cout << "nanosleep failed" << endl;
|
||||
}
|
||||
}
|
||||
inline void sleepmillis(int s) {
|
||||
sleepmicros( s * 1000 );
|
||||
}
|
||||
#endif
|
||||
|
||||
// note this wraps
|
||||
inline int tdiff(unsigned told, unsigned tnew) {
|
||||
return WrappingInt::diff(tnew, told);
|
||||
@ -219,6 +242,15 @@ namespace mongo {
|
||||
return (xt.sec & 0xfffff) * 1000 + t;
|
||||
}
|
||||
|
||||
struct Date_t {
|
||||
// TODO: make signed (and look for related TODO's)
|
||||
unsigned long long millis;
|
||||
Date_t(): millis(0) {}
|
||||
Date_t(unsigned long long m): millis(m) {}
|
||||
operator unsigned long long&() { return millis; }
|
||||
operator const unsigned long long&() const { return millis; }
|
||||
};
|
||||
|
||||
inline unsigned long long jsTime() {
|
||||
boost::xtime xt;
|
||||
boost::xtime_get(&xt, boost::TIME_UTC);
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
#include "../util/background.h"
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include "../db/cmdline.h"
|
||||
|
||||
namespace mongo {
|
||||
|
||||
@ -84,7 +85,7 @@ namespace mongo {
|
||||
continue;
|
||||
}
|
||||
disableNagle(s);
|
||||
log() << "connection accepted from " << from.toString() << " #" << ++connNumber << endl;
|
||||
if ( ! cmdLine.quiet ) log() << "connection accepted from " << from.toString() << " #" << ++connNumber << endl;
|
||||
accepted( new MessagingPort(s, from) );
|
||||
}
|
||||
}
|
||||
@ -295,6 +296,14 @@ again:
|
||||
}
|
||||
goto again;
|
||||
}
|
||||
|
||||
if ( len == 542393671 ){
|
||||
// an http GET
|
||||
log() << "looks like you're trying to access db over http on native driver port. please add 1000 for webserver" << endl;
|
||||
static const char * wrongPort = "HTTP 1.0 404 Not Found\nConnection: Close\n\nYou are trying to access MongoDB on the native driver port. For http access, add 1000 to the port\n\n";
|
||||
::send( sock , wrongPort , strlen( wrongPort ) , 0 );
|
||||
return false;
|
||||
}
|
||||
log() << "bad recv() len: " << len << '\n';
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -22,6 +22,10 @@ namespace mongo {
|
||||
class MemoryMappedFile {
|
||||
public:
|
||||
|
||||
enum Options {
|
||||
SEQUENTIAL = 1
|
||||
};
|
||||
|
||||
MemoryMappedFile();
|
||||
~MemoryMappedFile(); /* closes the file if open */
|
||||
void close();
|
||||
@ -32,7 +36,7 @@ namespace mongo {
|
||||
/* Creates with length if DNE, otherwise uses existing file length,
|
||||
passed length.
|
||||
*/
|
||||
void* map(const char *filename, long &length);
|
||||
void* map(const char *filename, long &length, int options = 0 );
|
||||
|
||||
void flush(bool sync);
|
||||
|
||||
|
||||
@ -49,7 +49,7 @@ namespace mongo {
|
||||
#define O_NOATIME 0
|
||||
#endif
|
||||
|
||||
void* MemoryMappedFile::map(const char *filename, long &length) {
|
||||
void* MemoryMappedFile::map(const char *filename, long &length, int options) {
|
||||
// length may be updated by callee.
|
||||
theFileAllocator().allocateAsap( filename, length );
|
||||
len = length;
|
||||
@ -76,9 +76,20 @@ namespace mongo {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(__sunos__)
|
||||
#warning madvise not supported on solaris yet
|
||||
#else
|
||||
|
||||
if ( options & SEQUENTIAL ){
|
||||
if ( madvise( view , length , MADV_SEQUENTIAL ) ){
|
||||
out() << " madvise failed for " << filename << " " << errno << endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return view;
|
||||
}
|
||||
|
||||
|
||||
void MemoryMappedFile::flush(bool sync) {
|
||||
if ( view == 0 || fd == 0 )
|
||||
return;
|
||||
|
||||
@ -25,6 +25,7 @@ namespace mongo {
|
||||
fd = 0;
|
||||
maphandle = 0;
|
||||
view = 0;
|
||||
len = 0;
|
||||
created();
|
||||
}
|
||||
|
||||
@ -48,7 +49,7 @@ namespace mongo {
|
||||
|
||||
unsigned mapped = 0;
|
||||
|
||||
void* MemoryMappedFile::map(const char *_filename, long &length) {
|
||||
void* MemoryMappedFile::map(const char *_filename, long &length, int options ) {
|
||||
/* big hack here: Babble uses db names with colons. doesn't seem to work on windows. temporary perhaps. */
|
||||
char filename[256];
|
||||
strncpy(filename, _filename, 255);
|
||||
@ -68,9 +69,13 @@ namespace mongo {
|
||||
updateLength( filename, length );
|
||||
std::wstring filenamew = toWideString(filename);
|
||||
|
||||
DWORD createOptions = FILE_ATTRIBUTE_NORMAL;
|
||||
if ( options & SEQUENTIAL )
|
||||
createOptions |= FILE_FLAG_SEQUENTIAL_SCAN;
|
||||
|
||||
fd = CreateFile(
|
||||
filenamew.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,
|
||||
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
NULL, OPEN_ALWAYS, createOptions , NULL);
|
||||
if ( fd == INVALID_HANDLE_VALUE ) {
|
||||
out() << "Create/OpenFile failed " << filename << ' ' << GetLastError() << endl;
|
||||
return 0;
|
||||
@ -94,7 +99,21 @@ namespace mongo {
|
||||
return view;
|
||||
}
|
||||
|
||||
void MemoryMappedFile::flush(bool) {
|
||||
}
|
||||
void MemoryMappedFile::flush(bool sync) {
|
||||
uassert("Async flushing not supported on windows", sync);
|
||||
|
||||
if (!view) return;
|
||||
|
||||
bool success = FlushViewOfFile(view, 0); // 0 means whole mapping
|
||||
if (!success){
|
||||
int err = GetLastError();
|
||||
out() << "FlushViewOfFile failed " << err << endl;
|
||||
}
|
||||
|
||||
success = FlushFileBuffers(fd);
|
||||
if (!success){
|
||||
int err = GetLastError();
|
||||
out() << "FlushFileBuffers failed " << err << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,15 +20,24 @@
|
||||
#include "../db/concurrency.h"
|
||||
|
||||
namespace mongo {
|
||||
void exitCleanly( int code );
|
||||
|
||||
/* Operation sequence #. A combination of current second plus an ordinal value.
|
||||
*/
|
||||
struct ClockSkewException : public DBException {
|
||||
virtual const char* what() const throw() { return "clock skew exception"; }
|
||||
virtual int getCode(){ return 20001; }
|
||||
};
|
||||
|
||||
#pragma pack(4)
|
||||
class OpTime {
|
||||
unsigned i;
|
||||
unsigned secs;
|
||||
static OpTime last;
|
||||
public:
|
||||
static void setLast(const Date_t &date) {
|
||||
last = OpTime(date);
|
||||
}
|
||||
unsigned getSecs() const {
|
||||
return secs;
|
||||
}
|
||||
@ -46,6 +55,20 @@ namespace mongo {
|
||||
static OpTime now() {
|
||||
unsigned t = (unsigned) time(0);
|
||||
// DEV assertInWriteLock();
|
||||
if ( t < last.secs ){
|
||||
bool toLog = false;
|
||||
ONCE toLog = true;
|
||||
RARELY toLog = true;
|
||||
if ( last.i & 0x80000000 )
|
||||
toLog = true;
|
||||
if ( toLog )
|
||||
log() << "clock skew detected prev: " << last.secs << " now: " << t << " trying to handle..." << endl;
|
||||
if ( last.i & 0x80000000 ) {
|
||||
log() << "ERROR Large clock skew detected, shutting down" << endl;
|
||||
throw ClockSkewException();
|
||||
}
|
||||
t = last.secs;
|
||||
}
|
||||
if ( last.secs == t ) {
|
||||
last.i++;
|
||||
return last;
|
||||
|
||||
@ -21,12 +21,6 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
#ifdef _WIN32
|
||||
int getpid(){
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace mongo {
|
||||
|
||||
ProcessInfo::ProcessInfo( pid_t pid ){
|
||||
|
||||
63
util/processinfo_win32.cpp
Normal file
63
util/processinfo_win32.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
// processinfo_win32.cpp
|
||||
|
||||
/* Copyright 2009 10gen Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "processinfo.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int getpid(){
|
||||
return GetCurrentProcessId();
|
||||
}
|
||||
|
||||
namespace mongo {
|
||||
|
||||
int _wconvertmtos( SIZE_T s ){
|
||||
return (int)( s / ( 1024 * 1024 ) );
|
||||
}
|
||||
|
||||
ProcessInfo::ProcessInfo( pid_t pid ){
|
||||
}
|
||||
|
||||
ProcessInfo::~ProcessInfo(){
|
||||
}
|
||||
|
||||
bool ProcessInfo::supported(){
|
||||
return true;
|
||||
}
|
||||
|
||||
int ProcessInfo::getVirtualMemorySize(){
|
||||
MEMORYSTATUSEX mse;
|
||||
mse.dwLength = sizeof(mse);
|
||||
assert( GlobalMemoryStatusEx( &mse ) );
|
||||
DWORDLONG x = (mse.ullTotalVirtual - mse.ullAvailVirtual) / (1024 * 1024) ;
|
||||
assert( x <= 0x7fffffff );
|
||||
return (int) x;
|
||||
}
|
||||
|
||||
int ProcessInfo::getResidentSize(){
|
||||
PROCESS_MEMORY_COUNTERS pmc;
|
||||
assert( GetProcessMemoryInfo( GetCurrentProcess() , &pmc, sizeof(pmc) ) );
|
||||
return _wconvertmtos( pmc.WorkingSetSize );
|
||||
}
|
||||
|
||||
}
|
||||
@ -122,9 +122,9 @@ namespace mongo {
|
||||
#if defined(_WIN32)
|
||||
(std::cout << now << " " << s).flush();
|
||||
#else
|
||||
assert( write( STDOUT_FILENO, now, 20 ) > 0 );
|
||||
assert( write( STDOUT_FILENO, " ", 1 ) > 0 );
|
||||
assert( write( STDOUT_FILENO, s.c_str(), s.length() ) > 0 );
|
||||
write( STDOUT_FILENO, now, 20 );
|
||||
write( STDOUT_FILENO, " ", 1 );
|
||||
write( STDOUT_FILENO, s.c_str(), s.length() );
|
||||
fsync( STDOUT_FILENO );
|
||||
#endif
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user