Thanks Elliot.
Yes it DOES work -- as long as you are on the latest Java Client
(2.7.3 -- I was on 2.6.5 and it failed)
BUT, if you use it as simply
new Mongo( "myANAME", 23456)
It does create the connection to the first one it gets from the list.
But if you call insureIndex() and it didn't happen to pick the Primary
It throws an Exception; MongoException : not talking to master and
retries used up
[02/17/12 17:24:14:919](main) ERROR - MongodbHASessionDAO -
EXCEPTION in Mongodb processing
MongoException : not talking to master and retries used up
Error with Mongo Server (sessionv2-mongo-replset-
ustst1.wvrgroup.internal:27017/MongoReplicaSetBasicsTest/sessions2)
com.mongodb.MongoException: not talking to master and retries used up
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:246)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:248)
at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:248)
at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305)
at com.mongodb.DBCollection.findOne(DBCollection.java:647)
at com.mongodb.DBCollection.findOne(DBCollection.java:626)
at com.mongodb.DBApiLayer$MyCollection.createIndex(DBApiLayer.java:
364)
at com.mongodb.DBCollection.createIndex(DBCollection.java:436)
at com.mongodb.DBCollection.ensureIndex(DBCollection.java:515)
at com.mongodb.DBCollection.ensureIndex(DBCollection.java:492)
I can, of course, work around this as:
List<ServerAddress> addrs = new
ArrayList<ServerAddress>();
InetAddress[] inetaddrs =
InetAddress.getAllByName(mongoServerName);
for(InetAddress addr : inetaddrs) {
addrs.add(new ServerAddress(addr, mongoServerPort));
}
return new Mongo(addrs, mongoOptions);
But I thought you'd like to know...
Thanks for all of your help.
Cheers,
-- Chris