import org.eclipse.tracecompass.tmf.core.signal.TmfEndSynchSignal;
import org.eclipse.tracecompass.tmf.core.signal.TmfStartSynchSignal;
import org.eclipse.tracecompass.tmf.core.tests.shared.TmfTestTrace;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfExperimentStub;
import org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub;
*/
public class TmfEventProviderCoalescingTest {
+ private static final int TRACE1_NB_EVENT = 10000;
+ private static final int TRACE2_NB_EVENT = 702;
+ private static final int TRACE3_NB_EVENT = 10000;
private static TmfTraceStub fTmfTrace1;
private static TmfTraceStub fTmfTrace2;
private static TmfTraceStub fTmfTrace3;
assertFalse(trace2Req.isTraceHandled(fTmfTrace3));
}
+ /**
+ * 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());
+ }
+
+ /**
+ * 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());
+ }
+
+ /**
+ * 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());
+ }
+
+ /**
+ * 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());
+ }
+
// ------------------------------------------------------------------------
// Helper methods
// ------------------------------------------------------------------------
super(dataType, index, nbRequested, priority);
}
+ public InnerEventRequest(Class<? extends ITmfEvent> dataType, long index, int nbRequested, ExecutionType priority, int dependency) {
+ super(dataType, TmfTimeRange.ETERNITY, index, nbRequested, priority, dependency);
+ }
+
@Override
public void handleData(ITmfEvent event) {
super.handleData(event);
return traces.contains(trace.getName());
}
}
+
}
@Before
public void setUp() {
- fRequest1 = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
- fRequest2 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 100, ExecutionType.FOREGROUND);
- fRequest3 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 200, ExecutionType.FOREGROUND);
- fRequest4 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 200, ExecutionType.FOREGROUND);
+ fRequest1 = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0);
+ fRequest2 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 100, ExecutionType.FOREGROUND, 0);
+ fRequest3 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 200, ExecutionType.FOREGROUND, 0);
+ fRequest4 = new TmfCoalescedEventRequest(ITmfEvent.class, range2, 0, 200, ExecutionType.FOREGROUND, 0);
- fRequest1c = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
+ fRequest1c = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0);
fRequestCount = fRequest1c.getRequestId() + 1;
}
private TmfCoalescedEventRequest setupTestRequest(final boolean[] flags) {
- TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND) {
+ TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0) {
@Override
public void handleCompleted() {
super.handleCompleted();
@Test
public void testTmfCoalescedEventRequestIndexNbEventsBlocksize() {
- TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
+ TmfCoalescedEventRequest request = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0);
assertEquals("getRequestId", fRequestCount++, request.getRequestId());
assertEquals("getDataType", ITmfEvent.class, request.getDataType());
@Test
public void testIsCompatible() {
- TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND);
+ TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0);
TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range2, 100, 200);
TmfEventRequest req3 = new TmfEventRequestStub(ITmfEvent.class, range1, 101, 200);
assertTrue("isCompatible", coalescedRequest.isCompatible(req3));
}
+ @Test
+ public void testIsCompatibleDependency() {
+ TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 1);
+ TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200, ExecutionType.FOREGROUND, 0);
+ TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range2, 100, 2000, ExecutionType.FOREGROUND, 1);
+ TmfEventRequest req3 = new TmfEventRequestStub(ITmfEvent.class, range1, 101, 200, ExecutionType.FOREGROUND, 2);
+
+ assertFalse("isCompatible", coalescedRequest.isCompatible(req1));
+ assertTrue("isCompatible", coalescedRequest.isCompatible(req2));
+ assertFalse("isCompatible", coalescedRequest.isCompatible(req3));
+
+ coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 100, ExecutionType.FOREGROUND, 0);
+ assertTrue("isCompatible", coalescedRequest.isCompatible(req1));
+ assertFalse("isCompatible", coalescedRequest.isCompatible(req2));
+ assertFalse("isCompatible", coalescedRequest.isCompatible(req3));
+
+ }
+
// ------------------------------------------------------------------------
// addEvent
// ------------------------------------------------------------------------
@Test
public void testAddEvent1() {
- TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 2147483647, ExecutionType.FOREGROUND);
+ TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 0, 2147483647, ExecutionType.FOREGROUND, 0);
TmfEventRequest req1 = new TmfEventRequestStub(ITmfEvent.class, range1, 0, 2147483647, 200);
TmfEventRequest req2 = new TmfEventRequestStub(ITmfEvent.class, range1, 1, 2147483647, 200);
@Test
public void testAddEvent2() {
- TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(ITmfEvent.class, range1, 1, 2147483647, ExecutionType.FOREGROUND);
+ 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);
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
+import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest.ExecutionType;
import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
private static TmfEventRequest fRequest2;
private static TmfEventRequest fRequest3;
private static TmfEventRequest fRequest4;
+ private static TmfEventRequest fRequest5;
// ------------------------------------------------------------------------
// Housekeeping
fRequest2 = new TmfEventRequestStub(ITmfEvent.class, range2, 100, 200);
fRequest3 = new TmfEventRequestStub(ITmfEvent.class, range2, 200, 200);
fRequest4 = new TmfEventRequestStub(ITmfEvent.class, range2, 200, 300);
+ fRequest5 = new TmfEventRequestStub(ITmfEvent.class, range2, 200, 300, ExecutionType.FOREGROUND, 1);
}
private static TmfEventRequest setupTestRequest(final boolean[] flags) {
assertFalse("isCancelled", request.isCancelled());
assertEquals("getNbRead", 0, request.getNbRead());
+ assertEquals("getDependencyLevel", 0, request.getDependencyLevel());
}
@Test
assertFalse("isCancelled", request.isCancelled());
assertEquals("getNbRead", 0, request.getNbRead());
+ assertEquals("getDependencyLevel", 0, request.getDependencyLevel());
}
@Test
assertFalse("isCancelled", request.isCancelled());
assertEquals("getNbRead", 0, request.getNbRead());
+ assertEquals("getDependencyLevel", 0, request.getDependencyLevel());
}
@Test
assertFalse("isCancelled", request.isCancelled());
assertEquals("getNbRead", 0, request.getNbRead());
+ assertEquals("getDependencyLevel", 0, request.getDependencyLevel());
+ }
+
+ @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());
}
// ------------------------------------------------------------------------
assertFalse(fRequest1.equals(fRequest2));
assertFalse(fRequest1.equals(fRequest3));
assertFalse(fRequest1.equals(fRequest4));
+
+ /* Request with different dependency level, but otherwise identical, are not equal */
+ assertFalse(fRequest4.equals(fRequest5));
}
// ------------------------------------------------------------------------
@Test
public void testToString() {
- String expected1 = "[TmfEventRequestStub(" + fRequest1.getRequestId() + ",ITmfEvent,FOREGROUND," + range1 + ",0,100)]";
- String expected2 = "[TmfEventRequestStub(" + fRequest2.getRequestId() + ",ITmfEvent,FOREGROUND," + range2 + ",0,100)]";
- String expected3 = "[TmfEventRequestStub(" + fRequest3.getRequestId() + ",ITmfEvent,FOREGROUND," + range2 + ",0,200)]";
- String expected4 = "[TmfEventRequestStub(" + fRequest4.getRequestId() + ",ITmfEvent,FOREGROUND," + range2 + ",0,200)]";
+ String expected1 = "[TmfEventRequestStub(" + fRequest1.getRequestId() + ",ITmfEvent,FOREGROUND," + range1 + ",0,100,0)]";
+ String expected2 = "[TmfEventRequestStub(" + fRequest2.getRequestId() + ",ITmfEvent,FOREGROUND," + range2 + ",0,100,0)]";
+ String expected3 = "[TmfEventRequestStub(" + fRequest3.getRequestId() + ",ITmfEvent,FOREGROUND," + range2 + ",0,200,0)]";
+ String expected4 = "[TmfEventRequestStub(" + fRequest4.getRequestId() + ",ITmfEvent,FOREGROUND," + range2 + ",0,200,0)]";
+ String expected5 = "[TmfEventRequestStub(" + fRequest5.getRequestId() + ",ITmfEvent,FOREGROUND," + range2 + ",0,200,1)]";
assertEquals("toString", expected1, fRequest1.toString());
assertEquals("toString", expected2, fRequest2.toString());
assertEquals("toString", expected3, fRequest3.toString());
assertEquals("toString", expected4, fRequest4.toString());
+ assertEquals("toString", expected5, fRequest5.toString());
}
// ------------------------------------------------------------------------
super(dataType, range, index, nbRequested, ExecutionType.FOREGROUND);
}
+ /**
+ * @param dataType the event type
+ * @param range the requested time range
+ * @param nbRequested the number of events requested
+ * @param blockSize the event block size
+ * @param type the execution type
+ * @param dependency the dependency
+ */
+ public TmfEventRequestStub(final Class<? extends ITmfEvent> dataType, final TmfTimeRange range, final int nbRequested, final int blockSize, ExecutionType type, int dependency) {
+ super(dataType, range, 0, nbRequested, type, dependency);
+ }
+
@Override
public void handleData(final ITmfEvent data) {
super.handleData(data);
* {@link TmfEventRequest#ALL_DATA} to request all events.
* @param priority
* The requested execution priority
+ * @param dependencyLevel
+ * The dependency level. Use 0 if no dependency with other
+ * requests.
*/
public TmfCoalescedEventRequest(Class<? extends ITmfEvent> dataType,
TmfTimeRange range,
long index,
int nbRequested,
- ExecutionType priority) {
- super(ITmfEvent.class, null, index, nbRequested, priority);
+ ExecutionType priority,
+ int dependencyLevel) {
+ super(ITmfEvent.class, null, index, nbRequested, priority, dependencyLevel);
fRange = range;
if (TmfCoreTracer.isRequestTraced()) {
*/
public boolean isCompatible(ITmfEventRequest request) {
if (request.getExecType() == getExecType() &&
+ request.getDependencyLevel() == getDependencyLevel() &&
ranksOverlap(request) &&
timeRangesOverlap(request)) {
return true;
request.getRange(),
request.getIndex(),
request.getNbRequested(),
- request.getExecType());
+ request.getExecType(),
+ request.getDependencyLevel());
coalescedRequest.addRequest(request);
coalescedRequest.setProviderFilter(this);
if (TmfCoreTracer.isRequestTraced()) {
*/
enum ExecutionType {
/**
- * Backgroung, long-running, lower priority request
+ * Background, long-running, lower priority request.
*/
BACKGROUND,
/**
- * Foreground, short-running, high priority request
+ * Foreground, short-running, high priority request.
*/
- FOREGROUND
+ FOREGROUND,
}
// ------------------------------------------------------------------------
*/
ExecutionType getExecType();
+ /**
+ * Gets the dependency level. Use different dependency level for requests
+ * that have a dependency with each other. They will be serviced separately.
+ *
+ * @return dependency
+ * @since 2.0
+ */
+ default int getDependencyLevel() {
+ return 0;
+ }
+
/**
* @return the index of the first event requested
*/
private ITmfFilter fEventFilter;
+ private int fDependencyLevel;
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
long index,
int nbRequested,
ExecutionType priority) {
+ this(dataType, range, index, nbRequested, priority, 0);
+ }
+
+ /**
+ * Request 'n' events of a given type, for the given time range, at the
+ * given priority.
+ *
+ * @param dataType
+ * The requested data type.
+ * @param range
+ * The time range of the requested events. You can use
+ * {@link TmfTimeRange#ETERNITY} to indicate you want to cover
+ * the whole trace.
+ * @param index
+ * The index of the first event to retrieve. You can use '0' to
+ * start at the beginning of the trace.
+ * @param nbRequested
+ * The number of events requested. You can use
+ * {@link TmfEventRequest#ALL_DATA} to indicate you want all
+ * events in the time range.
+ * @param priority
+ * The requested execution priority.
+ * @param dependencyLevel
+ * The dependency level. Use different dependency level for
+ * requests that have a dependency with each other. They will
+ * be serviced separately.
+ * @since 2.0
+ */
+ public TmfEventRequest(Class<? extends ITmfEvent> dataType,
+ TmfTimeRange range,
+ long index,
+ int nbRequested,
+ ExecutionType priority,
+ int dependencyLevel) {
synchronized (TmfEventRequest.class) {
fRequestId = fRequestNumber++;
fExecType = priority;
fRange = range;
fNbRead = 0;
+ fDependencyLevel = dependencyLevel;
fRequestRunning = false;
fRequestCompleted = false;
+ (getExecType() == ExecutionType.BACKGROUND ? "(BG)" : "(FG)")
+ " Type=" + type + " Index=" + getIndex() + " NbReq=" + getNbRequested()
+ " Range=" + getRange()
- + " DataType=" + getDataType().getSimpleName();
+ + " DataType=" + getDataType().getSimpleName()
+ + " DependencyLevel= " + fDependencyLevel;
TmfCoreTracer.traceRequest(fRequestId, message);
}
}
fEventFilter = provider;
}
+ /** @since 2.0 */
+ @Override
+ public int getDependencyLevel() {
+ return fDependencyLevel;
+ }
+
// ------------------------------------------------------------------------
// Setters
// ------------------------------------------------------------------------
}
return '[' + name + '(' + getRequestId() + ',' + getDataType().getSimpleName() +
',' + getExecType() + ',' + getRange() + ',' + getIndex() +
- ',' + getNbRequested() + ")]"; //$NON-NLS-1$
+ ',' + getNbRequested() + ','+ getDependencyLevel() + ")]"; //$NON-NLS-1$
}
}