bsoninlines.h   bsoninlines.h 
skipping to change at line 389 skipping to change at line 389
s << "new Date(" << date() << ')'; s << "new Date(" << date() << ')';
break; break;
case RegEx: case RegEx:
{ {
s << "/" << regex() << '/'; s << "/" << regex() << '/';
const char *p = regexFlags(); const char *p = regexFlags();
if ( p ) s << p; if ( p ) s << p;
} }
break; break;
case NumberDouble: case NumberDouble:
{ s.appendDoubleNice( number() );
stringstream tmp;
tmp.precision( 16 );
tmp << number();
string n = tmp.str();
s << n;
// indicate this is a double:
if( strchr(n.c_str(), '.') == 0 && strchr(n.c_str(), 'E') =
= 0 && strchr(n.c_str(), 'N') == 0 )
s << ".0";
}
break; break;
case NumberLong: case NumberLong:
s << _numberLong(); s << _numberLong();
break; break;
case NumberInt: case NumberInt:
s << _numberInt(); s << _numberInt();
break; break;
case mongo::Bool: case mongo::Bool:
s << ( boolean() ? "true" : "false" ); s << ( boolean() ? "true" : "false" );
break; break;
 End of changes. 1 change blocks. 
11 lines changed or deleted 1 lines changed or added


 builder.h   builder.h 
skipping to change at line 167 skipping to change at line 167
class StringBuilder { class StringBuilder {
public: public:
StringBuilder( int initsize=256 ) StringBuilder( int initsize=256 )
: _buf( initsize ){ : _buf( initsize ){
} }
#define SBNUM(val,maxSize,macro) \ #define SBNUM(val,maxSize,macro) \
int prev = _buf.l; \ int prev = _buf.l; \
int z = sprintf( _buf.grow(maxSize) , macro , (val) ); \ int z = sprintf( _buf.grow(maxSize) , macro , (val) ); \
assert( z >= 0 ); \
_buf.l = prev + z; \ _buf.l = prev + z; \
return *this; return *this;
StringBuilder& operator<<( double x ){ StringBuilder& operator<<( double x ){
SBNUM( x , 25 , "%g" ); SBNUM( x , 25 , "%g" );
} }
StringBuilder& operator<<( int x ){ StringBuilder& operator<<( int x ){
SBNUM( x , 11 , "%d" ); SBNUM( x , 11 , "%d" );
} }
StringBuilder& operator<<( unsigned x ){ StringBuilder& operator<<( unsigned x ){
skipping to change at line 200 skipping to change at line 201
} }
StringBuilder& operator<<( short x ){ StringBuilder& operator<<( short x ){
SBNUM( x , 8 , "%hd" ); SBNUM( x , 8 , "%hd" );
} }
StringBuilder& operator<<( char c ){ StringBuilder& operator<<( char c ){
_buf.grow( 1 )[0] = c; _buf.grow( 1 )[0] = c;
return *this; return *this;
} }
#undef SBNUM #undef SBNUM
void appendDoubleNice( double x ){
int prev = _buf.l;
char * start = _buf.grow( 32 );
int z = sprintf( start , "%.16g" , x );
assert( z >= 0 );
_buf.l = prev + z;
if( strchr(start, '.') == 0 && strchr(start, 'E') == 0 && strch
r(start, 'N') == 0 ){
write( ".0" , 2 );
}
}
void write( const char* buf, int len){ void write( const char* buf, int len){
memcpy( _buf.grow( len ) , buf , len ); memcpy( _buf.grow( len ) , buf , len );
} }
void append( const StringData& str ){ void append( const StringData& str ){
memcpy( _buf.grow( str.size() ) , str.data() , str.size() ); memcpy( _buf.grow( str.size() ) , str.data() , str.size() );
} }
StringBuilder& operator<<( const StringData& str ){ StringBuilder& operator<<( const StringData& str ){
append( str ); append( str );
return *this; return *this;
 End of changes. 2 change blocks. 
0 lines changed or deleted 13 lines changed or added


 chunk.h   chunk.h 
skipping to change at line 270 skipping to change at line 270
ShardKeyPattern& getShardKey(){ return _key; } ShardKeyPattern& getShardKey(){ return _key; }
const ShardKeyPattern& getShardKey() const { return _key; } const ShardKeyPattern& getShardKey() const { return _key; }
bool isUnique(){ return _unique; } bool isUnique(){ return _unique; }
void maybeChunkCollection(); void maybeChunkCollection();
void getShardsForQuery( set<Shard>& shards , const BSONObj& query ) ; void getShardsForQuery( set<Shard>& shards , const BSONObj& query ) ;
void getAllShards( set<Shard>& all ); void getAllShards( set<Shard>& all );
void getShardsForRange(set<Shard>& shards, const BSONObj& min, cons t BSONObj& max); // [min, max) void getShardsForRange(set<Shard>& shards, const BSONObj& min, cons t BSONObj& max); // [min, max)
void save(); void save( bool major );
string toString() const; string toString() const;
ShardChunkVersion getVersion( const Shard& shard ) const; ShardChunkVersion getVersion( const Shard& shard ) const;
ShardChunkVersion getVersion() const; ShardChunkVersion getVersion() const;
/** /**
* actually does a query on the server * actually does a query on the server
* doesn't look at any local data * doesn't look at any local data
*/ */
skipping to change at line 308 skipping to change at line 308
void drop( ChunkManagerPtr me ); void drop( ChunkManagerPtr me );
void _printChunks() const; void _printChunks() const;
private: private:
void _reload(); void _reload();
void _reload_inlock(); void _reload_inlock();
void _load(); void _load();
void save_inlock(); void save_inlock( bool major );
ShardChunkVersion getVersion_inlock() const; ShardChunkVersion getVersion_inlock() const;
void ensureIndex_inlock(); void ensureIndex_inlock();
DBConfig * _config; DBConfig * _config;
string _ns; string _ns;
ShardKeyPattern _key; ShardKeyPattern _key;
bool _unique; bool _unique;
map<string,unsigned long long> _maxMarkers; map<string,unsigned long long> _maxMarkers;
 End of changes. 2 change blocks. 
2 lines changed or deleted 2 lines changed or added


 dbclient.h   dbclient.h 
skipping to change at line 332 skipping to change at line 332
class DBConnector { class DBConnector {
public: public:
virtual ~DBConnector() {} virtual ~DBConnector() {}
virtual bool call( Message &toSend, Message &response, bool assertO k=true ) = 0; virtual bool call( Message &toSend, Message &response, bool assertO k=true ) = 0;
virtual void say( Message &toSend ) = 0; virtual void say( Message &toSend ) = 0;
virtual void sayPiggyBack( Message &toSend ) = 0; virtual void sayPiggyBack( Message &toSend ) = 0;
virtual void checkResponse( const char* data, int nReturned ) {} virtual void checkResponse( const char* data, int nReturned ) {}
/* used by QueryOption_Exhaust. To use that your subclass must imp lement this. */ /* used by QueryOption_Exhaust. To use that your subclass must imp lement this. */
virtual void recv( Message& m ) { assert(false); } virtual void recv( Message& m ) { assert(false); }
virtual string getServerAddress() const = 0;
}; };
/** /**
The interface that any db connection should implement The interface that any db connection should implement
*/ */
class DBClientInterface : boost::noncopyable { class DBClientInterface : boost::noncopyable {
public: public:
virtual auto_ptr<DBClientCursor> query(const string &ns, Query quer y, int nToReturn = 0, int nToSkip = 0, virtual auto_ptr<DBClientCursor> query(const string &ns, Query quer y, int nToReturn = 0, int nToSkip = 0,
const BSONObj *fieldsToRetur n = 0, int queryOptions = 0 , int batchSize = 0 ) = 0; const BSONObj *fieldsToRetur n = 0, int queryOptions = 0 , int batchSize = 0 ) = 0;
skipping to change at line 741 skipping to change at line 743
remove matching objects from the database remove matching objects from the database
@param justOne if this true, then once a single match is found w ill stop @param justOne if this true, then once a single match is found w ill stop
*/ */
virtual void remove( const string &ns , Query q , bool justOne = 0 ); virtual void remove( const string &ns , Query q , bool justOne = 0 );
/** /**
updates objects matching query updates objects matching query
*/ */
virtual void update( const string &ns , Query query , BSONObj obj , bool upsert = false , bool multi = false ); virtual void update( const string &ns , Query query , BSONObj obj , bool upsert = false , bool multi = false );
virtual string getServerAddress() const = 0;
virtual bool isFailed() const = 0; virtual bool isFailed() const = 0;
virtual void killCursor( long long cursorID ) = 0; virtual void killCursor( long long cursorID ) = 0;
static int countCommas( const string& s ){ static int countCommas( const string& s ){
int n = 0; int n = 0;
for ( unsigned i=0; i<s.size(); i++ ) for ( unsigned i=0; i<s.size(); i++ )
if ( s[i] == ',' ) if ( s[i] == ',' )
n++; n++;
return n; return n;
} }
virtual bool callRead( Message& toSend , Message& response ) = 0; virtual bool callRead( Message& toSend , Message& response ) = 0;
// virtual bool callWrite( Message& toSend , Message& response ) = 0; // TODO: add this if needed // virtual bool callWrite( Message& toSend , Message& response ) = 0; // TODO: add this if needed
virtual void say( Message& toSend ) = 0; virtual void say( Message& toSend ) = 0;
virtual ConnectionString::ConnectionType type() const = 0; virtual ConnectionString::ConnectionType type() const = 0;
/** @return true if conn is either equal to or contained in this co
nnection */
virtual bool isMember( const DBConnector * conn ) const = 0;
}; // DBClientBase }; // DBClientBase
class DBClientReplicaSet; class DBClientReplicaSet;
class ConnectException : public UserException { class ConnectException : public UserException {
public: public:
ConnectException(string msg) : UserException(9000,msg) { } ConnectException(string msg) : UserException(9000,msg) { }
}; };
/** /**
skipping to change at line 894 skipping to change at line 897
virtual void killCursor( long long cursorID ); virtual void killCursor( long long cursorID );
virtual bool callRead( Message& toSend , Message& response ){ virtual bool callRead( Message& toSend , Message& response ){
return call( toSend , response ); return call( toSend , response );
} }
virtual void say( Message &toSend ); virtual void say( Message &toSend );
virtual bool call( Message &toSend, Message &response, bool assertO k = true ); virtual bool call( Message &toSend, Message &response, bool assertO k = true );
virtual ConnectionString::ConnectionType type() const { return Conn ectionString::MASTER; } virtual ConnectionString::ConnectionType type() const { return Conn ectionString::MASTER; }
virtual bool isMember( const DBConnector * conn ) const { return th
is == conn; };
virtual void checkResponse( const char *data, int nReturned );
protected: protected:
friend class SyncClusterConnection; friend class SyncClusterConnection;
virtual void recv( Message& m ); virtual void recv( Message& m );
virtual void sayPiggyBack( Message &toSend ); virtual void sayPiggyBack( Message &toSend );
virtual void checkResponse( const char *data, int nReturned );
}; };
/** Use this class to connect to a replica set of servers. The class w ill manage /** Use this class to connect to a replica set of servers. The class w ill manage
checking for which server in a replica set is master, and do failove r automatically. checking for which server in a replica set is master, and do failove r automatically.
This can also be used to connect to replica pairs since pairs are a subset of sets This can also be used to connect to replica pairs since pairs are a subset of sets
On a failover situation, expect at least one operation to return an error (throw On a failover situation, expect at least one operation to return an error (throw
an exception) before the failover is complete. Operations are no t retried. an exception) before the failover is complete. Operations are no t retried.
*/ */
skipping to change at line 987 skipping to change at line 995
DBClientConnection& masterConn(); DBClientConnection& masterConn();
DBClientConnection& slaveConn(); DBClientConnection& slaveConn();
virtual bool call( Message &toSend, Message &response, bool assertO k=true ) { return checkMaster()->call( toSend , response , assertOk ); } virtual bool call( Message &toSend, Message &response, bool assertO k=true ) { return checkMaster()->call( toSend , response , assertOk ); }
virtual void say( Message &toSend ) { checkMaster()->say( toSend ); } virtual void say( Message &toSend ) { checkMaster()->say( toSend ); }
virtual bool callRead( Message& toSend , Message& response ){ retur n checkMaster()->callRead( toSend , response ); } virtual bool callRead( Message& toSend , Message& response ){ retur n checkMaster()->callRead( toSend , response ); }
virtual ConnectionString::ConnectionType type() const { return Conn ectionString::SET; } virtual ConnectionString::ConnectionType type() const { return Conn ectionString::SET; }
virtual bool isMember( const DBConnector * conn ) const;
virtual void checkResponse( const char *data, int nReturned ) { che
ckMaster()->checkResponse( data , nReturned ); }
protected: protected:
virtual void sayPiggyBack( Message &toSend ) { assert(false); } virtual void sayPiggyBack( Message &toSend ) { assert(false); }
virtual void checkResponse( const char *data, int nReturned ) { ass ert(false); }
bool isFailed() const { bool isFailed() const {
return _currentMaster == 0 || _currentMaster->isFailed(); return _currentMaster == 0 || _currentMaster->isFailed();
} }
}; };
/** pings server to check if it's up /** pings server to check if it's up
*/ */
bool serverAlive( const string &uri ); bool serverAlive( const string &uri );
 End of changes. 7 change blocks. 
4 lines changed or deleted 18 lines changed or added


 distlock.h   distlock.h 
skipping to change at line 38 skipping to change at line 38
namespace mongo { namespace mongo {
class DistributedLock { class DistributedLock {
public: public:
/** /**
* @param takeoverMinutes how long before we steal lock in minutes * @param takeoverMinutes how long before we steal lock in minutes
*/ */
DistributedLock( const ConnectionString& conn , const string& name , unsigned takeoverMinutes = 10 ); DistributedLock( const ConnectionString& conn , const string& name , unsigned takeoverMinutes = 10 );
int getState(){
return _state.get();
}
bool isLocked(){
return _state.get() != 0;
}
bool lock_try( string why , BSONObj * other = 0 ); bool lock_try( string why , BSONObj * other = 0 );
void unlock(); void unlock();
private: private:
ConnectionString _conn; ConnectionString _conn;
string _name; string _name;
unsigned _takeoverMinutes; unsigned _takeoverMinutes;
string _ns; string _ns;
BSONObj _id; BSONObj _id;
ThreadLocalValue<int> _state;
}; };
class dist_lock_try { class dist_lock_try {
public: public:
dist_lock_try( DistributedLock * lock , string why ) dist_lock_try( DistributedLock * lock , string why )
: _lock(lock){ : _lock(lock){
_got = _lock->lock_try( why , &_other ); _got = _lock->lock_try( why , &_other );
} }
 End of changes. 2 change blocks. 
10 lines changed or deleted 0 lines changed or added


 instance.h   instance.h 
skipping to change at line 145 skipping to change at line 145
return say( toSend ); return say( toSend );
} }
virtual void killCursor( long long cursorID ); virtual void killCursor( long long cursorID );
virtual bool callRead( Message& toSend , Message& response ){ virtual bool callRead( Message& toSend , Message& response ){
return call( toSend , response ); return call( toSend , response );
} }
virtual ConnectionString::ConnectionType type() const { return Conn ectionString::MASTER; } virtual ConnectionString::ConnectionType type() const { return Conn ectionString::MASTER; }
virtual bool isMember( const DBConnector * conn ) const { return th is == conn; };
}; };
extern int lockFile; extern int lockFile;
void acquirePathLock(); void acquirePathLock();
void maybeCreatePidFile(); void maybeCreatePidFile();
} // namespace mongo } // namespace mongo
 End of changes. 1 change blocks. 
0 lines changed or deleted 1 lines changed or added


 log.h   log.h 
skipping to change at line 161 skipping to change at line 161
class Logstream : public Nullstream { class Logstream : public Nullstream {
static mongo::mutex mutex; static mongo::mutex mutex;
static int doneSetup; static int doneSetup;
stringstream ss; stringstream ss;
LogLevel logLevel; LogLevel logLevel;
static FILE* logfile; static FILE* logfile;
static boost::scoped_ptr<ostream> stream; static boost::scoped_ptr<ostream> stream;
static vector<Tee*> * globalTees; static vector<Tee*> * globalTees;
public: public:
static void logLockless( const StringData& s ){ inline static void logLockless( const StringData& s );
if ( doneSetup == 1717 ){
fwrite( s.data() , s.size() , 1 , logfile );
fflush( logfile );
}
else {
cout << s.data() << endl;
}
}
static void setLogFile(FILE* f){ static void setLogFile(FILE* f){
scoped_lock lk(mutex); scoped_lock lk(mutex);
logfile = f; logfile = f;
} }
static int magicNumber(){ static int magicNumber(){
return 1717; return 1717;
} }
void flush(Tee *t = 0) { inline void flush(Tee *t = 0);
// this ensures things are sane
if ( doneSetup == 1717 ) {
string msg = ss.str();
string threadName = getThreadName();
const char * type = logLevelToString(logLevel);
int spaceNeeded = msg.size() + 64 + threadName.size();
int bufSize = 128;
while ( bufSize < spaceNeeded )
bufSize += 128;
BufBuilder b(bufSize);
time_t_to_String( time(0) , b.grow(20) );
if (!threadName.empty()){
b.appendChar( '[' );
b.appendStr( threadName , false );
b.appendChar( ']' );
b.appendChar( ' ' );
}
if ( type[0] ){
b.appendStr( type , false );
b.appendStr( ": " , false );
}
b.appendStr( msg );
string out( b.buf() , b.len() - 1);
scoped_lock lk(mutex);
if( t ) t->write(logLevel,out);
if ( globalTees ){
for ( unsigned i=0; i<globalTees->size(); i++ )
(*globalTees)[i]->write(logLevel,out);
}
#ifndef _WIN32
//syslog( LOG_INFO , "%s" , cc );
#endif
fwrite(out.data(), out.size(), 1, logfile);
fflush(logfile);
}
_init();
}
Nullstream& setLogLevel(LogLevel l){ inline Nullstream& setLogLevel(LogLevel l){
logLevel = l; logLevel = l;
return *this; return *this;
} }
/** note these are virtual */ /** note these are virtual */
Logstream& operator<<(const char *x) { ss << x; return *this; } Logstream& operator<<(const char *x) { ss << x; return *this; }
Logstream& operator<<(const string& x) { ss << x; return *this; } Logstream& operator<<(const string& x) { ss << x; return *this; }
Logstream& operator<<(char *x) { ss << x; return *this; } Logstream& operator<<(char *x) { ss << x; return *this; }
Logstream& operator<<(char x) { ss << x; return *this; } Logstream& operator<<(char x) { ss << x; return *this; }
Logstream& operator<<(int x) { ss << x; return *this; } Logstream& operator<<(int x) { ss << x; return *this; }
skipping to change at line 418 skipping to change at line 367
*/ */
#else #else
s << strerror(x); s << strerror(x);
#endif #endif
return s.str(); return s.str();
} }
/** output the error # and error message with prefix. /** output the error # and error message with prefix.
handy for use as parm in uassert/massert. handy for use as parm in uassert/massert.
*/ */
string errnoWithPrefix( const char * prefix = 0 ); string errnoWithPrefix( const char * prefix );
void Logstream::logLockless( const StringData& s ){
if ( doneSetup == 1717 ){
if(fwrite(s.data(), s.size(), 1, logfile)){
fflush(logfile);
}else{
int x = errno;
cout << "Failed to write to logfile: " << errnoWithDescript
ion(x) << ": " << out << endl;
}
}
else {
cout << s.data() << endl;
}
}
void Logstream::flush(Tee *t) {
// this ensures things are sane
if ( doneSetup == 1717 ) {
string msg = ss.str();
string threadName = getThreadName();
const char * type = logLevelToString(logLevel);
int spaceNeeded = msg.size() + 64 + threadName.size();
int bufSize = 128;
while ( bufSize < spaceNeeded )
bufSize += 128;
BufBuilder b(bufSize);
time_t_to_String( time(0) , b.grow(20) );
if (!threadName.empty()){
b.appendChar( '[' );
b.appendStr( threadName , false );
b.appendChar( ']' );
b.appendChar( ' ' );
}
if ( type[0] ){
b.appendStr( type , false );
b.appendStr( ": " , false );
}
b.appendStr( msg );
string out( b.buf() , b.len() - 1);
scoped_lock lk(mutex);
if( t ) t->write(logLevel,out);
if ( globalTees ){
for ( unsigned i=0; i<globalTees->size(); i++ )
(*globalTees)[i]->write(logLevel,out);
}
#ifndef _WIN32
//syslog( LOG_INFO , "%s" , cc );
#endif
if(fwrite(out.data(), out.size(), 1, logfile)){
fflush(logfile);
}else{
int x = errno;
cout << "Failed to write to logfile: " << errnoWithDescript
ion(x) << ": " << out << endl;
}
}
_init();
}
} // namespace mongo } // namespace mongo
 End of changes. 4 change blocks. 
55 lines changed or deleted 69 lines changed or added


 syncclusterconnection.h   syncclusterconnection.h 
skipping to change at line 92 skipping to change at line 92
virtual string getServerAddress() const { return _address; } virtual string getServerAddress() const { return _address; }
virtual bool isFailed() const { return false; } virtual bool isFailed() const { return false; }
virtual string toString() { return _toString(); } virtual string toString() { return _toString(); }
virtual BSONObj getLastErrorDetailed(); virtual BSONObj getLastErrorDetailed();
virtual bool callRead( Message& toSend , Message& response ); virtual bool callRead( Message& toSend , Message& response );
virtual ConnectionString::ConnectionType type() const { return Conn ectionString::SYNC; } virtual ConnectionString::ConnectionType type() const { return Conn ectionString::SYNC; }
virtual bool isMember( const DBConnector * conn ) const;
private: private:
SyncClusterConnection( SyncClusterConnection& prev ); SyncClusterConnection( SyncClusterConnection& prev );
string _toString() const; string _toString() const;
bool _commandOnActive(const string &dbname, const BSONObj& cmd, BSO NObj &info, int options=0); bool _commandOnActive(const string &dbname, const BSONObj& cmd, BSO NObj &info, int options=0);
auto_ptr<DBClientCursor> _queryOnActive(const string &ns, Query que ry, int nToReturn, int nToSkip, auto_ptr<DBClientCursor> _queryOnActive(const string &ns, Query que ry, int nToReturn, int nToSkip,
const BSONObj *fieldsToRetu rn, int queryOptions, int batchSize ); const BSONObj *fieldsToRetu rn, int queryOptions, int batchSize );
int _lockType( const string& name ); int _lockType( const string& name );
void _checkLast(); void _checkLast();
void _connect( string host ); void _connect( string host );
 End of changes. 1 change blocks. 
0 lines changed or deleted 2 lines changed or added


 util.h   util.h 
skipping to change at line 61 skipping to change at line 61
} }
else if ( e.eoo() ){ else if ( e.eoo() ){
_combined = 0; _combined = 0;
} }
else { else {
log() << "ShardChunkVersion can't handle type (" << (int)(e .type()) << ") " << e << endl; log() << "ShardChunkVersion can't handle type (" << (int)(e .type()) << ") " << e << endl;
assert(0); assert(0);
} }
} }
ShardChunkVersion incMajor() const { void inc( bool major ){
return ShardChunkVersion( _major + 1 , 0 ); if ( major )
incMajor();
else
incMinor();
} }
void operator++(){ void incMajor() {
_major++;
_minor = 0;
}
void incMinor() {
_minor++; _minor++;
} }
unsigned long long toLong() const { unsigned long long toLong() const {
return _combined; return _combined;
} }
bool isSet() const { bool isSet() const {
return _combined > 0; return _combined > 0;
} }
 End of changes. 2 change blocks. 
3 lines changed or deleted 11 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/