Search in sources :

Example 6 with TmfEventRequest

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

the class TmfCoalescedEventRequestTest method trigger.

@TmfSignalHandler
public void trigger(final TmfTestTriggerSignal signal) {
    TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
    final long REQUEST_OFFSET = 1000;
    requestedEvents1 = new Vector<>();
    request1 = new TmfEventRequest(ITmfEvent.class, range, signal.fIndex, NB_EVENTS, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(ITmfEvent event) {
            super.handleData(event);
            if (!isCompleted()) {
                requestedEvents1.add(event);
                if (signal.forceCancel) {
                    cancel();
                }
            }
        }
    };
    requestedEvents2 = new Vector<>();
    request2 = new TmfEventRequest(ITmfEvent.class, range, signal.fIndex + REQUEST_OFFSET, NB_EVENTS, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(ITmfEvent event) {
            super.handleData(event);
            if (!isCompleted()) {
                requestedEvents2.add(event);
            }
        }
    };
    requestedEvents3 = new Vector<>();
    request3 = new TmfEventRequest(ITmfEvent.class, range, signal.fIndex + 2 * REQUEST_OFFSET, NB_EVENTS, ExecutionType.FOREGROUND) {

        @Override
        public void handleData(ITmfEvent event) {
            super.handleData(event);
            if (!isCompleted()) {
                requestedEvents3.add(event);
            }
        }
    };
    providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
    providers[0].sendRequest(request1);
    providers[0].sendRequest(request2);
    providers[0].sendRequest(request3);
}
Also used : ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfTraceStub(org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 7 with TmfEventRequest

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

the class TmfEventRequestIntegrationTest method testSingleRequestException.

/**
 * Test the behavior of a failed request
 *
 * @throws InterruptedException
 *             The test timed out
 */
@Test
public void testSingleRequestException() throws InterruptedException {
    TmfTrace trace = fTrace;
    TmfEventRequest requestFail = new TmfEventRequestStub(ITmfEvent.class, TmfTimeRange.ETERNITY, 2, 0, ExecutionType.BACKGROUND, 0) {

        @Override
        public void handleData(@NonNull ITmfEvent data) {
            throw new IllegalArgumentException();
        }
    };
    trace.sendRequest(requestFail);
    requestFail.waitForCompletion();
    assertTrue(requestFail.isCompleted());
    assertFalse(requestFail.isCancelled());
    assertTrue(requestFail.isFailed());
}
Also used : TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) NonNull(org.eclipse.jdt.annotation.NonNull) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 8 with TmfEventRequest

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

the class TmfEventRequestTest method testTmfEventRequestWithDependencyLevel.

@Test
public void testTmfEventRequestWithDependencyLevel() {
    TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH);
    TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range, 100, 200, ExecutionType.FOREGROUND, 1);
    assertEquals("getDataType", ITmfEvent.class, request.getDataType());
    assertEquals("StartTime", TmfTimestamp.fromSeconds(0), request.getRange().getStartTime());
    assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
    assertEquals("getIndex", 0, request.getIndex());
    assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
    assertFalse("isCompleted", request.isCompleted());
    assertFalse("isFailed", request.isFailed());
    assertFalse("isCancelled", request.isCancelled());
    assertEquals("getNbRead", 0, request.getNbRead());
    assertEquals("getDependencyLevel", 1, request.getDependencyLevel());
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 9 with TmfEventRequest

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

the class TmfEventRequestTest method testTmfEventRequest.

// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
@Test
public void testTmfEventRequest() {
    TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class);
    assertEquals("getDataType", ITmfEvent.class, request.getDataType());
    assertEquals("StartTime", TmfTimestamp.BIG_BANG, request.getRange().getStartTime());
    assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
    assertEquals("getRange", TmfTimeRange.ETERNITY, request.getRange());
    assertSame("getRange", TmfTimeRange.ETERNITY, request.getRange());
    assertEquals("getIndex", 0, request.getIndex());
    assertEquals("getNbRequestedEvents", ITmfEventRequest.ALL_DATA, request.getNbRequested());
    assertFalse("isCompleted", request.isCompleted());
    assertFalse("isFailed", request.isFailed());
    assertFalse("isCancelled", request.isCancelled());
    assertEquals("getNbRead", 0, request.getNbRead());
    assertEquals("getDependencyLevel", 0, request.getDependencyLevel());
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Example 10 with TmfEventRequest

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

the class TmfEventRequestTest method testTmfEventRequestTimeRangeNbRequestedBlocksize.

@Test
public void testTmfEventRequestTimeRangeNbRequestedBlocksize() {
    TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromSeconds(0), TmfTimestamp.BIG_CRUNCH);
    TmfEventRequest request = new TmfEventRequestStub(ITmfEvent.class, range, 100, 200);
    assertEquals("getDataType", ITmfEvent.class, request.getDataType());
    assertEquals("StartTime", TmfTimestamp.fromSeconds(0), request.getRange().getStartTime());
    assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
    assertEquals("getIndex", 0, request.getIndex());
    assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
    assertFalse("isCompleted", request.isCompleted());
    assertFalse("isFailed", request.isFailed());
    assertFalse("isCancelled", request.isCancelled());
    assertEquals("getNbRead", 0, request.getNbRead());
    assertEquals("getDependencyLevel", 0, request.getDependencyLevel());
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) ITmfEventRequest(org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest) 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