-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
does not support mongo replica sets #6
Comments
This might work: (defn connect "Returns a single server connection. Defaults to host 127.0.0.1:27017 Supports replica sets if passed a vector of host-port vectors." ([] (connect "127.0.0.1")) ([host] (cond (string? host) (connect host 27017) (vector? host) (Mongo. (map #(ServerAddress. (first %) (second %)) host)))) ([#^String host port] (Mongo. host (int port))) The below assumes that mongod is running on localhost and that there are three different mongod servers running as a replica set at mongo1.foo.com, mongo2.foo.com, and mongo3.foo.com. karras.core> (connect) #<Mongo com.mongodb.Mongo@404c7788> karras.core> (connect "mongo1.foo.com" 27017) #<Mongo com.mongodb.Mongo@3d5bf0c5> karras.core> (connect [["mongo1.foo.com" 27017] ["mongo2.foo" 27017] ["mongo3.foo.com" 27017]]) #<Mongo com.mongodb.Mongo@75896415> |
|
You'll want to use a newer version of mongo-java-driver. Version 2.3 works and doesn't break any of your tests. |
I'll get this in this week. Thanks! |
Welcome. Thanks for your great work! ^_^ |
This bit: ([host] (cond (string? host) (connect host 27017) (vector? host) (Mongo. (map #(ServerAddress. (first %) (second %)) host)))) Should be the following instead: ([host] (cond (string? host) (connect host 27017) (coll? host) (Mongo. (map #(ServerAddress. (first %) (second %)) host)))) That particular constructor for the Mongo class can accept anything that implements the List interface, so it doesn't make sense to require only a vector (we have yaml-reading code that returns a list when it parses a yaml array). Also, we've run tests, and it looks like mongo-java-driver 2.3 has pretty solid replica set support that tolerates the failure of a primary node well. |
mongo-java-driver 2.1 does not support mongo replica sets.
Upgrade to a newer version of mongo-java-driver is necessary.
The text was updated successfully, but these errors were encountered: