use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.
the class TmfCoalescedEventRequestTest method testIsCompatible.
// ------------------------------------------------------------------------
// isCompatible
// ------------------------------------------------------------------------
@Test
public void testIsCompatible() {
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(req1));
assertTrue("isCompatible", coalescedRequest.isCompatible(req2));
assertTrue("isCompatible", coalescedRequest.isCompatible(req3));
}
use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.
the class TmfEventRequestIntegrationTest method testRequestException.
/**
* Test the behavior of multiple coalesced requests when one fails
*
* @throws InterruptedException
* The test timed out
*/
@Test
public void testRequestException() throws InterruptedException {
TmfTrace trace = fTrace;
TmfCoalescedEventRequest allRequests = new TmfCoalescedEventRequest(ITmfEvent.class, TmfTimeRange.ETERNITY, 2, 0, ExecutionType.BACKGROUND, 0);
TmfEventRequest requestOk = new TmfEventRequestStub(ITmfEvent.class, TmfTimeRange.ETERNITY, 2, 0, ExecutionType.BACKGROUND, 0);
requestOk.setProviderFilter(trace);
allRequests.addRequest(requestOk);
TmfEventRequest requestFail = new TmfEventRequestStub(ITmfEvent.class, TmfTimeRange.ETERNITY, 2, 0, ExecutionType.BACKGROUND, 0) {
@Override
public void handleData(@NonNull ITmfEvent data) {
throw new IllegalArgumentException();
}
};
requestFail.setProviderFilter(trace);
allRequests.addRequest(requestFail);
trace.sendRequest(allRequests);
requestOk.waitForCompletion();
requestFail.waitForCompletion();
assertTrue(requestOk.isCompleted());
assertFalse(requestOk.isCancelled());
assertFalse(requestOk.isFailed());
assertTrue(requestFail.isCompleted());
assertFalse(requestFail.isCancelled());
assertTrue(requestFail.isFailed());
}
use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.
the class TmfCoalescedEventRequestTest method testIsCompatibleDependency.
@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));
}
use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.
the class TmfCoalescedEventRequestTest method testCancel.
// ------------------------------------------------------------------------
// cancel
// ------------------------------------------------------------------------
@Test
public void testCancel() {
final boolean[] crFlags = new boolean[4];
TmfCoalescedEventRequest request = setupTestRequest(crFlags);
TmfEventRequest subRequest1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
TmfEventRequest subRequest2 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
request.addRequest(subRequest1);
request.addRequest(subRequest2);
request.cancel();
// Validate the coalescing request
assertTrue("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
assertTrue("isCancelled", request.isCancelled());
assertTrue("handleCompleted", crFlags[0]);
assertFalse("handleSuccess", crFlags[1]);
assertFalse("handleFailure", crFlags[2]);
assertTrue("handleCancel", crFlags[3]);
// Validate the first coalesced request
assertTrue("isCompleted", subRequest1.isCompleted());
assertFalse("isFailed", subRequest1.isFailed());
assertTrue("isCancelled", subRequest1.isCancelled());
// Validate the second coalesced request
assertTrue("isCompleted", subRequest2.isCompleted());
assertFalse("isFailed", subRequest2.isFailed());
assertTrue("isCancelled", subRequest2.isCancelled());
}
use of org.eclipse.tracecompass.tmf.core.request.TmfEventRequest in project tracecompass by tracecompass.
the class TmfExperimentTest method testCancel.
// ------------------------------------------------------------------------
// cancel
// ------------------------------------------------------------------------
@Test
public void testCancel() throws InterruptedException {
final int nbEvents = NB_EVENTS;
final int limit = BLOCK_SIZE;
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) {
int nbRead = 0;
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
if (++nbRead == limit) {
cancel();
}
}
@Override
public void handleCancel() {
if (requestedEvents.size() < limit) {
System.out.println("aie");
}
}
};
fExperiment.sendRequest(request);
request.waitForCompletion();
assertEquals("nbEvents", limit, requestedEvents.size());
assertTrue("isCompleted", request.isCompleted());
assertTrue("isCancelled", request.isCancelled());
}
Aggregations