parent
61ec03c966
commit
b039f7591f
@ -143,14 +143,15 @@ private synchronized void handleStartEvent(TIMEOUT_PAYLOAD payload,
|
||||
protected synchronized void handleCompletion(COMPLETION_PAYLOAD
|
||||
completionPayload, EventPublisher publisher) throws
|
||||
LeaseNotFoundException {
|
||||
metrics.incrementCompletedEvents();
|
||||
long id = completionPayload.getId();
|
||||
leaseManager.release(id);
|
||||
TIMEOUT_PAYLOAD payload = trackedEventsByID.remove(id);
|
||||
trackedEvents.remove(payload);
|
||||
long originalTime = startTrackingTimes.remove(id);
|
||||
metrics.updateFinishingTime(System.currentTimeMillis() - originalTime);
|
||||
onFinished(publisher, payload);
|
||||
if (trackedEvents.remove(payload)) {
|
||||
metrics.incrementCompletedEvents();
|
||||
long originalTime = startTrackingTimes.remove(id);
|
||||
metrics.updateFinishingTime(System.currentTimeMillis() - originalTime);
|
||||
onFinished(publisher, payload);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void handleTimeout(EventPublisher publisher,
|
||||
|
@ -179,22 +179,32 @@ public void testMetrics() throws InterruptedException {
|
||||
|
||||
queue.fireEvent(REPLICATION_COMPLETED, event1Completed);
|
||||
|
||||
Thread.sleep(2200L);
|
||||
//lease manager timeout = 2000L
|
||||
Thread.sleep(3 * 2000L);
|
||||
|
||||
queue.processAll(2000L);
|
||||
|
||||
//until now: 3 in-progress activities are tracked with three
|
||||
// UnderreplicatedEvents. The first one is completed, the remaining two
|
||||
// are timed out (as the timeout -- defined in the leasmanager -- is 2000ms.
|
||||
// are timed out (as the timeout -- defined in the lease manager -- is
|
||||
// 2000ms).
|
||||
|
||||
EventWatcherMetrics metrics = replicationWatcher.getMetrics();
|
||||
|
||||
//3 events are received
|
||||
Assert.assertEquals(3, metrics.getTrackedEvents().value());
|
||||
|
||||
//one is finished. doesn't need to be resent
|
||||
Assert.assertEquals(1, metrics.getCompletedEvents().value());
|
||||
//completed + timed out = all messages
|
||||
Assert.assertEquals(
|
||||
"number of timed out and completed messages should be the same as the"
|
||||
+ " all messages",
|
||||
metrics.getTrackedEvents().value(),
|
||||
metrics.getCompletedEvents().value() + metrics.getTimedOutEvents()
|
||||
.value());
|
||||
|
||||
//Other two are timed out and resent
|
||||
Assert.assertEquals(2, metrics.getTimedOutEvents().value());
|
||||
//_at least_ two are timed out.
|
||||
Assert.assertTrue("At least two events should be timed out.",
|
||||
metrics.getTimedOutEvents().value() >= 2);
|
||||
|
||||
DefaultMetricsSystem.shutdown();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user