Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Is it (already) possible to retrieve a list of all the peers for a cluster? #19

Closed
thisisaaronland opened this issue Mar 27, 2017 · 5 comments

Comments

@thisisaaronland
Copy link

I know you can get the current state of any one peer but I'd like to be able to keep a list of all the peers in case the initial host that a client connects to goes down and reconnect to one of the other hosts without having to know that list in advance.

The context is this: https://github.com/thisisaaronland/go-artisanal-integers#summitdb

Also: This project (go-artisanal-integers) is as a dumb and silly as it sounds except for the part where it's been a running gag for going on 5 years now...

https://github.com/thisisaaronland/go-artisanal-integers#see-also

@tidwall
Copy link
Owner

tidwall commented Mar 27, 2017

Hi Aaron, The RAFTPEERS command will return a list of the peers and their status.

127.0.0.1:7481> raftpeers
1) "127.0.0.1:7481"
2) "Leader"
3) "127.0.0.1:7482"
4) "Follower"
5) "127.0.0.1:7483"
6) "Follower"

This is useful if you want to look for failures or log leadership changes, such as for cluster diagnostics.

Even with a sane cluster with all nodes running 100%, there will occasionally be leadership changes. As long as your client connection follows the -TRY <addr> responses and updates the leader, you should be good.

@thisisaaronland
Copy link
Author

thisisaaronland commented Mar 27, 2017

Thanks!

I now appear to be bumping up against the "What is redigo actually returning..." problem similar to an issue I filed for Tile-38.

I tried the OUTPUT json trick but it doesn't appear that SummitDB knows about this? Thoughts?

https://github.com/thisisaaronland/go-artisanal-integers/compare/peers

./bin/int -engine summitdb -dsn 'redis://localhost:7482'
2017/03/27 20:19:26 [[49 50 55 46 48 46 48 46 49 58 55 52 56 49] [73 110 118 97 108 105 100] [49 50 55 46 48 46 48 46 49 58 55 52 56 50] [70 111 108 108 111 119 101 114] [49 50 55 46 48 46 48 46 49 58 55 52 56 51] [76 101 97 100 101 114]]

@tidwall
Copy link
Owner

tidwall commented Mar 27, 2017

That's an array of bulk strings. The redis.Strings(conn.Do("RAFTPEERS")) should work.

@thisisaaronland
Copy link
Author

Bingo, thanks! One day I will figure out redigo responses...

./bin/int -engine summitdb -dsn 'redis://localhost:7482'
2017/03/27 20:49:28 127.0.0.1:7481
2017/03/27 20:49:28 Invalid
2017/03/27 20:49:28 127.0.0.1:7482
2017/03/27 20:49:28 Follower
2017/03/27 20:49:28 127.0.0.1:7483
2017/03/27 20:49:28 Leader
summitdb told me to try redis://127.0.0.1:7483 instead, so here we go...

@tidwall
Copy link
Owner

tidwall commented Mar 27, 2017

I agree. Redigo can take a little getting use to.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants