Replica Sets Implementation Question

1 view
Skip to first unread message

Randolph

unread,
Oct 7, 2010, 10:52:54 PM10/7/10
to Mongo node .js driver
Hi!

I would like to confirm on the responsibility of the driver with
regards to replica sets. Should the driver silently try to find the
new master if the original master is lost or should it just provide
api and make the client responsible for reestablishing the connection?

I also have a question regarding node js. Does anybody know a function
that can allow you to execute external commands (like for example,
kill a process)? I was thinking on how to write test for the replica
sets since you need to cut off the master to simulate a real life
situation. I also noticed that there seems to be no test for the
connection "class" (Do you call them class in js?).

Kristina Chodorow

unread,
Oct 8, 2010, 6:59:23 AM10/8/10
to mongo-node...@googlegroups.com
Yes, the driver should find a new master.  The user should be able to pass in a host or list of hosts when they connect and not have to worry about failover.  Does that make sense?

Unfortunately, no one has come up with a particularly good way of testing replica sets.  Sorry to start you guys on a problem that's so difficult to test.  The way we've been doing it for other drivers is to manually test it: write a simple program that does queries (or some operation) in an infinite loop and try bringing members of the set up and down, making sure failover works.  For example, see http://github.com/mongodb/mongo-perl-driver/blob/master/t/rs.pl.

Pratik Daga

unread,
Oct 8, 2010, 2:31:27 PM10/8/10
to mongo-node...@googlegroups.com
as you said:- The user should be able to
> pass
> in a host or list of hosts when they connect and not have to worry about
> failover

so you mean something like this (this is java code, for sake of understanding I used it). Or I am confusing it?

List<ServerAddress> addrs = new LinkedList<ServerAddress>();
addrs.add( new ServerAddress( "localhost" , 27017 ) );
addrs.add( new ServerAddress( "localhost" , 27018 ) );

Mongo m = new Mongo( addrs );
ReplicaSetStatus status = new ReplicaSetStatus( m , addrs );

Kristina Chodorow

unread,
Oct 8, 2010, 3:36:57 PM10/8/10
to mongo-node...@googlegroups.com
I'm not sure what ReplicaSetStatus is, but the first 4 lines look right.

Say you have five servers in your set: 27017-27021.  If localhost:27020 is master and you say "new Mongo(addrs)", the driver should connect to the two listed (27017, 27018) and use one of those connections to figure out that 27020 is master and connect to it, then use that connection for subsequent operations.
Reply all
Reply to author
Forward
0 new messages