/** Distribute peer information */ private void sendHello() { HeartBeatMsg.Hello msg = new HeartBeatMsg.Hello(); for (Map.Entry<String, JiniPeer> entry : agent.getPeers().entrySet()) { if (!entry.getValue().getReady()) continue; msg.appendPeers(entry.getKey()); } msg.setUnversionedHeaders(agent.getHeaders()); for (JiniPeer peer : agent.getPeers().values()) { if (!peer.getReady()) continue; msg.setSequence(peer.incSequence()); peer.send(msg); } }
@Override public long processTimer(long interval) { ArrayList<String> expired = new ArrayList<String>(); for (JiniPeer peer : agent.getPeers().values()) { if (peer.expiredAt() > 0 && System.currentTimeMillis() >= peer.expiredAt()) { expired.add(peer.getEndpoint()); agent.onEvent(JiniEvent.PEER_EXIT, peer.getEndpoint()); } else if (System.currentTimeMillis() >= peer.evasiveAt()) { peer.send(new HeartBeatMsg.Ping(peer.incSequence())); } } if (!expired.isEmpty()) agent.removePeer(expired.toArray(new String[0])); return interval; }