0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

Merge branch 'master' of git@github.com:mongodb/mongo

This commit is contained in:
Aaron 2009-02-18 15:25:56 -05:00
commit 2ad191b266
5 changed files with 94 additions and 10 deletions

View File

@ -0,0 +1,20 @@
/**
* this tests some of the ground work
*/
s = new ShardingTest( "shard1" , 2 );
db = s.getDB( "test" );
db.foo.insert( { num : 1 , name : "eliot" } );
db.foo.insert( { num : 2 , name : "sara" } );
db.foo.insert( { num : -1 , name : "joe" } );
assert.eq( 3 , db.foo.count() );
assert( s.admin.runCommand( { partition : "test" } ).ok == 1 , "partition failed" );
//assert.eq( 3 , db.foo.count() , "after partitioning count failed" );
//s.admin.runCommand( { shard : "test.foo" , key : { num : 1 } } );
//assert.eq( 3 , db.foo.count() , "after sharding, no split count failed" );
s.stop();

View File

@ -119,7 +119,7 @@ namespace mongo {
}
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool){
string dbname = cmdObj["moveprimary"].valuestrsafe();
if ( dbname.size() == 0 ){
errmsg = "no db";
return false;
@ -193,9 +193,61 @@ namespace mongo {
}
} movePrimary;
class PartitionCmd : public GridAdminCmd {
public:
PartitionCmd() : GridAdminCmd( "partition" ){}
virtual void help( stringstream& help ) const {
help
<< "turns on partitioning for a db. have to do this before sharding, etc.. will work.\n"
<< " { partition : \"alleyinsider\" }\n";
}
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool){
string dbname = cmdObj["partition"].valuestrsafe();
if ( dbname.size() == 0 ){
errmsg = "no db";
return false;
}
DBConfig * config = grid.getDBConfig( dbname );
if ( config->isPartitioned() ){
errmsg = "already partitioned";
return false;
}
config->turnOnPartitioning();
config->save();
result << "ok" << 1;
return true;
}
} partitionCmd;
// ------------ collection level commands -------------
class ShardCmd : public GridAdminCmd {
public:
ShardCmd() : GridAdminCmd( "shard" ){}
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool){
}
} shardCmd;
class SplitCollection : public GridAdminCmd {
public:
SplitCollection() : GridAdminCmd( "split" ){}
virtual void help( stringstream& help ) const {
help << " example: { shard : 'alleyinsider.blog.posts' , key : { ts : 1 } }";
}
bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool){
}
} splitCollectionCmd;
// ------------ server level commands -------------
class ListServers : public GridAdminCmd {
public:
ListServers() : GridAdminCmd("listservers") { }

View File

@ -48,6 +48,8 @@ namespace mongo {
return _partitioned;
}
void turnOnPartitioning(){ _partitioned = true; }
/**
* @return whether or not this partition is partitioned
*/
@ -68,16 +70,16 @@ namespace mongo {
void setPrimary( string s ){
_primary = s;
}
virtual string modelServer();
// model stuff
virtual const char * getNS(){ return "config.databases"; }
virtual void serialize(BSONObjBuilder& to);
virtual void unserialize(BSONObj& from);
bool loadByName(const char *nm);
protected:
string _name; // e.g. "alleyinsider"
string _primary; // e.g. localhost , mongo.foo.com:9999

View File

@ -42,14 +42,12 @@ namespace mongo {
int op = m.data->operation();
assert( op > dbMsg );
Strategy * s = 0;
Strategy * s = SINGLE;
if ( r.getConfig()->isPartitioned() ){
uassert( "partitioned not supported" , 0 );
}
else {
s = SINGLE;
}
if ( op == dbQuery ) {
s->queryOp( r );
}

View File

@ -25,6 +25,18 @@ assert.soon = function( f ) {
}
}
assert.throws = function( func , params , msg ){
try {
func.apply( null , params );
}
catch ( e ){
return e;
}
throw "did not throw exception: " + msg ;
}
Object.extend = function( dst , src ){
for ( var k in src ){
dst[k] = src[k];