From ba8b57c15881ac8de4348aa35e375bc5394ce0b3 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Wed, 11 Feb 2009 10:37:04 -0500 Subject: Query::toString --- client/dbclient.cpp | 4 ++++ client/dbclient.h | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) 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" ) */ -- cgit v1.2.1 From 827e76b7793e7969c4c41aa6a130c7324fadb391 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Wed, 11 Feb 2009 10:37:27 -0500 Subject: filemd5 command --- db/dbcommands.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) 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 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 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 *commands; /* TODO make these all command objects -- legacy stuff here -- cgit v1.2.1 From bafd4aad058f846acee018dcfac30a8a014b1d17 Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Wed, 11 Feb 2009 10:53:51 -0500 Subject: name is mongodb not mongo-db --- SConstruct | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index e66d9e65a57..b5b67d75315 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: @@ -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: -- cgit v1.2.1 From b12f410c1800ddb52dba10492b4774a37f1a8a2a Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Wed, 11 Feb 2009 11:26:28 -0500 Subject: install notices on release build --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index b5b67d75315..4f3d8655f5c 100644 --- a/SConstruct +++ b/SConstruct @@ -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" ) -- cgit v1.2.1