marcesher / cfmongodb

MongoDB client wrapper for ColdFusion
89 stars 34 forks source link

replica sets #3

Closed andreacfm closed 14 years ago

andreacfm commented 14 years ago

Initial support for replica sets in mongodb. This commit just includes the ability to pass to mongoConfig an array of adrresses. Mongo client now knows the replica nodes and will try to contact the master. Still miss the lability to wait for sets to elect a new master if one fails.

marcesher commented 14 years ago

Hey Andrea, Thanks for the work!

I pulled the replica set additions, and when I run the tests I get: coldfusion.xml.rpc.CFCInvocationException: [coldfusion.runtime.java.JavaObjectInstantiationException : Object instantiation exception.An exception occurred while instantiating a Java object. The class must not be an interface or an abstract class. Error: ''.][java.lang.reflect.InvocationTargetException : null][java.lang.ClassCastException : com.mongodb.ServerAddress cannot be cast to com.mongodb.ServerAddress]

This is at line 13 in Mongo.cfc, at variables.mongo.init( mongoConfig.getServers() )

Any ideas?

marcesher commented 14 years ago

Hey Andrea,

I figured it out. I'll respond with more detail tomorrow... it's late here!

And thanks again! This will be a great addition

andreacfm commented 14 years ago

Mark, I think you are loading the jar twice. That's why I avoid using javaloader . Btw I test anything on Railo so I can see if code gets compatible with Railo too.

marcesher commented 14 years ago

Andrea,

Yup, that was it. I've been using javaloader exclusively b/c it makes things much easier for me, and I still had an old mongo jar in my lib folder. your MOngoConfig was creating objects directly, and it was using the mongo in my lib and not the one that javaloader uses.

I think what I'm going to do is change MongoConfig so that it accepts the factory, adn then just have Mongo.cfc get its object factory ot of MongoConfig. This will let us use the factory (either the default or javaloader) in both mongoconfig and mongo, along with all the other places.

Just so you know how the factory works: if you want to use javaloader, you create an instance of the JavaloaderFactory and pass it in a preinitialized javaloader instance. If you want to use the jars in your server's lib folder, you don't do anything.

andreacfm commented 14 years ago

Thanks Mark,

well done.

Andrea