Compare commits
18 Commits
wireVersio
...
r1.6.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c7f164b65 | ||
|
|
53d1c8bbad | ||
|
|
e4fcc800f7 | ||
|
|
7abf0580ca | ||
|
|
ae1e0804da | ||
|
|
50b7bbe934 | ||
|
|
fd26b536e9 | ||
|
|
6f6aa20e92 | ||
|
|
55937a8f3e | ||
|
|
8947d06986 | ||
|
|
8c095b2cb2 | ||
|
|
2e6aeb0229 | ||
|
|
cb661f73fd | ||
|
|
63f894763d | ||
|
|
2c3d88336e | ||
|
|
c542dbd78a | ||
|
|
b5ce278c18 | ||
|
|
a432ac592e |
@@ -136,7 +136,7 @@ namespace mongo {
|
||||
return false;
|
||||
}
|
||||
|
||||
Date_t elapsed = jsTime() - lastPing["ping"].Date(); // in ms
|
||||
unsigned long long elapsed = jsTime() - lastPing["ping"].Date(); // in ms
|
||||
elapsed = elapsed / ( 1000 * 60 ); // convert to minutes
|
||||
|
||||
if ( elapsed <= _takeoverMinutes ){
|
||||
|
||||
@@ -328,6 +328,38 @@ namespace mongo {
|
||||
void ParallelSortClusteredCursor::_finishCons(){
|
||||
_numServers = _servers.size();
|
||||
_cursors = 0;
|
||||
|
||||
if ( ! _sortKey.isEmpty() && ! _fields.isEmpty() ){
|
||||
// we need to make sure the sort key is in the project
|
||||
bool isNegative = false;
|
||||
BSONObjBuilder b;
|
||||
{
|
||||
BSONObjIterator i( _fields );
|
||||
while ( i.more() ){
|
||||
BSONElement e = i.next();
|
||||
b.append( e );
|
||||
if ( ! e.trueValue() )
|
||||
isNegative = true;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
BSONObjIterator i( _sortKey );
|
||||
while ( i.more() ){
|
||||
BSONElement e = i.next();
|
||||
BSONElement f = _fields.getField( e.fieldName() );
|
||||
if ( isNegative ){
|
||||
uassert( 13431 , "have to have sort key in projection and removing it" , f.eoo() );
|
||||
}
|
||||
else if ( f.eoo() ){
|
||||
// add to projection
|
||||
b.append( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_fields = b.obj();
|
||||
}
|
||||
}
|
||||
|
||||
void ParallelSortClusteredCursor::_init(){
|
||||
|
||||
@@ -126,6 +126,7 @@ namespace mongo {
|
||||
assert( sprintf( buf , "w block pass: %lld" , ++passes ) < 30 );
|
||||
c.curop()->setMessage( buf );
|
||||
sleepmillis(1);
|
||||
killCurrentOp.checkForInterrupt();
|
||||
}
|
||||
result.appendNumber( "wtime" , t.millis() );
|
||||
}
|
||||
|
||||
10
db/repl.cpp
10
db/repl.cpp
@@ -290,11 +290,13 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.append("ismaster", replSettings.master || replSettings.slave == 0 ? 1 : 0);
|
||||
//result.append("msg", "not paired");
|
||||
result.appendBool("ismaster", _isMaster() );
|
||||
}
|
||||
|
||||
if ( level ){
|
||||
|
||||
if ( level && replSet ){
|
||||
result.append( "info" , "is replica set" );
|
||||
}
|
||||
else if ( level ){
|
||||
BSONObjBuilder sources( result.subarrayStart( "sources" ) );
|
||||
|
||||
readlock lk( "local.sources" );
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace mongo {
|
||||
}
|
||||
|
||||
void ReplSetImpl::_getOplogDiagsAsHtml(unsigned server_id, stringstream& ss) const {
|
||||
Member *m = findById(server_id);
|
||||
const Member *m = findById(server_id);
|
||||
if( m == 0 ) {
|
||||
ss << "Error : can't find a member with id: " << server_id << '\n';
|
||||
return;
|
||||
@@ -329,7 +329,7 @@ namespace mongo {
|
||||
_rsLog.toHTML( s );
|
||||
}
|
||||
|
||||
Member* ReplSetImpl::findById(unsigned id) const {
|
||||
const Member* ReplSetImpl::findById(unsigned id) const {
|
||||
if( id == _self->id() ) return _self;
|
||||
for( Member *m = head(); m; m = m->next() )
|
||||
if( m->id() == id )
|
||||
@@ -371,6 +371,7 @@ namespace mongo {
|
||||
v.push_back(bb.obj());
|
||||
m = m->next();
|
||||
}
|
||||
sort(v.begin(), v.end());
|
||||
b.append("set", name());
|
||||
b.appendTimeT("date", time(0));
|
||||
b.append("myState", box.getState().s);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
namespace mongo {
|
||||
|
||||
void checkAllMembersUpForConfigChange(const ReplSetConfig& cfg, bool initial);
|
||||
void checkMembersUpForConfigChange(const ReplSetConfig& cfg, bool initial);
|
||||
|
||||
/* commands in other files:
|
||||
replSetHeartbeat - health.cpp
|
||||
@@ -151,9 +151,9 @@ namespace mongo {
|
||||
return false;
|
||||
}
|
||||
|
||||
checkAllMembersUpForConfigChange(newConfig,false);
|
||||
checkMembersUpForConfigChange(newConfig,false);
|
||||
|
||||
log() << "replSet replSetReconfig all members seem up" << rsLog;
|
||||
log() << "replSet replSetReconfig [2]" << rsLog;
|
||||
|
||||
theReplSet->haveNewConfig(newConfig, true);
|
||||
ReplSet::startupStatusMsg = "replSetReconfig'd";
|
||||
|
||||
@@ -390,9 +390,9 @@ namespace mongo {
|
||||
startupStatus = EMPTYCONFIG;
|
||||
startupStatusMsg = "can't get " + rsConfigNs + " config from self or any seed (EMPTYCONFIG)";
|
||||
log() << "replSet can't get " << rsConfigNs << " config from self or any seed (EMPTYCONFIG)" << rsLog;
|
||||
log() << "replSet have you ran replSetInitiate yet?" << rsLog;
|
||||
log(1) << "replSet have you ran replSetInitiate yet?" << rsLog;
|
||||
if( _seeds->size() == 0 )
|
||||
log() << "replSet no seed hosts were specified on the --replSet command line - that might be the issue" << rsLog;
|
||||
log(1) << "replSet info no seed hosts were specified on the --replSet command line" << rsLog;
|
||||
}
|
||||
else {
|
||||
startupStatus = EMPTYUNREACHABLE;
|
||||
|
||||
@@ -305,7 +305,9 @@ namespace mongo {
|
||||
|
||||
private:
|
||||
Member* head() const { return _members.head(); }
|
||||
Member* findById(unsigned id) const;
|
||||
public:
|
||||
const Member* findById(unsigned id) const;
|
||||
private:
|
||||
void _getTargets(list<Target>&, int &configVersion);
|
||||
void getTargets(list<Target>&, int &configVersion);
|
||||
void startThreads();
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace mongo {
|
||||
mchk(_id >= 0 && _id <= 255);
|
||||
mchk(priority >= 0 && priority <= 1000);
|
||||
mchk(votes >= 0 && votes <= 100);
|
||||
uassert(13419, "replica set config : this version of mongo only supports priorities 0 and 1", priority == 0 || priority == 1);
|
||||
uassert(13419, "this version of mongod only supports priorities 0 and 1", priority == 0 || priority == 1);
|
||||
}
|
||||
|
||||
/*static*/ bool ReplSetConfig::legalChange(const ReplSetConfig& o, const ReplSetConfig& n, string& errmsg) {
|
||||
@@ -133,7 +133,7 @@ namespace mongo {
|
||||
|
||||
/* TODO : MORE CHECKS HERE */
|
||||
|
||||
cout << "TODO : don't allow removal of a node until we handle it at the removed node end." << endl;
|
||||
log() << "replSet TODO : don't allow removal of a node until we handle it at the removed node end?" << endl;
|
||||
// we could change its votes to zero perhaps instead as a short term...
|
||||
|
||||
return true;
|
||||
@@ -220,7 +220,7 @@ namespace mongo {
|
||||
catch(DBException& e) {
|
||||
log() << "replSet cfg parsing exception for members[" << i << "] " << e.what() << rsLog;
|
||||
stringstream ss;
|
||||
ss << "replSet members[" << i << "] bad config object";
|
||||
ss << "bad config for member[" << i << "] " << e.what();
|
||||
uassert(13135, ss.str(), false);
|
||||
}
|
||||
if( !(ords.count(m._id) == 0 && hosts.count(m.h.toString()) == 0) ) {
|
||||
|
||||
@@ -32,10 +32,12 @@ using namespace mongoutils;
|
||||
|
||||
namespace mongo {
|
||||
|
||||
/* throws
|
||||
@param initial -
|
||||
/* called on a reconfig AND on initiate
|
||||
throws
|
||||
@param initial true when initiating
|
||||
*/
|
||||
void checkAllMembersUpForConfigChange(const ReplSetConfig& cfg, bool initial) {
|
||||
void checkMembersUpForConfigChange(const ReplSetConfig& cfg, bool initial) {
|
||||
int failures = 0;
|
||||
int me = 0;
|
||||
for( vector<ReplSetConfig::MemberCfg>::const_iterator i = cfg.members.begin(); i != cfg.members.end(); i++ ) {
|
||||
if( i->h.isSelf() ) {
|
||||
@@ -45,7 +47,7 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
}
|
||||
uassert(13278, "bad config?", me <= 1);
|
||||
uassert(13278, "bad config - dups?", me <= 1); // dups?
|
||||
uassert(13279, "can't find self in the replset config", me == 1);
|
||||
|
||||
for( vector<ReplSetConfig::MemberCfg>::const_iterator i = cfg.members.begin(); i != cfg.members.end(); i++ ) {
|
||||
@@ -62,12 +64,11 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
catch(DBException& e) {
|
||||
log() << "replSet requestHeartbeat " << i->h.toString() << " : " << e.toString() << rsLog;
|
||||
log() << "replSet cmufcc requestHeartbeat " << i->h.toString() << " : " << e.toString() << rsLog;
|
||||
}
|
||||
catch(...) {
|
||||
log() << "replSet error exception in requestHeartbeat?" << rsLog;
|
||||
log() << "replSet cmufcc error exception in requestHeartbeat?" << rsLog;
|
||||
}
|
||||
cout << "TEMP hb res cfg change:" << res.toString() << endl;
|
||||
if( res.getBoolField("mismatch") )
|
||||
uasserted(13145, "set name does not match the set name host " + i->h.toString() + " expects");
|
||||
if( *res.getStringField("set") ) {
|
||||
@@ -83,9 +84,31 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
if( !ok && !res["rs"].trueValue() ) {
|
||||
if( !res.isEmpty() )
|
||||
if( !res.isEmpty() ) {
|
||||
/* strange. got a response, but not "ok". log it. */
|
||||
log() << "replSet warning " << i->h.toString() << " replied: " << res.toString() << rsLog;
|
||||
uasserted(13144, "need members up to initiate/reconfig, not ok: " + i->h.toString());
|
||||
}
|
||||
|
||||
bool allowFailure = false;
|
||||
failures++;
|
||||
if( res.isEmpty() && !initial && failures == 1 ) {
|
||||
/* for now we are only allowing 1 node to be down on a reconfig. this can be made to be a minority
|
||||
trying to keep change small as release is near.
|
||||
*/
|
||||
const Member* m = theReplSet->findById( i->_id );
|
||||
if( m ) {
|
||||
// ok, so this was an existing member (wouldn't make sense to add to config a new member that is down)
|
||||
assert( m->h().toString() == i->h.toString() );
|
||||
allowFailure = true;
|
||||
}
|
||||
}
|
||||
|
||||
if( !allowFailure ) {
|
||||
string msg = string("need members up to initiate, not ok : ") + i->h.toString();
|
||||
if( !initial )
|
||||
msg = string("need most members up to reconfigure, not ok : ") + i->h.toString();
|
||||
uasserted(13144, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
if( initial ) {
|
||||
@@ -175,8 +198,10 @@ namespace mongo {
|
||||
configObj = cmdObj["replSetInitiate"].Obj();
|
||||
}
|
||||
|
||||
bool parsed = false;
|
||||
try {
|
||||
ReplSetConfig newConfig(configObj);
|
||||
parsed = true;
|
||||
|
||||
if( newConfig.version > 1 ) {
|
||||
errmsg = "can't initiate with a version number greater than 1";
|
||||
@@ -185,7 +210,7 @@ namespace mongo {
|
||||
|
||||
log() << "replSet replSetInitiate config object parses ok, " << newConfig.members.size() << " members specified" << rsLog;
|
||||
|
||||
checkAllMembersUpForConfigChange(newConfig, true);
|
||||
checkMembersUpForConfigChange(newConfig, true);
|
||||
|
||||
log() << "replSet replSetInitiate all members seem up" << rsLog;
|
||||
|
||||
@@ -199,7 +224,11 @@ namespace mongo {
|
||||
}
|
||||
catch( DBException& e ) {
|
||||
log() << "replSet replSetInitiate exception: " << e.what() << rsLog;
|
||||
throw;
|
||||
if( !parsed )
|
||||
errmsg = string("couldn't parse cfg object ") + e.what();
|
||||
else
|
||||
errmsg = string("couldn't initiate : ") + e.what();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -203,8 +203,8 @@ namespace mongo {
|
||||
OpTime ts = o["ts"]._opTime();
|
||||
long long h = o["h"].numberLong();
|
||||
if( ts != lastOpTimeWritten || h != lastH ) {
|
||||
log() << "TEMP our last op time written: " << lastOpTimeWritten.toStringPretty() << endl;
|
||||
log() << "TEMP primary's GTE: " << ts.toStringPretty() << endl;
|
||||
log(1) << "TEMP our last op time written: " << lastOpTimeWritten.toStringPretty() << endl;
|
||||
log(1) << "TEMP primary's GTE: " << ts.toStringPretty() << endl;
|
||||
/*
|
||||
}*/
|
||||
|
||||
@@ -243,7 +243,6 @@ namespace mongo {
|
||||
}
|
||||
else {
|
||||
sethbmsg(str::stream() << "still syncing, not yet to minValid optime " << minvalid.toString());
|
||||
//log() << "TEMP " << lastOpTimeWritten.toString() << rsLog;
|
||||
}
|
||||
|
||||
/* todo: too stale capability */
|
||||
|
||||
@@ -613,6 +613,8 @@ namespace mongo {
|
||||
BSONObjIteratorSorted i( query );
|
||||
while ( i.more() ){
|
||||
BSONElement e = i.next();
|
||||
if ( e.fieldName()[0] == '$' ) // for $atomic and anything else we add
|
||||
continue;
|
||||
|
||||
if ( e.type() == Object && e.embeddedObject().firstElement().fieldName()[0] == '$' ){
|
||||
// this means this is a $gt type filter, so don't make part of the new object
|
||||
|
||||
5
debian/changelog
vendored
5
debian/changelog
vendored
@@ -1,3 +1,8 @@
|
||||
mongodb (1.6.0) unstable; urgency=low
|
||||
|
||||
* sharding stable
|
||||
* replica_sets stable
|
||||
|
||||
mongodb (1.5.8) unstable; urgency=low
|
||||
|
||||
* sharding lots of changes
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = MongoDB
|
||||
PROJECT_NUMBER = 1.5.8
|
||||
PROJECT_NUMBER = 1.6.0
|
||||
OUTPUT_DIRECTORY = docs/doxygen
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
|
||||
@@ -141,6 +141,14 @@ assert.soon( function(){ return am.lotOfIndexes.getIndexes().length == as.lotOfI
|
||||
|
||||
assert.eq( am.lotOfIndexes.getIndexes().length , as.lotOfIndexes.getIndexes().length , "lots of indexes b" )
|
||||
|
||||
// multi-update with $inc
|
||||
|
||||
am.mu1.update( { _id : 1 , $atomic : 1 } , { $inc : { x : 1 } } , true , true )
|
||||
x = { _id : 1 , x : 1 }
|
||||
assert.eq( x , am.mu1.findOne() , "mu1" );
|
||||
assert.soon( function(){ z = as.mu1.findOne(); printjson( z ); return friendlyEqual( x , z ); } , "mu2" )
|
||||
|
||||
|
||||
|
||||
rt.stop();
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ doTest = function( signal ) {
|
||||
var master = replTest.getMaster();
|
||||
var config = master.getDB("local").system.replset.findOne();
|
||||
|
||||
replTest.stopSet( signal );
|
||||
replTest.stopSet( signal , true );
|
||||
|
||||
replTest.restart(0);
|
||||
replTest.restart(1);
|
||||
|
||||
@@ -6,8 +6,14 @@ s.adminCommand( { shardcollection : "test.data" , key : { num : 1 } } );
|
||||
|
||||
db = s.getDB( "test" );
|
||||
|
||||
for ( i=0; i<100; i++ ){
|
||||
db.data.insert( { _id : i , num : i } );
|
||||
N = 100
|
||||
|
||||
forward = []
|
||||
backward = []
|
||||
for ( i=0; i<N; i++ ){
|
||||
db.data.insert( { _id : i , num : i , x : N - i } )
|
||||
forward.push( i )
|
||||
backward.push( ( N - 1 ) - i )
|
||||
}
|
||||
db.getLastError();
|
||||
|
||||
@@ -23,7 +29,7 @@ assert.eq( temp[0].shard , temp[2].shard , "A2" );
|
||||
assert.neq( temp[0].shard , temp[1].shard , "A3" );
|
||||
|
||||
temp = db.data.find().sort( { num : 1 } ).toArray();
|
||||
assert.eq( 100 , temp.length , "B1" );
|
||||
assert.eq( N , temp.length , "B1" );
|
||||
for ( i=0; i<100; i++ ){
|
||||
assert.eq( i , temp[i].num , "B2" )
|
||||
}
|
||||
@@ -39,6 +45,37 @@ assert.eq( 67 , z.length , "C2" )
|
||||
|
||||
print( "a: " + a + " b:" + b + " mongos slow down: " + Math.ceil( 100 * ( ( a - b ) / b ) ) + "%" )
|
||||
|
||||
//assert.lt( a , b * 1.3 , "C3 - speed test" );
|
||||
// -- secondary index sorting
|
||||
|
||||
function getSorted( by , want , dir , proj ){
|
||||
var s = {}
|
||||
s[by] = dir || 1;
|
||||
printjson( s )
|
||||
var cur = db.data.find( {} , proj || {} ).sort( s )
|
||||
return terse( cur.map( function(z){ return z[want]; } ) );
|
||||
}
|
||||
|
||||
function terse( a ){
|
||||
var s = "";
|
||||
for ( var i=0; i<a.length; i++ ){
|
||||
if ( i > 0 )
|
||||
s += ",";
|
||||
s += a[i];
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
forward = terse(forward);
|
||||
backward = terse(backward);
|
||||
|
||||
assert.eq( forward , getSorted( "num" , "num" , 1 ) , "D1" )
|
||||
assert.eq( backward , getSorted( "num" , "num" , -1 ) , "D2" )
|
||||
|
||||
assert.eq( backward , getSorted( "x" , "num" , 1 ) , "D3" )
|
||||
assert.eq( forward , getSorted( "x" , "num" , -1 ) , "D4" )
|
||||
|
||||
assert.eq( backward , getSorted( "x" , "num" , 1 , { num : 1 } ) , "D5" )
|
||||
assert.eq( forward , getSorted( "x" , "num" , -1 , { num : 1 } ) , "D6" )
|
||||
|
||||
|
||||
s.stop();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Name: mongo
|
||||
Version: 1.5.8
|
||||
Version: 1.6.0
|
||||
Release: mongodb_1%{?dist}
|
||||
Summary: mongo client shell and tools
|
||||
License: AGPL 3.0
|
||||
@@ -130,11 +130,6 @@ fi
|
||||
%attr(0755,mongod,mongod) %dir /var/log/mongo
|
||||
%attr(0640,mongod,mongod) %config(noreplace) %verify(not md5 size mtime) /var/log/mongo/mongod.log
|
||||
|
||||
%files devel
|
||||
/usr/include/mongo
|
||||
%{_libdir}/libmongoclient.a
|
||||
#%{_libdir}/libmongotestfiles.a
|
||||
|
||||
%changelog
|
||||
* Thu Jan 28 2010 Richard M Kreuter <richard@10gen.com>
|
||||
- Minor fixes.
|
||||
|
||||
@@ -624,8 +624,7 @@ namespace mongo {
|
||||
return false;
|
||||
}
|
||||
|
||||
// HostAndPort defaults to a different port; adjust if needed.
|
||||
if ( shardAddr.port() == CmdLine::DefaultDBPort ){
|
||||
if ( ! shardAddr.hasPort() ){
|
||||
shardAddr.setPort( CmdLine::ShardServerPort );
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace mongo {
|
||||
|
||||
/**
|
||||
* holds all the actual db connections for a client to various servers
|
||||
* 1 pre thread, so don't have to worry about thread safety
|
||||
*/
|
||||
class ClientConnections : boost::noncopyable {
|
||||
public:
|
||||
@@ -70,7 +71,8 @@ namespace mongo {
|
||||
_hosts.clear();
|
||||
}
|
||||
|
||||
DBClientBase * get( const string& addr ){
|
||||
DBClientBase * get( const string& addr , const string& ns ){
|
||||
_check( ns );
|
||||
scoped_lock lk( _mutex );
|
||||
Status* &s = _hosts[addr];
|
||||
if ( ! s )
|
||||
@@ -152,9 +154,16 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
|
||||
void _check( const string& ns ){
|
||||
if ( ns.size() == 0 || _seenNS.count( ns ) )
|
||||
return;
|
||||
_seenNS.insert( ns );
|
||||
checkVersions( ns );
|
||||
}
|
||||
|
||||
map<string,Status*> _hosts;
|
||||
mongo::mutex _mutex;
|
||||
|
||||
set<string> _seenNS;
|
||||
// -----
|
||||
|
||||
static thread_specific_ptr<ClientConnections> _perThread;
|
||||
@@ -188,7 +197,7 @@ namespace mongo {
|
||||
|
||||
void ShardConnection::_init(){
|
||||
assert( _addr.size() );
|
||||
_conn = ClientConnections::get()->get( _addr );
|
||||
_conn = ClientConnections::get()->get( _addr , _ns );
|
||||
_finishedInit = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -243,6 +243,20 @@ DBQuery.prototype.explain = function (verbose) {
|
||||
if (!verbose) {
|
||||
delete e.allPlans;
|
||||
delete e.oldPlan;
|
||||
if (e.shards){
|
||||
for (var key in e.shards){
|
||||
var s = e.shards[key];
|
||||
if(s.length === undefined){
|
||||
delete s.allPlans;
|
||||
delete s.oldPlan;
|
||||
} else {
|
||||
for (var i=0; i < s.length; i++){
|
||||
delete s[i].allPlans;
|
||||
delete s[i].oldPlan;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
@@ -157,6 +157,9 @@ ShardingTest = function( testName , numShards , verboseLevel , numMongos , other
|
||||
|
||||
var localhost = "localhost";
|
||||
|
||||
this._alldbpaths = []
|
||||
|
||||
|
||||
if ( otherParams.rs ){
|
||||
localhost = getHostName();
|
||||
// start replica sets
|
||||
@@ -173,6 +176,7 @@ ShardingTest = function( testName , numShards , verboseLevel , numMongos , other
|
||||
this._configServers = []
|
||||
for ( var i=0; i<3; i++ ){
|
||||
var conn = startMongodTest( 30000 + i , testName + "-config" + i );
|
||||
this._alldbpaths.push( testName + "-config" + i )
|
||||
this._configServers.push( conn );
|
||||
}
|
||||
|
||||
@@ -183,6 +187,7 @@ ShardingTest = function( testName , numShards , verboseLevel , numMongos , other
|
||||
else {
|
||||
for ( var i=0; i<numShards; i++){
|
||||
var conn = startMongodTest( 30000 + i , testName + i );
|
||||
this._alldbpaths.push( testName +i )
|
||||
this._connections.push( conn );
|
||||
}
|
||||
|
||||
@@ -316,6 +321,11 @@ ShardingTest.prototype.stop = function(){
|
||||
this._rs[i].test.stopSet( 15 );
|
||||
}
|
||||
}
|
||||
if ( this._alldbpaths ){
|
||||
for( i=0; i<this._alldbpaths.length; i++ ){
|
||||
resetDbpath( "/data/db/" + this._alldbpaths[i] );
|
||||
}
|
||||
}
|
||||
|
||||
print('*** ' + this._testName + " completed successfully ***");
|
||||
}
|
||||
@@ -966,6 +976,8 @@ ReplSetTest = function( opts ){
|
||||
this.name = opts.name || "testReplSet";
|
||||
this.host = opts.host || getHostName();
|
||||
this.numNodes = opts.nodes || 0;
|
||||
this.useSeedList = opts.useSeedList || false;
|
||||
|
||||
this.bridged = opts.bridged || false;
|
||||
this.ports = [];
|
||||
|
||||
@@ -1024,6 +1036,10 @@ ReplSetTest.prototype.getPort = function( n ){
|
||||
ReplSetTest.prototype.getPath = function( n ){
|
||||
var p = "/data/db/" + this.name + "-";
|
||||
p += n.toString();
|
||||
if ( ! this._alldbpaths )
|
||||
this._alldbpaths = [ p ];
|
||||
else
|
||||
this._alldbpaths.push( p );
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -1326,9 +1342,15 @@ ReplSetTest.prototype.stop = function( n , signal ){
|
||||
return stopMongod( port , signal || 15 );
|
||||
}
|
||||
|
||||
ReplSetTest.prototype.stopSet = function( signal ) {
|
||||
ReplSetTest.prototype.stopSet = function( signal , forRestart ) {
|
||||
for(i=0; i < this.ports.length; i++) {
|
||||
this.stop( i, signal );
|
||||
}
|
||||
if ( ! forRestart && this._alldbpaths ){
|
||||
for( i=0; i<this._alldbpaths.length; i++ ){
|
||||
resetDbpath( this._alldbpaths[i] );
|
||||
}
|
||||
}
|
||||
|
||||
print('*** Shut down repl set - test worked ****' )
|
||||
}
|
||||
|
||||
@@ -27,13 +27,13 @@ namespace mongo {
|
||||
|
||||
typedef boost::function<void()> lam;
|
||||
|
||||
/** typical usage is: task::fork( serverPtr ); */
|
||||
/** typical usage is: task::fork( new Server("threadname") ); */
|
||||
class Server : public Task {
|
||||
public:
|
||||
/** send a message to the port */
|
||||
void send(lam);
|
||||
|
||||
Server(string name) : _name(name) { }
|
||||
Server(string name) : _name(name), rq(false) { }
|
||||
virtual ~Server() { }
|
||||
|
||||
/** send message but block until function completes */
|
||||
@@ -42,9 +42,8 @@ namespace mongo {
|
||||
void requeue() { rq = true; }
|
||||
|
||||
protected:
|
||||
/* this needn't be abstract; i left it that way for now so i remember
|
||||
to call Client::initThread() when using in mongo... */
|
||||
virtual void starting() = 0;
|
||||
/* REMINDER : for use in mongod, you will want to have this call Client::initThread(). */
|
||||
virtual void starting() { }
|
||||
|
||||
private:
|
||||
virtual bool initClient() { return true; }
|
||||
|
||||
@@ -117,7 +117,6 @@ namespace mongo {
|
||||
|
||||
void Server::doWork() {
|
||||
starting();
|
||||
rq = false;
|
||||
while( 1 ) {
|
||||
lam f;
|
||||
try {
|
||||
@@ -134,7 +133,10 @@ namespace mongo {
|
||||
f();
|
||||
if( rq ) {
|
||||
rq = false;
|
||||
send(f);
|
||||
{
|
||||
boost::mutex::scoped_lock lk(m);
|
||||
d.push_back(f);
|
||||
}
|
||||
}
|
||||
} catch(std::exception& e) {
|
||||
log() << "Server::doWork() exception " << e.what() << endl;
|
||||
@@ -143,6 +145,27 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static Server *s;
|
||||
static void abc(int i) {
|
||||
cout << "Hello " << i << endl;
|
||||
s->requeue();
|
||||
}
|
||||
class TaskUnitTest : public mongo::UnitTest {
|
||||
public:
|
||||
virtual void run() {
|
||||
lam f = boost::bind(abc, 3);
|
||||
//f();
|
||||
|
||||
s = new Server("unittest");
|
||||
fork(s);
|
||||
s->send(f);
|
||||
|
||||
sleepsecs(30);
|
||||
cout <<" done" << endl;
|
||||
|
||||
}
|
||||
}; // not running. taskunittest;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,6 +74,7 @@ namespace mongo {
|
||||
string host() const { return _host; }
|
||||
|
||||
int port() const { return _port >= 0 ? _port : CmdLine::DefaultDBPort; }
|
||||
bool hasPort() const { return _port >= 0; }
|
||||
void setPort( int port ) { _port = port; }
|
||||
|
||||
private:
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace mongo {
|
||||
// mongo processes version support
|
||||
//
|
||||
|
||||
const char versionString[] = "1.5.9-pre-";
|
||||
const char versionString[] = "1.6.0";
|
||||
|
||||
string mongodVersion() {
|
||||
stringstream ss;
|
||||
|
||||
Reference in New Issue
Block a user