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); }
public void run() { Map.Entry entry; Object key; Long val; if(log.isTraceEnabled()) log.trace("checking for expired senders, table is:\n" + printTimeStamps()); long current_time=System.currentTimeMillis(), diff; for(Iterator it=timestamps.entrySet().iterator(); it.hasNext();) { entry=(Map.Entry)it.next(); key=entry.getKey(); val=(Long)entry.getValue(); if(val == null) { it.remove(); continue; } diff=current_time - val.longValue(); if(diff > timeout) { if(log.isTraceEnabled()) log.trace("haven't received a heartbeat from " + key + " for " + diff + " ms, suspecting it"); suspect((Address)key); } } }
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); }