protected void addIfAbsent(Address mbr) { if(mbr != null && !mbr.equals(local_addr)) timestamps.putIfAbsent(mbr, getTimestamp()); }
protected String _printTimestamps() { StringBuilder sb=new StringBuilder(); long current_time=getTimestamp(); for(Iterator<Entry<Address,Long>> it=timestamps.entrySet().iterator(); it.hasNext();) { Entry<Address,Long> entry=it.next(); sb.append(entry.getKey()).append(": "); sb.append(TimeUnit.SECONDS.convert (current_time - entry.getValue(), TimeUnit.NANOSECONDS)).append(" secs old\n"); } return sb.toString(); }
protected void update(Address sender) { if(sender != null && !sender.equals(local_addr)) timestamps.put(sender, getTimestamp()); if (log.isTraceEnabled()) log.trace("Received heartbeat from %s", sender); }
public void run() { List<Address> suspects=new LinkedList<>(); long current_time=getTimestamp(), diff; for(Iterator<Entry<Address,Long>> it=timestamps.entrySet().iterator(); it.hasNext();) { Entry<Address,Long> entry=it.next(); Address key=entry.getKey(); Long val=entry.getValue(); if(val == null) { it.remove(); continue; } diff=TimeUnit.MILLISECONDS.convert(current_time - val, TimeUnit.NANOSECONDS); if(diff > timeout) { log.debug("haven't received a heartbeat from " + key + " for " + diff + " ms, adding it to suspect list"); suspects.add(key); } } if(!suspects.isEmpty()) suspect(suspects); }
protected void update(Address sender) { if(sender != null && !sender.equals(local_addr)) timestamps.put(sender, getTimestamp()); }
protected void addIfAbsent(Address mbr) { if(mbr != null && !mbr.equals(local_addr)) timestamps.putIfAbsent(mbr, getTimestamp()); }
protected String _printTimestamps() { StringBuilder sb=new StringBuilder(); long current_time=getTimestamp(); for(Iterator<Entry<Address,Long>> it=timestamps.entrySet().iterator(); it.hasNext();) { Entry<Address,Long> entry=it.next(); sb.append(entry.getKey()).append(": "); sb.append(TimeUnit.SECONDS.convert (current_time - entry.getValue(), TimeUnit.NANOSECONDS)).append(" secs old\n"); } return sb.toString(); }
public void run() { List<Address> suspects=new LinkedList<>(); long current_time=getTimestamp(), diff; for(Iterator<Entry<Address,Long>> it=timestamps.entrySet().iterator(); it.hasNext();) { Entry<Address,Long> entry=it.next(); Address key=entry.getKey(); Long val=entry.getValue(); if(val == null) { it.remove(); continue; } diff=TimeUnit.MILLISECONDS.convert(current_time - val, TimeUnit.NANOSECONDS); if(diff > timeout) { log.debug("haven't received a heartbeat from " + key + " for " + diff + " ms, adding it to suspect list"); suspects.add(key); } } if(!suspects.isEmpty()) suspect(suspects); }