Improve FD logging when the arrival time is ignored.

Patch by Brandon Williams for CASSANDRA-8245
This commit is contained in:
Brandon Williams 2015-01-06 09:30:07 -06:00
parent a22308294d
commit eb9c5bbcfd
2 changed files with 22 additions and 10 deletions

View File

@ -211,12 +211,12 @@ public class FailureDetector implements IFailureDetector, FailureDetectorMBean
{ {
// avoid adding an empty ArrivalWindow to the Map // avoid adding an empty ArrivalWindow to the Map
heartbeatWindow = new ArrivalWindow(SAMPLE_SIZE); heartbeatWindow = new ArrivalWindow(SAMPLE_SIZE);
heartbeatWindow.add(now); heartbeatWindow.add(now, ep);
arrivalSamples.put(ep, heartbeatWindow); arrivalSamples.put(ep, heartbeatWindow);
} }
else else
{ {
heartbeatWindow.add(now); heartbeatWindow.add(now, ep);
} }
} }
@ -326,7 +326,7 @@ class ArrivalWindow
} }
} }
synchronized void add(long value) synchronized void add(long value, InetAddress ep)
{ {
assert tLast >= 0; assert tLast >= 0;
if (tLast > 0L) if (tLast > 0L)
@ -335,7 +335,7 @@ class ArrivalWindow
if (interArrivalTime <= MAX_INTERVAL_IN_NANO) if (interArrivalTime <= MAX_INTERVAL_IN_NANO)
arrivalIntervals.add(interArrivalTime); arrivalIntervals.add(interArrivalTime);
else else
logger.debug("Ignoring interval time of {}", interArrivalTime); logger.debug("Ignoring interval time of {} for {}", interArrivalTime, ep);
} }
else else
{ {

View File

@ -25,6 +25,10 @@ import static org.junit.Assert.*;
import org.junit.Test; import org.junit.Test;
import java.lang.RuntimeException;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class ArrivalWindowTest public class ArrivalWindowTest
{ {
@Test @Test
@ -32,12 +36,20 @@ public class ArrivalWindowTest
{ {
final ArrivalWindow windowWithNano = new ArrivalWindow(4); final ArrivalWindow windowWithNano = new ArrivalWindow(4);
final long toNano = 1000000L; final long toNano = 1000000L;
InetAddress ep;
windowWithNano.add(111 * toNano); try
windowWithNano.add(222 * toNano); {
windowWithNano.add(333 * toNano); ep = InetAddress.getLocalHost();
windowWithNano.add(444 * toNano); }
windowWithNano.add(555 * toNano); catch (UnknownHostException e)
{
throw new RuntimeException(e);
}
windowWithNano.add(111 * toNano, ep);
windowWithNano.add(222 * toNano, ep);
windowWithNano.add(333 * toNano, ep);
windowWithNano.add(444 * toNano, ep);
windowWithNano.add(555 * toNano, ep);
//all good //all good
assertEquals(1.0, windowWithNano.phi(666 * toNano), 0.01); assertEquals(1.0, windowWithNano.phi(666 * toNano), 0.01);