diff --git a/SConstruct b/SConstruct index 652f45df063..52330831f4c 100644 --- a/SConstruct +++ b/SConstruct @@ -314,7 +314,7 @@ commonFiles += [ "util/background.cpp" , "util/mmap.cpp" , "util/sock.cpp" , " "util/assert_util.cpp" , "util/httpclient.cpp" , "util/md5main.cpp" , "util/base64.cpp", "util/debug_util.cpp", "util/thread_pool.cpp" ] commonFiles += Glob( "util/*.c" ) -commonFiles += Split( "client/connpool.cpp client/dbclient.cpp client/model.cpp client/parallel.cpp client/quorum.cpp" ) +commonFiles += Split( "client/connpool.cpp client/dbclient.cpp client/model.cpp client/parallel.cpp client/syncclusterconnection.cpp" ) commonFiles += [ "scripting/engine.cpp" ] #mmap stuff diff --git a/client/quorum.cpp b/client/syncclusterconnection.cpp similarity index 65% rename from client/quorum.cpp rename to client/syncclusterconnection.cpp index 1782bf6a858..b9427090bd1 100644 --- a/client/quorum.cpp +++ b/client/syncclusterconnection.cpp @@ -1,13 +1,13 @@ -// quorum.cpp +// syncclusterconnection.cpp #include "stdafx.h" -#include "quorum.h" +#include "syncclusterconnection.h" // error codes 8000-8009 namespace mongo { - QuorumConnection::QuorumConnection( string commaSeperated ){ + SyncCluterConnection::SyncCluterConnection( string commaSeperated ){ string::size_type idx; while ( ( idx = commaSeperated.find( ',' ) ) != string::npos ){ string h = commaSeperated.substr( 0 , idx ); @@ -15,27 +15,27 @@ namespace mongo { _connect( h ); } _connect( commaSeperated ); - uassert( 8004 , "QuorumConnection needs 3 servers" , _conns.size() == 3 ); + uassert( 8004 , "SyncCluterConnection needs 3 servers" , _conns.size() == 3 ); } - QuorumConnection::QuorumConnection( string a , string b , string c ){ + SyncCluterConnection::SyncCluterConnection( string a , string b , string c ){ // connect to all even if not working _connect( a ); _connect( b ); _connect( c ); } - QuorumConnection::~QuorumConnection(){ + SyncCluterConnection::~SyncCluterConnection(){ for ( size_t i=0; i<_conns.size(); i++ ) delete _conns[i]; _conns.clear(); } - bool QuorumConnection::prepare( string& errmsg ){ + bool SyncCluterConnection::prepare( string& errmsg ){ return fsync( errmsg ); } - bool QuorumConnection::fsync( string& errmsg ){ + bool SyncCluterConnection::fsync( string& errmsg ){ bool ok = true; errmsg = ""; for ( size_t i=0; i<_conns.size(); i++ ){ @@ -55,7 +55,7 @@ namespace mongo { return ok; } - void QuorumConnection::_checkLast(){ + void SyncCluterConnection::_checkLast(){ vector all; vector errors; @@ -91,22 +91,22 @@ namespace mongo { if ( ok ) return; - throw UserException( 8001 , (string)"QuorumConnection write op failed: " + err.str() ); + throw UserException( 8001 , (string)"SyncCluterConnection write op failed: " + err.str() ); } - void QuorumConnection::_connect( string host ){ - log() << "QuorumConnection connecting to: " << host << endl; + void SyncCluterConnection::_connect( string host ){ + log() << "SyncCluterConnection connecting to: " << host << endl; DBClientConnection * c = new DBClientConnection( true ); string errmsg; if ( ! c->connect( host , errmsg ) ) - log() << "QuorumConnection connect fail to: " << host << " errmsg: " << errmsg << endl; + log() << "SyncCluterConnection connect fail to: " << host << " errmsg: " << errmsg << endl; _conns.push_back( c ); } - auto_ptr QuorumConnection::query(const string &ns, Query query, int nToReturn, int nToSkip, + auto_ptr SyncCluterConnection::query(const string &ns, Query query, int nToReturn, int nToSkip, const BSONObj *fieldsToReturn, int queryOptions){ - uassert( 10021 , "$cmd not support yet in QuorumConnection::query" , ns.find( "$cmd" ) == string::npos ); + uassert( 10021 , "$cmd not support yet in SyncCluterConnection::query" , ns.find( "$cmd" ) == string::npos ); for ( size_t i=0; i<_conns.size(); i++ ){ try { @@ -123,16 +123,16 @@ namespace mongo { throw UserException( 8002 , "all servers down!" ); } - auto_ptr QuorumConnection::getMore( const string &ns, long long cursorId, int nToReturn, int options ){ - uassert( 10022 , "QuorumConnection::getMore not supported yet" , 0); + auto_ptr SyncCluterConnection::getMore( const string &ns, long long cursorId, int nToReturn, int options ){ + uassert( 10022 , "SyncCluterConnection::getMore not supported yet" , 0); auto_ptr c; return c; } - void QuorumConnection::insert( const string &ns, BSONObj obj ){ + void SyncCluterConnection::insert( const string &ns, BSONObj obj ){ string errmsg; if ( ! prepare( errmsg ) ) - throw UserException( 8003 , (string)"QuorumConnection::insert prepare failed: " + errmsg ); + throw UserException( 8003 , (string)"SyncCluterConnection::insert prepare failed: " + errmsg ); for ( size_t i=0; i<_conns.size(); i++ ){ _conns[i]->insert( ns , obj ); @@ -141,17 +141,17 @@ namespace mongo { _checkLast(); } - void QuorumConnection::insert( const string &ns, const vector< BSONObj >& v ){ - uassert( 10023 , "QuorumConnection bulk insert not implemented" , 0); + void SyncCluterConnection::insert( const string &ns, const vector< BSONObj >& v ){ + uassert( 10023 , "SyncCluterConnection bulk insert not implemented" , 0); } - void QuorumConnection::remove( const string &ns , Query query, bool justOne ){ assert(0); } + void SyncCluterConnection::remove( const string &ns , Query query, bool justOne ){ assert(0); } - void QuorumConnection::update( const string &ns , Query query , BSONObj obj , bool upsert , bool multi ){ assert(0); } + void SyncCluterConnection::update( const string &ns , Query query , BSONObj obj , bool upsert , bool multi ){ assert(0); } - string QuorumConnection::toString(){ + string SyncCluterConnection::toString(){ stringstream ss; - ss << "QuorumConnection ["; + ss << "SyncCluterConnection ["; for ( size_t i=0; i<_conns.size(); i++ ){ if ( i > 0 ) ss << ","; diff --git a/client/quorum.h b/client/syncclusterconnection.h similarity index 85% rename from client/quorum.h rename to client/syncclusterconnection.h index af987772f13..c14a9bb7b3d 100644 --- a/client/quorum.h +++ b/client/syncclusterconnection.h @@ -1,4 +1,4 @@ -// quorum.h +// syncclusterconnection.h #include "../stdafx.h" #include "dbclient.h" @@ -9,14 +9,14 @@ namespace mongo { * this is a connection to a cluster of servers that operate as one * for super high durability */ - class QuorumConnection : public DBClientWithCommands { + class SyncCluterConnection : public DBClientWithCommands { public: /** * @param commaSeperated should be 3 hosts comma seperated */ - QuorumConnection( string commaSeperated ); - QuorumConnection( string a , string b , string c ); - ~QuorumConnection(); + SyncCluterConnection( string commaSeperated ); + SyncCluterConnection( string a , string b , string c ); + ~SyncCluterConnection(); /** diff --git a/scripting/sm_db.cpp b/scripting/sm_db.cpp index e9ab636f737..72d8638e2b2 100644 --- a/scripting/sm_db.cpp +++ b/scripting/sm_db.cpp @@ -17,7 +17,7 @@ // hacked in right now from engine_spidermonkey.cpp -#include "../client/quorum.h" +#include "../client/syncclusterconnection.h" namespace mongo { @@ -173,7 +173,7 @@ namespace mongo { } } else if ( numCommas == 2 ){ - conn.reset( new QuorumConnection( host ) ); + conn.reset( new SyncCluterConnection( host ) ); } else { JS_ReportError( cx , "1 (paired) or 2(quorum) commas are allowed" );