edwardcapriolo / gossip

A Mavenized Apache V2 gossip implementation for Java
Apache License 2.0
160 stars 54 forks source link

Heartbeat is always =0 #8

Closed hvandenb closed 8 years ago

hvandenb commented 8 years ago

I have the following initialization code where I specify a timeout of 20. However, when I look at the logs the heartbeat always stays at 0 and it never continue to check if the other nodes come back.

Here is the log

 Started Application in 2.735 seconds (JVM running for 3.108)
2015-10-11 14:43:04.667  INFO 69599 --- [        Timer-0] com.google.code.gossip.GossipService     : Dead member detected: Member [address=10.0.1.156:2000, id=10.0.1.156-2000, heartbeat=0]
2015-10-11 14:43:04.667  INFO 69599 --- [        Timer-1] com.google.code.gossip.GossipService     : Dead member detected: Member [address=10.0.1.9:2000, id=10.0.1.9-2000, heartbeat=0]
2015-10-11 14:43:04.667  INFO 69599 --- [        Timer-0] p2.server.service.GossipProtocolService  : Member [address=10.0.1.156:2000, id=10.0.1.156-2000, heartbeat=0] DOWN
2015-10-11 14:43:04.667  INFO 69599 --- [        Timer-1] p2.server.service.GossipProtocolService  : Member [address=10.0.1.9:2000, id=10.0.1.9-2000, heartbeat=0] DOWN
    public void initMembers() {
int heartbeat = 20;
        log.info("Initializing Gossip, with seeds: " + getSeeds().toString());

        for (String host: seeds) {
            GossipMember g = new RemoteGossipMember(host, this.port, host + "-"+ this.port, heartbeat);
            startupMembers.add(g);
        }

        try { 
            gossipService = new GossipService("127.0.0.1", port, "1-1", LogLevel.DEBUG, startupMembers, settings, this);
          } catch (UnknownHostException | InterruptedException e) {
            throw new RuntimeException(e);
          }
          gossipService.start();        
hvandenb commented 8 years ago

Found what the issue was, the heartbeat was being used as the id, error on the calling side.

edwardcapriolo commented 8 years ago

Cool sorry i lost track of this, how are you using the library?

edwardcapriolo commented 8 years ago

Cool sorry i lost track of this, how are you using the library?

hvandenb commented 8 years ago

I'm writing a distributed application that needs to discover other members. I did noticed that I fixed the issue on the calling side, e.g. when adding the seed members. Below is the code how I'm using it. However, I noticed that the heartbeat = 0 when the LocalGossipMember gets established. I'm tracking that down as well.

            GossipSettings gossipSettings = new GossipSettings();
            List<HostAndPort> seeds = buildEndpointList(settings.getSeeds(), ClusterConstants.DEFAULT_GOSSIP_PORT);
            seedMembers = Lists.newArrayListWithCapacity(seeds.size());
            seedMembers.clear();

            for (HostAndPort hap : seeds) {
                seedMembers.add(new RemoteGossipMember(hap.getHostText(), 
                        hap.getPort(),
                        Node.generateId(hap.getHostText(), hap.getPort()),
                        settings.getHeartBeat()));
            }