Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server state is shared with pool instead of seperate
- Loading branch information
Showing
26 changed files
with
552 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
var ReplSetManager = require('mongodb-topology-manager').ReplSet, | ||
f = require('util').format; | ||
|
||
var rsOptions = { | ||
server: { | ||
keyFile: __dirname + '/test/functional/data/keyfile.txt', | ||
auth: null, | ||
replSet: 'rs' | ||
}, | ||
client: { | ||
replSet: 'rs' | ||
} | ||
} | ||
|
||
// Set up the nodes | ||
var nodes = [{ | ||
options: { | ||
bind_ip: 'localhost', port: 31000, | ||
dbpath: f('%s/../db/31000', __dirname), | ||
} | ||
}, { | ||
options: { | ||
bind_ip: 'localhost', port: 31001, | ||
dbpath: f('%s/../db/31001', __dirname), | ||
} | ||
}, { | ||
options: { | ||
bind_ip: 'localhost', port: 31002, | ||
dbpath: f('%s/../db/31002', __dirname), | ||
} | ||
}] | ||
|
||
// Merge in any node start up options | ||
for(var i = 0; i < nodes.length; i++) { | ||
for(var name in rsOptions.server) { | ||
nodes[i].options[name] = rsOptions.server[name]; | ||
} | ||
} | ||
|
||
// Create a manager | ||
var replicasetManager = new ReplSetManager('mongod', nodes, rsOptions.client); | ||
// Purge the set | ||
replicasetManager.purge().then(function() { | ||
// Start the server | ||
replicasetManager.start().then(function() { | ||
process.exit(0); | ||
}).catch(function(e) { | ||
console.log("====== ") | ||
console.dir(e) | ||
// // console.dir(e); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
var mongodb = require("./"); | ||
/* | ||
db.createUser( { | ||
user: "root", | ||
pwd: "root", | ||
roles: [ { role: "root", db: "admin" } ] | ||
}); | ||
*/ | ||
// var uri = "mongodb://muser:mpass@ds021331-a0.mlab.com:21331,ds021331-a1.mlab.com:21331/mdb?replicaSet=rs-ds021331"; | ||
// var uri = "mongodb://root:root@localhost:31000,localhost:31001/admin?replicaSet=rs"; | ||
// var uri = "mongodb://foo:bar@ds021331-a0.mlab.com:21331,ds021331-a1.mlab.com:21331/driver-test?replicaSet=rs-ds021331"; | ||
var uri = "mongodb://root:root@localhost:27017/admin?socketTimeoutMS=5000&connectTimeoutMS=5000"; | ||
var interval = 1000; | ||
var index = 0; | ||
var total = 1000; | ||
|
||
var openThenClose = function(){ | ||
var i = index; | ||
var MongoClient = mongodb.MongoClient; | ||
MongoClient.connect(uri, function(err, db) { | ||
if(!err) { | ||
console.log("open " + i); | ||
var descriptors = db.db('test').collection("some-collection").find(); | ||
descriptors.toArray(function(err, docs){ | ||
db.close(function(){ | ||
console.log("close " + i); | ||
}); | ||
}); | ||
} | ||
}); | ||
}; | ||
|
||
// Run interval total times | ||
var intervalId = setInterval(function(){ | ||
index = index + 1; | ||
|
||
if(index > total) { | ||
return clearInterval(intervalId); | ||
} | ||
|
||
openThenClose(); | ||
}, interval); | ||
|
||
// keep alive | ||
setInterval(function(){ | ||
}, interval * 10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.