Search in sources :

Example 1 with ITmfLostEvent

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();
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) ITmfLostEvent(org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) Test(org.junit.Test)

Example 2 with ITmfLostEvent

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());
            }
        }
    }
}
Also used : ITmfLostEvent(org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent)

Example 3 with ITmfLostEvent

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());
}
Also used : CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) ITmfLostEvent(org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent)

Example 4 with ITmfLostEvent

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());
}
Also used : CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) ITmfLostEvent(org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent) Test(org.junit.Test)

Example 5 with ITmfLostEvent

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);
        }
    }
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) ITmfLostEvent(org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent)

Aggregations

ITmfLostEvent (org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent)5 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)3 CtfTmfEvent (org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent)3 Test (org.junit.Test)2 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)1 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)1