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

Merge branch 'master' of ssh://aaron@git.10gen.com/data/gitroot/p

This commit is contained in:
Aaron 2009-02-11 13:18:01 -05:00
commit bd3b8ec5e1
12 changed files with 112 additions and 27 deletions

View File

@ -598,7 +598,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:
@ -638,7 +638,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" )
@ -713,7 +713,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:

View File

@ -71,6 +71,10 @@ namespace mongo {
return *this;
}
string Query::toString() const{
return obj.toString();
}
/* --- dbclientcommands --- */
inline bool DBClientWithCommands::isOk(const BSONObj& o) {

View File

@ -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" )
*/
@ -640,9 +642,10 @@ namespace mongo {
DBClientConnection& checkMaster();
public:
/** Call connect() after constructing. autoReconnect is always on for DBClientPaired connections. */
DBClientPaired();
/* Returns false is neither member of the pair were reachable, or neither is
/** Returns false is neither member of the pair were reachable, or neither is
master, although,
when false returned, you can still try to use this connection object, it will
try reconnects.
@ -658,46 +661,49 @@ namespace mongo {
return false;
}
/** Authorize. Authorizes both sides of the pair as needed.
*/
bool auth(const char *dbname, const char *username, const char *pwd, string& errmsg);
/* throws userassertion "no master found" */
/** throws userassertion "no master found" */
virtual
auto_ptr<DBClientCursor> query(const char *ns, Query query, int nToReturn = 0, int nToSkip = 0,
BSONObj *fieldsToReturn = 0, int queryOptions = 0);
/* throws userassertion "no master found" */
/** throws userassertion "no master found" */
virtual
BSONObj findOne(const char *ns, Query query, BSONObj *fieldsToReturn = 0, int queryOptions = 0);
// Not yet implemented
/** insert */
virtual void insert( const char * ns , BSONObj obj ) {
assert( false );
checkMaster().insert(ns, obj);
}
// Not yet implemented
/** insert multiple objects. Note that single object insert is asynchronous, so this version
is only nominally faster and not worth a special effort to try to use. */
virtual void insert( const char * ns, const vector< BSONObj >& v ) {
assert( false );
checkMaster().insert(ns, v);
}
// Not yet implemented
/** remove */
virtual void remove( const char * ns , Query obj , bool justOne = 0 ) {
assert( false );
checkMaster().remove(ns, obj, justOne);
}
// Not yet implemented
/** update */
virtual void update( const char * ns , Query query , BSONObj obj , bool upsert = 0 ) {
assert( false );
return checkMaster().update(ns, query, obj, upsert);
}
string toString();
/* notification that we got a "not master" error.
/* this is the callback from our underlying connections to notify us that we got a "not master" error.
*/
void isntMaster() {
master = ( ( master == Left ) ? NotSetR : NotSetL );
}
/* TODO */
/* TODO - not yet implemented. mongos may need these. */
virtual bool call( Message &toSend, Message &response, bool assertOk=true ) { assert(false); return false; }
virtual void say( Message &toSend ) { assert(false); }
virtual void sayPiggyBack( Message &toSend ) { assert(false); }

View File

@ -111,9 +111,14 @@ namespace mongo {
js = fixindex(tmp);
}
theDataFileMgr.insert(to_collection, js);
if ( logForRepl )
logOp("i", to_collection, js);
try {
theDataFileMgr.insert(to_collection, js);
if ( logForRepl )
logOp("i", to_collection, js);
}
catch( UserException& e ) {
log() << "warning: exception cloning object in " << from_collection << ' ' << e.what() << " obj:" << js.toString() << '\n';
}
}
}

View File

@ -118,7 +118,7 @@ namespace mongo {
115 replay, opLogging
*/
void listen(int port) {
const char *Version = "db version 122";
const char *Version = "db version v0.8.0";
log() << Version << ", pdfile version " << VERSION << "." << VERSION_MINOR << endl;
pdfileInit();
//testTheDb();
@ -365,6 +365,7 @@ namespace mongo {
} // namespace mongo
using namespace mongo;
int q;

View File

@ -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

View File

@ -228,7 +228,10 @@ namespace mongo {
assert( size % 4096 == 0 );
header = (MDFHeader *) mmf.map(filename, size);
uassert("can't map file memory", header);
if( sizeof(char *) == 4 )
uassert("can't map file memory - mongo requires 64 bit build for larger datasets", header);
else
uassert("can't map file memory", header);
// If opening an existing file, this is a no-op.
header->init(fileNo, size);
}

View File

@ -426,6 +426,7 @@ namespace mongo {
}
inline NamespaceDetails* nsdetails(const char *ns) {
// if this faults, did you set the current db first? (DBContext + dblock)
return nsindex(ns)->details(ns);
}

View File

@ -651,7 +651,11 @@ namespace mongo {
BSONElement _id;
if( !o.getObjectID(_id) ) {
/* No _id. This will be very slow. */
Timer t;
_updateObjects(ns, o, o, true, ss);
if( t.millis() >= 2 ) {
RARELY RARELY log() << "warning, repl doing slow updates (no _id field) for " << ns << endl;
}
}
else {
BSONObjBuilder b;

View File

@ -289,10 +289,11 @@ namespace mongo {
#define DEBUGGING if( 0 )
extern unsigned occasion;
extern unsigned occasionR;
extern unsigned once;
#define OCCASIONALLY if( ++occasion % 16 == 0 )
#define RARELY if( ++occasion % 128 == 0 )
#define RARELY if( ++occasionR % 128 == 0 )
#define ONCE if( ++once == 1 )
#if defined(_WIN32)

View File

@ -49,7 +49,19 @@ namespace mongo {
unsigned mapped = 0;
void* MemoryMappedFile::map(const char *filename, int length) {
void* MemoryMappedFile::map(const char *_filename, int length) {
/* big hack here: Babble uses db names with colons. doesn't seem to work on windows. temporary perhaps. */
char filename[256];
strncpy(filename, _filename, 255);
filename[255] = 0;
{
char *p = filename;
while( *p ) {
if( *p == ':' ) *p = '_';
p++;
}
}
updateLength( filename, length );
std::wstring filenamew = toWideString(filename);

View File

@ -31,6 +31,7 @@ namespace mongo {
boost::mutex Logstream::mutex;
unsigned occasion = 0;
unsigned occasionR = 0;
unsigned once = 0;
bool goingAway = false;