Search in sources :

Example 11 with TmfCoalescedEventRequest

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

the class TmfEventProviderCoalescingTest method testParentFirstCoalescing.

/**
 * Verify coalescing across providers where a parent request is sent first
 * before the children requests. All requests are coalesced at the top
 * level parent.
 *
 * @throws Exception if an error occurred
 */
@Test
public void testParentFirstCoalescing() throws Exception {
    InnerEventRequest expReq = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
    InnerEventRequest trace1Req = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
    InnerEventRequest trace2Req = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
    fExperiment.sendRequest(expReq);
    fTmfTrace1.sendRequest(trace1Req);
    fTmfTrace2.sendRequest(trace2Req);
    // Verify that requests are coalesced properly with the experiment request
    List<TmfCoalescedEventRequest> pending = fExperiment.getAllPendingRequests();
    assertEquals(1, pending.size());
    assertEquals(0, fTmfTrace1.getAllPendingRequests().size());
    assertEquals(0, fTmfTrace2.getAllPendingRequests().size());
    String expectedIds = "[" + expReq.getRequestId() + ", " + trace1Req.getRequestId() + ", " + trace2Req.getRequestId() + "]";
    TmfCoalescedEventRequest coalescedRequest = pending.get(0);
    assertEquals(expectedIds, coalescedRequest.getSubRequestIds());
}
Also used : TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) Test(org.junit.Test)

Example 12 with TmfCoalescedEventRequest

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

the class TmfEventProviderCoalescingTest method testParentDependencyBackground.

/**
 * Verify coalescing across providers where a parent request is sent first
 * before the children requests. One child request has a dependency on the
 * other child so that it is not coalesced with the other requests.
 *
 * @throws Exception if an error occurred
 */
@Test
public void testParentDependencyBackground() throws Exception {
    InnerEventRequest expReq = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
    InnerEventRequest expReq2 = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND, 1);
    InnerEventRequest trace1Req = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
    InnerEventRequest trace2Req = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND, 1);
    fExperiment.sendRequest(expReq);
    fTmfTrace1.sendRequest(trace1Req);
    fExperiment.sendRequest(expReq2);
    fTmfTrace2.sendRequest(trace2Req);
    // Verify that requests are coalesced properly with the experiment request
    List<TmfCoalescedEventRequest> pending = fExperiment.getAllPendingRequests();
    assertEquals(2, pending.size());
    assertEquals(0, fTmfTrace1.getAllPendingRequests().size());
    assertEquals(0, fTmfTrace2.getAllPendingRequests().size());
    // Now trigger manually the sending of the request
    fExperiment.notifyPendingRequest(false);
    /*
         * expReq and trace1Req are coalesced together
         */
    String expectedIds = "[" + expReq.getRequestId() + ", " + trace1Req.getRequestId() + "]";
    TmfCoalescedEventRequest coalescedRequest = pending.get(0);
    assertEquals(expectedIds, coalescedRequest.getSubRequestIds());
    /*
         * expReq2 and trace2Req are coalesced together
         */
    expectedIds = "[" + expReq2.getRequestId() + ", " + trace2Req.getRequestId() + "]";
    coalescedRequest = pending.get(1);
    assertEquals(expectedIds, coalescedRequest.getSubRequestIds());
    expReq.waitForCompletion();
    expReq2.waitForCompletion();
    trace1Req.waitForCompletion();
    trace2Req.waitForCompletion();
    assertTrue(expReq.isTraceHandled(fTmfTrace1));
    assertTrue(expReq.isTraceHandled(fTmfTrace2));
    assertTrue(expReq.isTraceHandled(fTmfTrace3));
    assertTrue(trace1Req.isTraceHandled(fTmfTrace1));
    assertFalse(trace1Req.isTraceHandled(fTmfTrace2));
    assertFalse(trace1Req.isTraceHandled(fTmfTrace3));
    assertTrue(expReq2.isTraceHandled(fTmfTrace1));
    assertTrue(expReq2.isTraceHandled(fTmfTrace2));
    assertTrue(expReq2.isTraceHandled(fTmfTrace3));
    assertFalse(trace2Req.isTraceHandled(fTmfTrace1));
    assertTrue(trace2Req.isTraceHandled(fTmfTrace2));
    assertFalse(trace2Req.isTraceHandled(fTmfTrace3));
    assertEquals(TRACE1_NB_EVENT + TRACE2_NB_EVENT + TRACE3_NB_EVENT, expReq.getNbRead());
    assertEquals(TRACE1_NB_EVENT, trace1Req.getNbRead());
    assertEquals(TRACE2_NB_EVENT, trace2Req.getNbRead());
}
Also used : TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) Test(org.junit.Test)

Example 13 with TmfCoalescedEventRequest

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

the class TmfTraceStub method getAllPendingRequests.

/**
 * @return a copy of the pending request list
 * @throws Exception if java reflection failed
 */
public List<TmfCoalescedEventRequest> getAllPendingRequests() throws Exception {
    Method m = TmfEventProvider.class.getDeclaredMethod("getPendingRequests");
    m.setAccessible(true);
    LinkedList<?> list = (LinkedList<?>) m.invoke(this);
    LinkedList<TmfCoalescedEventRequest> retList = new LinkedList<>();
    for (Object element : list) {
        retList.add((TmfCoalescedEventRequest) element);
    }
    return retList;
}
Also used : Method(java.lang.reflect.Method) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) LinkedList(java.util.LinkedList)

Example 14 with TmfCoalescedEventRequest

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

the class TmfExperimentStub method getAllPendingRequests.

/**
 * @return a copy of the pending request list
 * @throws Exception if java reflection failed
 */
public List<TmfCoalescedEventRequest> getAllPendingRequests() throws Exception {
    Method m = TmfEventProvider.class.getDeclaredMethod("getPendingRequests");
    m.setAccessible(true);
    LinkedList<?> list = (LinkedList<?>) m.invoke(this);
    LinkedList<TmfCoalescedEventRequest> retList = new LinkedList<>();
    for (Object element : list) {
        retList.add((TmfCoalescedEventRequest) element);
    }
    return retList;
}
Also used : Method(java.lang.reflect.Method) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) LinkedList(java.util.LinkedList)

Example 15 with TmfCoalescedEventRequest

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

the class TmfCoalescedEventRequestTest method testAddEvent2.

@Test
public void testAddEvent2() {
    TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 1, 2147483647, ExecutionType.FOREGROUND, 0);
    TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 1, 2147483647, 200);
    TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range1, 0, 2147483647, 200);
    assertTrue("isCompatible", coalescedRequest.isCompatible(req1));
    assertTrue("isCompatible", coalescedRequest.isCompatible(req2));
    coalescedRequest.addRequest(req1);
    coalescedRequest.addRequest(req2);
    assertEquals("addRequest", 0, coalescedRequest.getIndex());
    assertEquals("addRequest", 2147483647, coalescedRequest.getNbRequested());
}
Also used : TmfEventRequestStub(org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub) TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) TmfEventRequest(org.eclipse.tracecompass.tmf.core.request.TmfEventRequest) Test(org.junit.Test)

Aggregations

TmfCoalescedEventRequest (org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest)22 Test (org.junit.Test)14 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)8 TmfEventRequestStub (org.eclipse.tracecompass.tmf.tests.stubs.request.TmfEventRequestStub)8 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)3 Method (java.lang.reflect.Method)2 LinkedList (java.util.LinkedList)2 IllformedLocaleException (java.util.IllformedLocaleException)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)1 ExecutionType (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)1 Before (org.junit.Before)1