Class MessageTracker
- java.lang.Object
-
- org.opendaylight.controller.cluster.common.actor.MessageTracker
-
@Beta public final class MessageTracker extends Object
MessageTracker is a diagnostic utility class to be used for figuring out why a certain message which was expected to arrive in a given time interval does not arrive. It attempts to keep track of all the messages that received between the arrival of two instances of the same message and the amount of time it took to process each of those messages.
Usage of the API is as follows,// Track the Foo class, Here we expect to see a message of type Foo come in every 10 millis MessageTracker tracker = new MessageTracker(Foo.class, 10); // Begin the tracking process. If this is not called then calling received and done on the resultant Context // will do nothing tracker.begin(); ..... try (MessageTracker.Context context = tracker.received(message)) { if (context.error().isPresent()){ LOG.error("{}", context.error().get()); } // Some custom processing process(message); }
This class is NOT thread-safe.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
MessageTracker.Context
static interface
MessageTracker.Error
static class
MessageTracker.MessageProcessingTime
-
Constructor Summary
Constructors Constructor Description MessageTracker(Class<?> expectedMessageClass, long expectedArrivalIntervalInMillis)
Constructs an instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
begin()
List<MessageTracker.MessageProcessingTime>
getMessagesSinceLastExpectedMessage()
MessageTracker.Context
received(Object message)
-
-
-
Constructor Detail
-
MessageTracker
public MessageTracker(Class<?> expectedMessageClass, long expectedArrivalIntervalInMillis)
Constructs an instance.- Parameters:
expectedMessageClass
- the class of the message to trackexpectedArrivalIntervalInMillis
- the expected arrival interval between two instances of the expected message
-
-
Method Detail
-
begin
public void begin()
-
received
public MessageTracker.Context received(Object message)
-
getMessagesSinceLastExpectedMessage
public List<MessageTracker.MessageProcessingTime> getMessagesSinceLastExpectedMessage()
-
-