tmf: Merge TmfDataProvider and TmfEventProvider together
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 4 Oct 2013 20:50:46 +0000 (16:50 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Fri, 22 Nov 2013 21:26:02 +0000 (16:26 -0500)
Initially, there was a plan to support "traces" that had no timestamps,
and this would be handled by a DataProvider. Turns out the whole
framework requires some sort of timestamp nowadays, so this distinction
is no longer necessary.

(If a trace really does not have any timestamp, they could just use the
event rank as a sort of dummy timestamp, which is quite intuitive anyway).

This also merges Tmf{Data|Event}Request and TmfCoalesced{Data|Event}Request.

Change-Id: I734bb297d252d56902e1eb0534669b0d4088d911
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
Reviewed-on: https://git.eclipse.org/r/17052
Tested-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
IP-Clean: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
48 files changed:
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/TmfEventProviderTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/component/TmfProviderManagerTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/ctfadaptor/CtfTmfLostEventsTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/AllTests.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedDataRequestTest.java [deleted file]
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedEventRequestTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfDataRequestTest.java [deleted file]
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfEventRequestTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfSchedulerBenchmark.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfSchedulerTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfExperimentTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfMultiTraceExperimentTest.java
org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/trace/TmfTraceTest.java
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfClientStub.java
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfDataProviderStub.java [deleted file]
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfEventProviderStub.java
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfSyntheticEventProviderStub.java
org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/request/TmfDataRequestStub.java [deleted file]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/TmfCoreTracer.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/component/TmfEventThread.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/component/TmfProviderManager.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedDataRequest.java [deleted file]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedEventRequest.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfRequestExecutor.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/HistoryBuilder.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/statesystem/backends/partial/PartialHistoryBackend.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfDataProvider.java [deleted file]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfEventProvider.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java [deleted file]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfEventProvider.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/matching/TmfEventMatching.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/ITmfDataRequest.java [deleted file]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/ITmfEventRequest.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfDataRequest.java [deleted file]
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfEventRequest.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/statistics/TmfEventsStatistics.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/ITmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfExperiment.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/TmfTrace.java
org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/trace/indexer/checkpoint/TmfCheckpointIndexer.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/commands/ExportToTextRequest.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsCache.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/statistics/TmfStatisticsViewer.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramRequest.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/histogram/HistogramView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/statistics/TmfStatisticsView.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/uml2sd/loader/TmfUml2SDSyncLoader.java

index 904f6f7fae16b2ff0eb52bd149be706db178e9fb..04a5317cf9ac73c7751eec1ab6730f8aac082aaa 100644 (file)
@@ -22,9 +22,9 @@ import java.io.IOException;
 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;
@@ -79,7 +79,7 @@ public class TmfEventProviderTest {
     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);
@@ -106,9 +106,9 @@ public class TmfEventProviderTest {
         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,
@@ -150,9 +150,9 @@ public class TmfEventProviderTest {
         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);
 
@@ -255,9 +255,9 @@ public class TmfEventProviderTest {
         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) {
@@ -345,7 +345,7 @@ public class TmfEventProviderTest {
 
         // 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);
index 2b61fb6f566f979457a691f15320678a310607cf..b12ea0e1d3c02a28a60f235bbad3a8142a7d7944 100644 (file)
@@ -17,10 +17,10 @@ import static org.junit.Assert.assertEquals;
 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;
 
@@ -33,13 +33,13 @@ public class TmfProviderManagerTest {
     // 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;
         }
 
@@ -49,18 +49,18 @@ public class TmfProviderManagerTest {
         }
 
         @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;
         }
 
@@ -70,7 +70,7 @@ public class TmfProviderManagerTest {
         }
 
         @Override
-        public boolean isCompleted(ITmfDataRequest request, ITmfEvent data, int nbRead) {
+        public boolean isCompleted(ITmfEventRequest request, ITmfEvent data, int nbRead) {
             return false;
         }
     }
@@ -78,13 +78,13 @@ public class TmfProviderManagerTest {
     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;
         }
 
@@ -94,7 +94,7 @@ public class TmfProviderManagerTest {
         }
 
         @Override
-        public boolean isCompleted(ITmfDataRequest request, ITmfEvent data, int nbRead) {
+        public boolean isCompleted(ITmfEventRequest request, ITmfEvent data, int nbRead) {
             return false;
         }
     }
@@ -108,7 +108,7 @@ public class TmfProviderManagerTest {
      */
     @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);
@@ -124,7 +124,7 @@ public class TmfProviderManagerTest {
         // 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]);
 
@@ -152,7 +152,7 @@ public class TmfProviderManagerTest {
         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) {
@@ -209,7 +209,7 @@ public class TmfProviderManagerTest {
         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]);
@@ -219,7 +219,7 @@ public class TmfProviderManagerTest {
             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]);
 
@@ -307,7 +307,7 @@ public class TmfProviderManagerTest {
         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]);
index dc1f50827c8a50cc9485c2ab3641835a21fc8a92..f0b3af170023776a025cae1410d795fd65b6b2aa 100644 (file)
@@ -22,7 +22,6 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfTimestamp;
 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;
@@ -233,7 +232,7 @@ public class CtfTmfLostEventsTest {
 
         public EventCountRequest() {
             super(CtfTmfEvent.class, TmfTimeRange.ETERNITY, 0,
-                    TmfDataRequest.ALL_DATA, ExecutionType.FOREGROUND);
+                    TmfEventRequest.ALL_DATA, ExecutionType.FOREGROUND);
         }
 
         @Override
index 4bbb06f20e384f11fc34ed293bd563097423aa84..1dbe93d038b37f542dfb582537beb72dcc2d55c9 100644 (file)
@@ -21,9 +21,7 @@ import org.junit.runners.Suite;
  */
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
-    TmfCoalescedDataRequestTest.class,
     TmfCoalescedEventRequestTest.class,
-    TmfDataRequestTest.class,
     TmfEventRequestTest.class,
     TmfSchedulerTest.class
 })
diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedDataRequestTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfCoalescedDataRequestTest.java
deleted file mode 100644 (file)
index 6869cc8..0000000
+++ /dev/null
@@ -1,465 +0,0 @@
-/*******************************************************************************
- * 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]);
-    }
-
-}
index 6f26ac60d457153a9f323934c8d76a55e3033e18..e09d68ea2e9127717a25da95db69daf872489f69 100644 (file)
@@ -26,13 +26,11 @@ import java.util.Vector;
 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;
@@ -75,7 +73,7 @@ public class TmfCoalescedEventRequestTest {
 
     @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);
@@ -175,30 +173,6 @@ public class TmfCoalescedEventRequestTest {
         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
     // ------------------------------------------------------------------------
@@ -423,7 +397,7 @@ public class TmfCoalescedEventRequestTest {
     TmfEventRequest request2;
     TmfEventRequest request3;
 
-    ITmfDataProvider[] providers;
+    ITmfEventProvider[] providers;
 
     private static class TmfTestTriggerSignal extends TmfSignal {
         public final boolean forceCancel;
diff --git a/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfDataRequestTest.java b/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/request/TmfDataRequestTest.java
deleted file mode 100644 (file)
index b42c0be..0000000
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * 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]);
-    }
-
-}
index aff6b7c0b4e4041a18725c4305d5f47a1f9e1011..d10ce0c02e2ab47cbc6085b95b932cb2188b4e87 100644 (file)
@@ -15,10 +15,10 @@ 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.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;
@@ -54,7 +54,7 @@ public class TmfEventRequestTest {
 
     @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);
@@ -108,8 +108,11 @@ public class TmfEventRequestTest {
         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());
@@ -130,7 +133,7 @@ public class TmfEventRequestTest {
         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());
index f9600b757630183dd0cb93838e9b18fb84232150..4f07b30f8832865b10681363b48d85ab606f4c4f 100644 (file)
@@ -16,7 +16,6 @@ import java.io.PrintWriter;
 
 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;
@@ -238,7 +237,7 @@ public class TmfSchedulerBenchmark {
             super(trace.getEventType(),
                     timeRange,
                     0,
-                    TmfDataRequest.ALL_DATA,
+                    TmfEventRequest.ALL_DATA,
                     ExecutionType.BACKGROUND);
             startTime = System.nanoTime();
         }
@@ -303,7 +302,7 @@ public class TmfSchedulerBenchmark {
             super(trace.getEventType(),
                     timeRange,
                     0,
-                    TmfDataRequest.ALL_DATA,
+                    TmfEventRequest.ALL_DATA,
                     ExecutionType.FOREGROUND);
             startTime = System.nanoTime();
         }
index 8681002afa412a1cfbe38280fc32575832b54348..09a9b8c847c17d024b753984b2eb1a2a6109aa73 100644 (file)
@@ -27,7 +27,6 @@ import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
 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;
@@ -385,7 +384,7 @@ public class TmfSchedulerTest {
             super(fixture.getEventType(),
                     timeRange,
                     0,
-                    TmfDataRequest.ALL_DATA,
+                    TmfEventRequest.ALL_DATA,
                     ExecutionType.BACKGROUND);
             backgroundName = getExecType().toString() + ++fBackgroundId;
         }
@@ -414,7 +413,7 @@ public class TmfSchedulerTest {
             super(fixture.getEventType(),
                     timeRange,
                     0,
-                    TmfDataRequest.ALL_DATA,
+                    TmfEventRequest.ALL_DATA,
                     ExecutionType.FOREGROUND);
             foregroundName = getExecType().toString() + ++fForegroundId;
         }
index bcde123c64600297045ce67f4ae6631ff7143744..15206a7ff5210ce3a5cd87daee0342a11c4ef72c 100644 (file)
@@ -35,8 +35,7 @@ import org.eclipse.linuxtools.internal.tmf.core.trace.TmfExperimentLocation;
 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;
@@ -853,7 +852,7 @@ public class TmfExperimentTest {
 
     @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;
 
index 10924ac64de3671b167699e711bffa66a39930bf..3600a5cd3c8d9f70725ccd3047d6b9cc864a8797 100644 (file)
@@ -31,9 +31,8 @@ import org.eclipse.core.runtime.Path;
 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;
@@ -702,7 +701,7 @@ public class TmfMultiTraceExperimentTest {
 
     @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;
 
index fcbfb569608b1da6f081e212a588fb8f30a7c553..30e8577ef6cfa43409e2fcd2542d4a8db62e79a7 100644 (file)
@@ -32,11 +32,10 @@ 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.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;
@@ -1160,7 +1159,7 @@ public class TmfTraceTest {
                 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();
 
@@ -1189,7 +1188,7 @@ public class TmfTraceTest {
                 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();
 
@@ -1219,7 +1218,7 @@ public class TmfTraceTest {
                 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();
 
@@ -1250,7 +1249,7 @@ public class TmfTraceTest {
                 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();
 
@@ -1271,17 +1270,18 @@ public class TmfTraceTest {
         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();
 
@@ -1319,7 +1319,7 @@ public class TmfTraceTest {
                 }
             }
         };
-        final ITmfDataProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
+        final ITmfEventProvider[] providers = TmfProviderManager.getProviders(ITmfEvent.class, TmfTraceStub.class);
         providers[0].sendRequest(request);
         request.waitForCompletion();
 
index 776a194bce1b32597378eeab344fbe46bfe52f28..6aac5a682fe27712dba0c8042fae2d79da45f0cd 100644 (file)
@@ -14,7 +14,7 @@ package org.eclipse.linuxtools.tmf.tests.stubs.component;
 
 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;
 
 /**
@@ -25,7 +25,7 @@ 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");
diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfDataProviderStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/component/TmfDataProviderStub.java
deleted file mode 100644 (file)
index b4fc281..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * 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;
-    }
-
-}
index cd078952a80c29e43681cb64ba70b295b641cc27..84397c7dcb686f5c9dc4bf355def72048b6a39a0 100644 (file)
@@ -22,7 +22,6 @@ import org.eclipse.core.runtime.Path;
 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;
@@ -67,12 +66,9 @@ public class TmfEventProviderStub extends TmfEventProvider {
     // ------------------------------------------------------------------------
 
     @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
index 524d5127375111e812a903ba11769bbdac7bf181..ecf96aec5a4d46acad54aadfacd08ff141987d98 100644 (file)
@@ -15,13 +15,12 @@ package org.eclipse.linuxtools.tmf.tests.stubs.component;
 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;
@@ -42,20 +41,13 @@ public class TmfSyntheticEventProviderStub extends TmfEventProvider {
     }
 
     @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
diff --git a/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/request/TmfDataRequestStub.java b/org.eclipse.linuxtools.tmf.core.tests/stubs/org/eclipse/linuxtools/tmf/tests/stubs/request/TmfDataRequestStub.java
deleted file mode 100644 (file)
index e36dd2c..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * 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);
-    }
-
-}
index e4a57a76ab623b03170cc5b13361339a07d83472..d40f15db0339bf7c6f962436fa91ceadf9fbf030 100644 (file)
@@ -18,9 +18,9 @@ import java.io.IOException;
 
 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;
 
 /**
@@ -211,7 +211,7 @@ public class TmfCoreTracer {
     }
 
     @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);
@@ -228,7 +228,7 @@ public class TmfCoreTracer {
     }
 
     @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());
index 896dc577df5d2afd2ed13641676144541f7a7563..f15ebed8a81567dd19fafe9a79ba914a66691da9 100644 (file)
@@ -15,11 +15,11 @@ package org.eclipse.linuxtools.internal.tmf.core.component;
 
 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;
 
 /**
@@ -38,12 +38,12 @@ public class TmfEventThread implements Runnable {
     /**
      * 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
@@ -76,7 +76,7 @@ public class TmfEventThread implements Runnable {
      * @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;
@@ -111,14 +111,14 @@ public class TmfEventThread implements Runnable {
     /**
      * @return The event provider
      */
-    public ITmfDataProvider getProvider() {
+    public ITmfEventProvider getProvider() {
         return fProvider;
     }
 
     /**
      * @return The event request
      */
-    public ITmfDataRequest getRequest() {
+    public ITmfEventRequest getRequest() {
         return fRequest;
     }
 
index 3393b33ca9e7a4a2eeb3636d6bf0a00aeb6aeea0..63d7d4376d85297f6dd66418e703f48c93012714 100644 (file)
@@ -17,7 +17,7 @@ import java.util.HashMap;
 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;
 
 /**
@@ -28,85 +28,95 @@ 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);
+    }
 
 }
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedDataRequest.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/internal/tmf/core/request/TmfCoalescedDataRequest.java
deleted file mode 100644 (file)
index 2b8d0b7..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-/*******************************************************************************
- * 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() + ")]";
-    }
-}
index 1cd07f01465dcaff768c635798da80ec2a7d57de..e990f7e791f6a533409bbf968a4943074c1f190c 100644 (file)
@@ -8,31 +8,41 @@
  *
  * 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
@@ -52,7 +62,7 @@ public class TmfCoalescedEventRequest extends TmfCoalescedDataRequest implements
      *            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
      */
@@ -61,7 +71,7 @@ public class TmfCoalescedEventRequest extends TmfCoalescedDataRequest implements
             long index,
             int nbRequested,
             ExecutionType priority) {
-        super(ITmfEvent.class, index, nbRequested, priority);
+        super(ITmfEvent.class, null, index, nbRequested, priority);
         fRange = range;
 
         if (TmfCoreTracer.isRequestTraced()) {
@@ -69,7 +79,7 @@ public class TmfCoalescedEventRequest extends TmfCoalescedDataRequest implements
             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();
@@ -77,35 +87,75 @@ public class TmfCoalescedEventRequest extends TmfCoalescedDataRequest implements
         }
     }
 
+    @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) {
@@ -116,36 +166,41 @@ public class TmfCoalescedEventRequest extends TmfCoalescedDataRequest implements
         }
     }
 
+    /**
+     * @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);
                         }
                     }
                 }
@@ -153,18 +208,89 @@ public class TmfCoalescedEventRequest extends TmfCoalescedDataRequest implements
         }
     }
 
-    // ------------------------------------------------------------------------
-    // 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;
+
     }
 
     // ------------------------------------------------------------------------
@@ -184,10 +310,7 @@ public class TmfCoalescedEventRequest extends TmfCoalescedDataRequest implements
             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;
     }
index 09be187272f1c6865ae4f44ed1166acd8ce74629..d62fcb7d1ae54edad80d2632dc8f5b28ccce49ee 100644 (file)
@@ -24,7 +24,7 @@ import java.util.concurrent.Executors;
 
 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
index 6abe91c55da31b3fc8fbafdcca943efd23e941b5..b1c3c28385fdfbe6434b851f29cef52d9035dd6f 100644 (file)
@@ -17,8 +17,7 @@ import java.io.IOException;
 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;
@@ -233,8 +232,8 @@ class StateSystemBuildRequest extends TmfEventRequest {
         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();
index a73c5c0e8d223a9cf4bbcebc5ce509d47243979a..22d22e90f30f1cbed11e9e51dd3ec929b2ad65b2 100644 (file)
@@ -26,9 +26,7 @@ import org.eclipse.linuxtools.tmf.core.exceptions.StateSystemDisposedException;
 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;
@@ -292,8 +290,8 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
             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;
@@ -333,8 +331,8 @@ public class PartialHistoryBackend implements IStateHistoryBackend {
             super(sci.getExpectedEventType(),
                     range,
                     0,
-                    TmfDataRequest.ALL_DATA,
-                    ITmfDataRequest.ExecutionType.BACKGROUND);
+                    TmfEventRequest.ALL_DATA,
+                    ITmfEventRequest.ExecutionType.BACKGROUND);
             this.sci = sci;
             this.trace = sci.getTrace();
         }
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfDataProvider.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfDataProvider.java
deleted file mode 100644 (file)
index 6d5f074..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * 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);
-}
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfEventProvider.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/ITmfEventProvider.java
new file mode 100644 (file)
index 0000000..7cc9185
--- /dev/null
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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);
+}
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/component/TmfDataProvider.java
deleted file mode 100644 (file)
index 849fc2a..0000000
+++ /dev/null
@@ -1,433 +0,0 @@
-/*******************************************************************************
- * 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();
-            }
-        }
-    }
-
-}
index 7f661679f4d009c3f8145b21721057102a0e2a01..013a261999e8f29452fcd897a2c4659357e27487 100644 (file)
@@ -7,26 +7,78 @@
  * 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
@@ -37,81 +89,338 @@ public abstract class TmfEventProvider extends TmfDataProvider {
      */
     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();
+            }
         }
     }
 
index fe694f628f0b7e074fdbbaaca1b8ab9fe1b279cb..ee8e6b85ca715413e01b67b7bcf64e2663932c77 100644 (file)
@@ -20,8 +20,7 @@ import java.util.Map;
 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;
@@ -244,8 +243,8 @@ class EventMatchingBuildRequest extends TmfEventRequest {
         super(CtfTmfEvent.class,
                 TmfTimeRange.ETERNITY,
                 0,
-                TmfDataRequest.ALL_DATA,
-                ITmfDataRequest.ExecutionType.FOREGROUND);
+                TmfEventRequest.ALL_DATA,
+                ITmfEventRequest.ExecutionType.FOREGROUND);
         this.matching = matching;
         this.traceno = traceno;
     }
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/ITmfDataRequest.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/ITmfDataRequest.java
deleted file mode 100644 (file)
index 36dbdbf..0000000
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * 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();
-}
index 811626796fb595024af4a838e9dd25d7f957c894..bf51365bd7e97e803ae64cbaa50b2912751d621c 100644 (file)
  *
  * 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);
 
diff --git a/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfDataRequest.java b/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/request/TmfDataRequest.java
deleted file mode 100644 (file)
index 2076525..0000000
+++ /dev/null
@@ -1,463 +0,0 @@
-/*******************************************************************************
- * 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&lt;DataType[]&gt; request = new TmfDataRequest&lt;DataType[]&gt;(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 + ")]";
-    }
-}
index 32dd8fb211545f591615e6bfaade76d168fe6dc9..e6ccfd50139c663373a161a12b42badf3b75afbc 100644 (file)
  *
  * 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.
@@ -54,22 +148,33 @@ public abstract class TmfEventRequest extends TmfDataRequest implements ITmfEven
      *            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();
@@ -77,14 +182,67 @@ public abstract class TmfEventRequest extends TmfDataRequest implements ITmfEven
         }
     }
 
+    /**
+     * 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;
@@ -95,17 +253,142 @@ public abstract class TmfEventRequest extends TmfDataRequest implements ITmfEven
     // ------------------------------------------------------------------------
 
     /**
-     * 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
     // ------------------------------------------------------------------------
@@ -120,21 +403,24 @@ public abstract class TmfEventRequest extends TmfDataRequest implements ITmfEven
     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$
     }
 
 }
index bd709647c4deba1caaf0a61ec8901afa6d09f3c5..f5bf45f7c49f7043f546f718a797209c674e8cef 100644 (file)
@@ -21,8 +21,7 @@ import java.util.TreeMap;
 
 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;
@@ -224,8 +223,8 @@ public class TmfEventsStatistics implements ITmfStatistics {
         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;
         }
 
@@ -252,8 +251,8 @@ public class TmfEventsStatistics implements ITmfStatistics {
         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>();
         }
 
@@ -317,8 +316,8 @@ public class TmfEventsStatistics implements ITmfStatistics {
                             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>();
index 292102e19452c55d38db11b7eb396d205ff15b04..896ae5f81332f04df4aa2821554ed2ea76e0f989 100644 (file)
@@ -22,7 +22,7 @@ import org.eclipse.core.resources.IProject;
 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;
@@ -123,7 +123,7 @@ import org.eclipse.linuxtools.tmf.core.trace.location.ITmfLocation;
  * @see ITmfTraceIndexer
  * @see ITmfEventParser
  */
-public interface ITmfTrace extends ITmfDataProvider {
+public interface ITmfTrace extends ITmfEventProvider {
 
     // ------------------------------------------------------------------------
     // Constants
index 106492e92069d8c1f7df8882c90a302ba0ea52b1..b999bf41cbfafbcf4e645dcf27797f5966b12bd2 100644 (file)
@@ -32,7 +32,6 @@ import org.eclipse.linuxtools.internal.tmf.core.trace.TmfLocationArray;
 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;
@@ -273,19 +272,17 @@ public class TmfExperiment extends TmfTrace implements ITmfEventParser, ITmfPers
      * @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;
 
         }
index 666708645d6dbf85c40f26f8d034e158da09f435..f5f018ea3fc3c51a2b32726a606bbdbbf8873408 100644 (file)
@@ -45,7 +45,6 @@ import org.eclipse.linuxtools.tmf.core.component.TmfEventProvider;
 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;
@@ -709,16 +708,14 @@ public abstract class TmfTrace extends TmfEventProvider implements ITmfTrace {
      * @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;
 
         }
index 9e830e326a38353c8af5043bc9eafc81176938e1..183562ca651335629e1d6ab9bb1c6b687ee9ced8 100644 (file)
@@ -18,11 +18,9 @@ import org.eclipse.core.runtime.Status;
 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;
@@ -88,7 +86,7 @@ public class TmfCheckpointIndexer implements ITmfTraceIndexer {
      * @param trace the trace to index
      */
     public TmfCheckpointIndexer(final ITmfTrace trace) {
-        this(trace, TmfDataProvider.DEFAULT_BLOCK_SIZE);
+        this(trace, TmfEventProvider.DEFAULT_BLOCK_SIZE);
     }
 
     /**
@@ -186,8 +184,8 @@ public class TmfCheckpointIndexer implements ITmfTraceIndexer {
         // 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);
index 339ba80fb1087dbd287fb756f4ab2441a7894faf..eee476a518fdb483ec9efa319fafec7679c29438 100644 (file)
@@ -18,14 +18,15 @@ import java.io.Writer;
 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;
@@ -42,7 +43,7 @@ public class ExportToTextRequest extends TmfDataRequest {
      *            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;
index 9135b4669fd7ce94ba8fe9a27395d633fda635a2..7cafec194498465533e09e17b2325c3af9ccc2e7 100644 (file)
@@ -21,10 +21,11 @@ import org.eclipse.core.runtime.IStatus;
 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;
 
 /**
@@ -199,7 +200,7 @@ public class TmfEventsCache {
     public int getFilteredEventIndex(final long rank) {
         int current;
         int startRank;
-        TmfDataRequest request;
+        TmfEventRequest request;
         final ITmfFilter filter = fFilter;
         synchronized (this) {
             int start = 0;
@@ -235,14 +236,14 @@ public class TmfEventsCache {
 
         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;
@@ -269,8 +270,8 @@ public class TmfEventsCache {
             }
         }
 
-        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();
@@ -324,7 +325,7 @@ public class TmfEventsCache {
                 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);
@@ -332,10 +333,11 @@ public class TmfEventsCache {
                     }
                 }
 
-                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
@@ -370,7 +372,7 @@ public class TmfEventsCache {
                     }
                 };
 
-                ((ITmfDataProvider) fTrace).sendRequest(request);
+                ((ITmfEventProvider) fTrace).sendRequest(request);
                 try {
                     request.waitForCompletion();
                 } catch (InterruptedException e) {
index 105a466fde411b6702dd05bf4896b3e962b784d8..b0de03965665f7f5adc34ec8980ebd69197f8660 100644 (file)
@@ -75,7 +75,7 @@ import org.eclipse.linuxtools.internal.tmf.ui.Activator;
 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;
@@ -88,14 +88,15 @@ import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
 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;
@@ -1446,7 +1447,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
      */
     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();
@@ -1471,8 +1472,8 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
             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);
@@ -1491,7 +1492,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                     fFilterCheckCount++;
                 }
             };
-            ((ITmfDataProvider) fTrace).sendRequest(request);
+            ((ITmfEventProvider) fTrace).sendRequest(request);
             try {
                 request.waitForCompletion();
             } catch (final InterruptedException e) {
@@ -1632,7 +1633,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
         private int direction;
         private long rank;
         private long foundRank = -1;
-        private TmfDataRequest request;
+        private TmfEventRequest request;
         private ITmfTimestamp foundTimestamp = null;
 
         /**
@@ -1710,7 +1711,8 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                 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
@@ -1727,7 +1729,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                         currentRank++;
                     }
                 };
-                ((ITmfDataProvider) fTrace).sendRequest(request);
+                ((ITmfEventProvider) fTrace).sendRequest(request);
                 try {
                     request.waitForCompletion();
                     if (request.isCancelled()) {
@@ -2264,8 +2266,8 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
             // 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());
 
@@ -2319,7 +2321,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
                 }
             };
 
-            ((ITmfDataProvider) fTrace).sendRequest(subRequest);
+            ((ITmfEventProvider) fTrace).sendRequest(subRequest);
         }
     }
 
index d46bc5c75f67c82ae4fe99f16384b9d10412b44f..06264b523b1bb930e5eb428f3ea1c4f778abdb5b 100644 (file)
@@ -22,7 +22,7 @@ import org.eclipse.jface.viewers.TreeViewerColumn;
 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;
@@ -451,7 +451,7 @@ public class TmfStatisticsViewer extends TmfViewer {
      * @param request
      *            The request to be canceled
      */
-    protected void cancelOngoingRequest(ITmfDataRequest request) {
+    protected void cancelOngoingRequest(ITmfEventRequest request) {
         if (request != null && !request.isCompleted()) {
             request.cancel();
         }
index 30aab4a18eeb5e41413a3a72b694cdb2e56b30bc..7e50f393497a4eff5cfb7db0e3d3020f0ddfe8c4 100644 (file)
@@ -18,7 +18,7 @@ package org.eclipse.linuxtools.tmf.ui.views.histogram;
 
 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;
@@ -69,7 +69,7 @@ public class HistogramRequest extends TmfEventRequest {
     @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) {
@@ -101,7 +101,7 @@ public class HistogramRequest extends TmfEventRequest {
      */
     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;
@@ -116,7 +116,7 @@ public class HistogramRequest extends TmfEventRequest {
      *
      * @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) {
@@ -138,7 +138,7 @@ public class HistogramRequest extends TmfEventRequest {
      * 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() {
index 4035b12c12b7659a52a14b332b1cf205212fc6d8..2c8c5ac862a6755e3899b24a83754ec1134d0d2e 100644 (file)
@@ -23,8 +23,8 @@ import org.eclipse.jface.action.IAction;
 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;
@@ -658,7 +658,7 @@ public class HistogramView extends TmfView {
         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);
     }
 
@@ -668,7 +668,7 @@ public class HistogramView extends TmfView {
         }
         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);
     }
 
index 81f261ddcf4a6bdf20c5155d4faea4bb4cc62765..2ec58e159362f391edcd0cc77bd3072bd81528d3 100755 (executable)
@@ -17,7 +17,7 @@
 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;
@@ -156,16 +156,16 @@ public class TmfStatisticsView extends TmfView {
             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 {
             /*
index 633287c32c18b69590f0aa28914e1a9a430dcfa3..cb221cf9f9460461e8037dcc528528bcc8347be6 100644 (file)
@@ -29,9 +29,7 @@ import org.eclipse.linuxtools.internal.tmf.ui.Activator;
 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;
@@ -312,7 +310,8 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
 
             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;
@@ -1075,7 +1074,8 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
             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
@@ -1246,7 +1246,8 @@ public class TmfUml2SDSyncLoader extends TmfComponent implements IUml2SDLoader,
          */
         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
This page took 0.094677 seconds and 5 git commands to generate.