From 46ceb972bfae03f2dc9dc9e723dd5b2e5378a8ac Mon Sep 17 00:00:00 2001 From: edwardcapriolo Date: Wed, 14 Jan 2015 11:06:35 -0500 Subject: [PATCH] Update README.md --- README.md | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c81baa8..f864ab4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,33 @@ +Gossip protocol is a method for a group of nodes to discover and check the livelyness of a cluster. More information can be found at http://en.wikipedia.org/wiki/Gossip_protocol. -A gossip implementation forked from https://code.google.com/p/java-gossip/ +The original implementation was forked from https://code.google.com/p/java-gossip/. Several bug fixes and changes have already been added. + +Usage +----- + +To gossip you need one or more seed nodes. Seed is just a list of places to initially connect to. + + GossipSettings settings = new GossipSettings(); + int seedNodes = 3; + ArrayList startupMembers = new ArrayList(); + for (int i = 1; i < seedNodes+1; ++i) { + startupMembers.add(new RemoteGossipMember("127.0.0." + i, 2000, i + "")); + } + +Here we start five gossip processes and check that they discover each other. (Normally these are on different hosts but here we give each process a distinct local ip. + + ArrayList clients = new ArrayList(); + int clusterMembers = 5; + for (int i = 1; i < clusterMembers+1; ++i) { + GossipService gossipService = new GossipService("127.0.0." + i, 2000, i + "", LogLevel.DEBUG, startupMembers, settings); + clients.add(gossipService); + gossipService.start(); + } + +Later we can check that the nodes discover each other + + Thread.sleep(10000); + for (int i = 0; i < clusterMembers; ++i) { + Assert.assertEquals(4, clients.get(i).get_gossipManager().getMemberList().size()); + }