Skip to content

Commit

Permalink
Break servers.js into several files
Browse files Browse the repository at this point in the history
The addition of some (ok, a lot of) comments into shell/servers.js made
the processed file shell/mongo-server.cpp contain a string constant longer
than 65536 characters, and this made it not compile in MSVC any more (scons
or Visual Studio).  This commit breaks the file into smaller sections,
somewhat logically grouped, and feeds them to the JavaScript engine in the
same order as before (so it shouldn't break anything).  No code was added
or removed other than to restore Randolph's comments, and nothing was
rearranged other than the disassembly into separate source files, with
resulting separate string constants.
  • Loading branch information
Tad Marshall committed Apr 12, 2012
1 parent 892331f commit 869e8b4
Show file tree
Hide file tree
Showing 10 changed files with 2,276 additions and 2,097 deletions.
4 changes: 2 additions & 2 deletions src/mongo/SConscript
Expand Up @@ -392,13 +392,13 @@ if darwin or env["_HAVEPCAP"]:

# --- shell ---

# note, if you add a file here, you need to add it in scripting/engine.cpp and shell/msvc/createCPPfromJavaScriptFiles.js as well
# note, if you add a file here, you need to add it in scripting/engine.cpp and shell/createCPPfromJavaScriptFiles.js as well
env.Depends( "shell/dbshell.cpp",
env.JSHeader( "shell/mongo.cpp" ,
Glob( "shell/utils*.js" ) +
[ "shell/db.js","shell/mongo.js","shell/mr.js","shell/query.js","shell/collection.js"] ) )

env.JSHeader( "shell/mongo-server.cpp" , [ "shell/servers.js"] )
env.JSHeader( "shell/mongo-server.cpp" , ["shell/servers.js", "shell/shardingtest.js", "shell/servers_misc.js", "shell/replsettest.js", "shell/replsetbridge.js"] )

coreShellFiles = [ "shell/dbshell.cpp",
"shell/shell_utils.cpp",
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/shell/createCPPfromJavaScriptFiles.js
Expand Up @@ -102,4 +102,4 @@ shell.CurrentDirectory = WScript.Arguments.Unnamed.Item( 0 );

var fso = new ActiveXObject( "Scripting.FileSystemObject" );
rebuildIfNeeded( fso, "shell/mongo.cpp", ["shell/utils.js", "shell/utils_sh.js", "shell/db.js", "shell/mongo.js", "shell/mr.js", "shell/query.js", "shell/collection.js"] );
rebuildIfNeeded( fso, "shell/mongo-server.cpp", ["shell/servers.js"] );
rebuildIfNeeded( fso, "shell/mongo-server.cpp", ["shell/servers.js", "shell/shardingtest.js", "shell/servers_misc.js", "shell/replsettest.js", "shell/replsetbridge.js"] );
4 changes: 4 additions & 0 deletions src/mongo/shell/mongo.vcxproj
Expand Up @@ -1340,7 +1340,11 @@
<None Include="mongo.js" />
<None Include="mr.js" />
<None Include="query.js" />
<None Include="replsetbridge.js" />
<None Include="replsettest.js" />
<None Include="servers.js" />
<None Include="servers_misc.js" />
<None Include="shardingtest.js" />
<None Include="utils.js" />
<None Include="utils_sh.js" />
</ItemGroup>
Expand Down
12 changes: 12 additions & 0 deletions src/mongo/shell/mongo.vcxproj.filters
Expand Up @@ -402,6 +402,18 @@
<None Include="utils_sh.js">
<Filter>JavaScript source files</Filter>
</None>
<None Include="servers_misc.js">
<Filter>JavaScript source files</Filter>
</None>
<None Include="replsetbridge.js">
<Filter>JavaScript source files</Filter>
</None>
<None Include="replsettest.js">
<Filter>JavaScript source files</Filter>
</None>
<None Include="shardingtest.js">
<Filter>JavaScript source files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Library Include="..\..\..\..\js\js32d.lib">
Expand Down
26 changes: 26 additions & 0 deletions 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;
};

0 comments on commit 869e8b4

Please sign in to comment.