Permalink
Browse files

issue42: SSL must be set on every single Mongo instance

  • Loading branch information...
agirbal committed Nov 15, 2011
1 parent 8f5455f commit e63b2fc09bf9193e0eeb058893ba943d86d53bdc
@@ -50,7 +50,7 @@ protected void populateChildren() {
// check if mongos
boolean added = false;
ServerAddress addr = addrs.get(0);
- ServerNode node = new ServerNode(addr);
+ ServerNode node = new ServerNode(mongo);
try {
CommandResult res = node.getServerDB().command("isdbgrid");
if (res.ok()) {
@@ -6,6 +6,7 @@
package org.mongo.jmongob;
import com.mongodb.Mongo;
+import com.mongodb.MongoOptions;
import com.mongodb.ServerAddress;
import java.util.List;
import java.util.logging.Level;
@@ -31,8 +32,8 @@ public ReplSetNode(String name, Mongo mongo) {
markStructured();
}
- public ReplSetNode(String name, List<ServerAddress> addrs) {
- this.mongo = new Mongo(addrs);
+ public ReplSetNode(String name, List<ServerAddress> addrs, MongoOptions opts) {
+ this.mongo = new Mongo(addrs, opts);
this.name = name != null ? name : "Replica Set";
try {
xmlLoad(Resource.getXmlDir(), Resource.File.replSetNode, null);
@@ -47,7 +48,7 @@ protected void populateChildren() {
mongo.getDatabaseNames();
List<ServerAddress> addrs = mongo.getServerAddressList();
for (ServerAddress addr : addrs) {
- addChild(new ServerNode(addr));
+ addChild(new ServerNode(addr, mongo.getMongoOptions()));
}
}
@@ -60,9 +60,9 @@ protected void populateChildren() {
}
if (repl != null || addrs.size() > 1) {
- addChild(new ReplSetNode(repl, addrs));
+ addChild(new ReplSetNode(repl, addrs, mongo.getMongoOptions()));
} else {
- addChild(new ServerNode(addrs.get(0)));
+ addChild(new ServerNode(addrs.get(0), mongo.getMongoOptions()));
}
} catch (Exception e) {
getLogger().log(Level.WARNING, null, e);
@@ -6,6 +6,7 @@
import com.edgytech.swingfast.SwingFast;
import com.mongodb.BasicDBObject;
+import com.mongodb.Bytes;
import com.mongodb.CommandResult;
import com.mongodb.DB;
import com.mongodb.Mongo;
@@ -24,11 +25,22 @@
ServerAddress serverAddress;
Mongo serverMongo;
- public ServerNode(ServerAddress serverAddress) {
+ public ServerNode(Mongo mongo) {
+ serverMongo = mongo;
+ serverAddress = mongo.getAddress();
+ try {
+ xmlLoad(Resource.getXmlDir(), Resource.File.serverNode, null);
+ } catch (Exception ex) {
+ getLogger().log(Level.SEVERE, null, ex);
+ }
+ markStructured();
+ }
+
+ public ServerNode(ServerAddress serverAddress, MongoOptions opts) {
this.serverAddress = serverAddress;
- MongoOptions opts = new MongoOptions();
- opts.slaveOk = true;
serverMongo = new Mongo(serverAddress, opts);
+ serverMongo.addOption( Bytes.QUERYOPTION_SLAVEOK );
+
try {
xmlLoad(Resource.getXmlDir(), Resource.File.serverNode, null);
} catch (Exception ex) {

0 comments on commit e63b2fc

Please sign in to comment.