diff options
author | Dwight <dmerriman@gmail.com> | 2009-02-11 11:28:56 -0500 |
---|---|---|
committer | Dwight <dmerriman@gmail.com> | 2009-02-11 11:28:56 -0500 |
commit | d063654ff5757f1dbe2c315e0f14c6a54b4130a6 (patch) | |
tree | 6ee946d514e7ffc5c329028f0e3c4cd7fdc586ca | |
parent | 9f5fe79f2f30ff4a9cfb4b5a528d40ae2a199641 (diff) | |
parent | b12f410c1800ddb52dba10492b4774a37f1a8a2a (diff) | |
download | mongo-d063654ff5757f1dbe2c315e0f14c6a54b4130a6.tar.gz |
Merge branch 'master' of git.10gen.com:/data/gitroot/p
-rw-r--r-- | SConstruct | 6 | ||||
-rw-r--r-- | client/dbclient.cpp | 4 | ||||
-rw-r--r-- | client/dbclient.h | 6 | ||||
-rw-r--r-- | db/dbcommands.cpp | 51 |
4 files changed, 60 insertions, 7 deletions
diff --git a/SConstruct b/SConstruct index e66d9e65a57..4f3d8655f5c 100644 --- a/SConstruct +++ b/SConstruct @@ -595,7 +595,7 @@ testEnv.AlwaysBuild( "smokeClient" ) if distBuild: from datetime import date today = date.today() - installDir = "mongo-db-" + platform + "-" + processor + "-"; + installDir = "mongodb-" + platform + "-" + processor + "-"; if distName is None: installDir += today.strftime( "%Y-%m-%d" ) else: @@ -635,7 +635,7 @@ env.Install( installDir + "/" + nixLibPrefix, clientLibName ) env.Install( installDir + "/" + nixLibPrefix + "/mongo/jars" , Glob( "jars/*" ) ) #textfiles -if distBuild: +if distBuild or release: #don't want to install these /usr/local/ for example env.Install( installDir , "distsrc/README" ) env.Install( installDir , "distsrc/THIRD-PARTY-NOTICES" ) @@ -710,7 +710,7 @@ env.Alias( "s3shell" , [ "mongo" ] , [ s3shellpush ] ) env.AlwaysBuild( "s3shell" ) def s3dist( env , target , source ): - s3push( distFile , "mongo-db" ) + s3push( distFile , "mongodb" ) env.Append( TARFLAGS=" -z " ) if windows: diff --git a/client/dbclient.cpp b/client/dbclient.cpp index 1bc3337f48a..8976b0c664e 100644 --- a/client/dbclient.cpp +++ b/client/dbclient.cpp @@ -71,6 +71,10 @@ namespace mongo { return *this; } + string Query::toString() const{ + return obj.toString(); + } + /* --- dbclientcommands --- */ inline bool DBClientWithCommands::isOk(const BSONObj& o) { diff --git a/client/dbclient.h b/client/dbclient.h index 5949cde1f00..572df9209f7 100644 --- a/client/dbclient.h +++ b/client/dbclient.h @@ -79,7 +79,7 @@ namespace mongo { Example: QUERY( "age" << 33 << "school" << "UCLA" ).sort("name") */ - class Query { + class Query : public Stringable { public: BSONObj obj; Query(const BSONObj& b) : obj(b) { } @@ -133,8 +133,10 @@ namespace mongo { */ Query& where(const char *jscode, BSONObj scope); Query& where(const char *jscode) { return where(jscode, BSONObj()); } - }; + virtual string toString() const; + }; + /** Typically one uses the QUERY(...) macro to construct a Query object. Example: QUERY( "age" << 33 << "school" << "UCLA" ) */ diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index 3c937e19ebe..e383a4bb2b4 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -24,6 +24,7 @@ #include "introspect.h" #include "btree.h" #include "../util/lruishmap.h" +#include "../util/md5.hpp" #include "json.h" #include "repl.h" #include "replset.h" @@ -654,7 +655,7 @@ namespace mongo { return true; } } cmdDeleteIndexes; - + class CmdListDatabases : public Command { public: virtual bool logTheOp() { @@ -674,7 +675,7 @@ namespace mongo { vector< string > dbNames; getDatabaseNames( dbNames ); vector< BSONObj > dbInfos; - + set<string> seen; for ( vector< string >::iterator i = dbNames.begin(); i != dbNames.end(); ++i ) { BSONObjBuilder b; @@ -700,6 +701,52 @@ namespace mongo { } } cmdListDatabases; + class CmdFileMD5 : public Command { + public: + CmdFileMD5() : Command( "filemd5" ){} + virtual bool slaveOk() { + return true; + } + bool run(const char *dbname, BSONObj& jsobj, string& errmsg, BSONObjBuilder& result, bool fromRepl ){ + static DBDirectClient db; + + string ns = nsToClient( dbname ); + ns += ".fs.chunks"; // make this an option in jsobj + + BSONObjBuilder query; + query.appendAs( jsobj["filemd5"] , "files_id" ); + Query q( query.obj() ); + q.sort( BSON( "files_id" << 1 << "n" << 1 ) ); + + md5digest d; + md5_state_t st; + md5_init(&st); + + dbtemprelease temp; + + auto_ptr<DBClientCursor> cursor = db.query( ns.c_str() , q ); + int n = 0; + while ( cursor->more() ){ + BSONObj c = cursor->next(); + int myn = c.getIntField( "n" ); + if ( n != myn ){ + log() << "should have chunk: " << n << " have:" << myn << endl; + uassert( "chunks out of order" , n == myn ); + } + + int len; + const char * data = c["data"].binData( len ); + md5_append( &st , (const md5_byte_t*)(data + 4) , len - 4 ); + + n++; + } + md5_finish(&st, d); + + result.append( "md5" , digestToString( d ) ); + return true; + } + } cmdFileMD5; + extern map<string,Command*> *commands; /* TODO make these all command objects -- legacy stuff here |