2010-07-08 Francois Chouinard <fchouinard@gmail.com> Partial implementation of...
authorFrancois Chouinard <fchouinard@gmail.com>
Thu, 8 Jul 2010 20:54:57 +0000 (20:54 +0000)
committerFrancois Chouinard <fchouinard@gmail.com>
Thu, 8 Jul 2010 20:54:57 +0000 (20:54 +0000)
* src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java (indexTrace): New method + renamed a constant

org.eclipse.linuxtools.lttng.ui.tests/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/tests/trace/TmfTraceTest.java
org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfTraceStub.java
org.eclipse.linuxtools.tmf/ChangeLog
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java

index 91ba9941e59044281be4eeffa15c03ebfdcfb88a..5f1a4a072b53c0c99b72ebed54619507a79915d2 100644 (file)
@@ -52,7 +52,7 @@ public class LTTngTraceStub extends TmfTrace<LttngEvent> {
      * @throws FileNotFoundException
      */
     public LTTngTraceStub(String filename) throws FileNotFoundException {
-        this(filename, DEFAULT_CACHE_SIZE);
+        this(filename, DEFAULT_INDEX_PAGE_SIZE);
     }
 
     /**
index aa8ee511296017bbfe4d7e48eec71bb0775752a6..8f3ce4903cc580a814554233c33e9e001869b2a3 100644 (file)
@@ -122,7 +122,7 @@ public class TmfTraceTest extends TestCase {
                assertEquals("getType",      TmfEvent.class, trace.getType());
                assertEquals("getPath",      testfile.getPath(), trace.getPath());
                assertEquals("getName",      TEST_STREAM, trace.getName());
-               assertEquals("getCacheSize", TmfTrace.DEFAULT_CACHE_SIZE, trace.getCacheSize());
+               assertEquals("getCacheSize", TmfTrace.DEFAULT_INDEX_PAGE_SIZE, trace.getCacheSize());
     }
 
     public void testTmfTraceDefaultCacheSize() throws Exception {
@@ -141,7 +141,7 @@ public class TmfTraceTest extends TestCase {
                assertEquals("getType",      TmfEvent.class, trace.getType());
                assertEquals("getPath",      testfile.getPath(), trace.getPath());
                assertEquals("getName",      TEST_STREAM, trace.getName());
-               assertEquals("getCacheSize", TmfTrace.DEFAULT_CACHE_SIZE, trace.getCacheSize());
+               assertEquals("getCacheSize", TmfTrace.DEFAULT_INDEX_PAGE_SIZE, trace.getCacheSize());
     }
 
     public void testTmfTrace() throws Exception {
index b6913267583876697df43fdc14e75b340bca5e70..da556ba02926de68c036f82456de35d1e278b00e 100644 (file)
@@ -47,7 +47,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
      * @throws FileNotFoundException
      */
     public TmfTraceStub(String filename) throws FileNotFoundException {
-        this(filename, DEFAULT_CACHE_SIZE, false);
+        this(filename, DEFAULT_INDEX_PAGE_SIZE, false);
     }
 
     /**
@@ -65,7 +65,7 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
      * @throws FileNotFoundException
      */
     public TmfTraceStub(String filename, boolean waitForCompletion) throws FileNotFoundException {
-        this(filename, DEFAULT_CACHE_SIZE, waitForCompletion);
+        this(filename, DEFAULT_INDEX_PAGE_SIZE, waitForCompletion);
     }
     
     /**
index 9df424b2d5286d835d5cc6cd4cd4e0daf097c73d..37961d5c40599f21761020568563085320a642e6 100644 (file)
@@ -1,3 +1,7 @@
+2010-07-08  Francois Chouinard  <fchouinard@gmail.com>
+
+       * src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java (indexTrace): New method + renamed a constant
+
 2009-06-16  Andrew Overholt  <overholt@redhat.com>
 
        * META-INF/MANIFEST.MF: Change provider from Ericsson to Eclipse.
\ No newline at end of file
index 959fb32264dd83361d2a66af7fc2bde7c1ba0b30..667b594380c45452b7d6cb77e9e73bd263e61676 100644 (file)
@@ -23,6 +23,9 @@ import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
 import org.eclipse.linuxtools.tmf.request.ITmfEventRequest;
+import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.signal.TmfTraceUpdatedSignal;
 
 /**
  * <b><u>TmfTrace</u></b>
@@ -52,7 +55,7 @@ public abstract class TmfTrace<T extends TmfEvent> extends TmfEventProvider<T> i
 
     // The default number of events to cache
        // TODO: Make the DEFAULT_CACHE_SIZE a preference
-    public static final int DEFAULT_CACHE_SIZE = 1000;
+    public static final int DEFAULT_INDEX_PAGE_SIZE = 1000;
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -83,7 +86,7 @@ public abstract class TmfTrace<T extends TmfEvent> extends TmfEventProvider<T> i
      * @throws FileNotFoundException
      */
     protected TmfTrace(String name, Class<T> type, String path) throws FileNotFoundException {
-       this(name, type, path, DEFAULT_CACHE_SIZE);
+       this(name, type, path, DEFAULT_INDEX_PAGE_SIZE);
     }
 
     /**
@@ -97,7 +100,7 @@ public abstract class TmfTrace<T extends TmfEvent> extends TmfEventProvider<T> i
        String simpleName = (sep >= 0) ? path.substring(sep + 1) : path;
        setName(simpleName);
        fPath = path;
-        fIndexPageSize = (cacheSize > 0) ? cacheSize : DEFAULT_CACHE_SIZE;
+        fIndexPageSize = (cacheSize > 0) ? cacheSize : DEFAULT_INDEX_PAGE_SIZE;
     }
 
     /* (non-Javadoc)
@@ -358,4 +361,66 @@ public abstract class TmfTrace<T extends TmfEvent> extends TmfEventProvider<T> i
                return "[TmfTrace (" + getName() + ")]";
        }
    
+    // ------------------------------------------------------------------------
+    // Indexing
+    // ------------------------------------------------------------------------
+
+       /*
+        * The purpose of the index is to keep the information needed to rapidly
+        * restore the traces contexts at regular intervals (every INDEX_PAGE_SIZE
+        * event).
+        */
+
+       @SuppressWarnings({ "unchecked", "unused" })
+       private void indexTrace(boolean waitForCompletion) {
+
+               fCheckpoints.clear();
+               
+               ITmfEventRequest<TmfEvent> request = new TmfEventRequest<TmfEvent>(TmfEvent.class, TmfTimeRange.Eternity, TmfDataRequest.ALL_DATA, 1, ITmfDataRequest.ExecutionType.LONG) {
+
+                       TmfTimestamp startTime =  null;
+                       TmfTimestamp lastTime  =  null;
+
+                       @Override
+                       public void handleData() {
+                               TmfEvent[] events = getData();
+                               if (events.length > 0) {
+                                       TmfTimestamp ts = events[0].getTimestamp();
+                                       if (startTime == null) {
+                                               startTime = new TmfTimestamp(ts);
+                                               fStartTime = startTime;
+                                       }
+                                       lastTime = new TmfTimestamp(ts);
+
+                                       if ((fNbRead % DEFAULT_INDEX_PAGE_SIZE) == 0) {
+                                               updateTraceData();
+                                       }
+                               }
+                       }
+
+                       @Override
+                       public void handleSuccess() {
+                               updateTraceData();
+                       }
+
+                       private void updateTraceData() {
+                               fEndTime  = new TmfTimestamp(lastTime);
+                               fNbEvents = fNbRead;
+                               notifyListeners();
+                       }
+               };
+
+               sendRequest((ITmfDataRequest<T>) request);
+               if (waitForCompletion)
+                       try {
+                               request.waitForCompletion();
+                       } catch (InterruptedException e) {
+                               e.printStackTrace();
+                       }
+       }
+       
+       protected void notifyListeners() {
+       broadcast(new TmfTraceUpdatedSignal(this, this, new TmfTimeRange(fStartTime, fEndTime)));
+       }
+   
 }
This page took 0.043746 seconds and 5 git commands to generate.