diff options
author | Eliot Horowitz <eliot@10gen.com> | 2011-02-12 14:48:35 -0500 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2011-02-12 14:48:35 -0500 |
commit | 64e39098c4eab5502bd993a37e75262f015f1a2c (patch) | |
tree | c0ffa2c18b76f6df7bbed7fbffd67031e208775d /s/shard.h | |
parent | f4f7ceccf88c7653fd8173cae666200b64a07e36 (diff) | |
download | mongo-64e39098c4eab5502bd993a37e75262f015f1a2c.tar.gz |
writeback listener handles replica sets correctly SERVER-2540
Diffstat (limited to 's/shard.h')
-rw-r--r-- | s/shard.h | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/s/shard.h b/s/shard.h index 97f0339bb25..5898a6fcca7 100644 --- a/s/shard.h +++ b/s/shard.h @@ -39,6 +39,7 @@ namespace mongo { Shard( const string& name , const string& addr, long long maxSize = 0 , bool isDraining = false ) : _name(name) , _addr( addr ) , _maxSize( maxSize ) , _isDraining( isDraining ) { + _setAddr( addr ); } Shard( const string& ident ) { @@ -46,11 +47,13 @@ namespace mongo { } Shard( const Shard& other ) - : _name( other._name ) , _addr( other._addr ) , _maxSize( other._maxSize ) , _isDraining( other._isDraining ) { + : _name( other._name ) , _addr( other._addr ) , _cs( other._cs ) , + _maxSize( other._maxSize ) , _isDraining( other._isDraining ) , _rs( other._rs ) { } Shard( const Shard* other ) - : _name( other->_name ) , _addr( other->_addr ), _maxSize( other->_maxSize ) , _isDraining( other->_isDraining ) { + : _name( other->_name ) , _addr( other->_addr ), _cs( other->_cs ) , + _maxSize( other->_maxSize ) , _isDraining( other->_isDraining ) , _rs( other->_rs ) { } static Shard make( const string& ident ) { @@ -59,8 +62,6 @@ namespace mongo { return s; } - static bool isAShard( const string& ident ); - /** * @param ident either name or address */ @@ -131,10 +132,17 @@ namespace mongo { BSONObj runCommand( const string& db , const BSONObj& cmd ) const ; ShardStatus getStatus() const ; + + /** + * mostly for replica set + * retursn true if node is the shard + * of if the replica set contains node + */ + bool containsNode( const string& node ) const; static void getAllShards( vector<Shard>& all ); static void printShardInfo( ostream& out ); - + /** * @parm current - shard where the chunk/database currently lives in * @return the currently emptiest shard, if best then current, or EMPTY @@ -145,15 +153,20 @@ namespace mongo { static void removeShard( const string& name ); - static bool isMember( const string& addr ); + static bool isAShardNode( const string& ident ); static Shard EMPTY; - + private: + + void _setAddr( const string& addr ); + string _name; string _addr; + ConnectionString _cs; long long _maxSize; // in MBytes, 0 is unlimited bool _isDraining; // shard is currently being removed + ReplicaSetMonitorPtr _rs; }; class ShardStatus { |