Search in sources :

Example 11 with ITmfEventProvider

use of org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider in project tracecompass by tracecompass.

the class TmfTrace method traceOpened.

// ------------------------------------------------------------------------
// Signal handlers
// ------------------------------------------------------------------------
/**
 * Handler for the Trace Opened signal
 *
 * @param signal
 *            The incoming signal
 */
@TmfSignalHandler
public void traceOpened(TmfTraceOpenedSignal signal) {
    boolean signalIsForUs = false;
    ITmfEventProvider provider = this;
    while (provider != null) {
        if (provider == signal.getTrace()) {
            signalIsForUs = true;
            break;
        }
        provider = provider.getParent();
    }
    if (!signalIsForUs) {
        return;
    }
    /*
         * The signal is either for this trace, or for a parent of this trace.
         */
    IStatus status = executeAnalysis();
    if (!status.isOK()) {
        Activator.log(status);
    }
    /* Refresh supplementary files in separate thread to prevent deadlock */
    new // $NON-NLS-1$
    Thread(// $NON-NLS-1$
    "Refresh supplementary files") {

        @Override
        public void run() {
            TmfTraceManager.refreshSupplementaryFiles(TmfTrace.this);
        }
    }.start();
    if (signal.getTrace() == this) {
        /* Additionally, the signal is directly for this trace. */
        if (getNbEvents() == 0) {
            return;
        }
        /* For a streaming trace, the range updated signal should be sent
             * by the subclass when a new safe time is determined.
             */
        if (getStreamingInterval() > 0) {
            return;
        }
        if (isComplete()) {
            final TmfTimeRange timeRange = new TmfTimeRange(getStartTime(), TmfTimestamp.BIG_CRUNCH);
            final TmfTraceRangeUpdatedSignal rangeUpdatedsignal = new TmfTraceRangeUpdatedSignal(this, this, timeRange);
            // Broadcast in separate thread to prevent deadlock
            broadcastAsync(rangeUpdatedsignal);
        }
        return;
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ITmfEventProvider(org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider) TmfTraceRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 12 with ITmfEventProvider

use of org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider in project tracecompass by tracecompass.

the class TmfTraceTest method testProcessDataRequestForSomeEvents.

@Test
public void testProcessDataRequestForSomeEvents() throws InterruptedException {
    final int startIndex = 100;
    final int nbEvents = 1000;
    final Vector<ITmfEvent> requestedEvents = new Vector<>();
    final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, TmfTimeRange.ETERNITY, startIndex, nbEvents, TmfEventRequest.ExecutionType.FOREGROUND) {

        @Override
        public void handleData(final ITmfEvent event) {
            super.handleData(event);
            requestedEvents.add(event);
        }
    };
    final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
    providers[0].sendRequest(request);
    request.waitForCompletion();
    assertEquals("nbEvents", nbEvents, requestedEvents.size());
    assertTrue("isCompleted", request.isCompleted());
    assertFalse("isCancelled", request.isCancelled());
    // Don't go overboard: we are not validating the stub!
    for (int i = 0; i < nbEvents; i++) {
        assertEquals("Distinct events", startIndex + 1 + i, requestedEvents.get(i).getTimestamp().getValue());
    }
}
Also used : ITmfEventProvider(org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) Vector(java.util.Vector) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 13 with ITmfEventProvider

use of org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider in project tracecompass by tracecompass.

the class TmfTraceTest method testProcessEventRequestForAllEvents.

// ------------------------------------------------------------------------
// processRequest
// ------------------------------------------------------------------------
@Test
public void testProcessEventRequestForAllEvents() throws InterruptedException {
    final Vector<ITmfEvent> requestedEvents = new Vector<>();
    final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
    final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(final ITmfEvent event) {
            super.handleData(event);
            requestedEvents.add(event);
        }
    };
    final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
    providers[0].sendRequest(request);
    request.waitForCompletion();
    assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
    assertTrue("isCompleted", request.isCompleted());
    assertFalse("isCancelled", request.isCancelled());
    // Don't go overboard: we are not validating the stub!
    for (int i = 0; i < NB_EVENTS; i++) {
        assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
    }
}
Also used : ITmfEventProvider(org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Vector(java.util.Vector) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 14 with ITmfEventProvider

use of org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider in project tracecompass by tracecompass.

the class TmfTraceTest method testProcessEventRequestForSomeEvents.

@Test
public void testProcessEventRequestForSomeEvents() throws InterruptedException {
    final long startTime = 100;
    final int nbEvents = 1000;
    final Vector<ITmfEvent> requestedEvents = new Vector<>();
    final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.create(startTime, SCALE), TmfTimestamp.BIG_CRUNCH);
    final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class, range, 0, nbEvents, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(final ITmfEvent event) {
            super.handleData(event);
            requestedEvents.add(event);
        }
    };
    final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
    providers[0].sendRequest(request);
    request.waitForCompletion();
    assertEquals("nbEvents", nbEvents, requestedEvents.size());
    assertTrue("isCompleted", request.isCompleted());
    assertFalse("isCancelled", request.isCancelled());
    // Don't go overboard: we are not validating the stub!
    for (int i = 0; i < nbEvents; i++) {
        assertEquals("Distinct events", startTime + i, requestedEvents.get(i).getTimestamp().getValue());
    }
}
Also used : ITmfEventProvider(org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Vector(java.util.Vector) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Aggregations

ITmfEventProvider (org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider)14 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)11 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)11 Vector (java.util.Vector)9 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)9 Test (org.junit.Test)8 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 IFile (org.eclipse.core.resources.IFile)1 IStatus (org.eclipse.core.runtime.IStatus)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 TmfCollapseFilter (org.eclipse.tracecompass.internal.tmf.core.filter.TmfCollapseFilter)1 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)1 ITmfFilter (org.eclipse.tracecompass.tmf.core.filter.ITmfFilter)1 TmfEndSynchSignal (org.eclipse.tracecompass.tmf.core.signal.TmfEndSynchSignal)1 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)1 TmfStartSynchSignal (org.eclipse.tracecompass.tmf.core.signal.TmfStartSynchSignal)1 TmfTraceRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceRangeUpdatedSignal)1 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)1