summaryrefslogtreecommitdiff
path: root/s/config.cpp
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2010-03-25 19:21:32 +0100
committerAntonin Kral <a.kral@bobek.cz>2010-03-25 19:21:32 +0100
commit0ca01a91ae0a3562e54c226e7b9512feb2ea83d0 (patch)
tree2b3886e435b0217d6afd63a213b04d32bb4b4f6f /s/config.cpp
parenta696359b248adef0cc8576fce3f473535e995136 (diff)
downloadmongodb-0ca01a91ae0a3562e54c226e7b9512feb2ea83d0.tar.gz
Imported Upstream version 1.4.0
Diffstat (limited to 's/config.cpp')
-rw-r--r--s/config.cpp49
1 files changed, 41 insertions, 8 deletions
diff --git a/s/config.cpp b/s/config.cpp
index 0bfb5a3..c3c3668 100644
--- a/s/config.cpp
+++ b/s/config.cpp
@@ -129,6 +129,8 @@ namespace mongo {
void DBConfig::unserialize(const BSONObj& from){
_name = from.getStringField("name");
+ log(1) << "DBConfig unserialize: " << _name << " " << from << endl;
+
_shardingEnabled = from.getBoolField("partitioned");
_primary = from.getStringField("primary");
@@ -297,7 +299,7 @@ namespace mongo {
if ( database == "config" )
return &configServer;
- boostlock l( _lock );
+ scoped_lock l( _lock );
DBConfig*& cc = _databases[database];
if ( cc == 0 ){
@@ -333,7 +335,7 @@ namespace mongo {
void Grid::removeDB( string database ){
uassert( 10186 , "removeDB expects db name" , database.find( '.' ) == string::npos );
- boostlock l( _lock );
+ scoped_lock l( _lock );
_databases.erase( database );
}
@@ -369,30 +371,35 @@ namespace mongo {
}
ourHostname = hn;
+ stringstream fullString;
+
set<string> hosts;
for ( size_t i=0; i<configHosts.size(); i++ ){
string host = configHosts[i];
hosts.insert( getHost( host , false ) );
configHosts[i] = getHost( host , true );
+ if ( i > 0 )
+ fullString << ",";
+ fullString << configHosts[i];
}
-
+
for ( set<string>::iterator i=hosts.begin(); i!=hosts.end(); i++ ){
string host = *i;
bool ok = false;
- for ( int x=0; x<10; x++ ){
+ for ( int x=10; x>0; x-- ){
if ( ! hostbyname( host.c_str() ).empty() ){
ok = true;
break;
}
- log() << "can't resolve DNS for [" << host << "] sleeping and trying " << (10-x) << " more times" << endl;
+ log() << "can't resolve DNS for [" << host << "] sleeping and trying " << x << " more times" << endl;
sleepsecs( 10 );
}
if ( ! ok )
return false;
}
- uassert( 10188 , "can only hand 1 config db right now" , configHosts.size() == 1 );
- _primary = configHosts[0];
+ _primary = fullString.str();
+ log(1) << " config string : " << fullString.str() << endl;
return true;
}
@@ -448,7 +455,7 @@ namespace mongo {
if ( cur == 0 ){
ScopedDbConnection conn( _primary );
- conn->insert( "config.version" , BSON( "version" << VERSION ) );
+ conn->insert( "config.version" , BSON( "_id" << 1 << "version" << VERSION ) );
pool.flush();
assert( VERSION == dbConfigVersion( conn.conn() ) );
conn.done();
@@ -459,6 +466,32 @@ namespace mongo {
return -8;
}
+ void ConfigServer::reloadSettings(){
+ set<string> got;
+
+ ScopedDbConnection conn( _primary );
+ auto_ptr<DBClientCursor> c = conn->query( "config.settings" , BSONObj() );
+ while ( c->more() ){
+ BSONObj o = c->next();
+ string name = o["_id"].valuestrsafe();
+ got.insert( name );
+ if ( name == "chunksize" ){
+ log(1) << "MaxChunkSize: " << o["value"] << endl;
+ Chunk::MaxChunkSize = o["value"].numberInt() * 1024 * 1024;
+ }
+ else {
+ log() << "warning: unknown setting [" << name << "]" << endl;
+ }
+ }
+
+ if ( ! got.count( "chunksize" ) ){
+ conn->insert( "config.settings" , BSON( "_id" << "chunksize" <<
+ "value" << (Chunk::MaxChunkSize / ( 1024 * 1024 ) ) ) );
+ }
+
+ conn.done();
+ }
+
string ConfigServer::getHost( string name , bool withPort ){
if ( name.find( ":" ) ){
if ( withPort )