use of org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent in project tracecompass by tracecompass.
the class CtfTmfLostEventsTest method testLostEventWithTransform.
/**
* Test getting a lost event from a trace that has a timestamp transform.
*/
@Test
public void testLostEventWithTransform() {
CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(testTrace);
long offset = 1234567890L;
trace.setTimestampTransform(TimestampTransformFactory.createWithOffset(offset));
trace.indexTrace(true);
final long rank = 190;
final ITmfTimestamp start = TmfTimestamp.fromNanos(1376592664828900165L + offset);
final ITmfTimestamp end = TmfTimestamp.fromNanos(1376592664828900165L + 502911L + offset);
final long nbLost = 859;
ITmfContext context = trace.seekEvent(rank);
final CtfTmfEvent ev = trace.getNext(context);
context.dispose();
assertTrue(ev instanceof ITmfLostEvent);
ITmfLostEvent event = (ITmfLostEvent) ev;
assertEquals(start, event.getTimestamp());
assertEquals(start, event.getTimeRange().getStartTime());
assertEquals(end, event.getTimeRange().getEndTime());
assertEquals(nbLost, event.getNbLostEvents());
trace.setTimestampTransform(null);
trace.dispose();
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent in project tracecompass by tracecompass.
the class HistogramRequest method handleData.
// ------------------------------------------------------------------------
// TmfEventRequest
// ------------------------------------------------------------------------
/**
* Handle the event from the trace by updating the histogram data model.
*
* @param event
* a event from the trace
* @see org.eclipse.tracecompass.tmf.core.request.TmfEventRequest#handleData(org.eclipse.tracecompass.tmf.core.event.ITmfEvent)
*/
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
synchronized (fHistogram) {
if (!isCancelled()) {
if (event instanceof ITmfLostEvent) {
ITmfLostEvent lostEvents = (ITmfLostEvent) event;
/* clear the old data when it is a new request */
fHistogram.countLostEvent(lostEvents.getTimeRange(), lostEvents.getNbLostEvents(), fFullRange);
} else {
/* handle lost event */
long timestamp = event.getTimestamp().toNanos();
fHistogram.countEvent(getNbRead(), timestamp, event.getTrace());
}
}
}
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent in project tracecompass by tracecompass.
the class CtfTmfLostEventsTest method validateLostEvent.
private void validateLostEvent(final long rank, @NonNull final ITmfTimestamp start, final ITmfTimestamp end, final long nbLost) {
final CtfTmfEvent ev = getOneEventTime(start);
/* Make sure seeking by rank yields the same event */
final CtfTmfEvent ev2 = getOneEventRank(rank);
assertEquals(ev, ev2);
assertTrue(ev instanceof ITmfLostEvent);
ITmfLostEvent event = (ITmfLostEvent) ev;
assertEquals(start, event.getTimestamp());
assertEquals(start, event.getTimeRange().getStartTime());
assertEquals(end, event.getTimeRange().getEndTime());
assertEquals(nbLost, event.getNbLostEvents());
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent in project tracecompass by tracecompass.
the class CtfTmfLostEventsTest method testNormalEvent.
/**
* Test getting one normal event from the trace (lost events should not
* interfere).
*/
@Test
public void testNormalEvent() {
final long rank = 200;
final ITmfTimestamp ts = TmfTimestamp.fromNanos(1376592664829425780L);
final CtfTmfEvent event = getOneEventTime(ts);
/* Make sure seeking by rank yields the same event */
final CtfTmfEvent event2 = getOneEventRank(rank);
assertEquals(event, event2);
assertFalse(event instanceof ITmfLostEvent);
assertEquals(ts, event.getTimestamp());
}
use of org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent in project tracecompass by tracecompass.
the class TmfTrace method updateAttributes.
/**
* Update the trace attributes
*
* @param context the current trace context
* @param event the corresponding event
* @since 1.1
*/
protected synchronized void updateAttributes(final ITmfContext context, @NonNull final ITmfEvent event) {
ITmfTimestamp timestamp = event.getTimestamp();
ITmfTimestamp endTime = timestamp;
if (event instanceof ITmfLostEvent) {
endTime = ((ITmfLostEvent) event).getTimeRange().getEndTime();
}
if (fStartTime.equals(TmfTimestamp.BIG_BANG) || (fStartTime.compareTo(timestamp) > 0)) {
fStartTime = timestamp;
}
if (fEndTime.equals(TmfTimestamp.BIG_CRUNCH) || (fEndTime.compareTo(endTime) < 0)) {
fEndTime = endTime;
}
if (context.hasValidRank()) {
long rank = context.getRank();
if (fNbEvents <= rank) {
fNbEvents = rank + 1;
}
if (fIndexer != null) {
fIndexer.updateIndex(context, timestamp);
}
}
}
Aggregations