summaryrefslogtreecommitdiff
path: root/s/config.cpp
diff options
context:
space:
mode:
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 )