import java.util.Vector;
import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
-import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal;
public void testGetProviders() {
// There should be 2 TmfEvent providers: a TmfTraceStub and a
// TmfEventProviderStub
- ITmfDataProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class);
+ ITmfEventProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class);
assertEquals("getProviders", 2, eventProviders.length);
eventProviders = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
// Get the TmfSyntheticEventStub provider
- ITmfDataProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class,
+ ITmfEventProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class,
TmfEventProviderStub.class);
- ITmfDataProvider provider = eventProviders[0];
+ ITmfEventProvider provider = eventProviders[0];
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
final Vector<ITmfEvent> requestedEventsReq2 = new Vector<ITmfEvent>();
// Get the TmfSyntheticEventStub provider
- ITmfDataProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class,
+ ITmfEventProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class,
TmfEventProviderStub.class);
- ITmfDataProvider provider = eventProviders[0];
+ ITmfEventProvider provider = eventProviders[0];
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BIG_BANG, TmfTimestamp.BIG_CRUNCH);
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
// Get the event provider
- ITmfDataProvider[] eventProviders = TmfProviderManager
+ ITmfEventProvider[] eventProviders = TmfProviderManager
.getProviders(TmfSyntheticEventStub.class);
- ITmfDataProvider provider = eventProviders[0];
+ ITmfEventProvider provider = eventProviders[0];
final TmfEventRequest request = new TmfEventRequest(TmfSyntheticEventStub.class, range,
0, nbEvents, ExecutionType.FOREGROUND) {
// There should be 2 TmfEvent providers: a TmfTraceStub and a
// TmfEventProviderStub
- ITmfDataProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class);
+ ITmfEventProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class);
assertEquals("getProviders", 2, eventProviders.length);
eventProviders = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
import static org.junit.Assert.assertTrue;
import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
-import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.junit.Test;
// Dummy Providers
// ------------------------------------------------------------------------
- private class TestProvider1 extends TmfDataProvider {
+ private class TestProvider1 extends TmfEventProvider {
public TestProvider1(Class<ITmfEvent> type) {
super("TestProvider1", type);
}
@Override
- public ITmfContext armRequest(ITmfDataRequest request) {
+ public ITmfContext armRequest(ITmfEventRequest request) {
return null;
}
}
@Override
- public boolean isCompleted(ITmfDataRequest request, ITmfEvent data, int nbRead) {
+ public boolean isCompleted(ITmfEventRequest request, ITmfEvent data, int nbRead) {
return false;
}
}
- private class TestProvider2 extends TmfDataProvider {
+ private class TestProvider2 extends TmfEventProvider {
public TestProvider2(Class<ITmfEvent> type) {
super("TestProvider2", type);
}
@Override
- public ITmfContext armRequest(ITmfDataRequest request) {
+ public ITmfContext armRequest(ITmfEventRequest request) {
return null;
}
}
@Override
- public boolean isCompleted(ITmfDataRequest request, ITmfEvent data, int nbRead) {
+ public boolean isCompleted(ITmfEventRequest request, ITmfEvent data, int nbRead) {
return false;
}
}
private class TmfEvent3 extends TmfEvent {
}
- private class TestProvider3 extends TmfDataProvider {
+ private class TestProvider3 extends TmfEventProvider {
public TestProvider3(Class<TmfEvent3> type) {
super("TestProvider3", type);
}
@Override
- public ITmfContext armRequest(ITmfDataRequest request) {
+ public ITmfContext armRequest(ITmfEventRequest request) {
return null;
}
}
@Override
- public boolean isCompleted(ITmfDataRequest request, ITmfEvent data, int nbRead) {
+ public boolean isCompleted(ITmfEventRequest request, ITmfEvent data, int nbRead) {
return false;
}
}
*/
@Test
public void testRegister_0() {
- TmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
+ TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
assertEquals("getProviders", 0, providers.length);
providers = TmfProviderManager.getProviders(ITmfEvent.class, TestProvider1.class);
// Register a single provider
TestProvider1 testProvider1 = new TestProvider1(ITmfEvent.class);
- TmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
+ TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
assertEquals("getProviders", 1, providers.length);
assertEquals("getProviders", testProvider1, providers[0]);
TestProvider1 testProvider1 = new TestProvider1(ITmfEvent.class);
TestProvider2 testProvider2 = new TestProvider2(ITmfEvent.class);
- TmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
+ TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
assertEquals("getProviders", 2, providers.length);
assertTrue(providers.length == 2);
if (providers[0] == testProvider1) {
TestProvider2 testProvider2 = new TestProvider2(ITmfEvent.class);
TestProvider3 testProvider3 = new TestProvider3(TmfEvent3.class);
- TmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
+ TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class);
assertEquals("getProviders", 2, providers.length);
if (providers[0] == testProvider1) {
assertEquals("getProviders", testProvider2, providers[1]);
assertEquals("getProviders", testProvider1, providers[1]);
}
- TmfDataProvider[] providers3 = TmfProviderManager.getProviders(TmfEvent3.class);
+ TmfEventProvider[] providers3 = TmfProviderManager.getProviders(TmfEvent3.class);
assertEquals("getProviders", 1, providers3.length);
assertEquals("getProviders", testProvider3, providers3[0]);
TestProvider2 testProvider2 = new TestProvider2(ITmfEvent.class);
TestProvider3 testProvider3 = new TestProvider3(TmfEvent3.class);
- TmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, null);
+ TmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, null);
assertEquals("getProviders", 2, providers.length);
if (providers[0] == testProvider1) {
assertEquals("getProviders", testProvider2, providers[1]);
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfLostEvent;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
public EventCountRequest() {
super(CtfTmfEvent.class, TmfTimeRange.ETERNITY, 0,
- TmfDataRequest.ALL_DATA, ExecutionType.FOREGROUND);
+ TmfEventRequest.ALL_DATA, ExecutionType.FOREGROUND);
}
@Override
*/
@RunWith(Suite.class)
@Suite.SuiteClasses({
- TmfCoalescedDataRequestTest.class,
TmfCoalescedEventRequestTest.class,
- TmfDataRequestTest.class,
TmfEventRequestTest.class,
TmfSchedulerTest.class
})
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Added tests to check offsets
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.request;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.linuxtools.internal.tmf.core.request.TmfCoalescedDataRequest;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.tests.stubs.request.TmfDataRequestStub;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfCoalescedDataRequest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfCoalescedDataRequestTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private TmfCoalescedDataRequest fRequest1;
- private TmfCoalescedDataRequest fRequest2;
- private TmfCoalescedDataRequest fRequest3;
- private TmfCoalescedDataRequest fRequest4;
-
- private TmfCoalescedDataRequest fRequest1b;
- private TmfCoalescedDataRequest fRequest1c;
-
- private int fRequestCount;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- TmfDataRequest.reset();
- fRequest1 = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
- fRequest2 = new TmfCoalescedDataRequest(ITmfEvent.class, 20, 100, ExecutionType.FOREGROUND);
- fRequest3 = new TmfCoalescedDataRequest(ITmfEvent.class, 20, 200, ExecutionType.FOREGROUND);
- fRequest4 = new TmfCoalescedDataRequest(ITmfEvent.class, 20, 200, ExecutionType.FOREGROUND);
-
- fRequest1b = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
- fRequest1c = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
-
- fRequestCount = fRequest1c.getRequestId() + 1;
- }
-
- private static TmfCoalescedDataRequest setupTestRequest(final boolean[] flags) {
-
- TmfCoalescedDataRequest request = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND) {
- @Override
- public void handleCompleted() {
- super.handleCompleted();
- flags[0] = true;
- }
-
- @Override
- public void handleSuccess() {
- super.handleSuccess();
- flags[1] = true;
- }
-
- @Override
- public void handleFailure() {
- super.handleFailure();
- flags[2] = true;
- }
-
- @Override
- public void handleCancel() {
- super.handleCancel();
- flags[3] = true;
- }
- };
- return request;
- }
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfCoalescedDataRequestIndexNbEventsBlocksize() {
- TmfCoalescedDataRequest request = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getIndex", 10, request.getIndex());
- assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fRequest1.equals(fRequest1));
- assertTrue("equals", fRequest2.equals(fRequest2));
-
- assertFalse("equals", fRequest1.equals(fRequest2));
- assertFalse("equals", fRequest2.equals(fRequest1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- assertTrue("equals", fRequest1.equals(fRequest1b));
- assertTrue("equals", fRequest1b.equals(fRequest1));
-
- assertFalse("equals", fRequest1.equals(fRequest3));
- assertFalse("equals", fRequest2.equals(fRequest3));
- assertFalse("equals", fRequest3.equals(fRequest1));
- assertFalse("equals", fRequest3.equals(fRequest2));
- }
-
- @Test
- public void testEqualsTransivity() {
- assertTrue("equals", fRequest1.equals(fRequest1b));
- assertTrue("equals", fRequest1b.equals(fRequest1c));
- assertTrue("equals", fRequest1.equals(fRequest1c));
- }
-
- @Test
- public void testEqualsNull() {
- assertFalse("equals", fRequest1.equals(null));
- assertFalse("equals", fRequest2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- assertTrue("hashCode", fRequest1.hashCode() == fRequest1.hashCode());
- assertTrue("hashCode", fRequest2.hashCode() == fRequest2.hashCode());
- assertTrue("hashCode", fRequest1.hashCode() != fRequest2.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- String expected1 = "[TmfCoalescedDataRequest(0,ITmfEvent,FOREGROUND,10,100, [])]";
- String expected2 = "[TmfCoalescedDataRequest(1,ITmfEvent,FOREGROUND,20,100, [])]";
- String expected3 = "[TmfCoalescedDataRequest(2,ITmfEvent,FOREGROUND,20,200, [])]";
- String expected4 = "[TmfCoalescedDataRequest(3,ITmfEvent,FOREGROUND,20,200, [])]";
-
- assertEquals("toString", expected1, fRequest1.toString());
- assertEquals("toString", expected2, fRequest2.toString());
- assertEquals("toString", expected3, fRequest3.toString());
- assertEquals("toString", expected4, fRequest4.toString());
- }
-
- // ------------------------------------------------------------------------
- // isCompatible
- // ------------------------------------------------------------------------
-
- @Test
- public void testIsCompatible() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
- TmfDataRequest request1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- TmfDataRequest request2 = new TmfDataRequestStub(ITmfEvent.class, 5, 100);
- TmfDataRequest request3 = new TmfDataRequestStub(ITmfEvent.class, 5, 4);
- TmfDataRequest request4 = new TmfDataRequestStub(ITmfEvent.class, 5, 5);
- TmfDataRequest request5 = new TmfDataRequestStub(ITmfEvent.class, 15, 100);
- TmfDataRequest request6 = new TmfDataRequestStub(ITmfEvent.class, 100, 100);
- TmfDataRequest request7 = new TmfDataRequestStub(ITmfEvent.class, 110, 100);
- TmfDataRequest request8 = new TmfDataRequestStub(ITmfEvent.class, 111, 100);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(request1));
- assertTrue("isCompatible", coalescedRequest.isCompatible(request2));
- assertTrue("isCompatible", coalescedRequest.isCompatible(request3));
- assertTrue("isCompatible", coalescedRequest.isCompatible(request4));
- assertTrue("isCompatible", coalescedRequest.isCompatible(request5));
- assertTrue("isCompatible", coalescedRequest.isCompatible(request6));
- assertTrue("isCompatible", coalescedRequest.isCompatible(request7));
- assertTrue("isCompatible", coalescedRequest.isCompatible(request8));
-
- TmfDataRequest request9 = new TmfDataRequestStub(ITmfEvent.class, 5, 3);
- TmfDataRequest request10 = new TmfDataRequestStub(ITmfEvent.class, 112, 100);
-
- assertFalse("isCompatible", coalescedRequest.isCompatible(request9));
- assertFalse("isCompatible", coalescedRequest.isCompatible(request10));
- }
-
- // ------------------------------------------------------------------------
- // addRequest
- // ------------------------------------------------------------------------
-
- @Test
- public void testAddRequest1() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(request));
- coalescedRequest.addRequest(request);
- assertEquals("addRequest", 10, coalescedRequest.getIndex());
- assertEquals("addRequest", 100, coalescedRequest.getNbRequested());
- }
-
- @Test
- public void testAddRequest2() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 5, 100);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(request));
- coalescedRequest.addRequest(request);
- assertEquals("addRequest", 5, coalescedRequest.getIndex());
- assertEquals("addRequest", 105, coalescedRequest.getNbRequested());
- }
-
- @Test
- public void testAddRequest3() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 5, 4);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(request));
- coalescedRequest.addRequest(request);
- assertEquals("addRequest", 5, coalescedRequest.getIndex());
- assertEquals("addRequest", 105, coalescedRequest.getNbRequested());
- }
-
- @Test
- public void testAddRequest4() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 5, 5);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(request));
- coalescedRequest.addRequest(request);
- assertEquals("addRequest", 5, coalescedRequest.getIndex());
- assertEquals("addRequest", 105, coalescedRequest.getNbRequested());
- }
-
- @Test
- public void testAddRequest5() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 15, 100);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(request));
- coalescedRequest.addRequest(request);
- assertEquals("addRequest", 10, coalescedRequest.getIndex());
- assertEquals("addRequest", 105, coalescedRequest.getNbRequested());
- }
-
- @Test
- public void testAddRequest6() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 100, 100);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(request));
- coalescedRequest.addRequest(request);
- assertEquals("addRequest", 10, coalescedRequest.getIndex());
- assertEquals("addRequest", 190, coalescedRequest.getNbRequested());
- }
-
- @Test
- public void testAddRequest7() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 110, 100);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(request));
- coalescedRequest.addRequest(request);
- assertEquals("addRequest", 10, coalescedRequest.getIndex());
- assertEquals("addRequest", 200, coalescedRequest.getNbRequested());
- }
-
- @Test
- public void testAddRequest8() {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(ITmfEvent.class, 10, 100, ExecutionType.FOREGROUND);
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 111, 100);
-
- assertTrue("isCompatible", coalescedRequest.isCompatible(request));
- coalescedRequest.addRequest(request);
- assertEquals("addRequest", 10, coalescedRequest.getIndex());
- assertEquals("addRequest", 201, coalescedRequest.getNbRequested());
- }
-
- // ------------------------------------------------------------------------
- // done
- // ------------------------------------------------------------------------
-
- @Test
- public void testDone() {
- // Test request
- final boolean[] crFlags = new boolean[4];
- TmfCoalescedDataRequest request = setupTestRequest(crFlags);
- TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- request.addRequest(subRequest1);
- request.addRequest(subRequest2);
-
- request.done();
-
- // Validate the coalescing request
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertTrue("handleCompleted", crFlags[0]);
- assertTrue("handleSuccess", crFlags[1]);
- assertFalse("handleFailure", crFlags[2]);
- assertFalse("handleCancel", crFlags[3]);
-
- // Validate the first coalesced request
- assertTrue("isCompleted", subRequest1.isCompleted());
- assertFalse("isFailed", subRequest1.isFailed());
- assertFalse("isCancelled", subRequest1.isCancelled());
-
- // Validate the second coalesced request
- assertTrue("isCompleted", subRequest2.isCompleted());
- assertFalse("isFailed", subRequest2.isFailed());
- assertFalse("isCancelled", subRequest2.isCancelled());
- }
-
- // ------------------------------------------------------------------------
- // fail
- // ------------------------------------------------------------------------
-
- @Test
- public void testFail() {
- final boolean[] crFlags = new boolean[4];
- TmfCoalescedDataRequest request = setupTestRequest(crFlags);
- TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- request.addRequest(subRequest1);
- request.addRequest(subRequest2);
-
- request.fail();
-
- // Validate the coalescing request
- assertTrue("isCompleted", request.isCompleted());
- assertTrue("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertTrue("handleCompleted", crFlags[0]);
- assertFalse("handleSuccess", crFlags[1]);
- assertTrue("handleFailure", crFlags[2]);
- assertFalse("handleCancel", crFlags[3]);
-
- // Validate the first coalesced request
- assertTrue("isCompleted", subRequest1.isCompleted());
- assertTrue("isFailed", subRequest1.isFailed());
- assertFalse("isCancelled", subRequest1.isCancelled());
-
- // Validate the second coalesced request
- assertTrue("isCompleted", subRequest2.isCompleted());
- assertTrue("isFailed", subRequest2.isFailed());
- assertFalse("isCancelled", subRequest2.isCancelled());
- }
-
- // ------------------------------------------------------------------------
- // cancel
- // ------------------------------------------------------------------------
-
- @Test
- public void testCancel() {
- final boolean[] crFlags = new boolean[4];
- TmfCoalescedDataRequest request = setupTestRequest(crFlags);
- TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- 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());
- }
-
- // ------------------------------------------------------------------------
- // cancel sub-requests
- // ------------------------------------------------------------------------
-
- @Test
- public void testCancelSubRequests() {
- final boolean[] crFlags = new boolean[4];
- TmfCoalescedDataRequest request = setupTestRequest(crFlags);
- TmfDataRequest subRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- TmfDataRequest subRequest2 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- request.addRequest(subRequest1);
- request.addRequest(subRequest2);
-
- subRequest1.cancel();
-
- // Validate the first coalesced request
- assertTrue ("isCompleted", subRequest1.isCompleted());
- assertFalse("isFailed", subRequest1.isFailed());
- assertTrue ("isCancelled", subRequest1.isCancelled());
-
- // Validate the coalescing request
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- // Cancel second sub-request
- subRequest2.cancel();
-
- // Validate the second coalesced request
- assertTrue ("isCompleted", subRequest2.isCompleted());
- assertFalse("isFailed", subRequest2.isFailed());
- assertTrue("isCancelled", subRequest2.isCancelled());
-
- // Validate the coalescing request
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertTrue("isCancelled", request.isCancelled());
-
- // Finalize coalescing request -
- // Note: No need to check "request.isCancelled()" since it was verified
- // above
- request.cancel();
-
- assertTrue("handleCompleted", crFlags[0]);
- assertFalse("handleSuccess", crFlags[1]);
- assertFalse("handleFailure", crFlags[2]);
- assertTrue("handleCancel", crFlags[3]);
- }
-
-}
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
-import org.eclipse.linuxtools.internal.tmf.core.request.TmfCoalescedDataRequest;
import org.eclipse.linuxtools.internal.tmf.core.request.TmfCoalescedEventRequest;
-import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
@Before
public void setUp() {
- TmfDataRequest.reset();
+ TmfEventRequest.reset();
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);
assertFalse("equals", fRequest2.equals(null));
}
- @Test
- public void testEqualsSuper() {
- TmfCoalescedDataRequest dataRequest1 = new TmfCoalescedDataRequest(
- fRequest1.getDataType(),
- fRequest1.getIndex(),
- fRequest1.getNbRequested(),
- ExecutionType.FOREGROUND);
- TmfCoalescedDataRequest dataRequest2 = new TmfCoalescedDataRequest(
- fRequest1.getDataType(),
- fRequest1.getIndex(),
- fRequest1.getNbRequested(),
- ExecutionType.FOREGROUND);
- TmfCoalescedDataRequest dataRequest3 = new TmfCoalescedDataRequest(
- fRequest3.getDataType(),
- fRequest3.getIndex(),
- fRequest3.getNbRequested(),
- ExecutionType.FOREGROUND);
-
- assertTrue("equals", fRequest1.equals(dataRequest2));
- assertTrue("equals", fRequest2.equals(dataRequest1));
- assertFalse("equals", fRequest1.equals(dataRequest3));
- assertFalse("equals", fRequest3.equals(dataRequest1));
- }
-
// ------------------------------------------------------------------------
// hashCode
// ------------------------------------------------------------------------
TmfEventRequest request2;
TmfEventRequest request3;
- ITmfDataProvider[] providers;
+ ITmfEventProvider[] providers;
private static class TmfTestTriggerSignal extends TmfSignal {
public final boolean forceCancel;
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Alexandre Montplaisir - Port to JUnit4
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.tests.request;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
-import org.eclipse.linuxtools.tmf.tests.stubs.request.TmfDataRequestStub;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test suite for the TmfDataRequest class.
- */
-@SuppressWarnings("javadoc")
-public class TmfDataRequestTest {
-
- // ------------------------------------------------------------------------
- // Variables
- // ------------------------------------------------------------------------
-
- private static TmfDataRequest fRequest1;
- private static TmfDataRequest fRequest1b;
- private static TmfDataRequest fRequest1c;
- private static TmfDataRequest fRequest2;
- private static TmfDataRequest fRequest3;
- private static TmfDataRequest fRequest4;
-
- private static int fRequestCount;
-
- // ------------------------------------------------------------------------
- // Housekeeping
- // ------------------------------------------------------------------------
-
- @Before
- public void setUp() {
- TmfDataRequest.reset();
- fRequest1 = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- fRequest2 = new TmfDataRequestStub(ITmfEvent.class, 20, 100);
- fRequest3 = new TmfDataRequestStub(ITmfEvent.class, 20, 200);
- fRequest4 = new TmfDataRequestStub(ITmfEvent.class, 20, 200);
- fRequest1b = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- fRequest1c = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
- fRequestCount = fRequest1c.getRequestId() + 1;
- }
-
- private static TmfDataRequest setupTestRequest(final boolean[] flags) {
-
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 10, 100) {
- @Override
- public void handleCompleted() {
- super.handleCompleted();
- flags[0] = true;
- }
-
- @Override
- public void handleSuccess() {
- super.handleSuccess();
- flags[1] = true;
- }
-
- @Override
- public void handleFailure() {
- super.handleFailure();
- flags[2] = true;
- }
-
- @Override
- public void handleCancel() {
- super.handleCancel();
- flags[3] = true;
- }
- };
- return request;
- }
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- @Test
- public void testTmfDataRequest() {
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getIndex", 0, request.getIndex());
- assertEquals("getNbRequestedEvents", TmfDataRequest.ALL_DATA, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- @Test
- public void testTmfDataRequestIndex() {
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 10);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getIndex", 10, request.getIndex());
- assertEquals("getNbRequestedEvents", TmfDataRequest.ALL_DATA, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- @Test
- public void testTmfDataRequestIndexNbRequested() {
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getIndex", 10, request.getIndex());
- assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- @Test
- public void testTmfDataRequestIndexNbEventsBlocksize() {
- TmfDataRequest request = new TmfDataRequestStub(ITmfEvent.class, 10, 100);
-
- assertEquals("getRequestId", fRequestCount++, request.getRequestId());
- assertEquals("getDataType", ITmfEvent.class, request.getDataType());
-
- assertEquals("getIndex", 10, request.getIndex());
- assertEquals("getNbRequestedEvents", 100, request.getNbRequested());
-
- assertFalse("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertEquals("getNbRead", 0, request.getNbRead());
- }
-
- // ------------------------------------------------------------------------
- // equals
- // ------------------------------------------------------------------------
-
- @Test
- public void testEqualsReflexivity() {
- assertTrue("equals", fRequest1.equals(fRequest1));
- assertTrue("equals", fRequest2.equals(fRequest2));
-
- assertFalse("equals", fRequest1.equals(fRequest2));
- assertFalse("equals", fRequest2.equals(fRequest1));
- }
-
- @Test
- public void testEqualsSymmetry() {
- assertTrue("equals", fRequest1.equals(fRequest1b));
- assertTrue("equals", fRequest1b.equals(fRequest1));
-
- assertFalse("equals", fRequest1.equals(fRequest3));
- assertFalse("equals", fRequest2.equals(fRequest3));
- assertFalse("equals", fRequest3.equals(fRequest1));
- assertFalse("equals", fRequest3.equals(fRequest2));
- }
-
- @Test
- public void testEqualsTransivity() {
- assertTrue("equals", fRequest1.equals(fRequest1b));
- assertTrue("equals", fRequest1b.equals(fRequest1c));
- assertTrue("equals", fRequest1.equals(fRequest1c));
- }
-
- @Test
- public void testEqualsNull() {
- assertFalse("equals", fRequest1.equals(null));
- assertFalse("equals", fRequest2.equals(null));
- }
-
- // ------------------------------------------------------------------------
- // hashCode
- // ------------------------------------------------------------------------
-
- @Test
- public void testHashCode() {
- assertTrue("hashCode", fRequest1.hashCode() == fRequest1.hashCode());
- assertTrue("hashCode", fRequest2.hashCode() == fRequest2.hashCode());
- assertTrue("hashCode", fRequest1.hashCode() != fRequest2.hashCode());
- }
-
- // ------------------------------------------------------------------------
- // toString
- // ------------------------------------------------------------------------
-
- @Test
- public void testToString() {
- String expected1 = "[TmfDataRequestStub(0,ITmfEvent,FOREGROUND,10,100)]";
- String expected2 = "[TmfDataRequestStub(1,ITmfEvent,FOREGROUND,20,100)]";
- String expected3 = "[TmfDataRequestStub(2,ITmfEvent,FOREGROUND,20,200)]";
- String expected4 = "[TmfDataRequestStub(3,ITmfEvent,FOREGROUND,20,200)]";
-
- assertEquals("toString", expected1, fRequest1.toString());
- assertEquals("toString", expected2, fRequest2.toString());
- assertEquals("toString", expected3, fRequest3.toString());
- assertEquals("toString", expected4, fRequest4.toString());
- }
-
- // ------------------------------------------------------------------------
- // done
- // ------------------------------------------------------------------------
-
- @Test
- public void testDone() {
- final boolean[] flags = new boolean[4];
- TmfDataRequest request = setupTestRequest(flags);
- request.done();
-
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertTrue("handleCompleted", flags[0]);
- assertTrue("handleSuccess", flags[1]);
- assertFalse("handleFailure", flags[2]);
- assertFalse("handleCancel", flags[3]);
- }
-
- // ------------------------------------------------------------------------
- // fail
- // ------------------------------------------------------------------------
-
- @Test
- public void testFail() {
- final boolean[] flags = new boolean[4];
- TmfDataRequest request = setupTestRequest(flags);
- request.fail();
-
- assertTrue("isCompleted", request.isCompleted());
- assertTrue("isFailed", request.isFailed());
- assertFalse("isCancelled", request.isCancelled());
-
- assertTrue("handleCompleted", flags[0]);
- assertFalse("handleSuccess", flags[1]);
- assertTrue("handleFailure", flags[2]);
- assertFalse("handleCancel", flags[3]);
- }
-
- // ------------------------------------------------------------------------
- // cancel
- // ------------------------------------------------------------------------
-
- @Test
- public void testCancel() {
- final boolean[] flags = new boolean[4];
- TmfDataRequest request = setupTestRequest(flags);
- request.cancel();
-
- assertTrue("isCompleted", request.isCompleted());
- assertFalse("isFailed", request.isFailed());
- assertTrue("isCancelled", request.isCancelled());
-
- assertTrue("handleCompleted", flags[0]);
- assertFalse("handleSuccess", flags[1]);
- assertFalse("handleFailure", flags[2]);
- assertTrue("handleCancel", flags[3]);
- }
-
-}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
@Before
public void setUp() {
- TmfDataRequest.reset();
+ TmfEventRequest.reset();
fRequest1 = new TmfEventRequestStub(ITmfEvent.class, range1, 100, 200);
fRequest2 = new TmfEventRequestStub(ITmfEvent.class, range2, 100, 200);
fRequest3 = new TmfEventRequestStub(ITmfEvent.class, range2, 200, 200);
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", TmfDataRequest.ALL_DATA, request.getNbRequested());
+ assertEquals("getNbRequestedEvents", TmfEventRequest.ALL_DATA, request.getNbRequested());
assertFalse("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
assertEquals("EndTime", TmfTimestamp.BIG_CRUNCH, request.getRange().getEndTime());
assertEquals("getIndex", 0, request.getIndex());
- assertEquals("getNbRequestedEvents", TmfDataRequest.ALL_DATA, request.getNbRequested());
+ assertEquals("getNbRequestedEvents", TmfEventRequest.ALL_DATA, request.getNbRequested());
assertFalse("isCompleted", request.isCompleted());
assertFalse("isFailed", request.isFailed());
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
super(trace.getEventType(),
timeRange,
0,
- TmfDataRequest.ALL_DATA,
+ TmfEventRequest.ALL_DATA,
ExecutionType.BACKGROUND);
startTime = System.nanoTime();
}
super(trace.getEventType(),
timeRange,
0,
- TmfDataRequest.ALL_DATA,
+ TmfEventRequest.ALL_DATA,
ExecutionType.FOREGROUND);
startTime = System.nanoTime();
}
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTrace;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
import org.eclipse.linuxtools.tmf.core.tests.shared.CtfTmfTestTrace;
super(fixture.getEventType(),
timeRange,
0,
- TmfDataRequest.ALL_DATA,
+ TmfEventRequest.ALL_DATA,
ExecutionType.BACKGROUND);
backgroundName = getExecType().toString() + ++fBackgroundId;
}
super(fixture.getEventType(),
timeRange,
0,
- TmfDataRequest.ALL_DATA,
+ TmfEventRequest.ALL_DATA,
ExecutionType.FOREGROUND);
foregroundName = getExecType().toString() + ++fForegroundId;
}
import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.statistics.ITmfStatistics;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
@Test
public void testProcessRequestForAllEvents() throws InterruptedException {
- final int nbEvents = TmfDataRequest.ALL_DATA;
+ final int nbEvents = TmfEventRequest.ALL_DATA;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final long nbExpectedEvents = NB_EVENTS;
import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentContext;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
@Test
public void testProcessRequestForAllEvents() throws InterruptedException {
- final int nbEvents = TmfDataRequest.ALL_DATA;
+ final int nbEvents = TmfEventRequest.ALL_DATA;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
final long nbExpectedEvents = NB_EVENTS;
import org.eclipse.core.runtime.Path;
import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
-import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
requestedEvents.add(event);
}
};
- final ITmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
+ final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
requestedEvents.add(event);
}
};
- final ITmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
+ final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
requestedEvents.add(event);
}
};
- final ITmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
+ final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
requestedEvents.add(event);
}
};
- final ITmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
+ final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
final int nbEvents = 1000;
final Vector<ITmfEvent> requestedEvents = new Vector<ITmfEvent>();
- final TmfDataRequest request = new TmfDataRequest(ITmfEvent.class,
+ final TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ TmfTimeRange.ETERNITY,
startIndex,
nbEvents,
- TmfDataRequest.ExecutionType.FOREGROUND) {
+ TmfEventRequest.ExecutionType.FOREGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
requestedEvents.add(event);
}
};
- final ITmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
+ final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
}
}
};
- final ITmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
+ final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
providers[0].sendRequest(request);
request.waitForCompletion();
import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
-import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
import org.eclipse.linuxtools.tmf.tests.stubs.event.TmfSyntheticEventStub;
/**
@SuppressWarnings("javadoc")
public class TmfClientStub extends TmfComponent {
- private TmfDataProvider[] fProviders;
+ private TmfEventProvider[] fProviders;
public TmfClientStub() {
super("TmfClientStub");
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.tests.stubs.component;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-import org.eclipse.linuxtools.tmf.tests.stubs.trace.TmfTraceStub;
-
-/**
- * <b><u>TmfDataProviderStub</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-@SuppressWarnings("javadoc")
-public class TmfDataProviderStub extends TmfDataProvider {
-
- private static final String DIRECTORY = "testfiles";
- private static final String TEST_STREAM = "M-Test-10K";
-
- private TmfTraceStub fTrace;
-
- public TmfDataProviderStub(final String path) throws IOException {
- super("TmfDataProviderStub", ITmfEvent.class);
- final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
- try {
- final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TmfTraceStub(test.getPath(), 0, true, null);
- } catch (final TmfTraceException e) {
- e.printStackTrace();
- } catch (final URISyntaxException e) {
- e.printStackTrace();
- }
- }
-
- public TmfDataProviderStub() throws IOException {
- this(DIRECTORY + File.separator + TEST_STREAM);
- }
-
- // ------------------------------------------------------------------------
- // TmfProvider
- // ------------------------------------------------------------------------
-
- @Override
- public ITmfContext armRequest(final ITmfDataRequest request) {
- if (request instanceof ITmfEventRequest) {
- final ITmfContext context = fTrace.seekEvent(((ITmfEventRequest) request).getRange().getStartTime());
- return context;
- }
- return null;
- }
-
- @Override
- public ITmfEvent getNext(final ITmfContext context) {
- return fTrace.getNext(context);
- }
-
- @Override
- public boolean isCompleted(final ITmfDataRequest request, final ITmfEvent data, final int nbRead) {
- return false;
- }
-
-}
import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.tests.TmfCoreTestPlugin;
import org.eclipse.linuxtools.tmf.core.tests.shared.TmfTestTrace;
// ------------------------------------------------------------------------
@Override
- public ITmfContext armRequest(final ITmfDataRequest request) {
- if (request instanceof ITmfEventRequest) {
- final ITmfContext context = fTrace.seekEvent(((ITmfEventRequest) request).getRange().getStartTime());
- return context;
- }
- return null;
+ public ITmfContext armRequest(final ITmfEventRequest request) {
+ final ITmfContext context = fTrace.seekEvent(request.getRange().getStartTime());
+ return context;
}
@Override
import java.util.concurrent.TimeUnit;
import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
-import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
}
@Override
- public ITmfContext armRequest(final ITmfDataRequest request) {
+ public ITmfContext armRequest(final ITmfEventRequest request) {
// Get the TmfSyntheticEventStub provider
- final ITmfDataProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class, TmfEventProviderStub.class);
- final ITmfDataProvider provider = eventProviders[0];
+ final ITmfEventProvider[] eventProviders = TmfProviderManager.getProviders(ITmfEvent.class, TmfEventProviderStub.class);
+ final ITmfEventProvider provider = eventProviders[0];
- // make sure we have the right type of request
- if (!(request instanceof ITmfEventRequest)) {
- request.cancel();
- return null;
- }
-
- final TmfEventRequest eventRequest = (TmfEventRequest) request;
- final TmfTimeRange range = eventRequest.getRange();
+ final TmfTimeRange range = request.getRange();
final TmfEventRequest subRequest =
new TmfEventRequest(ITmfEvent.class, range, 0, NB_EVENTS, ExecutionType.FOREGROUND) {
@Override
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.tests.stubs.request;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
-
-/**
- *
- */
-public class TmfDataRequestStub extends TmfDataRequest {
-
- /**
- * Default constructor
- *
- * @param dataType the request data type
- */
- public TmfDataRequestStub(final Class<? extends ITmfEvent> dataType) {
- super(dataType, 0, ALL_DATA, ExecutionType.FOREGROUND);
- }
-
- /**
- * @param dataType the request data type
- * @param index the initial event index
- */
- public TmfDataRequestStub(final Class<? extends ITmfEvent> dataType, final int index) {
- super(dataType, index, ALL_DATA, ExecutionType.FOREGROUND);
- }
-
- /**
- * @param dataType the request data type
- * @param index the initial event index
- * @param nbRequested the number of events requested
- */
- public TmfDataRequestStub(final Class<? extends ITmfEvent> dataType,
- final int index, final int nbRequested) {
- super(dataType, index, nbRequested, ExecutionType.FOREGROUND);
- }
-
- @Override
- public void handleData(final ITmfEvent data) {
- super.handleData(data);
- }
-
-}
import org.eclipse.core.runtime.Platform;
import org.eclipse.linuxtools.tmf.core.component.ITmfComponent;
-import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
/**
}
@SuppressWarnings("javadoc")
- public static void traceRequest(ITmfDataRequest request, String msg) {
+ public static void traceRequest(ITmfEventRequest request, String msg) {
if (REQUEST_CLASS_ENABLED) {
String message = ("[REQ] Req=" + request.getRequestId() + " " + msg);
trace(message);
}
@SuppressWarnings("javadoc")
- public static void traceEvent(ITmfDataProvider provider, ITmfDataRequest request, ITmfEvent event) {
+ public static void traceEvent(ITmfEventProvider provider, ITmfEventRequest request, ITmfEvent event) {
if (EVENT_CLASS_ENABLED) {
String message = ("[EVT] Provider=" + provider.toString()
+ ", Req=" + request.getRequestId() + ", Event=" + event.getTimestamp());
import org.eclipse.linuxtools.internal.tmf.core.Activator;
import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
-import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
-import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
+import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
/**
/**
* The event provider
*/
- private final TmfDataProvider fProvider;
+ private final TmfEventProvider fProvider;
/**
* The wrapped event request
*/
- private final ITmfDataRequest fRequest;
+ private final ITmfEventRequest fRequest;
/**
* The request execution priority
* @param provider the event provider
* @param request the request to process
*/
- public TmfEventThread(TmfDataProvider provider, ITmfDataRequest request) {
+ public TmfEventThread(TmfEventProvider provider, ITmfEventRequest request) {
assert provider != null;
assert request != null;
fProvider = provider;
/**
* @return The event provider
*/
- public ITmfDataProvider getProvider() {
+ public ITmfEventProvider getProvider() {
return fProvider;
}
/**
* @return The event request
*/
- public ITmfDataRequest getRequest() {
+ public ITmfEventRequest getRequest() {
return fRequest;
}
import java.util.List;
import java.util.Map;
-import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
/**
*/
public class TmfProviderManager {
- // ------------------------------------------------------------------------
- // No constructor
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+ // No constructor
+ // ------------------------------------------------------------------------
- private TmfProviderManager() {}
+ private TmfProviderManager() {
+ }
- // ------------------------------------------------------------------------
- // Keeps track of the providers for each event type
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+ // Keeps track of the providers for each event type
+ // ------------------------------------------------------------------------
- private static Map<Class<? extends ITmfEvent>, List<TmfDataProvider>> fProviders =
- new HashMap<Class<? extends ITmfEvent>, List<TmfDataProvider>>();
+ private static Map<Class<? extends ITmfEvent>, List<TmfEventProvider>> fProviders =
+ new HashMap<Class<? extends ITmfEvent>, List<TmfEventProvider>>();
- /**
- * Registers [provider] as a provider of [eventType]
- *
- * @param eventType The event type
- * @param provider The data provider
- */
- public static <T extends ITmfEvent> void register(Class<T> eventType, TmfDataProvider provider) {
- if (fProviders.get(eventType) == null) {
- fProviders.put(eventType, new ArrayList<TmfDataProvider>());
+ /**
+ * Registers [provider] as a provider of [eventType]
+ *
+ * @param eventType
+ * The event type
+ * @param provider
+ * The data provider
+ */
+ public static <T extends ITmfEvent> void register(Class<T> eventType, TmfEventProvider provider) {
+ if (fProviders.get(eventType) == null) {
+ fProviders.put(eventType, new ArrayList<TmfEventProvider>());
}
- fProviders.get(eventType).add(provider);
- }
+ fProviders.get(eventType).add(provider);
+ }
- /**
- * Re-registers [provider] as a provider of [eventType]
- *
- * @param eventType The event type
- * @param provider The data provider
- */
- public static <T extends ITmfEvent> void deregister(Class<T> eventType, TmfDataProvider provider) {
- List<TmfDataProvider> list = fProviders.get(eventType);
- if (list != null) {
- list.remove(provider);
- if (list.size() == 0) {
+ /**
+ * Re-registers [provider] as a provider of [eventType]
+ *
+ * @param eventType
+ * The event type
+ * @param provider
+ * The data provider
+ */
+ public static <T extends ITmfEvent> void deregister(Class<T> eventType, TmfEventProvider provider) {
+ List<TmfEventProvider> list = fProviders.get(eventType);
+ if (list != null) {
+ list.remove(provider);
+ if (list.size() == 0) {
fProviders.remove(eventType);
}
- }
- }
+ }
+ }
- /**
- * Returns the list of components that provide [eventType]
- *
- * @param eventType The event type
- * @return the list of components that provide [eventType]
- */
- public static TmfDataProvider[] getProviders(Class<? extends ITmfEvent> eventType) {
- List<TmfDataProvider> list = fProviders.get(eventType);
- if (list == null) {
- list = new ArrayList<TmfDataProvider>();
+ /**
+ * Returns the list of components that provide [eventType]
+ *
+ * @param eventType
+ * The event type
+ * @return the list of components that provide [eventType]
+ */
+ public static TmfEventProvider[] getProviders(Class<? extends ITmfEvent> eventType) {
+ List<TmfEventProvider> list = fProviders.get(eventType);
+ if (list == null) {
+ list = new ArrayList<TmfEventProvider>();
}
- TmfDataProvider[] result = new TmfDataProvider[list.size()];
- return list.toArray(result);
- }
+ TmfEventProvider[] result = new TmfEventProvider[list.size()];
+ return list.toArray(result);
+ }
- /**
- * Returns the list of components of type [providerType] that provide [eventType]
- *
- * @param eventType The event type
- * @param providerType The data provider
- * @return the list of components of type [providerType] that provide [eventType]
- */
- public static TmfDataProvider[] getProviders(Class<? extends ITmfEvent> eventType, Class<? extends TmfDataProvider> providerType) {
- if (providerType == null) {
- return getProviders(eventType);
- }
- TmfDataProvider[] list = getProviders(eventType);
- List<TmfDataProvider> result = new ArrayList<TmfDataProvider>();
- if (list != null) {
- for (TmfDataProvider provider : list) {
- if (provider.getClass() == providerType) {
- result.add(provider);
- }
- }
- }
- TmfDataProvider[] array = new TmfDataProvider[result.size()];
- return result.toArray(array);
- }
+ /**
+ * Returns the list of components of type [providerType] that provide
+ * [eventType]
+ *
+ * @param eventType
+ * The event type
+ * @param providerType
+ * The data provider
+ * @return the list of components of type [providerType] that provide
+ * [eventType]
+ */
+ public static TmfEventProvider[] getProviders(Class<? extends ITmfEvent> eventType, Class<? extends TmfEventProvider> providerType) {
+ if (providerType == null) {
+ return getProviders(eventType);
+ }
+ TmfEventProvider[] list = getProviders(eventType);
+ List<TmfEventProvider> result = new ArrayList<TmfEventProvider>();
+ if (list != null) {
+ for (TmfEventProvider provider : list) {
+ if (provider.getClass() == providerType) {
+ result.add(provider);
+ }
+ }
+ }
+ TmfEventProvider[] array = new TmfEventProvider[result.size()];
+ return result.toArray(array);
+ }
}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.internal.tmf.core.request;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
-
-/**
- * The TMF coalesced data request
- *
- * @version 1.0
- * @author Francois Chouinard
- */
-public class TmfCoalescedDataRequest extends TmfDataRequest {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /**
- * The list of coalesced requests
- */
- protected final List<ITmfDataRequest> fRequests = new ArrayList<ITmfDataRequest>();
-
- // ------------------------------------------------------------------------
- // Constructor
- // ------------------------------------------------------------------------
-
- /**
- * Request 'n' events of a given type from the given index (given priority).
- * Events are returned in blocks of the given size.
- *
- * @param dataType
- * The requested data type
- * @param index
- * The index of the first event to retrieve. Use '0' to start at
- * the beginning.
- * @param nbRequested
- * The number of events requested. You can use
- * {@link TmfDataRequest#ALL_DATA} to request all events.
- * @param priority
- * The requested execution priority
- */
- public TmfCoalescedDataRequest(Class<? extends ITmfEvent> dataType,
- long index,
- int nbRequested,
- ExecutionType priority) {
- super(ITmfEvent.class, index, nbRequested, priority);
- }
-
- // ------------------------------------------------------------------------
- // Management
- // ------------------------------------------------------------------------
-
- /**
- * Add a request to this one.
- *
- * @param request
- * The request to add
- */
- public void addRequest(ITmfDataRequest request) {
- fRequests.add(request);
- merge(request);
- }
-
- /**
- * Check if a request is compatible with the current coalesced one
- *
- * @param request
- * The request to verify
- * @return If the request is compatible, true or false
- */
- public boolean isCompatible(ITmfDataRequest request) {
- if (request.getExecType() == getExecType()) {
- return overlaps(request);
- }
- return false;
- }
-
- private boolean overlaps(ITmfDataRequest request) {
- long start = request.getIndex();
- long end = start + request.getNbRequested();
-
- // Return true if either the start or end index falls within
- // the coalesced request boundaries
- return (start <= (fIndex + fNbRequested + 1) && (end >= fIndex - 1));
- }
-
- private void merge(ITmfDataRequest request) {
- long start = request.getIndex();
- long end = Math.min(start + request.getNbRequested(), TmfDataRequest.ALL_DATA);
-
- if (start < fIndex) {
- if (fNbRequested != TmfDataRequest.ALL_DATA) {
- fNbRequested += (fIndex - start);
- }
- fIndex = start;
- }
- if ((request.getNbRequested() == TmfDataRequest.ALL_DATA) ||
- (fNbRequested == TmfDataRequest.ALL_DATA))
- {
- fNbRequested = TmfDataRequest.ALL_DATA;
- } else {
- fNbRequested = (int) Math.max(end - fIndex, fNbRequested);
- }
- }
-
- /**
- * @return The list of IDs of the sub-requests
- */
- @SuppressWarnings("nls")
- public String getSubRequestIds() {
- StringBuffer result = new StringBuffer("[");
- for (int i = 0; i < fRequests.size(); i++) {
- if (i != 0) {
- result.append(", ");
- }
- result.append(fRequests.get(i).getRequestId());
- }
- result.append("]");
- return result.toString();
- }
-
- // ------------------------------------------------------------------------
- // ITmfDataRequest
- // ------------------------------------------------------------------------
-
- @Override
- public void handleData(ITmfEvent data) {
- super.handleData(data);
- // Don't call sub-requests handleData() unless this is a
- // TmfCoalescedDataRequest; extended classes should call
- // the sub-requests handleData().
- if (getClass() == TmfCoalescedDataRequest.class) {
- long index = getIndex() + getNbRead() - 1;
- for (ITmfDataRequest request : fRequests) {
- if (!request.isCompleted()) {
- if (request.getDataType().isInstance(data)) {
- long start = request.getIndex();
- long end = start + request.getNbRequested();
- if (index >= start && index < end) {
- request.handleData(data);
- }
- }
- }
- }
- }
- }
-
- @Override
- public void start() {
- for (ITmfDataRequest request : fRequests) {
- if (!request.isCompleted()) {
- request.start();
- }
- }
- super.start();
- }
-
- @Override
- public void done() {
- for (ITmfDataRequest request : fRequests) {
- if (!request.isCompleted()) {
- request.done();
- }
- }
- super.done();
- }
-
- @Override
- public void fail() {
- for (ITmfDataRequest request : fRequests) {
- request.fail();
- }
- super.fail();
- }
-
- @Override
- public void cancel() {
- for (ITmfDataRequest request : fRequests) {
- if (!request.isCompleted()) {
- request.cancel();
- }
- }
- super.cancel();
- }
-
- @Override
- public synchronized boolean isCompleted() {
- // Firstly, check if coalescing request is completed
- if (super.isCompleted()) {
- return true;
- }
-
- // Secondly, check if all sub-requests are finished
- if (fRequests.size() > 0) {
- // If all sub requests are completed the coalesced request is
- // treated as completed, too.
- for (ITmfDataRequest request : fRequests) {
- if (!request.isCompleted()) {
- return false;
- }
- }
- return true;
- }
-
- // Coalescing request is not finished if there are no sub-requests
- return false;
- }
-
- @Override
- public synchronized boolean isCancelled() {
- // Firstly, check if coalescing request is canceled
- if (super.isCancelled()) {
- return true;
- }
-
- // Secondly, check if all sub-requests are canceled
- if (fRequests.size() > 0) {
- // If all sub requests are canceled the coalesced request is
- // treated as completed, too.
- for (ITmfDataRequest request : fRequests) {
- if (!request.isCancelled()) {
- return false;
- }
- }
- return true;
- }
-
- // Coalescing request is not canceled if there are no sub-requests
- return false;
-
- }
-
- // ------------------------------------------------------------------------
- // Object
- // ------------------------------------------------------------------------
-
- @Override
- // All requests have a unique id
- public int hashCode() {
- return super.hashCode();
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof TmfCoalescedDataRequest) {
- TmfCoalescedDataRequest request = (TmfCoalescedDataRequest) other;
- return (request.getDataType() == getDataType()) &&
- (request.getIndex() == getIndex()) &&
- (request.getNbRequested() == getNbRequested() &&
- (request.getExecType() == getExecType()));
- }
- return false;
- }
-
- @Override
- @SuppressWarnings("nls")
- public String toString() {
- return "[TmfCoalescedDataRequest(" + getRequestId() + "," + getDataType().getSimpleName()
- + "," + getExecType() + "," + getIndex() + "," + getNbRequested() + ", "
- + fRequests.toString() + ")]";
- }
-}
*
* Contributors:
* Francois Chouinard - Initial API and implementation
+ * Alexandre Montplaisir - Merge with TmfCoalescedDataRequest
*******************************************************************************/
package org.eclipse.linuxtools.internal.tmf.core.request;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
/**
* The TMF coalesced event request
*
- * @version 1.0
* @author Francois Chouinard
+ * @since 3.0
*/
-public class TmfCoalescedEventRequest extends TmfCoalescedDataRequest implements ITmfEventRequest {
+public class TmfCoalescedEventRequest extends TmfEventRequest {
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
- private TmfTimeRange fRange; // The requested events time range
+ /** The list of coalesced requests */
+ private final List<ITmfEventRequest> fRequests = new ArrayList<ITmfEventRequest>();
+
+ /**
+ * We do not use super.fRange, because in the case of coalesced requests,
+ * the global range can be modified as sub-requets are added.
+ */
+ private TmfTimeRange fRange;
// ------------------------------------------------------------------------
// Constructor
* the beginning.
* @param nbRequested
* The number of events requested. You can use
- * {@link TmfDataRequest#ALL_DATA} to request all events.
+ * {@link TmfEventRequest#ALL_DATA} to request all events.
* @param priority
* The requested execution priority
*/
long index,
int nbRequested,
ExecutionType priority) {
- super(ITmfEvent.class, index, nbRequested, priority);
+ super(ITmfEvent.class, null, index, nbRequested, priority);
fRange = range;
if (TmfCoreTracer.isRequestTraced()) {
type = type.substring(type.lastIndexOf('.') + 1);
@SuppressWarnings("nls")
String message = "CREATED "
- + (getExecType() == ITmfDataRequest.ExecutionType.BACKGROUND ? "(BG)" : "(FG)")
+ + (getExecType() == ITmfEventRequest.ExecutionType.BACKGROUND ? "(BG)" : "(FG)")
+ " Type=" + type + " Index=" + getIndex() + " NbReq=" + getNbRequested()
+ " Range=" + getRange()
+ " DataType=" + getDataType().getSimpleName();
}
}
+ @Override
+ public TmfTimeRange getRange() {
+ return fRange;
+ }
+
// ------------------------------------------------------------------------
// Management
// ------------------------------------------------------------------------
- @Override
- public void addRequest(ITmfDataRequest request) {
- super.addRequest(request);
- if (request instanceof ITmfEventRequest) {
- merge((ITmfEventRequest) request);
- }
+ /**
+ * Add a request to this one.
+ *
+ * @param request
+ * The request to add
+ */
+ public void addRequest(ITmfEventRequest request) {
+ fRequests.add(request);
+ merge(request);
}
- @Override
- public boolean isCompatible(ITmfDataRequest request) {
- if (request instanceof ITmfEventRequest) {
- if (super.isCompatible(request)) {
- return overlaps((ITmfEventRequest) request);
- }
+ /**
+ * Check if a request is compatible with the current coalesced one
+ *
+ * @param request
+ * The request to verify
+ * @return If the request is compatible, true or false
+ */
+ public boolean isCompatible(ITmfEventRequest request) {
+ if (request.getExecType() == getExecType() &&
+ ranksOverlap(request) &&
+ timeRangesOverlap(request)) {
+ return true;
}
return false;
}
- private boolean overlaps(ITmfEventRequest request) {
+ private boolean ranksOverlap(ITmfEventRequest request) {
+ long start = request.getIndex();
+ long end = start + request.getNbRequested();
+
+ // Return true if either the start or end index falls within
+ // the coalesced request boundaries
+ return (start <= (fIndex + fNbRequested + 1) && (end >= fIndex - 1));
+ }
+
+ private boolean timeRangesOverlap(ITmfEventRequest request) {
ITmfTimestamp startTime = request.getRange().getStartTime();
ITmfTimestamp endTime = request.getRange().getEndTime();
- return (startTime.compareTo(endTime) <= 0) && (fRange.getStartTime().compareTo(fRange.getEndTime()) <= 0);
+ return (startTime.compareTo(endTime) <= 0) &&
+ (fRange.getStartTime().compareTo(fRange.getEndTime()) <= 0);
}
private void merge(ITmfEventRequest request) {
+ long start = request.getIndex();
+ long end = Math.min(start + request.getNbRequested(), TmfEventRequest.ALL_DATA);
+
+ if (start < fIndex) {
+ if (fNbRequested != TmfEventRequest.ALL_DATA) {
+ fNbRequested += (fIndex - start);
+ }
+ fIndex = start;
+ }
+ if ((request.getNbRequested() == TmfEventRequest.ALL_DATA) ||
+ (fNbRequested == TmfEventRequest.ALL_DATA)) {
+ fNbRequested = TmfEventRequest.ALL_DATA;
+ } else {
+ fNbRequested = (int) Math.max(end - fIndex, fNbRequested);
+ }
+
ITmfTimestamp startTime = request.getRange().getStartTime();
ITmfTimestamp endTime = request.getRange().getEndTime();
if (!fRange.contains(startTime) && fRange.getStartTime().compareTo(startTime) > 0) {
}
}
+ /**
+ * @return The list of IDs of the sub-requests
+ */
+ @SuppressWarnings("nls")
+ public String getSubRequestIds() {
+ StringBuffer result = new StringBuffer("[");
+ for (int i = 0; i < fRequests.size(); i++) {
+ if (i != 0) {
+ result.append(", ");
+ }
+ result.append(fRequests.get(i).getRequestId());
+ }
+ result.append("]");
+ return result.toString();
+ }
+
// ------------------------------------------------------------------------
- // ITmfDataRequest
+ // ITmfEventRequest
// ------------------------------------------------------------------------
@Override
public void handleData(ITmfEvent data) {
super.handleData(data);
long index = getIndex() + getNbRead() - 1;
- for (ITmfDataRequest request : fRequests) {
+ for (ITmfEventRequest request : fRequests) {
if (data == null) {
request.handleData(null);
} else {
long start = request.getIndex();
long end = start + request.getNbRequested();
- if (request instanceof ITmfEventRequest) {
- ITmfEventRequest req = (ITmfEventRequest) request;
- if (!req.isCompleted() && index >= start && index < end) {
- ITmfTimestamp ts = data.getTimestamp();
- if (req.getRange().contains(ts)) {
- if (req.getDataType().isInstance(data)) {
- req.handleData(data);
- }
- }
- }
- }
- else {
- TmfDataRequest req = (TmfDataRequest) request;
- if (!req.isCompleted() && index >= start && index < end) {
- if (req.getDataType().isInstance(data)) {
- req.handleData(data);
+ if (!request.isCompleted() && index >= start && index < end) {
+ ITmfTimestamp ts = data.getTimestamp();
+ if (request.getRange().contains(ts)) {
+ if (request.getDataType().isInstance(data)) {
+ request.handleData(data);
}
}
}
}
}
- // ------------------------------------------------------------------------
- // ITmfEventRequest
- // ------------------------------------------------------------------------
+ @Override
+ public void start() {
+ for (ITmfEventRequest request : fRequests) {
+ if (!request.isCompleted()) {
+ request.start();
+ }
+ }
+ super.start();
+ }
@Override
- public TmfTimeRange getRange() {
- return fRange;
+ public void done() {
+ for (ITmfEventRequest request : fRequests) {
+ if (!request.isCompleted()) {
+ request.done();
+ }
+ }
+ super.done();
+ }
+
+ @Override
+ public void fail() {
+ for (ITmfEventRequest request : fRequests) {
+ request.fail();
+ }
+ super.fail();
+ }
+
+ @Override
+ public void cancel() {
+ for (ITmfEventRequest request : fRequests) {
+ if (!request.isCompleted()) {
+ request.cancel();
+ }
+ }
+ super.cancel();
}
@Override
- public void setStartIndex(int index) {
- setIndex(index);
+ public synchronized boolean isCompleted() {
+ // Firstly, check if coalescing request is completed
+ if (super.isCompleted()) {
+ return true;
+ }
+
+ // Secondly, check if all sub-requests are finished
+ if (fRequests.size() > 0) {
+ // If all sub requests are completed the coalesced request is
+ // treated as completed, too.
+ for (ITmfEventRequest request : fRequests) {
+ if (!request.isCompleted()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // Coalescing request is not finished if there are no sub-requests
+ return false;
+ }
+
+ @Override
+ public synchronized boolean isCancelled() {
+ // Firstly, check if coalescing request is canceled
+ if (super.isCancelled()) {
+ return true;
+ }
+
+ // Secondly, check if all sub-requests are canceled
+ if (fRequests.size() > 0) {
+ // If all sub requests are canceled the coalesced request is
+ // treated as completed, too.
+ for (ITmfEventRequest request : fRequests) {
+ if (!request.isCancelled()) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ // Coalescing request is not canceled if there are no sub-requests
+ return false;
+
}
// ------------------------------------------------------------------------
return (request.getDataType() == getDataType()) &&
(request.getIndex() == getIndex()) &&
(request.getNbRequested() == getNbRequested()) &&
- (request.getRange().equals(getRange()));
- }
- if (other instanceof TmfCoalescedDataRequest) {
- return super.equals(other);
+ (request.getRange().equals(fRange));
}
return false;
}
import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
import org.eclipse.linuxtools.internal.tmf.core.component.TmfEventThread;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
/**
* The request scheduler works with 5 slots with a specific time. It has 4 slots
import org.eclipse.linuxtools.internal.tmf.core.statesystem.backends.IStateHistoryBackend;
import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
super(builder.getStateProvider().getExpectedEventType(),
TmfTimeRange.ETERNITY,
0,
- TmfDataRequest.ALL_DATA,
- ITmfDataRequest.ExecutionType.BACKGROUND);
+ TmfEventRequest.ALL_DATA,
+ ITmfEventRequest.ExecutionType.BACKGROUND);
this.builder = builder;
this.sci = builder.getStateProvider();
this.trace = sci.getTrace();
import org.eclipse.linuxtools.tmf.core.exceptions.TimeRangeException;
import org.eclipse.linuxtools.tmf.core.interval.ITmfStateInterval;
import org.eclipse.linuxtools.tmf.core.interval.TmfStateInterval;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.statesystem.AbstractTmfStateProvider;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateProvider;
super(input.getExpectedEventType(),
TmfTimeRange.ETERNITY,
0,
- TmfDataRequest.ALL_DATA,
- ITmfDataRequest.ExecutionType.BACKGROUND);
+ TmfEventRequest.ALL_DATA,
+ ITmfEventRequest.ExecutionType.BACKGROUND);
checkpoints.clear();
this.trace = input.getTrace();
this.checkpts = checkpoints;
super(sci.getExpectedEventType(),
range,
0,
- TmfDataRequest.ALL_DATA,
- ITmfDataRequest.ExecutionType.BACKGROUND);
+ TmfEventRequest.ALL_DATA,
+ ITmfEventRequest.ExecutionType.BACKGROUND);
this.sci = sci;
this.trace = sci.getTrace();
}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.component;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-
-/**
- * This is the interface of the data providers in TMF. Data providers have the
- * capability of handling data requests.
- *
- * @version 1.0
- * @author Francois Chouinard
- *
- * @see TmfDataProvider
- * @see TmfEventProvider
- */
-public interface ITmfDataProvider extends ITmfComponent {
-
- /**
- * Queue the request for processing.
- *
- * @param request The request to process
- */
- void sendRequest(ITmfDataRequest request);
-
- /**
- * Queue the coalesced requests.
- */
- void fireRequest();
-
- /**
- * Increments/decrements the pending requests counters and fires the request
- * if necessary (counter == 0). Used for coalescing requests across multiple
- * TmfDataProvider's.
- *
- * @param isIncrement
- * Should we increment (true) or decrement (false) the pending
- * counter
- */
- void notifyPendingRequest(boolean isIncrement);
-
- /**
- * Return the next event based on the context supplied. The context
- * will be updated for the subsequent read.
- *
- * @param context the trace read context (updated)
- * @return the event referred to by context
- */
- ITmfEvent getNext(ITmfContext context);
-}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.component;
+
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
+
+/**
+ * This is the interface of the data providers in TMF. Data providers have the
+ * capability of handling data requests.
+ *
+ * @version 1.0
+ * @author Francois Chouinard
+ *
+ * @see TmfEventProvider
+ */
+public interface ITmfEventProvider extends ITmfComponent {
+
+ /**
+ * Queue the request for processing.
+ *
+ * @param request The request to process
+ */
+ void sendRequest(ITmfEventRequest request);
+
+ /**
+ * Queue the coalesced requests.
+ */
+ void fireRequest();
+
+ /**
+ * Increments/decrements the pending requests counters and fires the request
+ * if necessary (counter == 0). Used for coalescing requests across multiple
+ * TmfDataProvider's.
+ *
+ * @param isIncrement
+ * Should we increment (true) or decrement (false) the pending
+ * counter
+ */
+ void notifyPendingRequest(boolean isIncrement);
+
+ /**
+ * Return the next event based on the context supplied. The context
+ * will be updated for the subsequent read.
+ *
+ * @param context the trace read context (updated)
+ * @return the event referred to by context
+ */
+ ITmfEvent getNext(ITmfContext context);
+}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Replace background requests by pre-emptable requests
- * Patrick Tasse - Fix TimerThread leak
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.component;
-
-import java.util.Vector;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.SynchronousQueue;
-
-import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
-import org.eclipse.linuxtools.internal.tmf.core.component.TmfEventThread;
-import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
-import org.eclipse.linuxtools.internal.tmf.core.request.TmfCoalescedDataRequest;
-import org.eclipse.linuxtools.internal.tmf.core.request.TmfRequestExecutor;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
-import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
-import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
-
-/**
- * An abstract base class that implements ITmfDataProvider.
- * <p>
- * This abstract class implements the housekeeping methods to register/
- * de-register the event provider and to handle generically the event requests.
- * <p>
- * The concrete class can either re-implement processRequest() entirely or just
- * implement the hooks (initializeContext() and getNext()).
- * <p>
- *
- * @author Francois Chouinard
- * @version 1.1
- */
-public abstract class TmfDataProvider extends TmfComponent implements ITmfDataProvider {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- /** Default amount of events per request "chunk" */
- public static final int DEFAULT_BLOCK_SIZE = 50000;
-
- /** Default size of the queue */
- public static final int DEFAULT_QUEUE_SIZE = 1000;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- /** The type of event handled by this provider */
- protected Class<? extends ITmfEvent> fType;
-
- /** Is there some data being logged? */
- protected boolean fLogData;
-
- /** Are errors being logged? */
- protected boolean fLogError;
-
- /** Queue of events */
- protected BlockingQueue<ITmfEvent> fDataQueue;
-
- /** Size of the fDataQueue */
- protected int fQueueSize = DEFAULT_QUEUE_SIZE;
-
- private final TmfRequestExecutor fExecutor;
-
- private int fSignalDepth = 0;
- private final Object fLock = new Object();
-
- private int fRequestPendingCounter = 0;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Default constructor
- */
- public TmfDataProvider() {
- super();
- fQueueSize = DEFAULT_QUEUE_SIZE;
- fDataQueue = new LinkedBlockingQueue<ITmfEvent>(fQueueSize);
- fExecutor = new TmfRequestExecutor();
- }
-
- /**
- * Initialize this data provider
- *
- * @param name
- * Name of the provider
- * @param type
- * The type of events that will be handled
- */
- public void init(String name, Class<? extends ITmfEvent> type) {
- super.init(name);
- fType = type;
- fDataQueue = (fQueueSize > 1) ? new LinkedBlockingQueue<ITmfEvent>(fQueueSize) : new SynchronousQueue<ITmfEvent>();
-
- fExecutor.init();
- fSignalDepth = 0;
-
- fLogData = TmfCoreTracer.isEventTraced();
-// fLogError = TmfCoreTracer.isErrorTraced();
-
- TmfProviderManager.register(fType, this);
- }
-
- /**
- * Constructor specifying the event type and the queue size.
- *
- * @param name
- * Name of the provider
- * @param type
- * Type of event that will be handled
- * @param queueSize
- * Size of the event queue
- */
- protected TmfDataProvider(String name, Class<? extends ITmfEvent> type, int queueSize) {
- this();
- fQueueSize = queueSize;
- init(name, type);
- }
-
- /**
- * Copy constructor
- *
- * @param other
- * The other object to copy
- */
- public TmfDataProvider(TmfDataProvider other) {
- this();
- init(other.getName(), other.fType);
- }
-
- /**
- * Standard constructor. Instantiate and initialize at the same time.
- *
- * @param name
- * Name of the provider
- * @param type
- * The type of events that will be handled
- */
- public TmfDataProvider(String name, Class<? extends ITmfEvent> type) {
- this(name, type, DEFAULT_QUEUE_SIZE);
- }
-
- @Override
- public void dispose() {
- TmfProviderManager.deregister(fType, this);
- fExecutor.stop();
- super.dispose();
- // if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "stopped");
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * Get the queue size of this provider
- *
- * @return The size of the queue
- */
- public int getQueueSize() {
- return fQueueSize;
- }
-
- /**
- * Get the event type this provider handles
- *
- * @return The type of ITmfEvent
- */
- public Class<?> getType() {
- return fType;
- }
-
- // ------------------------------------------------------------------------
- // ITmfRequestHandler
- // ------------------------------------------------------------------------
-
- @Override
- public void sendRequest(final ITmfDataRequest request) {
- synchronized (fLock) {
- if (fSignalDepth > 0) {
- coalesceDataRequest(request);
- } else {
- dispatchRequest(request);
- }
- }
- }
-
- @Override
- public void fireRequest() {
- synchronized (fLock) {
- if (fRequestPendingCounter > 0) {
- return;
- }
- if (fPendingCoalescedRequests.size() > 0) {
- for (TmfDataRequest request : fPendingCoalescedRequests) {
- dispatchRequest(request);
- }
- fPendingCoalescedRequests.clear();
- }
- }
- }
-
- /**
- * Increments/decrements the pending requests counters and fires the request
- * if necessary (counter == 0). Used for coalescing requests across multiple
- * TmfDataProvider's.
- *
- * @param isIncrement
- * Should we increment (true) or decrement (false) the pending
- * counter
- */
- @Override
- public void notifyPendingRequest(boolean isIncrement) {
- synchronized (fLock) {
- if (isIncrement) {
- if (fSignalDepth > 0) {
- fRequestPendingCounter++;
- }
- } else {
- if (fRequestPendingCounter > 0) {
- fRequestPendingCounter--;
- }
-
- // fire request if all pending requests are received
- if (fRequestPendingCounter == 0) {
- fireRequest();
- }
- }
- }
- }
-
- // ------------------------------------------------------------------------
- // Coalescing (primitive test...)
- // ------------------------------------------------------------------------
-
- /** List of coalesced requests */
- protected Vector<TmfCoalescedDataRequest> fPendingCoalescedRequests = new Vector<TmfCoalescedDataRequest>();
-
- /**
- * Create a new request from an existing one, and add it to the coalesced
- * requests
- *
- * @param request
- * The request to copy
- */
- protected void newCoalescedDataRequest(ITmfDataRequest request) {
- synchronized (fLock) {
- TmfCoalescedDataRequest coalescedRequest = new TmfCoalescedDataRequest(request.getDataType(), request.getIndex(),
- request.getNbRequested(), request.getExecType());
- coalescedRequest.addRequest(request);
- if (TmfCoreTracer.isRequestTraced()) {
- TmfCoreTracer.traceRequest(request, "COALESCED with " + coalescedRequest.getRequestId()); //$NON-NLS-1$
- TmfCoreTracer.traceRequest(coalescedRequest, "now contains " + coalescedRequest.getSubRequestIds()); //$NON-NLS-1$
- }
- fPendingCoalescedRequests.add(coalescedRequest);
- }
- }
-
- /**
- * Add an existing requests to the list of coalesced ones
- *
- * @param request
- * The request to add to the list
- */
- protected void coalesceDataRequest(ITmfDataRequest request) {
- synchronized (fLock) {
- for (TmfCoalescedDataRequest coalescedRequest : fPendingCoalescedRequests) {
- if (coalescedRequest.isCompatible(request)) {
- coalescedRequest.addRequest(request);
- if (TmfCoreTracer.isRequestTraced()) {
- TmfCoreTracer.traceRequest(request, "COALESCED with " + coalescedRequest.getRequestId()); //$NON-NLS-1$
- TmfCoreTracer.traceRequest(coalescedRequest, "now contains " + coalescedRequest.getSubRequestIds()); //$NON-NLS-1$
- }
- return;
- }
- }
- newCoalescedDataRequest(request);
- }
- }
-
- // ------------------------------------------------------------------------
- // Request processing
- // ------------------------------------------------------------------------
-
- private void dispatchRequest(final ITmfDataRequest request) {
- if (request.getExecType() == ExecutionType.FOREGROUND) {
- queueRequest(request);
- } else {
- queueBackgroundRequest(request, true);
- }
- }
-
- /**
- * Queue a request.
- *
- * @param request
- * The data request
- */
- protected void queueRequest(final ITmfDataRequest request) {
-
- if (fExecutor.isShutdown()) {
- request.cancel();
- return;
- }
-
- TmfEventThread thread = new TmfEventThread(this, request);
-
- if (TmfCoreTracer.isRequestTraced()) {
- TmfCoreTracer.traceRequest(request, "QUEUED"); //$NON-NLS-1$
- }
-
- fExecutor.execute(thread);
- }
-
- /**
- * Queue a background request
- *
- * @param request
- * The request
- * @param indexing
- * Should we index the chunks
- * @since 3.0
- */
- protected void queueBackgroundRequest(final ITmfDataRequest request, final boolean indexing) {
- queueRequest(request);
- }
-
- /**
- * Initialize the provider based on the request. The context is provider
- * specific and will be updated by getNext().
- *
- * @param request
- * The request
- * @return An application specific context; null if request can't be
- * serviced
- * @since 2.0
- */
- public abstract ITmfContext armRequest(ITmfDataRequest request);
-
-// /**
-// * Return the next event based on the context supplied. The context
-// * will be updated for the subsequent read.
-// *
-// * @param context the trace read context (updated)
-// * @return the event referred to by context
-// */
-// public abstract T getNext(ITmfContext context);
-
- /**
- * Checks if the data meets the request completion criteria.
- *
- * @param request the request
- * @param data the data to verify
- * @param nbRead the number of events read so far
- * @return true if completion criteria is met
- */
- public boolean isCompleted(ITmfDataRequest request, ITmfEvent data, int nbRead) {
- return request.isCompleted() || nbRead >= request.getNbRequested();
- }
-
- // ------------------------------------------------------------------------
- // Pass-through's to the request executor
- // ------------------------------------------------------------------------
-
- /**
- * @return the shutdown state (i.e. if it is accepting new requests)
- * @since 2.0
- */
- protected boolean executorIsShutdown() {
- return fExecutor.isShutdown();
- }
-
- /**
- * @return the termination state
- * @since 2.0
- */
- protected boolean executorIsTerminated() {
- return fExecutor.isTerminated();
- }
-
- // ------------------------------------------------------------------------
- // Signal handlers
- // ------------------------------------------------------------------------
-
- /**
- * Handler for the start synch signal
- *
- * @param signal
- * Incoming signal
- */
- @TmfSignalHandler
- public void startSynch(TmfStartSynchSignal signal) {
- synchronized (fLock) {
- fSignalDepth++;
- }
- }
-
- /**
- * Handler for the end synch signal
- *
- * @param signal
- * Incoming signal
- */
- @TmfSignalHandler
- public void endSynch(TmfEndSynchSignal signal) {
- synchronized (fLock) {
- fSignalDepth--;
- if (fSignalDepth == 0) {
- fireRequest();
- }
- }
- }
-
-}
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Francois Chouinard - Initial API and implementation
- * Francois Chouinard - Replace background requests by pre-emptable requests
+ * Francois Chouinard - Initial API and implementation, replace background
+ * requests by preemptable requests
+ * Alexandre Montplaisir - Merge with TmfDataProvider
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.component;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.SynchronousQueue;
+
import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
+import org.eclipse.linuxtools.internal.tmf.core.component.TmfEventThread;
+import org.eclipse.linuxtools.internal.tmf.core.component.TmfProviderManager;
import org.eclipse.linuxtools.internal.tmf.core.request.TmfCoalescedEventRequest;
+import org.eclipse.linuxtools.internal.tmf.core.request.TmfRequestExecutor;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
+import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
+import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
/**
- * An extension of TmfDataProvider timestamped events providers.
+ * An abstract base class that implements ITmfEventProvider.
+ * <p>
+ * This abstract class implements the housekeeping methods to register/
+ * de-register the event provider and to handle generically the event requests.
+ * </p>
*
* @author Francois Chouinard
- * @version 1.1
*/
-public abstract class TmfEventProvider extends TmfDataProvider {
+public abstract class TmfEventProvider extends TmfComponent implements ITmfEventProvider {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /** Default amount of events per request "chunk" */
+ public static final int DEFAULT_BLOCK_SIZE = 50000;
+
+ /** Default size of the queue */
+ public static final int DEFAULT_QUEUE_SIZE = 1000;
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /** List of coalesced requests */
+ protected final List<TmfCoalescedEventRequest> fPendingCoalescedRequests =
+ new ArrayList<TmfCoalescedEventRequest>();
+
+ /** The type of event handled by this provider */
+ protected Class<? extends ITmfEvent> fType;
+
+ /** Queue of events */
+ protected BlockingQueue<ITmfEvent> fDataQueue;
+
+ /** Size of the fDataQueue */
+ protected int fQueueSize = DEFAULT_QUEUE_SIZE;
+
+ private final TmfRequestExecutor fExecutor;
+
+ private final Object fLock = new Object();
+
+ private int fSignalDepth = 0;
+
+ private int fRequestPendingCounter = 0;
// ------------------------------------------------------------------------
// Constructors
*/
public TmfEventProvider() {
super();
- }
-
- @Override
- public void init(String name, Class<? extends ITmfEvent> type) {
- super.init(name, type);
+ fQueueSize = DEFAULT_QUEUE_SIZE;
+ fDataQueue = new LinkedBlockingQueue<ITmfEvent>(fQueueSize);
+ fExecutor = new TmfRequestExecutor();
}
/**
- * Standard constructor
+ * Initialize this data provider
*
* @param name
- * The name of the provider
+ * Name of the provider
* @param type
- * The type of handled events
+ * The type of events that will be handled
*/
- public TmfEventProvider(String name, Class<? extends ITmfEvent> type) {
- super(name, type);
+ public void init(String name, Class<? extends ITmfEvent> type) {
+ super.init(name);
+ fType = type;
+ fDataQueue = (fQueueSize > 1) ? new LinkedBlockingQueue<ITmfEvent>(fQueueSize) : new SynchronousQueue<ITmfEvent>();
+
+ fExecutor.init();
+ fSignalDepth = 0;
+
+ TmfProviderManager.register(fType, this);
}
/**
- * Standard constructor which also sets the queue size
+ * Constructor specifying the event type and the queue size.
*
* @param name
- * The name of the provider
+ * Name of the provider
* @param type
- * The type of handled events
+ * Type of event that will be handled
* @param queueSize
- * The size of the queue
+ * Size of the event queue
*/
- public TmfEventProvider(String name, Class<? extends ITmfEvent> type, int queueSize) {
- super(name, type, queueSize);
+ protected TmfEventProvider(String name, Class<? extends ITmfEvent> type, int queueSize) {
+ this();
+ fQueueSize = queueSize;
+ init(name, type);
}
/**
* Copy constructor
*
* @param other
- * The other TmfEventProvider to copy
+ * The other object to copy
*/
public TmfEventProvider(TmfEventProvider other) {
- super(other);
+ this();
+ init(other.getName(), other.fType);
+ }
+
+ /**
+ * Standard constructor. Instantiate and initialize at the same time.
+ *
+ * @param name
+ * Name of the provider
+ * @param type
+ * The type of events that will be handled
+ */
+ public TmfEventProvider(String name, Class<? extends ITmfEvent> type) {
+ this(name, type, DEFAULT_QUEUE_SIZE);
+ }
+
+ @Override
+ public void dispose() {
+ TmfProviderManager.deregister(fType, this);
+ fExecutor.stop();
+ super.dispose();
}
// ------------------------------------------------------------------------
- // TmfDataProvider
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get the queue size of this provider
+ *
+ * @return The size of the queue
+ */
+ public int getQueueSize() {
+ return fQueueSize;
+ }
+
+ /**
+ * Get the event type this provider handles
+ *
+ * @return The type of ITmfEvent
+ */
+ public Class<?> getType() {
+ return fType;
+ }
+
+ // ------------------------------------------------------------------------
+ // ITmfRequestHandler
// ------------------------------------------------------------------------
@Override
- public boolean isCompleted(ITmfDataRequest request, ITmfEvent data, int nbRead) {
- boolean requestCompleted = super.isCompleted(request, data, nbRead);
- if (!requestCompleted && request instanceof ITmfEventRequest) {
- ITmfTimestamp endTime = ((ITmfEventRequest) request).getRange().getEndTime();
- return data.getTimestamp().compareTo(endTime, false) > 0;
+ public void sendRequest(final ITmfEventRequest request) {
+ synchronized (fLock) {
+ if (fSignalDepth > 0) {
+ coalesceEventRequest(request);
+ } else {
+ dispatchRequest(request);
+ }
+ }
+ }
+
+ @Override
+ public void fireRequest() {
+ synchronized (fLock) {
+ if (fRequestPendingCounter > 0) {
+ return;
+ }
+ if (fPendingCoalescedRequests.size() > 0) {
+ for (ITmfEventRequest request : fPendingCoalescedRequests) {
+ dispatchRequest(request);
+ }
+ fPendingCoalescedRequests.clear();
+ }
}
- return requestCompleted;
}
+ /**
+ * Increments/decrements the pending requests counters and fires the request
+ * if necessary (counter == 0). Used for coalescing requests across multiple
+ * TmfDataProvider's.
+ *
+ * @param isIncrement
+ * Should we increment (true) or decrement (false) the pending
+ * counter
+ */
@Override
- protected synchronized void newCoalescedDataRequest(ITmfDataRequest request) {
- if (request instanceof ITmfEventRequest) {
- ITmfEventRequest eventRequest = (ITmfEventRequest) request;
+ public void notifyPendingRequest(boolean isIncrement) {
+ synchronized (fLock) {
+ if (isIncrement) {
+ if (fSignalDepth > 0) {
+ fRequestPendingCounter++;
+ }
+ } else {
+ if (fRequestPendingCounter > 0) {
+ fRequestPendingCounter--;
+ }
+
+ // fire request if all pending requests are received
+ if (fRequestPendingCounter == 0) {
+ fireRequest();
+ }
+ }
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Coalescing
+ // ------------------------------------------------------------------------
+
+ /**
+ * Create a new request from an existing one, and add it to the coalesced
+ * requests
+ *
+ * @param request
+ * The request to copy
+ */
+ protected synchronized void newCoalescedEventRequest(ITmfEventRequest request) {
TmfCoalescedEventRequest coalescedRequest = new TmfCoalescedEventRequest(
- eventRequest.getDataType(),
- eventRequest.getRange(),
- eventRequest.getIndex(),
- eventRequest.getNbRequested(),
- eventRequest.getExecType());
- coalescedRequest.addRequest(eventRequest);
+ request.getDataType(),
+ request.getRange(),
+ request.getIndex(),
+ request.getNbRequested(),
+ request.getExecType());
+ coalescedRequest.addRequest(request);
if (TmfCoreTracer.isRequestTraced()) {
TmfCoreTracer.traceRequest(request, "COALESCED with " + coalescedRequest.getRequestId()); //$NON-NLS-1$
TmfCoreTracer.traceRequest(coalescedRequest, "now contains " + coalescedRequest.getSubRequestIds()); //$NON-NLS-1$
}
fPendingCoalescedRequests.add(coalescedRequest);
+ }
+
+ /**
+ * 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 : fPendingCoalescedRequests) {
+ if (coalescedRequest.isCompatible(request)) {
+ coalescedRequest.addRequest(request);
+ if (TmfCoreTracer.isRequestTraced()) {
+ TmfCoreTracer.traceRequest(request, "COALESCED with " + coalescedRequest.getRequestId()); //$NON-NLS-1$
+ TmfCoreTracer.traceRequest(coalescedRequest, "now contains " + coalescedRequest.getSubRequestIds()); //$NON-NLS-1$
+ }
+ return;
+ }
+ }
+ newCoalescedEventRequest(request);
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Request processing
+ // ------------------------------------------------------------------------
+
+ private void dispatchRequest(final ITmfEventRequest request) {
+ if (request.getExecType() == ExecutionType.FOREGROUND) {
+ queueRequest(request);
} else {
- super.newCoalescedDataRequest(request);
+ queueBackgroundRequest(request, true);
+ }
+ }
+
+ /**
+ * Queue a request.
+ *
+ * @param request
+ * The data request
+ */
+ protected void queueRequest(final ITmfEventRequest request) {
+
+ if (fExecutor.isShutdown()) {
+ request.cancel();
+ return;
+ }
+
+ TmfEventThread thread = new TmfEventThread(this, request);
+
+ if (TmfCoreTracer.isRequestTraced()) {
+ TmfCoreTracer.traceRequest(request, "QUEUED"); //$NON-NLS-1$
+ }
+
+ fExecutor.execute(thread);
+ }
+
+ /**
+ * Queue a background request
+ *
+ * @param request
+ * The request
+ * @param indexing
+ * Should we index the chunks
+ * @since 3.0
+ */
+ protected void queueBackgroundRequest(final ITmfEventRequest request, final boolean indexing) {
+ queueRequest(request);
+ }
+
+ /**
+ * Initialize the provider based on the request. The context is provider
+ * specific and will be updated by getNext().
+ *
+ * @param request
+ * The request
+ * @return An application specific context; null if request can't be
+ * serviced
+ * @since 2.0
+ */
+ public abstract ITmfContext armRequest(ITmfEventRequest request);
+
+ /**
+ * Checks if the data meets the request completion criteria.
+ *
+ * @param request
+ * The request
+ * @param event
+ * The data to verify
+ * @param nbRead
+ * The number of events read so far
+ * @return true if completion criteria is met
+ */
+ public boolean isCompleted(ITmfEventRequest request, ITmfEvent event, int nbRead) {
+ boolean requestCompleted = isCompleted2(request, nbRead);
+ if (!requestCompleted) {
+ ITmfTimestamp endTime = request.getRange().getEndTime();
+ return event.getTimestamp().compareTo(endTime, false) > 0;
+ }
+ return requestCompleted;
+ }
+
+ private static boolean isCompleted2(ITmfEventRequest request,int nbRead) {
+ return request.isCompleted() || nbRead >= request.getNbRequested();
+ }
+
+ // ------------------------------------------------------------------------
+ // Pass-through's to the request executor
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return the shutdown state (i.e. if it is accepting new requests)
+ * @since 2.0
+ */
+ protected boolean executorIsShutdown() {
+ return fExecutor.isShutdown();
+ }
+
+ /**
+ * @return the termination state
+ * @since 2.0
+ */
+ protected boolean executorIsTerminated() {
+ return fExecutor.isTerminated();
+ }
+
+ // ------------------------------------------------------------------------
+ // Signal handlers
+ // ------------------------------------------------------------------------
+
+ /**
+ * Handler for the start synch signal
+ *
+ * @param signal
+ * Incoming signal
+ */
+ @TmfSignalHandler
+ public void startSynch(TmfStartSynchSignal signal) {
+ synchronized (fLock) {
+ fSignalDepth++;
+ }
+ }
+
+ /**
+ * Handler for the end synch signal
+ *
+ * @param signal
+ * Incoming signal
+ */
+ @TmfSignalHandler
+ public void endSynch(TmfEndSynchSignal signal) {
+ synchronized (fLock) {
+ fSignalDepth--;
+ if (fSignalDepth == 0) {
+ fireRequest();
+ }
}
}
import org.eclipse.linuxtools.internal.tmf.core.Activator;
import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
super(CtfTmfEvent.class,
TmfTimeRange.ETERNITY,
0,
- TmfDataRequest.ALL_DATA,
- ITmfDataRequest.ExecutionType.FOREGROUND);
+ TmfEventRequest.ALL_DATA,
+ ITmfEventRequest.ExecutionType.FOREGROUND);
this.matching = matching;
this.traceno = traceno;
}
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.request;
-
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-
-/**
- * The TMF data request
- *
- * @version 1.0
- * @author Francois Chouinard
- */
-public interface ITmfDataRequest {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- /**
- * The request execution type/priority
- */
- public enum ExecutionType {
- /**
- * Backgroung, long-running, lower priority request
- */
- BACKGROUND,
- /**
- * Foreground, short-running, high priority request
- */
- FOREGROUND
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return request data type (T)
- */
- Class<? extends ITmfEvent> getDataType();
-
- /**
- * @return request ID
- */
- int getRequestId();
-
- /**
- * @return request ID
- */
- ExecutionType getExecType();
-
- /**
- * @return the index of the first event requested
- */
- long getIndex();
-
- /**
- * @return the number of requested events
- */
- int getNbRequested();
-
- /**
- * @return the number of events read so far
- */
- int getNbRead();
-
- // ------------------------------------------------------------------------
- // Request state predicates
- // ------------------------------------------------------------------------
-
- /**
- * @return true if the request is still active
- */
- boolean isRunning();
-
- /**
- * @return true if the request is completed
- */
- boolean isCompleted();
-
- /**
- * @return true if the request has failed
- */
- boolean isFailed();
-
- /**
- * @return true if the request was cancelled
- */
- boolean isCancelled();
-
- // ------------------------------------------------------------------------
- // Data handling
- // ------------------------------------------------------------------------
-
- /**
- * Process the piece of data
- *
- * @param data the data to process
- */
- void handleData(ITmfEvent data);
-
- // ------------------------------------------------------------------------
- // Request notifications
- // ------------------------------------------------------------------------
-
- /**
- * Request processing start notification
- */
- void handleStarted();
-
- /**
- * Request processing completion notification
- */
- void handleCompleted();
-
- /**
- * Request successful completion notification
- */
- void handleSuccess();
-
- /**
- * Request failure notification
- */
- void handleFailure();
-
- /**
- * Request cancellation notification
- */
- void handleCancel();
-
- /**
- * To suspend the client thread until the request completes
- * (or is canceled).
- *
- * @throws InterruptedException thrown if the request was cancelled
- */
- void waitForCompletion() throws InterruptedException;
-
- // ------------------------------------------------------------------------
- // Request state modifiers
- // ------------------------------------------------------------------------
-
- /**
- * Put the request in the running state
- */
- void start();
-
- /**
- * Put the request in the completed state
- */
- void done();
-
- /**
- * Put the request in the failed completed state
- */
- void fail();
-
- /**
- * Put the request in the cancelled completed state
- */
- void cancel();
-}
*
* Contributors:
* Francois Chouinard - Initial API and implementation
+ * Alexandre Montplaisir - Merge with ITmfDataRequest
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.request;
+import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
/**
* The TMF event request
*
- * @version 1.0
* @author Francois Chouinard
*/
-public interface ITmfEventRequest extends ITmfDataRequest {
+public interface ITmfEventRequest {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /**
+ * The request execution type/priority
+ */
+ enum ExecutionType {
+ /**
+ * Backgroung, long-running, lower priority request
+ */
+ BACKGROUND,
+ /**
+ * Foreground, short-running, high priority request
+ */
+ FOREGROUND
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return request data type (T)
+ */
+ Class<? extends ITmfEvent> getDataType();
+
+ /**
+ * @return request ID
+ */
+ int getRequestId();
+
+ /**
+ * @return request ID
+ */
+ ExecutionType getExecType();
+
+ /**
+ * @return the index of the first event requested
+ */
+ long getIndex();
+
+ /**
+ * @return the number of requested events
+ */
+ int getNbRequested();
+
+ /**
+ * @return the number of events read so far
+ */
+ int getNbRead();
/**
* @return the requested time range
- * @since 2.0
*/
TmfTimeRange getRange();
+ // ------------------------------------------------------------------------
+ // Request state predicates
+ // ------------------------------------------------------------------------
+
+ /**
+ * @return true if the request is still active
+ */
+ boolean isRunning();
+
+ /**
+ * @return true if the request is completed
+ */
+ boolean isCompleted();
+
+ /**
+ * @return true if the request has failed
+ */
+ boolean isFailed();
+
+ /**
+ * @return true if the request was cancelled
+ */
+ boolean isCancelled();
+
+ // ------------------------------------------------------------------------
+ // Data handling
+ // ------------------------------------------------------------------------
+
+ /**
+ * Process the piece of data
+ *
+ * @param event
+ * The trace event to process
+ */
+ void handleData(ITmfEvent event);
+
+ // ------------------------------------------------------------------------
+ // Request notifications
+ // ------------------------------------------------------------------------
+
+ /**
+ * Request processing start notification
+ */
+ void handleStarted();
+
+ /**
+ * Request processing completion notification
+ */
+ void handleCompleted();
+
+ /**
+ * Request successful completion notification
+ */
+ void handleSuccess();
+
+ /**
+ * Request failure notification
+ */
+ void handleFailure();
+
+ /**
+ * Request cancellation notification
+ */
+ void handleCancel();
+
+ /**
+ * To suspend the client thread until the request completes (or is
+ * cancelled).
+ *
+ * @throws InterruptedException
+ * thrown if the request was cancelled
+ */
+ void waitForCompletion() throws InterruptedException;
+
+ // ------------------------------------------------------------------------
+ // Request state modifiers
+ // ------------------------------------------------------------------------
+
+ /**
+ * Put the request in the running state
+ */
+ void start();
+
+ /**
+ * Put the request in the completed state
+ */
+ void done();
+
+ /**
+ * Put the request in the failed completed state
+ */
+ void fail();
+
+ /**
+ * Put the request in the cancelled completed state
+ */
+ void cancel();
+
+ // ------------------------------------------------------------------------
+ // Others
+ // ------------------------------------------------------------------------
+
/**
- * this method is called by the event provider to set the index corresponding to the time range start time
- * @param index the start time index
+ * This method is called by the event provider to set the index
+ * corresponding to the time range start time
+ *
+ * @param index
+ * The start time index
*/
void setStartIndex(int index);
+++ /dev/null
-/*******************************************************************************
- * Copyright (c) 2009, 2013 Ericsson
- *
- * All rights reserved. This program and the accompanying materials are
- * made available under the terms of the Eclipse Public License v1.0 which
- * accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Francois Chouinard - Initial API and implementation
- * Alexandre Montplaisir - Consolidated constructors
- *******************************************************************************/
-
-package org.eclipse.linuxtools.tmf.core.request;
-
-import java.util.concurrent.CountDownLatch;
-
-import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
-import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-
-/**
- * TmfDataRequests are used to obtain blocks of contiguous data from a data
- * provider. Open ranges can be used, especially for continuous streaming.
- * <p>
- * The request is processed asynchronously by a TmfProvider and, as blocks of
- * data become available, handleData() is invoked synchronously for each block.
- * Upon return, the data instances go out of scope and become eligible for gc.
- * It is is thus the responsibility of the requester to either clone or keep a
- * reference to the data it wishes to track specifically.
- * <p>
- * This data block approach is used to avoid busting the heap for very large
- * trace files. The block size is configurable.
- * <p>
- * The TmfProvider indicates that the request is completed by calling done().
- * The request can be canceled at any time with cancel().
- * <p>
- * Typical usage:
- *
- * <pre>
- * <code><i>TmfTimeWindow range = new TmfTimewindow(...);
- * TmfDataRequest<DataType[]> request = new TmfDataRequest<DataType[]>(DataType.class, 0, NB_EVENTS, BLOCK_SIZE) {
- * public void handleData() {
- * DataType[] data = request.getData();
- * for (DataType e : data) {
- * // do something
- * }
- * }
- * public void handleSuccess() {
- * // do something
- * }
- * }
- * public void handleFailure() {
- * // do something
- * }
- * }
- * public void handleCancel() {
- * // do something
- * }
- * }
- * };
- * fProcessor.process(request, true);
- * </i></code>
- * </pre>
- *
- * TODO: Consider decoupling from "time range", "rank", etc and for the more
- * generic notion of "criteria". This would allow to extend for "time range",
- * etc instead of providing specialized constructors. This also means removing
- * the criteria info from the data structure (with the possible exception of
- * fNbRequested). The nice thing about it is that it would prepare us well for
- * the coming generation of analysis tools.
- *
- * TODO: Implement request failures (codes, etc...)
- *
- * @version 1.0
- * @author Francois Chouinard
- */
-public abstract class TmfDataRequest implements ITmfDataRequest {
-
- // ------------------------------------------------------------------------
- // Constants
- // ------------------------------------------------------------------------
-
- /** The request count for all the events */
- public static final int ALL_DATA = Integer.MAX_VALUE;
-
- private static int fRequestNumber = 0;
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
-
- private final Class<? extends ITmfEvent> fDataType;
- private final ExecutionType fExecType;
-
- /** A unique request ID */
- private final int fRequestId;
-
- /** The index (rank) of the requested event */
- protected long fIndex;
-
- /** The number of requested events (ALL_DATA for all) */
- protected int fNbRequested;
-
- /** The number of reads so far */
- private int fNbRead;
-
- private final CountDownLatch startedLatch = new CountDownLatch(1);
- private final CountDownLatch completedLatch = new CountDownLatch(1);
- private boolean fRequestRunning;
- private boolean fRequestCompleted;
- private boolean fRequestFailed;
- private boolean fRequestCanceled;
-
- // ------------------------------------------------------------------------
- // Constructors
- // ------------------------------------------------------------------------
-
- /**
- * Resets the request counter (used for testing)
- */
- public static void reset() {
- fRequestNumber = 0;
- }
-
- /**
- * Request 'n' events of a given type from the given index (given priority).
- * Events are returned in blocks of the given size.
- *
- * @param dataType
- * The requested data type.
- * @param index
- * The index of the first event to retrieve. Use '0' to start at
- * the beginning of the trace.
- * @param nbRequested
- * The number of events requested. You can use
- * {@link TmfDataRequest#ALL_DATA} to specify you want all events
- * in the trace.
- * @param priority
- * The requested execution priority.
- */
- public TmfDataRequest(Class<? extends ITmfEvent> dataType,
- long index,
- int nbRequested,
- ExecutionType priority) {
- fRequestId = fRequestNumber++;
- fDataType = dataType;
- fIndex = index;
- fNbRequested = nbRequested;
- fExecType = priority;
- fNbRead = 0;
-
- fRequestRunning = false;
- fRequestCompleted = false;
- fRequestFailed = false;
- fRequestCanceled = false;
-
- if (!(this instanceof ITmfEventRequest) && TmfCoreTracer.isRequestTraced()) {
- String type = getClass().getName();
- type = type.substring(type.lastIndexOf('.') + 1);
- @SuppressWarnings("nls")
- String message = "CREATED "
- + (getExecType() == ITmfDataRequest.ExecutionType.BACKGROUND ? "(BG)" : "(FG)")
- + " Type=" + type + " Index=" + getIndex() + " NbReq=" + getNbRequested()
- + " DataType=" + getDataType().getSimpleName();
- TmfCoreTracer.traceRequest(this, message);
- }
- }
-
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
-
- /**
- * @return the request ID
- */
- @Override
- public int getRequestId() {
- return fRequestId;
- }
-
- /**
- * @return the index of the first event requested
- */
- @Override
- public long getIndex() {
- return fIndex;
- }
-
- /**
- * @return the execution type (priority)
- */
- @Override
- public ExecutionType getExecType() {
- return fExecType;
- }
-
- /**
- * @return the number of requested events (ALL_DATA = all)
- */
- @Override
- public int getNbRequested() {
- return fNbRequested;
- }
-
- /**
- * @return the number of events read so far
- */
- @Override
- public synchronized int getNbRead() {
- return fNbRead;
- }
-
- /**
- * @return indicates if the request is currently running
- */
- @Override
- public synchronized boolean isRunning() {
- return fRequestRunning;
- }
-
- /**
- * @return indicates if the request is completed
- */
- @Override
- public synchronized boolean isCompleted() {
- return fRequestCompleted;
- }
-
- /**
- * @return indicates if the request has failed
- */
- @Override
- public synchronized boolean isFailed() {
- return fRequestFailed;
- }
-
- /**
- * @return indicates if the request is canceled
- */
- @Override
- public synchronized boolean isCancelled() {
- return fRequestCanceled;
- }
-
- /**
- * @return the requested data type
- */
- @Override
- public Class<? extends ITmfEvent> getDataType() {
- return fDataType;
- }
-
- // ------------------------------------------------------------------------
- // Setters
- // ------------------------------------------------------------------------
-
- /**
- * this method is called by the event provider to set the index corresponding to the time range start time
- *
- * @param index
- * the start time index
- */
- protected void setIndex(int index) {
- fIndex = index;
- }
-
- // ------------------------------------------------------------------------
- // Operators
- // ------------------------------------------------------------------------
-
- /**
- * Handle incoming data, one event at a time i.e. this method is invoked
- * for every data item obtained by the request.
- *
- * - Data items are received in the order they appear in the stream
- * - Called by the request processor, in its execution thread, every time
- * a block of data becomes available.
- * - Request processor performs a synchronous call to handleData() i.e.
- * its execution threads holds until handleData() returns.
- * - Original data items are disposed of on return i.e. keep a reference
- * (or a copy) if some persistence is needed between invocations.
- * - When there is no more data, done() is called.
- *
- * @param data a piece of data
- */
- @Override
- public void handleData(ITmfEvent data) {
- if (data != null) {
- fNbRead++;
- }
- }
-
- @Override
- public void handleStarted() {
- if (TmfCoreTracer.isRequestTraced()) {
- TmfCoreTracer.traceRequest(this, "STARTED"); //$NON-NLS-1$
- }
- }
-
- /**
- * Handle the completion of the request. It is called when there is no
- * more data available either because:
- * - the request completed normally
- * - the request failed
- * - the request was canceled
- *
- * As a convenience, handleXXXX methods are provided. They are meant to be
- * overridden by the application if it needs to handle these conditions.
- */
- @Override
- public void handleCompleted() {
- boolean requestFailed = false;
- boolean requestCanceled = false;
- synchronized (this) {
- requestFailed = fRequestFailed;
- requestCanceled = fRequestCanceled;
- }
-
- if (requestFailed) {
- handleFailure();
- } else if (requestCanceled) {
- handleCancel();
- } else {
- handleSuccess();
- }
- if (TmfCoreTracer.isRequestTraced()) {
- TmfCoreTracer.traceRequest(this, "COMPLETED (" + fNbRead + " events read)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- @Override
- public void handleSuccess() {
- if (TmfCoreTracer.isRequestTraced()) {
- TmfCoreTracer.traceRequest(this, "SUCCEEDED"); //$NON-NLS-1$
- }
- }
-
- @Override
- public void handleFailure() {
- if (TmfCoreTracer.isRequestTraced()) {
- TmfCoreTracer.traceRequest(this, "FAILED"); //$NON-NLS-1$
- }
- }
-
- @Override
- public void handleCancel() {
- if (TmfCoreTracer.isRequestTraced()) {
- TmfCoreTracer.traceRequest(this, "CANCELLED"); //$NON-NLS-1$
- }
- }
-
- /**
- * To suspend the client thread until the request starts (or is canceled).
- *
- * @throws InterruptedException
- * If the thread was interrupted while waiting
- */
- public void waitForStart() throws InterruptedException {
- while (!fRequestRunning) {
- startedLatch.await();
- }
- }
-
- /**
- * To suspend the client thread until the request completes (or is
- * canceled).
- *
- * @throws InterruptedException
- * If the thread was interrupted while waiting
- */
- @Override
- public void waitForCompletion() throws InterruptedException {
- while (!fRequestCompleted) {
- completedLatch.await();
- }
- }
-
- /**
- * Called by the request processor upon starting to service the request.
- */
- @Override
- public void start() {
- synchronized (this) {
- fRequestRunning = true;
- }
- handleStarted();
- startedLatch.countDown();
- }
-
- /**
- * Called by the request processor upon completion.
- */
- @Override
- public void done() {
- synchronized (this) {
- if (!fRequestCompleted) {
- fRequestRunning = false;
- fRequestCompleted = true;
- } else {
- return;
- }
- }
- try {
- handleCompleted();
- } finally {
- completedLatch.countDown();
- }
- }
-
- /**
- * Called by the request processor upon failure.
- */
- @Override
- public void fail() {
- synchronized (this) {
- fRequestFailed = true;
- }
- done();
- }
-
- /**
- * Called by the request processor upon cancellation.
- */
- @Override
- public void cancel() {
- synchronized (this) {
- fRequestCanceled = true;
- }
- done();
- }
-
- // ------------------------------------------------------------------------
- // Object
- // ------------------------------------------------------------------------
-
- @Override
- // All requests have a unique id
- public int hashCode() {
- return getRequestId();
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof TmfDataRequest) {
- TmfDataRequest request = (TmfDataRequest) other;
- return (request.fDataType == fDataType) && (request.fIndex == fIndex)
- && (request.fNbRequested == fNbRequested);
- }
- return false;
- }
-
- @Override
- @SuppressWarnings("nls")
- public String toString() {
- String name = getClass().getName();
- int dot = name.lastIndexOf('.');
- if (dot >= 0) {
- name = name.substring(dot + 1);
- }
- return "[" + name + "(" + fRequestId + "," + fDataType.getSimpleName()+ "," + getExecType()
- + "," + fIndex + "," + fNbRequested + ")]";
- }
-}
*
* Contributors:
* Francois Chouinard - Initial API and implementation
- * Alexandre Montplaisir - Consolidated constructors
+ * Alexandre Montplaisir - Consolidate constructors, merge with TmfDataRequest
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.request;
+import java.util.concurrent.CountDownLatch;
+
import org.eclipse.linuxtools.internal.tmf.core.TmfCoreTracer;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
/**
- * An extension of TmfDataRequest for timestamped events.
+ * TmfEventRequest's are used to obtain series of events from an event provider.
+ * Open ranges can be used, especially for continuous streaming.
+ * <p>
+ * The request is processed asynchronously by a TmfEventProvider and, as events
+ * become available, handleData() is invoked synchronously for each one.
+ * <p>
+ * The TmfEventProvider indicates that the request is completed by calling
+ * done(). The request can be cancelled at any time with cancel().
+ * <p>
+ * Typical usage:
+ *
+ * <pre><code>
+ * TmfEventRequest request = new TmfEventRequest(DataType.class, range, startIndex, nbEvents, priority) {
+ *
+ * public void handleData(ITmfEvent event) {
+ * // do something with the event
+ * }
+ *
+ * public void handleSuccess() {
+ * // callback for when the request completes successfully
+ * }
+ *
+ * public void handleFailure() {
+ * // callback for when the request fails due to an error
+ * }
+ *
+ * public void handleCancel() {
+ * // callback for when the request is cancelled via .cancel()
+ * }
+ *
+ * };
+ *
+ * eventProvider.sendRequest(request);
+ * </code></pre>
+ *
+ *
+ * TODO: Implement request failures (codes, etc...)
*
- * @version 1.0
* @author Francois Chouinard
+ * @since 3.0
*/
-public abstract class TmfEventRequest extends TmfDataRequest implements ITmfEventRequest {
+public abstract class TmfEventRequest implements ITmfEventRequest {
+
+ // ------------------------------------------------------------------------
+ // Constants
+ // ------------------------------------------------------------------------
+
+ /** The request count for all the events */
+ public static final int ALL_DATA = Integer.MAX_VALUE;
+
+ private static int fRequestNumber = 0;
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
- private final TmfTimeRange fRange; // The requested events time range
+ private final Class<? extends ITmfEvent> fDataType;
+ private final ExecutionType fExecType;
+
+ /** A unique request ID */
+ private final int fRequestId;
+
+ /** The requested events time range */
+ private final TmfTimeRange fRange;
+
+ /** The index (rank) of the requested event */
+ protected long fIndex;
+
+ /** The number of requested events (ALL_DATA for all) */
+ protected int fNbRequested;
+
+ /** The number of reads so far */
+ private int fNbRead;
+
+ private final CountDownLatch startedLatch = new CountDownLatch(1);
+ private final CountDownLatch completedLatch = new CountDownLatch(1);
+
+ private boolean fRequestRunning;
+ private boolean fRequestCompleted;
+ private boolean fRequestFailed;
+ private boolean fRequestCanceled;
// ------------------------------------------------------------------------
- // Constructor
+ // Constructors
// ------------------------------------------------------------------------
/**
- * Request 'n' events of a given type for the given time range (given
- * priority). Events are returned in blocks of the given size.
+ * Request 'n' events of a given type, for the *whole* trace, at the given
+ * priority.
+ *
+ * @param dataType
+ * The requested data type.
+ * @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 trace.
+ * @param priority
+ * The requested execution priority.
+ */
+ public TmfEventRequest(Class<? extends ITmfEvent> dataType,
+ long index,
+ int nbRequested,
+ ExecutionType priority) {
+ this(dataType, TmfTimeRange.ETERNITY, index, nbRequested, priority);
+ }
+
+ /**
+ * Request 'n' events of a given type, for the given time range, at the
+ * given priority.
*
* @param dataType
* The requested data type.
* events in the time range.
* @param priority
* The requested execution priority.
- * @since 3.0
*/
public TmfEventRequest(Class<? extends ITmfEvent> dataType,
TmfTimeRange range,
long index,
int nbRequested,
ExecutionType priority) {
- super(dataType, index, nbRequested, priority);
+
+ fRequestId = fRequestNumber++;
+ fDataType = dataType;
+ fIndex = index;
+ fNbRequested = nbRequested;
+ fExecType = priority;
fRange = range;
+ fNbRead = 0;
+
+ fRequestRunning = false;
+ fRequestCompleted = false;
+ fRequestFailed = false;
+ fRequestCanceled = false;
+ /* Setup the request tracing if it's enabled */
if (TmfCoreTracer.isRequestTraced()) {
String type = getClass().getName();
type = type.substring(type.lastIndexOf('.') + 1);
@SuppressWarnings("nls")
String message = "CREATED "
- + (getExecType() == ITmfDataRequest.ExecutionType.BACKGROUND ? "(BG)" : "(FG)")
+ + (getExecType() == ExecutionType.BACKGROUND ? "(BG)" : "(FG)")
+ " Type=" + type + " Index=" + getIndex() + " NbReq=" + getNbRequested()
+ " Range=" + getRange()
+ " DataType=" + getDataType().getSimpleName();
}
}
+ /**
+ * Resets the request counter (used for testing)
+ */
+ public static void reset() {
+ fRequestNumber = 0;
+ }
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
- /**
- * @return the requested time range
- * @since 2.0
- */
+ @Override
+ public int getRequestId() {
+ return fRequestId;
+ }
+
+ @Override
+ public long getIndex() {
+ return fIndex;
+ }
+
+ @Override
+ public ExecutionType getExecType() {
+ return fExecType;
+ }
+
+ @Override
+ public int getNbRequested() {
+ return fNbRequested;
+ }
+
+ @Override
+ public synchronized int getNbRead() {
+ return fNbRead;
+ }
+
+ @Override
+ public synchronized boolean isRunning() {
+ return fRequestRunning;
+ }
+
+ @Override
+ public synchronized boolean isCompleted() {
+ return fRequestCompleted;
+ }
+
+ @Override
+ public synchronized boolean isFailed() {
+ return fRequestFailed;
+ }
+
+ @Override
+ public synchronized boolean isCancelled() {
+ return fRequestCanceled;
+ }
+
+ @Override
+ public Class<? extends ITmfEvent> getDataType() {
+ return fDataType;
+ }
+
@Override
public TmfTimeRange getRange() {
return fRange;
// ------------------------------------------------------------------------
/**
- * this method is called by the event provider to set the index
- * corresponding to the time range start time once it is known
+ * This method is called by the event provider to set the index
+ * corresponding to the time range start time
*
* @param index
- * the start index
+ * The start time index
*/
+ protected void setIndex(int index) {
+ fIndex = index;
+ }
+
@Override
public void setStartIndex(int index) {
setIndex(index);
}
+ // ------------------------------------------------------------------------
+ // Operators
+ // ------------------------------------------------------------------------
+
+ @Override
+ public void handleData(ITmfEvent event) {
+ if (event != null) {
+ fNbRead++;
+ }
+ }
+
+ @Override
+ public void handleStarted() {
+ if (TmfCoreTracer.isRequestTraced()) {
+ TmfCoreTracer.traceRequest(this, "STARTED"); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public void handleCompleted() {
+ boolean requestFailed = false;
+ boolean requestCanceled = false;
+ synchronized (this) {
+ requestFailed = fRequestFailed;
+ requestCanceled = fRequestCanceled;
+ }
+
+ if (requestFailed) {
+ handleFailure();
+ } else if (requestCanceled) {
+ handleCancel();
+ } else {
+ handleSuccess();
+ }
+ if (TmfCoreTracer.isRequestTraced()) {
+ TmfCoreTracer.traceRequest(this, "COMPLETED (" + fNbRead + " events read)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ @Override
+ public void handleSuccess() {
+ if (TmfCoreTracer.isRequestTraced()) {
+ TmfCoreTracer.traceRequest(this, "SUCCEEDED"); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public void handleFailure() {
+ if (TmfCoreTracer.isRequestTraced()) {
+ TmfCoreTracer.traceRequest(this, "FAILED"); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public void handleCancel() {
+ if (TmfCoreTracer.isRequestTraced()) {
+ TmfCoreTracer.traceRequest(this, "CANCELLED"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * To suspend the client thread until the request starts (or is canceled).
+ *
+ * @throws InterruptedException
+ * If the thread was interrupted while waiting
+ */
+ public void waitForStart() throws InterruptedException {
+ while (!fRequestRunning) {
+ startedLatch.await();
+ }
+ }
+
+ @Override
+ public void waitForCompletion() throws InterruptedException {
+ while (!fRequestCompleted) {
+ completedLatch.await();
+ }
+ }
+
+ @Override
+ public void start() {
+ synchronized (this) {
+ fRequestRunning = true;
+ }
+ handleStarted();
+ startedLatch.countDown();
+ }
+
+ @Override
+ public void done() {
+ synchronized (this) {
+ if (!fRequestCompleted) {
+ fRequestRunning = false;
+ fRequestCompleted = true;
+ } else {
+ return;
+ }
+ }
+ try {
+ handleCompleted();
+ } finally {
+ completedLatch.countDown();
+ }
+ }
+
+ @Override
+ public void fail() {
+ synchronized (this) {
+ fRequestFailed = true;
+ }
+ done();
+ }
+
+ @Override
+ public void cancel() {
+ synchronized (this) {
+ fRequestCanceled = true;
+ }
+ done();
+ }
+
// ------------------------------------------------------------------------
// Object
// ------------------------------------------------------------------------
public boolean equals(Object other) {
if (other instanceof TmfEventRequest) {
TmfEventRequest request = (TmfEventRequest) other;
- return super.equals(other) && request.fRange.equals(fRange);
+ return request.fDataType == fDataType
+ && request.fIndex == fIndex
+ && request.fNbRequested == fNbRequested
+ && request.fRange.equals(fRange);
}
return false;
}
@Override
- @SuppressWarnings("nls")
public String toString() {
String name = getClass().getName();
int dot = name.lastIndexOf('.');
if (dot >= 0) {
name = name.substring(dot + 1);
}
- return "[" + name + "(" + getRequestId() + "," + getDataType().getSimpleName() + "," + getExecType()
- + "," + getRange() + "," + getIndex() + "," + getNbRequested() + ")]";
+ return '[' + name + '(' + getRequestId() + ',' + getDataType().getSimpleName() +
+ ',' + getExecType() + ',' + getRange() + ',' + getIndex() +
+ ',' + getNbRequested() + ")]"; //$NON-NLS-1$
}
}
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfLostEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
private long total;
public StatsTotalRequest(ITmfTrace trace, TmfTimeRange range) {
- super(trace.getEventType(), range, 0, TmfDataRequest.ALL_DATA,
- ITmfDataRequest.ExecutionType.BACKGROUND);
+ super(trace.getEventType(), range, 0, TmfEventRequest.ALL_DATA,
+ ITmfEventRequest.ExecutionType.BACKGROUND);
total = 0;
}
private final Map<String, Long> stats;
public StatsPerTypeRequest(ITmfTrace trace, TmfTimeRange range) {
- super(trace.getEventType(), range, 0, TmfDataRequest.ALL_DATA,
- ITmfDataRequest.ExecutionType.BACKGROUND);
+ super(trace.getEventType(), range, 0, TmfEventRequest.ALL_DATA,
+ ITmfEventRequest.ExecutionType.BACKGROUND);
this.stats = new HashMap<String, Long>();
}
new TmfTimestamp(borders[0], SCALE),
new TmfTimestamp(endTime, SCALE)),
0,
- TmfDataRequest.ALL_DATA,
- ITmfDataRequest.ExecutionType.BACKGROUND);
+ TmfEventRequest.ALL_DATA,
+ ITmfEventRequest.ExecutionType.BACKGROUND);
/* Prepare the results map, with all counts at 0 */
results = new TreeMap<Long, Long>();
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.linuxtools.tmf.core.analysis.IAnalysisModule;
-import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.statesystem.ITmfStateSystem;
* @see ITmfTraceIndexer
* @see ITmfEventParser
*/
-public interface ITmfTrace extends ITmfDataProvider {
+public interface ITmfTrace extends ITmfEventProvider {
// ------------------------------------------------------------------------
// Constants
import org.eclipse.linuxtools.tmf.core.TmfCommonConstants;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceOpenedSignal;
* @since 2.0
*/
@Override
- public synchronized ITmfContext armRequest(final ITmfDataRequest request) {
+ public synchronized ITmfContext armRequest(final ITmfEventRequest request) {
// Make sure we have something to read from
if (fTraces == null) {
return null;
}
- if (request instanceof ITmfEventRequest
- && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest) request).getRange().getStartTime())
- && request.getIndex() == 0)
- {
- final ITmfContext context = seekEvent(((ITmfEventRequest) request).getRange().getStartTime());
- ((ITmfEventRequest) request).setStartIndex((int) context.getRank());
+ if (!TmfTimestamp.BIG_BANG.equals(request.getRange().getStartTime())
+ && request.getIndex() == 0) {
+ final ITmfContext context = seekEvent(request.getRange().getStartTime());
+ request.setStartIndex((int) context.getRank());
return context;
}
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfAnalysisException;
import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalManager;
* @since 2.0
*/
@Override
- public synchronized ITmfContext armRequest(final ITmfDataRequest request) {
+ public synchronized ITmfContext armRequest(final ITmfEventRequest request) {
if (executorIsShutdown()) {
return null;
}
- if ((request instanceof ITmfEventRequest)
- && !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest) request).getRange().getStartTime())
- && (request.getIndex() == 0))
- {
- final ITmfContext context = seekEvent(((ITmfEventRequest) request).getRange().getStartTime());
- ((ITmfEventRequest) request).setStartIndex((int) context.getRank());
+ if (!TmfTimestamp.BIG_BANG.equals(request.getRange().getStartTime())
+ && (request.getIndex() == 0)) {
+ final ITmfContext context = seekEvent(request.getRange().getStartTime());
+ request.setStartIndex((int) context.getRank());
return context;
}
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.linuxtools.internal.tmf.core.Messages;
import org.eclipse.linuxtools.internal.tmf.core.trace.indexer.TmfMemoryIndex;
-import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
* @param trace the trace to index
*/
public TmfCheckpointIndexer(final ITmfTrace trace) {
- this(trace, TmfDataProvider.DEFAULT_BLOCK_SIZE);
+ this(trace, TmfEventProvider.DEFAULT_BLOCK_SIZE);
}
/**
// Build a background request for all the trace data. The index is
// updated as we go by readNextEvent().
fIndexingRequest = new TmfEventRequest(ITmfEvent.class,
- range, offset, TmfDataRequest.ALL_DATA,
- ITmfDataRequest.ExecutionType.BACKGROUND) {
+ range, offset, TmfEventRequest.ALL_DATA,
+ ITmfEventRequest.ExecutionType.BACKGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
/**
* This TMF Requests exports traces to text files.
* @author Xavier Raynaud <xavier.raynaud@kalray.eu>
*/
-public class ExportToTextRequest extends TmfDataRequest {
+public class ExportToTextRequest extends TmfEventRequest {
private final Writer fWriter;
private final ITmfFilter fFilter;
* the {@link TmfEventsTable} requesting the export (may be <code>null</code>)
*/
public ExportToTextRequest(Writer w, ITmfFilter filter, TmfEventsTable table) {
- super(ITmfEvent.class, 0, TmfDataRequest.ALL_DATA, ExecutionType.FOREGROUND);
+ super(ITmfEvent.class, TmfTimeRange.ETERNITY, 0, TmfEventRequest.ALL_DATA, ExecutionType.FOREGROUND);
this.fWriter = w;
this.fFilter = filter;
this.fTable = table;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
-import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
/**
public int getFilteredEventIndex(final long rank) {
int current;
int startRank;
- TmfDataRequest request;
+ TmfEventRequest request;
final ITmfFilter filter = fFilter;
synchronized (this) {
int start = 0;
final int index = current * fCacheSize;
- class DataRequest extends TmfDataRequest {
+ class DataRequest extends TmfEventRequest {
ITmfFilter requestFilter;
int requestRank;
int requestIndex;
DataRequest(Class<? extends ITmfEvent> dataType, ITmfFilter reqFilter, int start, int nbRequested) {
- super(dataType, start, nbRequested,
- TmfDataRequest.ExecutionType.FOREGROUND);
+ super(dataType, TmfTimeRange.ETERNITY, start, nbRequested,
+ TmfEventRequest.ExecutionType.FOREGROUND);
requestFilter = reqFilter;
requestRank = start;
requestIndex = index;
}
}
- request = new DataRequest(ITmfEvent.class, filter, startRank, TmfDataRequest.ALL_DATA);
- ((ITmfDataProvider) fTrace).sendRequest(request);
+ request = new DataRequest(ITmfEvent.class, filter, startRank, TmfEventRequest.ALL_DATA);
+ ((ITmfEventProvider) fTrace).sendRequest(request);
try {
request.waitForCompletion();
return ((DataRequest) request).getFilteredIndex();
if (fFilter == null) {
nbRequested = fCache.length;
} else {
- nbRequested = TmfDataRequest.ALL_DATA;
+ nbRequested = TmfEventRequest.ALL_DATA;
int i = startIndex / fCacheSize;
if (i < fFilterIndex.size()) {
skipCount = startIndex - (i * fCacheSize);
}
}
- TmfDataRequest request = new TmfDataRequest(ITmfEvent.class,
+ TmfEventRequest request = new TmfEventRequest(ITmfEvent.class,
+ TmfTimeRange.ETERNITY,
startIndex,
nbRequested,
- TmfDataRequest.ExecutionType.FOREGROUND) {
+ TmfEventRequest.ExecutionType.FOREGROUND) {
private int count = 0;
private long rank = startIndex;
@Override
}
};
- ((ITmfDataProvider) fTrace).sendRequest(request);
+ ((ITmfEventProvider) fTrace).sendRequest(request);
try {
request.waitForCompletion();
} catch (InterruptedException e) {
import org.eclipse.linuxtools.internal.tmf.ui.Messages;
import org.eclipse.linuxtools.internal.tmf.ui.commands.ExportToTextCommandHandler;
import org.eclipse.linuxtools.internal.tmf.ui.dialogs.MultiLineInputDialog;
-import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.ITmfEventProvider;
import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;
import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterMatchesNode;
import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterNode;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfEventFilterAppliedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfEventSearchAppliedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfTimeSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
*/
protected class FilterThread extends Thread {
private final ITmfFilterTreeNode filter;
- private TmfDataRequest request;
+ private TmfEventRequest request;
private boolean refreshBusy = false;
private boolean refreshPending = false;
private final Object syncObj = new Object();
if (nbRequested <= 0) {
return;
}
- request = new TmfDataRequest(ITmfEvent.class, (int) fFilterCheckCount,
- nbRequested, ExecutionType.BACKGROUND) {
+ request = new TmfEventRequest(ITmfEvent.class, TmfTimeRange.ETERNITY,
+ (int) fFilterCheckCount, nbRequested, ExecutionType.BACKGROUND) {
@Override
public void handleData(final ITmfEvent event) {
super.handleData(event);
fFilterCheckCount++;
}
};
- ((ITmfDataProvider) fTrace).sendRequest(request);
+ ((ITmfEventProvider) fTrace).sendRequest(request);
try {
request.waitForCompletion();
} catch (final InterruptedException e) {
private int direction;
private long rank;
private long foundRank = -1;
- private TmfDataRequest request;
+ private TmfEventRequest request;
private ITmfTimestamp foundTimestamp = null;
/**
if (direction == Direction.BACKWARD) {
rank = Math.max(0, rank - fTrace.getCacheSize() + 1);
}
- request = new TmfDataRequest(ITmfEvent.class, (int) rank, nbRequested, ExecutionType.BACKGROUND) {
+ request = new TmfEventRequest(ITmfEvent.class, TmfTimeRange.ETERNITY,
+ (int) rank, nbRequested, ExecutionType.BACKGROUND) {
long currentRank = rank;
@Override
currentRank++;
}
};
- ((ITmfDataProvider) fTrace).sendRequest(request);
+ ((ITmfEventProvider) fTrace).sendRequest(request);
try {
request.waitForCompletion();
if (request.isCancelled()) {
// Create a request for one event that will be queued after other ongoing requests. When this request is completed
// do the work to select the actual event with the timestamp specified in the signal. This procedure prevents
// the method fTrace.getRank() from interfering and delaying ongoing requests.
- final TmfDataRequest subRequest = new TmfDataRequest(ITmfEvent.class,
- 0, 1, ExecutionType.FOREGROUND) {
+ final TmfEventRequest subRequest = new TmfEventRequest(ITmfEvent.class,
+ TmfTimeRange.ETERNITY, 0, 1, ExecutionType.FOREGROUND) {
TmfTimestamp ts = new TmfTimestamp(signal.getBeginTime());
}
};
- ((ITmfDataProvider) fTrace).sendRequest(subRequest);
+ ((ITmfEventProvider) fTrace).sendRequest(subRequest);
}
}
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfStatsUpdatedSignal;
* @param request
* The request to be canceled
*/
- protected void cancelOngoingRequest(ITmfDataRequest request) {
+ protected void cancelOngoingRequest(ITmfEventRequest request) {
if (request != null && !request.isCompleted()) {
request.cancel();
}
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfLostEvent;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
@Deprecated
public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range,
int rank, int nbEvents, int blockSize,
- ITmfDataRequest.ExecutionType execType) {
+ ITmfEventRequest.ExecutionType execType) {
super(ITmfEvent.class, range, rank, nbEvents, execType);
fHistogram = histogram;
if (execType == ExecutionType.FOREGROUND) {
*/
public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range,
int rank, int nbEvents, int blockSize,
- ITmfDataRequest.ExecutionType execType, boolean fullRange) {
+ ITmfEventRequest.ExecutionType execType, boolean fullRange) {
super(ITmfEvent.class, range, rank, nbEvents, execType);
fHistogram = histogram;
fFullRange = fullRange;
*
* @param event
* a event from the trace
- * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent)
+ * @see org.eclipse.linuxtools.tmf.core.request.TmfEventRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent)
*/
@Override
public void handleData(ITmfEvent event) {
* Complete the request. It also notifies the histogram model about the
* completion.
*
- * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleCompleted()
+ * @see org.eclipse.linuxtools.tmf.core.request.TmfEventRequest#handleCompleted()
*/
@Override
public void handleCompleted() {
import org.eclipse.jface.action.Separator;
import org.eclipse.linuxtools.internal.tmf.ui.Activator;
import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest.ExecutionType;
+import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalThrottler;
fTimeRangeHistogram.setTimeRange(startTime, endTime - startTime);
int cacheSize = fTrace.getCacheSize();
- fTimeRangeRequest = new HistogramRequest(fTimeRangeHistogram.getDataModel(), timeRange, 0, TmfDataRequest.ALL_DATA, cacheSize, ExecutionType.FOREGROUND, false);
+ fTimeRangeRequest = new HistogramRequest(fTimeRangeHistogram.getDataModel(), timeRange, 0, TmfEventRequest.ALL_DATA, cacheSize, ExecutionType.FOREGROUND, false);
fTrace.sendRequest(fTimeRangeRequest);
}
}
int cacheSize = fTrace.getCacheSize();
fFullTraceRequest = new HistogramRequest(fFullTraceHistogram.getDataModel(), fullRange, (int) fFullTraceHistogram.fDataModel.getNbEvents(),
- TmfDataRequest.ALL_DATA, cacheSize, ExecutionType.BACKGROUND, true);
+ TmfEventRequest.ALL_DATA, cacheSize, ExecutionType.BACKGROUND, true);
fTrace.sendRequest(fFullTraceRequest);
}
package org.eclipse.linuxtools.tmf.ui.views.statistics;
import org.eclipse.core.resources.IResource;
-import org.eclipse.linuxtools.tmf.core.component.TmfDataProvider;
+import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfStartSynchSignal;
TmfTraceRangeUpdatedSignal updateSignal = new TmfTraceRangeUpdatedSignal(this, fTrace, fTrace.getTimeRange());
// Synchronizes the requests to make them coalesced
- if (fTrace instanceof TmfDataProvider) {
- ((TmfDataProvider) fTrace).startSynch(new TmfStartSynchSignal(0));
+ if (fTrace instanceof TmfEventProvider) {
+ ((TmfEventProvider) fTrace).startSynch(new TmfStartSynchSignal(0));
}
for (ITmfViewer viewer : fStatsViewers.getViewers()) {
TmfStatisticsViewer statsViewer = (TmfStatisticsViewer) viewer;
statsViewer.sendPartialRequestOnNextUpdate();
statsViewer.traceRangeUpdated(updateSignal);
}
- if (fTrace instanceof TmfDataProvider) {
- ((TmfDataProvider) fTrace).endSynch(new TmfEndSynchSignal(0));
+ if (fTrace instanceof TmfEventProvider) {
+ ((TmfEventProvider) fTrace).endSynch(new TmfEndSynchSignal(0));
}
} else {
/*
import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
-import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignal;
TmfTimeRange window = TmfTimeRange.ETERNITY;
- fIndexRequest = new TmfEventRequest(ITmfEvent.class, window, 0, TmfDataRequest.ALL_DATA, ITmfDataRequest.ExecutionType.BACKGROUND) {
+ fIndexRequest = new TmfEventRequest(ITmfEvent.class, window, 0,
+ TmfEventRequest.ALL_DATA, ITmfEventRequest.ExecutionType.BACKGROUND) {
private ITmfTimestamp fFirstTime = null;
private ITmfTimestamp fLastTime = null;
window = TmfTimeRange.ETERNITY;
}
- fPageRequest = new TmfEventRequest(ITmfEvent.class, window, 0, TmfDataRequest.ALL_DATA, ITmfDataRequest.ExecutionType.FOREGROUND) {
+ fPageRequest = new TmfEventRequest(ITmfEvent.class, window, 0,
+ TmfEventRequest.ALL_DATA, ITmfEventRequest.ExecutionType.FOREGROUND) {
private final List<ITmfSyncSequenceDiagramEvent> fSdEvent = new ArrayList<ITmfSyncSequenceDiagramEvent>();
@Override
*/
public SearchJob(Criteria findCriteria, TmfTimeRange window) {
super(Messages.TmfUml2SDSyncLoader_SearchJobDescrition);
- fSearchRequest = new SearchEventRequest(window, TmfDataRequest.ALL_DATA, ITmfDataRequest.ExecutionType.FOREGROUND, findCriteria);
+ fSearchRequest = new SearchEventRequest(window, TmfEventRequest.ALL_DATA,
+ ITmfEventRequest.ExecutionType.FOREGROUND, findCriteria);
}
@Override