Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
35
SConstruct
35
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"
|
||||
@@ -1240,7 +1265,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 +1388,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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
16
db/db.cpp
16
db/db.cpp
@@ -113,9 +113,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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -283,7 +290,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 +354,7 @@ namespace mongo {
|
||||
|
||||
if ( shouldRepairDatabases ){
|
||||
log() << "finished checking dbs" << endl;
|
||||
cc().shutdown();
|
||||
dbexit( EXIT_CLEAN );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1185,6 +1185,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" ){
|
||||
@@ -1269,6 +1303,7 @@ namespace JsobjTests {
|
||||
add< BSONArrayBuilderTest >();
|
||||
add< ArrayMacroTest >();
|
||||
add< NumberParsing >();
|
||||
add< InvalidIDFind >();
|
||||
}
|
||||
} myall;
|
||||
|
||||
|
||||
2
debian/changelog
vendored
2
debian/changelog
vendored
@@ -1,4 +1,4 @@
|
||||
mongodb (1.1.3) unstable; urgency=low
|
||||
mongodb (1.2.2) stable; urgency=low
|
||||
|
||||
* Initial release
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = MongoDB
|
||||
PROJECT_NUMBER = 1.1.3
|
||||
PROJECT_NUMBER = 1.2.2
|
||||
OUTPUT_DIRECTORY = docs
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
|
||||
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()
|
||||
@@ -208,6 +208,7 @@
|
||||
93A6E10D0F24CFB100DA4EBF /* flushtest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = flushtest.cpp; sourceTree = "<group>"; };
|
||||
93A6E10E0F24CFD300DA4EBF /* security.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = security.h; sourceTree = "<group>"; };
|
||||
93A6E10F0F24CFEA00DA4EBF /* security_commands.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = security_commands.cpp; sourceTree = "<group>"; };
|
||||
93A71D2D10D04D15003C9E90 /* auth2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = auth2.js; sourceTree = "<group>"; };
|
||||
93A8CD170F33B78D00C92B85 /* mmap_mm.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_mm.cpp; path = util/mmap_mm.cpp; sourceTree = SOURCE_ROOT; };
|
||||
93A8CD180F33B7A000C92B85 /* mmap_posix.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_posix.cpp; path = util/mmap_posix.cpp; sourceTree = SOURCE_ROOT; };
|
||||
93A8CD190F33B7AF00C92B85 /* mmap_win.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mmap_win.cpp; path = util/mmap_win.cpp; sourceTree = SOURCE_ROOT; };
|
||||
@@ -641,6 +642,7 @@
|
||||
93A8D1D10F37544800C92B85 /* jstests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
93A71D2D10D04D15003C9E90 /* auth2.js */,
|
||||
935E7B8A0FCF37D40024B2E5 /* sharding */,
|
||||
936D937F0FCC67C700004410 /* index9.js */,
|
||||
936D931B0FCC58C900004410 /* regex.js */,
|
||||
|
||||
63
rpm/init.d-mongod
Normal file
63
rpm/init.d-mongod
Normal file
@@ -0,0 +1,63 @@
|
||||
#!/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"
|
||||
|
||||
mongod=${MONGOD-/usr/bin/mongod}
|
||||
pidfile=${PIDFILE-/var/run/mongod.pid}
|
||||
lockfile=${LOCKFILE-/var/lock/subsys/mongod}
|
||||
|
||||
start()
|
||||
{
|
||||
echo -n $"Starting mongod: "
|
||||
#daemon --pidfile=${pidfile} $mongod $OPTIONS > /var/log/mongod
|
||||
$mongod $OPTIONS > /var/log/mongod 2>&1 &
|
||||
RETVAL=$?
|
||||
[ $RETVAL = 0 ] && touch ${lockfile}
|
||||
echo OK
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
echo -n $"Stopping mongod: "
|
||||
#killproc -p ${pidfile} -d 10 $mongod
|
||||
#RETVAL=$?
|
||||
killall mongod > /dev/null 2>&1
|
||||
#[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
|
||||
echo OK
|
||||
}
|
||||
|
||||
ulimit -n 12000
|
||||
RETVAL=0
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
# status)
|
||||
# status -p ${pidfile} $mongod
|
||||
# ;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart}"
|
||||
RETVAL=1
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
128
rpm/mongo.spec
Normal file
128
rpm/mongo.spec
Normal file
@@ -0,0 +1,128 @@
|
||||
Name: mongo
|
||||
Version: 1.2.2
|
||||
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
|
||||
|
||||
%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/var/lib/mongo
|
||||
mkdir -p $RPM_BUILD_ROOT/var/log
|
||||
touch $RPM_BUILD_ROOT/var/log/mongo
|
||||
|
||||
%clean
|
||||
scons -c
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%pre server
|
||||
#/usr/sbin/useradd -M -o -r -d /var/mongo -s /bin/bash \
|
||||
# -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/mongodump.1*
|
||||
%{_mandir}/man1/mongoexport.1*
|
||||
%{_mandir}/man1/mongofiles.1*
|
||||
%{_mandir}/man1/mongoimport.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,root,root) %dir /var/mongo
|
||||
%attr(0640,root,root) %config(noreplace) %verify(not md5 size mtime) /var/log/mongo
|
||||
|
||||
%files devel
|
||||
/usr/include/mongo
|
||||
%{_libdir}/libmongoclient.a
|
||||
#%{_libdir}/libmongotestfiles.a
|
||||
|
||||
%changelog
|
||||
* Sat Oct 24 2009 Joe Miklojcik <jmiklojcik@shopwiki.com> -
|
||||
- Wrote mongo.spec.
|
||||
|
||||
86
rpm/mongod.conf
Normal file
86
rpm/mongod.conf
Normal file
@@ -0,0 +1,86 @@
|
||||
# mongo.conf
|
||||
|
||||
#where to log
|
||||
logpath=/var/log/mongod
|
||||
|
||||
#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>
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -32,6 +32,6 @@
|
||||
|
||||
namespace mongo {
|
||||
|
||||
const char versionString[] = "1.1.4-";
|
||||
const char versionString[] = "1.2.2";
|
||||
|
||||
} // namespace mongo
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace mongo {
|
||||
fd = 0;
|
||||
maphandle = 0;
|
||||
view = 0;
|
||||
len = 0;
|
||||
created();
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user