summaryrefslogtreecommitdiff
path: root/src/mongo/shell/replsetbridge.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/shell/replsetbridge.js')
-rw-r--r--src/mongo/shell/replsetbridge.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/shell/replsetbridge.js b/src/mongo/shell/replsetbridge.js
new file mode 100644
index 00000000000..bd5691372c3
--- /dev/null
+++ b/src/mongo/shell/replsetbridge.js
@@ -0,0 +1,26 @@
+ReplSetBridge = function(rst, from, to) {
+ var n = rst.nodes.length;
+
+ var startPort = rst.startPort+n;
+ this.port = (startPort+(from*n+to));
+ this.host = rst.host+":"+this.port;
+
+ this.dest = rst.host+":"+rst.ports[to];
+ this.start();
+};
+
+ReplSetBridge.prototype.start = function() {
+ var args = ["mongobridge", "--port", this.port, "--dest", this.dest];
+ print("ReplSetBridge starting: "+tojson(args));
+ this.bridge = startMongoProgram.apply( null , args );
+ print("ReplSetBridge started " + this.bridge);
+};
+
+ReplSetBridge.prototype.stop = function() {
+ print("ReplSetBridge stopping: " + this.port);
+ stopMongod(this.port, 9);
+};
+
+ReplSetBridge.prototype.toString = function() {
+ return this.host+" -> "+this.dest;
+};