Search in sources :

Example 16 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.

the class TmfMultiTraceExperimentTest method testProcessRequestForAllEvents.

@Test
public void testProcessRequestForAllEvents() throws InterruptedException {
    final int nbEvents = ITmfEventRequest.ALL_DATA;
    final Vector<ITmfEvent> requestedEvents = new Vector<>();
    final long nbExpectedEvents = NB_EVENTS;
    final TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, 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);
        }
    };
    fExperiment.sendRequest(request);
    request.waitForCompletion();
    assertEquals("nbEvents", nbExpectedEvents, 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 < nbExpectedEvents; i++) {
        assertEquals("Distinct events", i + 1, requestedEvents.get(i).getTimestamp().getValue());
    }
}
Also used : ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Vector(java.util.Vector) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 17 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.

the class TmfMultiTraceExperimentTest method testProcessRequestForNbEvents.

// ------------------------------------------------------------------------
// processRequest
// ------------------------------------------------------------------------
@Test
public void testProcessRequestForNbEvents() throws InterruptedException {
    final int nbEvents = 1000;
    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, nbEvents, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(final ITmfEvent event) {
            super.handleData(event);
            requestedEvents.add(event);
        }
    };
    fExperiment.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", i + 1, requestedEvents.get(i).getTimestamp().getValue());
    }
}
Also used : ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Vector(java.util.Vector) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 18 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.

the class TmfTraceTest method testProcessEventRequestForOtherEvents.

@Test
public void testProcessEventRequestForOtherEvents() throws InterruptedException {
    final int startIndex = 99;
    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, startIndex, 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)

Example 19 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.

the class TmfTraceTest method testCancel.

// ------------------------------------------------------------------------
// cancel
// ------------------------------------------------------------------------
@Test
public void testCancel() throws InterruptedException {
    final int limit = 500;
    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) {

        int nbRead = 0;

        @Override
        public void handleData(final ITmfEvent event) {
            super.handleData(event);
            requestedEvents.add(event);
            if (++nbRead == limit) {
                cancel();
            }
        }
    };
    final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
    providers[0].sendRequest(request);
    request.waitForCompletion();
    assertEquals("nbEvents", limit, requestedEvents.size());
    assertTrue("isCompleted", request.isCompleted());
    assertTrue("isCancelled", request.isCancelled());
}
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 20 with TmfEventRequest

use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.

the class TmfTraceTest method testProcessEventRequestForNbEvents.

@Test
public void testProcessEventRequestForNbEvents() throws InterruptedException {
    final int nbEvents = 1000;
    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, 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", 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)

Aggregations

TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)51 Test (org.junit.Test)36 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)31 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)29 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)24 Vector (java.util.Vector)15 TmfEventRequestStub (org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub)15 ITmfEventProvider (org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider)11 TmfCoalescedEventRequest (org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest)8 ArrayList (java.util.ArrayList)5 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 NonNull (org.eclipse.jdt.annotation.NonNull)3 AnalysisManagerTest (org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest)3 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 TmfCollapseFilter (org.eclipse.tracecompass.internal.tmf.core.filter.TmfCollapseFilter)2 ITmfFilter (org.eclipse.tracecompass.tmf.core.filter.ITmfFilter)2 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)2 ITmfSyncSequenceDiagramEvent (org.eclipse.tracecompass.tmf.core.uml2sd.ITmfSyncSequenceDiagramEvent)2