mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
Merge branch 'master' of git@github.com:mongodb/mongo
This commit is contained in:
commit
0dc74b1fe0
@ -162,6 +162,7 @@ allClientFiles = commonFiles + coreDbFiles + [ "client/clientOnly.cpp" , "client
|
||||
onlyServer = len( COMMAND_LINE_TARGETS ) == 0 or ( len( COMMAND_LINE_TARGETS ) == 1 and str( COMMAND_LINE_TARGETS[0] ) == "mongod" )
|
||||
nix = False
|
||||
useJavaHome = False
|
||||
linux = False
|
||||
linux64 = False
|
||||
darwin = False
|
||||
windows = False
|
||||
@ -231,6 +232,7 @@ if "darwin" == os.sys.platform:
|
||||
env.Append( LIBPATH=["/sw/lib/", "/opt/local/lib"] )
|
||||
|
||||
elif "linux2" == os.sys.platform:
|
||||
linux = True
|
||||
useJavaHome = True
|
||||
javaOS = "linux"
|
||||
platform = "linux"
|
||||
@ -480,6 +482,9 @@ def doConfigure( myenv , needJava=True , needPcre=True , shell=False ):
|
||||
else:
|
||||
print( "WARNING: no readline, shell will be a bit ugly" )
|
||||
|
||||
if linux:
|
||||
myCheckLib( "rt" , True )
|
||||
|
||||
# this will add it iff it exists and works
|
||||
myCheckLib( "boost_system-mt" )
|
||||
|
||||
|
@ -548,6 +548,8 @@ namespace mongo {
|
||||
*/
|
||||
virtual void resetIndexCache();
|
||||
|
||||
virtual string getServerAddress() const = 0;
|
||||
|
||||
private:
|
||||
set<string> _seenIndexes;
|
||||
};
|
||||
@ -640,6 +642,10 @@ namespace mongo {
|
||||
return serverAddress;
|
||||
}
|
||||
|
||||
string getServerAddress() const {
|
||||
return serverAddress;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool call( Message &toSend, Message &response, bool assertOk = true );
|
||||
virtual void say( Message &toSend );
|
||||
@ -726,6 +732,10 @@ namespace mongo {
|
||||
master = ( ( master == Left ) ? NotSetR : NotSetL );
|
||||
}
|
||||
|
||||
string getServerAddress() const {
|
||||
return left.getServerAddress() + "," + right.getServerAddress();
|
||||
}
|
||||
|
||||
/* TODO - not yet implemented. mongos may need these. */
|
||||
virtual bool call( Message &toSend, Message &response, bool assertOk=true ) { assert(false); return false; }
|
||||
virtual void say( Message &toSend ) { assert(false); }
|
||||
|
@ -47,8 +47,8 @@ namespace mongo {
|
||||
/** Load a single object.
|
||||
@return true if successful.
|
||||
*/
|
||||
bool load(BSONObj& query);
|
||||
void save( bool check=false );
|
||||
virtual bool load(BSONObj& query);
|
||||
virtual void save( bool check=false );
|
||||
|
||||
private:
|
||||
BSONObj _id;
|
||||
|
@ -130,7 +130,7 @@ namespace mongo {
|
||||
printSysInfo();
|
||||
pdfileInit();
|
||||
//testTheDb();
|
||||
log() << "waiting for connections on port " << port << "..." << endl;
|
||||
log() << "waiting for connections on port " << port << endl;
|
||||
OurListener l(port);
|
||||
startReplication();
|
||||
boost::thread thr(webServerThread);
|
||||
|
@ -147,7 +147,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
void doUnlockedStuff(stringstream& ss) {
|
||||
ss << "port: " << port << '\n';
|
||||
/* this is in the header already ss << "port: " << port << '\n'; */
|
||||
ss << "dblocked: " << dbMutexInfo.isLocked() << " (initial)\n";
|
||||
ss << "uptime: " << time(0)-started << " seconds\n";
|
||||
if ( replAllDead )
|
||||
@ -251,7 +251,7 @@ namespace mongo {
|
||||
string dbname;
|
||||
{
|
||||
stringstream z;
|
||||
z << "db " << getHostName() << ':' << port << ' ';
|
||||
z << "mongodb " << getHostName() << ':' << port << ' ';
|
||||
dbname = z.str();
|
||||
}
|
||||
ss << dbname << "</title></head><body><h2>" << dbname << "</h2><p>\n<pre>";
|
||||
@ -442,8 +442,14 @@ namespace mongo {
|
||||
AuthenticationInfo *ai = new AuthenticationInfo();
|
||||
authInfo.reset(ai);
|
||||
DbWebServer mini;
|
||||
if ( mini.init(port+1000) )
|
||||
int p = port + 1000;
|
||||
if ( mini.init(p) ) {
|
||||
log() << "web admin interface listening on port " << p << '\n';
|
||||
mini.run();
|
||||
}
|
||||
else {
|
||||
log() << "warning: web admin interface failed to initialize on port " << p << endl;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mongo
|
||||
|
@ -104,6 +104,9 @@ namespace mongo {
|
||||
virtual string toString() {
|
||||
return "DBDirectClient";
|
||||
}
|
||||
virtual string getServerAddress() const{
|
||||
return "localhost"; // TODO: should this have the port?
|
||||
}
|
||||
virtual bool call( Message &toSend, Message &response, bool assertOk=true );
|
||||
virtual void say( Message &toSend );
|
||||
virtual void sayPiggyBack( Message &toSend ) {
|
||||
|
76
jstests/repl/repl6.js
Normal file
76
jstests/repl/repl6.js
Normal file
@ -0,0 +1,76 @@
|
||||
// Test one master replicating to two slaves
|
||||
|
||||
var baseName = "jstests_repl6test";
|
||||
|
||||
soonCount = function( m, count ) {
|
||||
assert.soon( function() {
|
||||
// print( "check count" );
|
||||
if ( -1 == m.getDBNames().indexOf( baseName ) )
|
||||
return false;
|
||||
if ( -1 == m.getDB( baseName ).getCollectionNames().indexOf( "a" ) )
|
||||
return false;
|
||||
// print( "count: " + s.getDB( baseName ).z.find().count() );
|
||||
return m.getDB( baseName ).a.find().count() == count;
|
||||
} );
|
||||
}
|
||||
|
||||
doTest = function( signal ) {
|
||||
|
||||
// spec small oplog for fast startup on 64bit machines
|
||||
m = startMongod( "--port", "27018", "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
|
||||
s1 = startMongod( "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave1", "--slave", "--source", "127.0.0.1:27018" );
|
||||
s2 = startMongod( "--port", "27020", "--dbpath", "/data/db/" + baseName + "-slave2", "--slave", "--source", "127.0.0.1:27018" );
|
||||
|
||||
am = m.getDB( baseName ).a
|
||||
|
||||
for( i = 0; i < 1000; ++i )
|
||||
am.save( { _id: new ObjectId(), i: i } );
|
||||
|
||||
soonCount( s1, 1000 );
|
||||
soonCount( s2, 1000 );
|
||||
|
||||
check = function( as ) {
|
||||
assert.eq( 1, as.find( { i: 0 } ).count() );
|
||||
assert.eq( 1, as.find( { i: 999 } ).count() );
|
||||
}
|
||||
|
||||
as = s1.getDB( baseName ).a
|
||||
check( as );
|
||||
as = s2.getDB( baseName ).a
|
||||
check( as );
|
||||
|
||||
stopMongod( 27019, signal );
|
||||
stopMongod( 27020, signal );
|
||||
|
||||
for( i = 1000; i < 1010; ++i )
|
||||
am.save( { _id: new ObjectId(), i: i } );
|
||||
|
||||
s1 = startMongoProgram( "mongod", "--port", "27019", "--dbpath", "/data/db/" + baseName + "-slave1", "--slave", "--source", "127.0.0.1:27018" );
|
||||
soonCount( s1, 1010 );
|
||||
as = s1.getDB( baseName ).a
|
||||
assert.eq( 1, as.find( { i: 1009 } ).count() );
|
||||
|
||||
stopMongod( 27018, signal );
|
||||
|
||||
m = startMongoProgram( "mongod", "--port", "27018", "--dbpath", "/data/db/" + baseName + "-master", "--master", "--oplogSize", "1" );
|
||||
am = m.getDB( baseName ).a
|
||||
|
||||
for( i = 1010; i < 1020; ++i )
|
||||
am.save( { _id: new ObjectId(), i: i } );
|
||||
|
||||
soonCount( s1, 1020 );
|
||||
assert.eq( 1, as.find( { i: 1019 } ).count() );
|
||||
|
||||
s2 = startMongoProgram( "mongod", "--port", "27020", "--dbpath", "/data/db/" + baseName + "-slave2", "--slave", "--source", "127.0.0.1:27018" );
|
||||
soonCount( s2, 1020 );
|
||||
as = s2.getDB( baseName ).a
|
||||
assert.eq( 1, as.find( { i: 1009 } ).count() );
|
||||
assert.eq( 1, as.find( { i: 1019 } ).count() );
|
||||
|
||||
stopMongod( 27018 );
|
||||
stopMongod( 27019 );
|
||||
stopMongod( 27020 );
|
||||
}
|
||||
|
||||
doTest( 15 ); // SIGTERM
|
||||
doTest( 9 ); // SIGKILL
|
@ -243,6 +243,7 @@
|
||||
93D6BC9B0F266FC300FE5722 /* querytests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = querytests.cpp; sourceTree = "<group>"; };
|
||||
93D941BF0F77D64F00C3C768 /* replacePeer1.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = replacePeer1.js; sourceTree = "<group>"; };
|
||||
93D941C00F77D64F00C3C768 /* replacePeer2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = replacePeer2.js; sourceTree = "<group>"; };
|
||||
93D9469F0F7ABB0600C3C768 /* repl6.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl6.js; sourceTree = "<group>"; };
|
||||
93E3C5310F704C9D0029011E /* repl4.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl4.js; sourceTree = "<group>"; };
|
||||
93E3C5960F7149F40029011E /* repl5.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = repl5.js; sourceTree = "<group>"; };
|
||||
93E727090F4B5B5B004F9B5D /* shardkey.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = shardkey.cpp; sourceTree = "<group>"; };
|
||||
@ -608,6 +609,7 @@
|
||||
93A8D2040F37544800C92B85 /* repl */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
93D9469F0F7ABB0600C3C768 /* repl6.js */,
|
||||
93D941BF0F77D64F00C3C768 /* replacePeer1.js */,
|
||||
93D941C00F77D64F00C3C768 /* replacePeer2.js */,
|
||||
93E3C5960F7149F40029011E /* repl5.js */,
|
||||
|
@ -48,6 +48,8 @@ namespace mongo {
|
||||
}
|
||||
|
||||
ScopedDbConnection conn( server );
|
||||
checkShardVersion( conn.conn() , _ns );
|
||||
|
||||
log(5) << "ShardedCursor::query server:" << server << " ns:" << _ns << " query:" << q << " num:" << num << " _fields:" << _fields << " options: " << _options << endl;
|
||||
auto_ptr<DBClientCursor> cursor = conn->query( _ns.c_str() , q , num , 0 , ( _fields.isEmpty() ? 0 : &_fields ) , _options );
|
||||
conn.done();
|
||||
|
@ -67,7 +67,7 @@ namespace mongo {
|
||||
};
|
||||
|
||||
void start() {
|
||||
log() << "waiting for connections on port " << port << "..." << endl;
|
||||
log() << "waiting for connections on port " << port << endl;
|
||||
//DbGridListener l(port);
|
||||
//l.listen();
|
||||
ShardedMessageHandler handler;
|
||||
|
18
s/shard.cpp
18
s/shard.cpp
@ -200,6 +200,24 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
|
||||
ServerShardVersion ShardManager::getVersion( const string& server ) const{
|
||||
// TODO: cache or something?
|
||||
|
||||
ServerShardVersion max = 0;
|
||||
cout << "getVersion for: " << server << endl;
|
||||
for ( vector<Shard*>::const_iterator i=_shards.begin(); i!=_shards.end(); i++ ){
|
||||
Shard* s = *i;
|
||||
cout << "\t" << s->getServer() << endl;
|
||||
if ( s->getServer() != server )
|
||||
continue;
|
||||
|
||||
if ( s->_lastmod > max )
|
||||
max = s->_lastmod;
|
||||
}
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
string ShardManager::toString() const {
|
||||
stringstream ss;
|
||||
ss << "ShardManager: " << _ns << " key:" << _key.toString() << "\n";
|
||||
|
@ -35,6 +35,8 @@ namespace mongo {
|
||||
class ShardManager;
|
||||
class ShardObjUnitTest;
|
||||
|
||||
typedef unsigned long long ServerShardVersion;
|
||||
|
||||
/**
|
||||
config.shard
|
||||
{ ns : "alleyinsider.fs.chunks" , min : {} , max : {} , server : "localhost:30001" }
|
||||
@ -88,7 +90,7 @@ namespace mongo {
|
||||
BSONObj _min;
|
||||
BSONObj _max;
|
||||
string _server;
|
||||
unsigned long long _lastmod;
|
||||
ServerShardVersion _lastmod;
|
||||
|
||||
bool _modified;
|
||||
|
||||
@ -130,6 +132,7 @@ namespace mongo {
|
||||
string toString() const;
|
||||
operator string() const { return toString(); }
|
||||
|
||||
ServerShardVersion getVersion( const string& server ) const;
|
||||
private:
|
||||
DBConfig * _config;
|
||||
string _ns;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "request.h"
|
||||
#include "../client/connpool.h"
|
||||
#include "../db/commands.h"
|
||||
#include "shard.h"
|
||||
|
||||
namespace mongo {
|
||||
|
||||
@ -25,6 +26,8 @@ namespace mongo {
|
||||
ScopedDbConnection dbcon( server );
|
||||
DBClientBase &_c = dbcon.conn();
|
||||
|
||||
checkShardVersion( _c , r.getns() );
|
||||
|
||||
// TODO: This will not work with Paired connections. Fix.
|
||||
DBClientConnection&c = dynamic_cast<DBClientConnection&>(_c);
|
||||
Message response;
|
||||
@ -47,4 +50,22 @@ namespace mongo {
|
||||
dbcon.done();
|
||||
}
|
||||
|
||||
void checkShardVersion( DBClientBase& conn , const string& ns ){
|
||||
// TODO: cache, optimize, etc...
|
||||
|
||||
DBConfig * conf = grid.getDBConfig( ns );
|
||||
if ( ! conf )
|
||||
return;
|
||||
|
||||
if ( ! conf->sharded( ns ) )
|
||||
return;
|
||||
|
||||
ServerShardVersion version = conf->getShardManager( ns )->getVersion( conn.getServerAddress() );
|
||||
cout << "got version: " << version << " for : " << ns << endl;
|
||||
|
||||
|
||||
// grid->getVersion( conn.server() , ns );
|
||||
// check
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ namespace mongo {
|
||||
|
||||
};
|
||||
|
||||
void checkShardVersion( DBClientBase & conn , const string& ns );
|
||||
|
||||
extern Strategy * SINGLE;
|
||||
extern Strategy * SHARDED;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user