0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
This commit is contained in:
Eliot Horowitz 2009-02-27 12:51:49 -05:00
parent 0dc0ff0541
commit dfe0cff308
2 changed files with 24 additions and 9 deletions

View File

@ -32,7 +32,7 @@ namespace mongo {
void Shard::setServer( string s ){
_server = s;
_modified = true;
_markModified();
}
bool Shard::contains( const BSONObj& obj ){
@ -54,8 +54,8 @@ namespace mongo {
s->_min = m.getOwned();
s->_max = _max;
s->_modified = true;
_modified = true;
s->_markModified();
_markModified();
_manager->_shards.push_back( s );
@ -80,6 +80,8 @@ namespace mongo {
to << "min" << _min;
to << "max" << _max;
to << "server" << _server;
if ( _lastmod )
to.appendDate( "lastmod" , _lastmod );
}
void Shard::unserialize(const BSONObj& from){
@ -87,6 +89,7 @@ namespace mongo {
_min = from.getObjectField( "min" ).getOwned();
_max = from.getObjectField( "max" ).getOwned();
_server = from.getStringField( "server" );
_lastmod = from.hasField( "lastmod" ) ? from["lastmod"].date() : 0;
uassert( "Shard needs a ns" , ! _ns.empty() );
uassert( "Shard needs a server" , ! _ns.empty() );
@ -100,6 +103,14 @@ namespace mongo {
return configServer.modelServer();
}
void Shard::_markModified(){
_modified = true;
unsigned long long t = time(0);
t *= 1000;
_lastmod = t;
}
string Shard::toString() const {
stringstream ss;
ss << "shard ns:" << _ns << " server: " << _server << " min: " << _min << " max: " << _max;
@ -127,7 +138,7 @@ namespace mongo {
s->_min = _key.globalMin();
s->_max = _key.globalMax();
s->_server = config->getPrimary();
s->_modified = true;
s->_markModified();
_shards.push_back( s );

View File

@ -79,12 +79,16 @@ namespace mongo {
Shard( ShardManager * info );
private:
void _markModified();
ShardManager * _manager;
string _ns;
BSONObj _min;
BSONObj _max;
string _server;
unsigned long long _lastmod;
bool _modified;