Search in sources :

Example 6 with TmfCoalescedEventRequest

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

the class TmfEventProvider method coalesceEventRequest.

/**
 * Add an existing requests to the list of coalesced ones
 *
 * @param request
 *            The request to add to the list
 */
protected void coalesceEventRequest(ITmfEventRequest request) {
    synchronized (fLock) {
        for (TmfCoalescedEventRequest coalescedRequest : getPendingRequests()) {
            if (coalescedRequest.isCompatible(request)) {
                coalescedRequest.addRequest(request);
                if (TmfCoreTracer.isRequestTraced()) {
                    // $NON-NLS-1$
                    TmfCoreTracer.traceRequest(request.getRequestId(), "COALESCED with " + coalescedRequest.getRequestId());
                    // $NON-NLS-1$
                    TmfCoreTracer.traceRequest(coalescedRequest.getRequestId(), "now contains " + coalescedRequest.getSubRequestIds());
                }
                coalesceChildrenRequests(coalescedRequest);
                return;
            }
        }
        newCoalescedEventRequest(request);
    }
}
Also used : TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest)

Example 7 with TmfCoalescedEventRequest

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

the class TmfEventProvider method coalesceCompatibleRequests.

/*
     * Coalesces all pending requests that are compatible with coalesced request.
     */
private void coalesceCompatibleRequests(TmfCoalescedEventRequest request) {
    Iterator<TmfCoalescedEventRequest> iter = getPendingRequests().iterator();
    while (iter.hasNext()) {
        TmfCoalescedEventRequest pendingRequest = iter.next();
        if (request.isCompatible(pendingRequest)) {
            request.addRequest(pendingRequest);
            if (TmfCoreTracer.isRequestTraced()) {
                // $NON-NLS-1$
                TmfCoreTracer.traceRequest(pendingRequest.getRequestId(), "COALESCED with " + request.getRequestId());
                // $NON-NLS-1$
                TmfCoreTracer.traceRequest(request.getRequestId(), "now contains " + request.getSubRequestIds());
            }
            iter.remove();
        }
    }
}
Also used : TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest)

Example 8 with TmfCoalescedEventRequest

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

the class TmfEventProviderCoalescingTest method testTraceDependencyForeground.

/**
 * Verify coalescing for a trace with different dependency level. Requests
 * on the same dependency level are coalesced together.
 *
 * @throws Exception
 *             if an error occurred
 */
@Test
public void testTraceDependencyForeground() throws Exception {
    InnerEventRequest traceReqLevel0 = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.FOREGROUND);
    InnerEventRequest traceReq2Level0 = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.FOREGROUND);
    InnerEventRequest traceReqLevel1 = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.FOREGROUND, 1);
    InnerEventRequest traceReq2Level1 = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.FOREGROUND, 1);
    sendSync(true);
    fTmfTrace1.sendRequest(traceReqLevel0);
    fTmfTrace1.sendRequest(traceReq2Level0);
    fTmfTrace1.sendRequest(traceReqLevel1);
    fTmfTrace1.sendRequest(traceReq2Level1);
    // Verify that requests are coalesced properly with the experiment
    // request
    List<TmfCoalescedEventRequest> pending = fTmfTrace1.getAllPendingRequests();
    assertEquals(2, pending.size());
    sendSync(false);
    /*
         * traceReqLevel0 and trace1Req are coalesced together
         */
    String expectedIds = "[" + traceReqLevel0.getRequestId() + ", " + traceReq2Level0.getRequestId() + "]";
    TmfCoalescedEventRequest coalescedRequest = pending.get(0);
    assertEquals(expectedIds, coalescedRequest.getSubRequestIds());
    /*
         * traceReqLevel1 and traceReq2Level1 are coalesced together
         */
    expectedIds = "[" + traceReqLevel1.getRequestId() + ", " + traceReq2Level1.getRequestId() + "]";
    coalescedRequest = pending.get(1);
    assertEquals(expectedIds, coalescedRequest.getSubRequestIds());
    traceReqLevel0.waitForCompletion();
    traceReq2Level0.waitForCompletion();
    traceReqLevel1.waitForCompletion();
    traceReq2Level1.waitForCompletion();
    assertEquals(TRACE1_NB_EVENT, traceReqLevel0.getNbRead());
    assertEquals(TRACE1_NB_EVENT, traceReq2Level0.getNbRead());
    assertEquals(TRACE1_NB_EVENT, traceReqLevel1.getNbRead());
    assertEquals(TRACE1_NB_EVENT, traceReq2Level1.getNbRead());
}
Also used : TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) Test(org.junit.Test)

Example 9 with TmfCoalescedEventRequest

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

the class TmfEventProviderCoalescingTest method testTraceDependencyBackground.

/**
 * Verify coalescing for a trace with different dependency level. Requests
 * on the same dependency level are coalesced together.
 *
 * @throws Exception
 *             if an error occurred
 */
@Test
public void testTraceDependencyBackground() throws Exception {
    InnerEventRequest traceReqLevel0 = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
    InnerEventRequest traceReq2Level0 = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND);
    InnerEventRequest traceReqLevel1 = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND, 1);
    InnerEventRequest traceReq2Level1 = new InnerEventRequest(ITmfEvent.class, 0, ITmfEventRequest.ALL_DATA, ExecutionType.BACKGROUND, 1);
    fTmfTrace1.sendRequest(traceReqLevel0);
    fTmfTrace1.sendRequest(traceReq2Level0);
    fTmfTrace1.sendRequest(traceReqLevel1);
    fTmfTrace1.sendRequest(traceReq2Level1);
    // Verify that requests are coalesced properly with the experiment
    // request
    List<TmfCoalescedEventRequest> pending = fTmfTrace1.getAllPendingRequests();
    assertEquals(2, pending.size());
    // Now trigger manually the sending of the request
    fTmfTrace1.notifyPendingRequest(false);
    /*
         * traceReqLevel0 and trace1Req are coalesced together
         */
    String expectedIds = "[" + traceReqLevel0.getRequestId() + ", " + traceReq2Level0.getRequestId() + "]";
    TmfCoalescedEventRequest coalescedRequest = pending.get(0);
    assertEquals(expectedIds, coalescedRequest.getSubRequestIds());
    /*
         * traceReqLevel1 and traceReq2Level1 are coalesced together
         */
    expectedIds = "[" + traceReqLevel1.getRequestId() + ", " + traceReq2Level1.getRequestId() + "]";
    coalescedRequest = pending.get(1);
    assertEquals(expectedIds, coalescedRequest.getSubRequestIds());
    traceReqLevel0.waitForCompletion();
    traceReq2Level0.waitForCompletion();
    traceReqLevel1.waitForCompletion();
    traceReq2Level1.waitForCompletion();
    assertEquals(TRACE1_NB_EVENT, traceReqLevel0.getNbRead());
    assertEquals(TRACE1_NB_EVENT, traceReq2Level0.getNbRead());
    assertEquals(TRACE1_NB_EVENT, traceReqLevel1.getNbRead());
    assertEquals(TRACE1_NB_EVENT, traceReq2Level1.getNbRead());
}
Also used : TmfCoalescedEventRequest(org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest) Test(org.junit.Test)

Example 10 with TmfCoalescedEventRequest

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

the class TmfEventProviderCoalescingTest method testChildFirstDependencyBackground.

/**
 * Verify coalescing across providers where a child request is sent first
 * before the children requests. One child request is deferred so that it is
 * not coalesced at the top level parent.
 *
 * @throws Exception
 *             if an error occurred
 */
@Test
public void testChildFirstDependencyBackground() 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);
    fTmfTrace1.sendRequest(trace1Req);
    fExperiment.sendRequest(expReq);
    fTmfTrace2.sendRequest(trace2Req);
    fExperiment.sendRequest(expReq2);
    // 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);
    fTmfTrace1.notifyPendingRequest(false);
    fTmfTrace2.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)

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