- Minor modification of the FW API (better trace/parser integration)
authorFrancois Chouinard <fchouinard@gmail.com>
Mon, 14 Sep 2009 14:30:20 +0000 (14:30 +0000)
committerFrancois Chouinard <fchouinard@gmail.com>
Mon, 14 Sep 2009 14:30:20 +0000 (14:30 +0000)
- Integration of LTTng parsing library

46 files changed:
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/project/ProjectView.java
org.eclipse.linuxtools.lttng.ui/src/org/eclipse/linuxtools/lttng/ui/views/timeframe/TimeFrameView.java
org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventParserStub.java
org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventStreamStub.java [deleted file]
org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngTraceStub.java
org.eclipse.linuxtools.lttng/META-INF/MANIFEST.MF
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEvent.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventContent.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventField.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventFormat.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventReference.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventSource.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventType.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngTimestamp.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniEvent.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniException.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniMarker.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniMarkerField.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniParser.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniTime.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/JniTracefile.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/jni/Jni_C_Common.java
org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LttngEventStream.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/event/TmfTimestampTest.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/stream/AllStreamTests.java [deleted file]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/stream/TmfEventStreamTest.java [deleted file]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/AllTraceTests.java
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/TmfExperimentTest.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/TmfTraceTest.java
org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/request/TmfRequestHandlerStub.java
org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfEventParserStub.java
org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfEventStreamStub.java [deleted file]
org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfTraceStub.java
org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/views/TmfEventsView.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfEventContent.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/event/TmfTimestamp.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/ITmfTrace.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfExperiment.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfExperimentUpdatedSignal.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfStreamCheckpoint.java [deleted file]
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfStreamUpdatedSignal.java [deleted file]
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTraceCheckpoint.java [new file with mode: 0644]
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTraceUpdatedSignal.java
org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace_old.java [deleted file]

index e3cd7320c5e4803d9fef73a411af0373dba46990..d2f41aa94a59afc70d704ad25568b1f231321e01 100644 (file)
@@ -25,10 +25,8 @@ import org.eclipse.jface.action.IMenuManager;
 import org.eclipse.jface.action.MenuManager;
 import org.eclipse.jface.viewers.TreeSelection;
 import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.linuxtools.lttng.stubs.LTTngEventParserStub;
-import org.eclipse.linuxtools.lttng.stubs.LTTngEventStreamStub;
+import org.eclipse.linuxtools.lttng.trace.LttngEventStream;
 import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
 import org.eclipse.linuxtools.tmf.trace.TmfExperiment;
 import org.eclipse.linuxtools.tmf.trace.TmfExperimentSelectedSignal;
@@ -137,11 +135,9 @@ public class ProjectView extends ViewPart {
         String expId = folder.getName();
         TmfExperiment experiment = new TmfExperiment(expId, new ITmfTrace[] { });
         try {
-            ITmfEventParser parser = new LTTngEventParserStub();
                for (IResource res : folder.members()) {
                 String traceId = Platform.getLocation() + res.getFullPath().toOSString();
-                ITmfTrace trace = new LTTngEventStreamStub(traceId, parser);
-                trace.indexStream(false);
+                ITmfTrace trace = new LttngEventStream(traceId);
                 experiment.addTrace(trace);
                }
         } catch (Exception e) {
index 62c3da695818942f60ea5147e6f372ccf943f600..e1deccd1562bd54b800ab2926a3ead87ec6ba8da 100644 (file)
@@ -19,7 +19,7 @@ import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
 import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
 import org.eclipse.linuxtools.tmf.trace.TmfExperiment;
 import org.eclipse.linuxtools.tmf.trace.TmfExperimentSelectedSignal;
-import org.eclipse.linuxtools.tmf.trace.TmfTraceUpdatedSignal;
+import org.eclipse.linuxtools.tmf.trace.TmfExperimentUpdatedSignal;
 import org.eclipse.linuxtools.tmf.ui.views.TmfViewer;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
@@ -274,7 +274,7 @@ public class TimeFrameView extends TmfViewer {
      * @param signal
      */
     @TmfSignalHandler
-    public void traceUpdated(TmfTraceUpdatedSignal signal) {
+    public void traceUpdated(TmfExperimentUpdatedSignal signal) {
 
         // Update the time frame
                fTraceTimeRange = signal.getTrace().getTimeRange();
index 7eb9b1f24de5541fcc5b8b9a319a4fc8094bafdc..b7875fc8d13c4a786e400d517e9d50c324044642 100644 (file)
@@ -70,11 +70,11 @@ public class LTTngEventParserStub implements ITmfEventParser {
     static final String typePrefix = "Type-";
     public TmfEvent getNextEvent(ITmfTrace eventStream) throws IOException {
 
-        if (! (eventStream instanceof LTTngEventStreamStub)) {
+        if (! (eventStream instanceof LTTngTraceStub)) {
             return null;
         }
 
-        RandomAccessFile stream = ((LTTngEventStreamStub) eventStream).getStream();
+        RandomAccessFile stream = ((LTTngTraceStub) eventStream).getStream();
         String name = eventStream.getName();
         name = name.substring(name.lastIndexOf('/') + 1);
 
diff --git a/org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventStreamStub.java b/org.eclipse.linuxtools.lttng.ui/stubs/org/eclipse/linuxtools/lttng/stubs/LTTngEventStreamStub.java
deleted file mode 100644 (file)
index d5885bb..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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 (fchouinard@gmail.com) - Initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.linuxtools.lttng.stubs;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Map;
-
-import org.eclipse.linuxtools.tmf.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.trace.TmfTrace;
-
-/**
- * <b><u>TmfEventStreamStub</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class LTTngEventStreamStub extends TmfTrace {
-
-    // ========================================================================
-    // Attributes
-    // ========================================================================
-
-    // The actual stream
-    private final RandomAccessFile fStream;
-
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-    /**
-     * @param filename
-     * @param parser
-     * @throws FileNotFoundException
-     */
-    public LTTngEventStreamStub(String filename, ITmfEventParser parser) throws FileNotFoundException {
-        this(filename, parser, DEFAULT_CACHE_SIZE);
-    }
-
-    /**
-     * @param filename
-     * @param parser
-     * @param cacheSize
-     * @throws FileNotFoundException
-     */
-    public LTTngEventStreamStub(String filename, ITmfEventParser parser, int cacheSize) throws FileNotFoundException {
-        super(filename, parser, cacheSize);
-        fStream = new RandomAccessFile(filename, "r");
-    }
-
-    // ========================================================================
-    // Accessors
-    // ========================================================================
-
-    public RandomAccessFile getStream() {
-        return fStream;
-    }
-
-    // ========================================================================
-    // Operators
-    // ========================================================================
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
-     */
-    public StreamContext seekLocation(Object location) {
-        StreamContext context = null;
-        try {
-            fStream.seek((location != null) ? (Long) location : 0);
-            context = new StreamContext(getCurrentLocation(), 0);
-        } catch (IOException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        return context;
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
-     */
-    public Object getCurrentLocation() {
-        try {
-            return new Long(fStream.getFilePointer());
-        } catch (IOException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    // ========================================================================
-    // Helper functions
-    // ========================================================================
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
-     */
-    public Map<String, Object> getAttributes() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-}
index e9cf908507e4cf1dab3b2fd03689a64c1cd6898e..81dcd103af00f26d6a4dd1ea2d64052018071a97 100644 (file)
@@ -15,16 +15,16 @@ package org.eclipse.linuxtools.lttng.stubs;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.RandomAccessFile;
+import java.util.Map;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.trace.ITmfEventParser;
 import org.eclipse.linuxtools.tmf.trace.TmfTrace;
-import org.eclipse.linuxtools.tmf.trace.TmfTraceContext;
 
 /**
  * <b><u>LTTngTraceStub</u></b>
  * <p>
- * Dummy test trace. Use in conjunction with LTTngEventParserStub.
+ * TODO: Implement me. Please.
  */
 public class LTTngTraceStub extends TmfTrace {
 
@@ -33,7 +33,7 @@ public class LTTngTraceStub extends TmfTrace {
     // ========================================================================
 
     // The actual stream
-    private final RandomAccessFile fTrace;
+    private final RandomAccessFile fStream;
 
     // The associated event parser
     private final ITmfEventParser fParser;
@@ -48,7 +48,7 @@ public class LTTngTraceStub extends TmfTrace {
      * @throws FileNotFoundException
      */
     public LTTngTraceStub(String filename) throws FileNotFoundException {
-        this(filename, DEFAULT_CACHE_SIZE);
+        this(filename, DEFAULT_PAGE_SIZE);
     }
 
     /**
@@ -58,8 +58,8 @@ public class LTTngTraceStub extends TmfTrace {
      * @throws FileNotFoundException
      */
     public LTTngTraceStub(String filename, int cacheSize) throws FileNotFoundException {
-        super(filename, cacheSize, false);
-        fTrace = new RandomAccessFile(filename, "r");
+        super(filename, cacheSize);
+        fStream = new RandomAccessFile(filename, "r");
        fParser = new LTTngEventParserStub();
        indexStream();
     }
@@ -69,7 +69,7 @@ public class LTTngTraceStub extends TmfTrace {
     // ========================================================================
 
     public RandomAccessFile getStream() {
-        return fTrace;
+        return fStream;
     }
 
     // ========================================================================
@@ -79,19 +79,14 @@ public class LTTngTraceStub extends TmfTrace {
     /* (non-Javadoc)
      * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
      */
-       public TmfTraceContext seekLocation(Object location) {
+    public TmfTraceContext seekLocation(Object location) {
         TmfTraceContext context = null;
-               try {
-                       synchronized(fTrace) {
-                       fTrace.seek((location != null) ? (Long) location : 0);
-                       context = new TmfTraceContext(getCurrentLocation(), null, 0);
-                       TmfTraceContext context2 = new TmfTraceContext(getCurrentLocation(), null, 0);
-                       TmfEvent event = parseEvent(context2);
-                       context.setTimestamp(event.getTimestamp());
-                       }
+        try {
+            fStream.seek((location != null) ? (Long) location : 0);
+            context = new TmfTraceContext(getCurrentLocation(), 0);
         } catch (IOException e) {
-               // TODO Auto-generated catch block
-               e.printStackTrace();
+            // TODO Auto-generated catch block
+            e.printStackTrace();
         }
         return context;
     }
@@ -99,54 +94,40 @@ public class LTTngTraceStub extends TmfTrace {
     /* (non-Javadoc)
      * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
      */
-    @Override
-       public Object getCurrentLocation() {
-               try {
-                       return new Long(fTrace.getFilePointer());
-               } catch (IOException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
+    public Object getCurrentLocation() {
+        try {
+            return new Long(fStream.getFilePointer());
+        } catch (IOException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
         return null;
     }
 
        /* (non-Javadoc)
         * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent()
         */
-       @Override
-       public TmfEvent parseEvent(TmfTraceContext context) {
-               try {
-                       // paserNextEvent updates the context
-                       TmfEvent event = fParser.parseNextEvent(this, context);
-//                     if (event != null) {
-//                             context.setTimestamp(event.getTimestamp());
-//                     }
-                       return event;
-               }
-               catch (IOException e) {
-                       e.printStackTrace();
-               }
-               return null;
+       public TmfEvent parseNextEvent() {
+               try {
+                       TmfEvent event = fParser.getNextEvent(this);
+                       return event;
+               }
+               catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return null;
        }
 
-       /* (non-Javadoc)
-        * @see java.lang.Object#toString()
-        */
-       @Override
-       public String toString() {
-               return "[LTTngTraceStub]";
-       }
+    // ========================================================================
+    // Helper functions
+    // ========================================================================
 
-//    // ========================================================================
-//    // Helper functions
-//    // ========================================================================
-//
-//    /* (non-Javadoc)
-//     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
-//     */
-//    public Map<String, Object> getAttributes() {
-//        // TODO Auto-generated method stub
-//        return null;
-//    }
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
+     */
+    public Map<String, Object> getAttributes() {
+        // TODO Auto-generated method stub
+        return null;
+    }
 
 }
index dab8114f3483e7f6cc6bda2ce16a384a1f89dccb..bbfaa3181f3b088d74d0eed5848dfd01f43d7232 100644 (file)
@@ -9,3 +9,6 @@ Require-Bundle: org.eclipse.core.runtime,
  org.eclipse.linuxtools.tmf;bundle-version="0.0.1"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy
+Export-Package: org.eclipse.linuxtools.lttng,
+ org.eclipse.linuxtools.lttng.event,
+ org.eclipse.linuxtools.lttng.trace
index 81a6f2f32ba4939a75306a97f6a09e8b728e7302..b3c4d8e992d916bd0d8c4ee09c6d62279ccab700 100644 (file)
@@ -1,24 +1,26 @@
 package org.eclipse.linuxtools.lttng.event;
 
-import org.eclipse.linuxtools.lttng.jni.JniEvent;
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfEventSource;
+import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
+import org.eclipse.linuxtools.lttng.jni.JniEvent;
 
 /**
- * <b><u>LttngEvent</u></b><p>
- * 
- * Lttng specific TmfEvent implementation.<p>
- * 
- * The main difference from the basic Tmf implementation is that we keep an internal reference to the JniEvent<br>
- * The conversion from this LttngEvent to the JniEvent is then possible.
+ * <b><u>LttngEvent</u></b>
+ * <p>
+ * Lttng specific TmfEvent implementation
+ * <p>
+ * The main difference from the basic Tmf implementation is that we keep an internal reference to the Jni JniEvent<br>
+ * The conversion from this LttngEvent to the JniEvent is then possible. 
+ * </ul>
  */
+@SuppressWarnings("unused")
 public class LttngEvent extends TmfEvent {
+    // Reference to the JNI JniEvent. Should only used INTERNALLY
+    JniEvent jniEventReference = null;
     
-    // Reference to the JNI JniEvent. Should only be used INTERNALLY
-    private JniEvent jniEventReference = null;
-
     /**
-     * Constructor with parameters.<p>
+     * Constructor with parameters <br>
+     * <br>
      * 
      * @param timestamp  The timestamp of this event   
      * @param source     The source of this event
@@ -28,130 +30,82 @@ public class LttngEvent extends TmfEvent {
      * @param lttEvent   A reference to a valid JniEvent object
      * 
      * @see org.eclipse.linuxtools.tmf.event.TmfTimestamp
-     * @see org.eclipse.linuxtools.tmf.event.TmfEventSource
+     * @see org.eclipse.linuxtools.lttng.event.LttngEventSource
      * @see org.eclipse.linuxtools.lttng.event.LttngEventType
      * @see org.eclipse.linuxtools.lttng.event.LttngEventContent
      * @see org.eclipse.linuxtools.lttng.event.LttngEventReference
-     * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * 
      */
-    public LttngEvent(LttngTimestamp timestamp, TmfEventSource source, LttngEventType type, LttngEventContent content, LttngEventReference reference, JniEvent lttEvent) { 
-        super(timestamp, source, type, reference);
+    public LttngEvent(LttngTimestamp timestamp, LttngEventSource source, LttngEventType type, LttngEventContent content, LttngEventReference reference, JniEvent lttEvent) { 
+        super(timestamp, source, type, content, reference);
         
-        fContent = content;
         jniEventReference = lttEvent;
     }
     
     /**
-     * Copy constructor.<p>
+     * Return the channel name of this event<br>
      * 
-     * @param oldEvent         Event we want to copy from.
-     */
-    public LttngEvent(LttngEvent oldEvent) {
-        this(  (LttngTimestamp)oldEvent.getTimestamp(), 
-                       (TmfEventSource)oldEvent.getSource(), 
-                       (LttngEventType)oldEvent.getType(), 
-                       (LttngEventContent)oldEvent.getContent(), 
-                       (LttngEventReference)oldEvent.getReference(), 
-                       oldEvent.jniEventReference
-               );
-    }
-    
-    
-    /**
-     * Return the channel name of this event.<p>
-     * 
-     * @return Channel (tracefile) for this event
+     * @return String The name of the channel
      */
     public String getChannelName() {
-        return ( (LttngEventType)this.getType() ).getTracefileName();
+        String returnedValue = "";
+        
+        if ( this.getType() instanceof LttngEventType ) {
+            returnedValue = ( (LttngEventType)this.getType() ).getChannelName();
+        }
+        
+        return returnedValue;
     }
     
     /**
-     * Cpu id number of this event.<p>
+     * Return the cpu id number of this event<br>
      * 
-     * @return CpuId
+     * @return long The cpu id
      */
     public long getCpuId() {
-        return ( (LttngEventType)this.getType() ).getCpuId();
+        long returnedValue =-1;
+        
+        if ( this.getType() instanceof LttngEventType ) {
+            returnedValue = ( (LttngEventType)this.getType() ).getCpuId();
+        }
+        
+        return returnedValue;
     }
     
     /**
-     * Marker name of this event.<p>
+     * Return the marker name of this event<br>
      * 
-     * @return Marker name
+     * @return String The marker name
      */
     public String getMarkerName() {
-        return ( (LttngEventType)this.getType() ).getMarkerName();
-    }
-    
-    /**
-     * Set a new JniReference for this event.<p>
-     * 
-     * Note : Reference is used to get back to the Jni during event parsing and need to be consistent.
-     * 
-     * @param newJniEventReference     New reference
-     * 
-     * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
-     */
-    public void updateJniEventReference(JniEvent newJniEventReference) {
-        this.jniEventReference = newJniEventReference;
-    }
-    
-    @Override
-    public LttngEventContent getContent() {
-        return (LttngEventContent)fContent;
-    }
-    
-    public void setContent(LttngEventContent newContent) {
-        fContent = newContent;
-    }
-    
-    @Override
-    public LttngEventType getType() {
-        return (LttngEventType)fType;
-    }
-    
-    public void setType(LttngEventType newType) {
-        fType = newType;
+        String returnedValue = "";
+        
+        if ( this.getType() instanceof LttngEventType ) {
+            returnedValue = ( (LttngEventType)this.getType() ).getMarkerName();
+        }
+        
+        return returnedValue;
     }
     
-    
     /**
-     * Convert this event into a Jni JniEvent.<p>
-     * 
-     * Note : Some verifications are done to make sure the event is still valid on 
-     * the Jni side before conversion.<br> If it is not the case, null will be returned.
-     * 
-     * @return The converted JniEvent
+     * Convert this event into a Jni JniEvent<br>
+     * <br>
+     * Note : Some verification are done to make sure the event is still valid on the Jni side.<br>
+     * If it is not the case, null will be returned.
      * 
-     * @see org.eclipse.linuxtools.org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @return JniEvent The converted event
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent convertEventTmfToJni() {
         JniEvent tmpEvent = null;
         
-        // ***TODO***
-        // Should we remove the check to save some time??
-        
         // We don't want to send away events that are outdated as their informations could be invalid
         //  If the timestamp between the event and the trace are not coherent we will not perform the conversion
         if ( jniEventReference.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime() == getTimestamp().getValue() ) {
             tmpEvent = jniEventReference;
         }
-        else {
-            System.out.println("convertEventTmfToJni() failed: Unsynced Timestamp > TMF:" + getTimestamp().getValue() + " <--> JNI:" + jniEventReference.getParentTracefile().getParentTrace().getCurrentEventTimestamp().getTime());
-        }
+
         return tmpEvent;
     }
-    
-    @Override
-       public String toString() {
-       String returnedData="";
-       
-       returnedData += "Event timestamp:" + this.getTimestamp().getValue() + " ";
-       returnedData += "Channel:" + getChannelName() + " ";
-       returnedData += "CPU:" + getCpuId() + " ";
-       returnedData += "Marker:" + getMarkerName() + " ";
-       
-       return returnedData;
-    }
 }
index 92ee00dc3cdb8469ea9305b421382c1cd6861657..e013fa32f6d58881a93aa4241fe3ecd11a41c9c9 100644 (file)
 
 package org.eclipse.linuxtools.lttng.event;
 
-import java.util.HashMap;
-
 import org.eclipse.linuxtools.tmf.event.TmfEventContent;
 
 /**
- * <b><u>LttngEventContent</u></b><p>
- * 
- * Lttng specific implementation of the TmfEventContent.<p>
+ * <b><u>LttngEventContent</u></b>
+ * <p>
+ * Lttng specific implementation of the TmfEventContent
+ * <p>
+ * Lttng LttngEventContent is very similar from TMF basic one. <br>
  */
 public class LttngEventContent extends TmfEventContent {
     
-    // Hash map that contain the (parsed) fields. This is the actual payload of the event.
-    HashMap<String, LttngEventField> fFieldsMap = new HashMap<String, LttngEventField>();
-    
-    /**
-     * Default constructor.<p>
-     * 
-     * 
-     */
-    public LttngEventContent() {
-        super(null, null);
-    }
-    
     /**
-     * Constructor with parameters.<p>
+     * Constructor with parameters<br>
+     * <br>
+     * Content will be null as no parsed content is given.
      * 
-     * @param thisParent    Parent event for this content.
-     * 
-     * @see org.eclipse.linuxtools.lttng.event.LttngEvent
+     * @param thisFormat    The LttngEventFormat relative to the JniEvent
      */
-    public LttngEventContent(LttngEvent thisParent) {
-        super(thisParent, null);
+    public LttngEventContent(LttngEventFormat thisFormat) {
+        super(null, thisFormat);
     }
-    
+
     /**
-     * Constructor with parameters, with optional content.<p>
+     * Constructor with parameters<br>
      * 
-     * @param thisParent    Parent event for this content.
-     * @param thisContent   Already parsed content.
-     * 
-     * @see org.eclipse.linuxtools.lttng.event.LttngEvent
-     */
-    public LttngEventContent(LttngEvent thisParent, HashMap<String, LttngEventField> thisContent) {
-        super(thisParent, null);
-        
-        fFieldsMap = thisContent;
-    }
-    
-    /**
-     * Copy Constructor.<p>
+     * @param thisFormat        The LttngEventFormat relative to this JniEvent
+     * @param thisParsedContent The string content of the JniEvent, already parsed
      * 
-     * @param oldContent  Content to copy from
      */
-    public LttngEventContent(LttngEventContent oldContent) {
-        this((LttngEvent)oldContent.getEvent(), oldContent.getRawContent() );
+    public LttngEventContent(LttngEventFormat thisFormat, String thisParsedContent, LttngEventField[] thisFields) {
+        super(thisParsedContent, thisFormat);
+        setFields(thisFields);
     }
     
     
-    @Override
-       public LttngEvent getEvent() {
-        return (LttngEvent)fParentEvent;
-    }
-    
-    public void setEvent(LttngEvent newParent) {
-        fParentEvent = newParent;
-    }
-    
-    
-    // *** VERIFY ***
-    // These are not very useful, are they?
-    @Override
-       public LttngEventType getType() {
-        return (LttngEventType)fParentEvent.getType();
-//        return (LttngEventType)fEventType;
-    }
-    public void setType(LttngEventType newType) {
-        ((LttngEvent)fParentEvent).setType(newType);
-//        fEventType = newType;
-    }
-    
-    
-    // ***TODO***
-    // Find a better way to ensure content is sane!!
-    public void emptyContent() {
-        fFieldsMap.clear();
-    }
-    
-    // ***VERIFY***
-    // A bit weird to return the _currently_parsed fields (unlike all like getFields() )
-    // Should we keep this?
-    /**
-     * Return currently parsed fields in an object array format.<p>
-     * 
-     * @return  Currently parsed fields.
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.event.TmfEventContent#getFields()
      */
     @Override
-    public Object[] getContent() {
-        Object[] returnedContent = fFieldsMap.values().toArray( new Object[fFieldsMap.size()] );
+    public LttngEventField[] getFields() {
+       
+       // Request the field variable from the inherited class
+        LttngEventField[] fields = (LttngEventField[])super.getFields();
         
-        return returnedContent;
-    }
-    
-    /**
-     * Return currently parsed fields in the internal hashmap format.<p>
-     * 
-     * @return  Currently parsed fields.
-     */
-    public HashMap<String, LttngEventField> getRawContent() {
-        return fFieldsMap;
+        // Field may be null if the content hasn't been parse yet
+        // If that's the case, call the parsing function
+        if (fields == null) {
+            fields = ((LttngEventFormat) this.getFormat()).parse(this.getContent());
+            setFields(fields);
+        }
+        return fields;
     }
-    
-//    @SuppressWarnings("unchecked")
-//    @Override
-//    public LttngEventField[] getFields() {
-//        LttngEventField tmpField = null;
-//        
-//        // *** TODO ***
-//        // SLOW! SLOW! SLOW! We should prevent the user to use this!!
-//        HashMap<String, Object> parsedContent = parseContent();
-//        
-//        String contentKey = null;
-//        Iterator<String> contentItr = parsedContent.keySet().iterator();
-//        while ( contentItr.hasNext() ) {
-//            contentKey = contentItr.next();
-//            
-//            tmpField = new LttngEventField(this, contentKey, parsedContent.get(contentKey));
-//            ((HashMap<String, LttngEventField>)fFields).put(contentKey, tmpField);
-//        }
-//        
-//        return fFields.values().toArray(new LttngEventField[fFields.size()]);
-//    }
-    
-    /**
-     * Parse all fields and return them as an array of LttngFields.<p>
-     * 
-     * Note : This function is heavy and should only be called if all fields are really needed.
-     * 
-     * @return  All fields.
-     * 
-     * @see @see org.eclipse.linuxtools.lttng.event.LttngEventField
+
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.event.TmfEventContent#getField(int)
      */
     @Override
-    public LttngEventField[] getFields() {
-        LttngEventField tmpField = null;
+    public LttngEventField getField(int id) {
+        assert id >= 0 && id < this.getNbFields();
         
-        LttngEventType tmpType = (LttngEventType)fParentEvent.getType();
+        LttngEventField returnedField = null;
+        LttngEventField[] allFields = this.getFields();
         
-        for ( int pos=0; pos<tmpType.getNbFields(); pos++ ) {
-            String name = tmpType.getLabel(pos);
-            Object newValue = ((LttngEvent)getEvent()).convertEventTmfToJni().parseFieldByName(name);
-            
-            tmpField = new LttngEventField(this, name, newValue );
-            fFieldsMap.put(name, tmpField);
+        if ( allFields != null ) {
+               returnedField = allFields[id];
         }
-        return fFieldsMap.values().toArray(new LttngEventField[fFieldsMap.size()]);
+        
+        return returnedField;
     }
     
     /**
-     * Parse a single field from its given position.<p>
-     * 
-     * @return  The parsed field or null.
-     * 
-     * @see @see org.eclipse.linuxtools.lttng.event.LttngEventField
+     * @param thisEvent
+     * @return
      */
-    @Override
-    public LttngEventField getField(int position) {
-        LttngEventField returnedField = null;
-        String label = fParentEvent.getType().getLabel(position);
+    public LttngEventField[] getFields(LttngEvent thisEvent) {
+       
+       // Request the field variable from the inherited class
+        LttngEventField[] fields = (LttngEventField[])super.getFields();
         
-        if ( label != null ) {
-            returnedField = this.getField(label);
+        // Field may be null if the content hasn't been parse yet
+        // If that's the case, call the parsing function
+        if (fields == null) {
+            fields = ((LttngEventFormat)this.getFormat()).parse(thisEvent);
+            setFields(fields);
         }
-        
-        return returnedField;
+        return fields;
     }
     
     /**
-     * Parse a single field from its given name.<p>
-     * 
-     * @return  The parsed field or null.
-     * 
-     * @see @see org.eclipse.linuxtools.lttng.event.LttngEventField
+     * @param id
+     * @param thisEvent
+     * @return
      */
-    @Override
-    public LttngEventField getField(String name) {
-        // *** VERIFY ***
-        // Should we check if the field exists in LttngType before parsing? 
-        // It could avoid calling parse for non-existent fields but would waste some cpu cycle on check?
-        LttngEventField returnedField = fFieldsMap.get(name);
+    public LttngEventField getField(int id, LttngEvent thisEvent) {
+        assert id >= 0 && id < this.getNbFields();
+        
+        LttngEventField returnedField = null;
+        LttngEventField[] allFields = this.getFields(thisEvent);
         
-        if ( returnedField == null ) {
-            // *** VERIFY ***
-            // Should we really make sure we didn't get null before creating/inserting a field?
-               Object newValue = ((LttngEvent)getEvent()).convertEventTmfToJni().parseFieldByName(name);
-            
-            if ( newValue!= null ) {
-                returnedField = new LttngEventField(this, name, newValue);
-                fFieldsMap.put(name, returnedField );
-            }
+        if ( allFields != null ) {
+               returnedField = allFields[id];
         }
         
         return returnedField;
     }
     
-    // *** VERIFY ***
-    // *** Is this even useful?
-    @Override
-    protected void parseContent() {
-        fFields = getFields();
-    }
-    
+
     /**
-     * toString() method to print the content
+     * basic toString() method.
      * 
-     * Note : this function parse all fields and so is very heavy to use.
+     * @return Attributes of the object concatenated in String
      */
-    @Override
     public String toString() {
-        String returnedString = "";
-        
-        LttngEventField[] allFields = getFields();
-        
-        for ( int pos=0; pos < allFields.length; pos++) {
-            returnedString +=  allFields[pos].toString() + " ";
-        }
-        
-        return returnedString;
-        
+        return getContent().toString();
     }
 }
\ No newline at end of file
index 31b15bb2e002d1d6ef051a2e5eefbb863bd1f218..d25c6dbf9f540f115939a63e8301d2e411f4bd63 100644 (file)
 
 package org.eclipse.linuxtools.lttng.event;
 
-import org.eclipse.linuxtools.tmf.event.TmfEventContent;
-import org.eclipse.linuxtools.tmf.event.TmfEventField;
+import org.eclipse.linuxtools.tmf.event.*;
 
 /**
- * <b><u>LttngEventField</u></b><p>
- * 
- * Lttng specific implementation of the TmfEventField.<p>
- * 
- * LttngEventField add a "name" attribute to the Tmf implementation This
- * mean the fields will have a name and a value.
+ * <b><u>LttngEventField</u></b>
+ * <p>
+ * Lttng specific implementation of the TmfEventField
+ * <p>
+ * Lttng LttngEventField add a "Name" attribute to the Tmf implementation
+ * This mean the fields will have a name and a value.
  */
-public class LttngEventField extends TmfEventField {
-       
-    /**
-     * Constructor with parameters.<p>
-     * 
-     * @param parent   Parent content for this field
-     * @param id       Name (label) of this field
-     */
-    public LttngEventField(TmfEventContent parent, String id) {
-        super(parent, id, null);
-    }
-    
-       /**
-        * Constructor with parameters with optional value.<p>
-        * 
-        * @param parent   Parent content for this field
-        * @param id       Name (label) of this field
-        * @param value    Parsed value (payload) of this field
-        */
-       public LttngEventField(TmfEventContent parent, String id, Object value) {
-               super(parent, id, value);
-       }
-       
-       /**
-        * Copy constructor.<p>
-        * 
-        * @param oldField     the field to copy from
-        */
-       public LttngEventField(LttngEventField oldField) {
-               this(oldField.getParent(), oldField.getId(), oldField.getValue());
-       }
-       
-       @Override
-       public String toString() {
-           return getId().toString() + ":" + getValue().toString();
-       }
-       
+public class LttngEventField extends TmfEventField 
+{
+        private String fieldName = "";
+        
+        /**
+         * Constructor with parameters<br>
+         * 
+         * @param newContent    The parsedContent we want to populate the field with. 
+         * 
+         * @see org.eclipse.linuxtools.lttng.jni.ParsedContent   
+         */
+        public LttngEventField(String name, Object newContent) {
+                super( newContent );
+        
+                fieldName = name;
+        }
+        
+        /**
+         * getter for the name attribute.
+         */
+        public String getName() {
+                return fieldName;
+        }
+        
+        /**
+         * overrided toString() method.<br>
+         * <br>
+         * Print both field name and value.
+         */
+        @Override
+        public String toString() {
+                return fieldName + " : " + getValue().toString();
+        }
 }
+
diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventFormat.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/event/LttngEventFormat.java
new file mode 100644 (file)
index 0000000..67d60f2
--- /dev/null
@@ -0,0 +1,138 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ *   William Bourque (wbourque@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.event;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.eclipse.linuxtools.tmf.event.TmfEventFormat;
+
+/**
+ * <b><u>LttngEventFormat</u></b>
+ * <p>
+ * Lttng specific implementation of the TmfEventFormat
+ * <p>
+ * The Lttng implementation of format override parse but require a LttngEvent for most functions so it can call Jni
+ */
+public class LttngEventFormat extends TmfEventFormat {
+
+    /**
+     * Default constructor
+     */
+    public LttngEventFormat() {
+        
+    }
+
+    /**
+     * Getter for the label of the fields for this event.<br>
+     * 
+     * @return String[]     A string array that contain the labels name
+     */
+    public String[] getLabels(LttngEvent thisEvent) {
+        String[] returnedLabels = null; 
+        returnedLabels = thisEvent.convertEventTmfToJni().requestEventMarker().getMarkerFieldsHashMap().keySet().toArray(returnedLabels);
+        
+        return returnedLabels;
+    }
+    
+    /**
+     * Parse the LttngEvent linked to this LttngEventFormat.<br>
+     * 
+     * @return LttngEventField[]     An array of LttngEventField that contain the parsed data
+     */
+    public LttngEventField[] parse(LttngEvent thisEvent) {
+        HashMap<String, Object> parsedMap = thisEvent.convertEventTmfToJni().parseAllFields();
+        LttngEventField[] returnedField = new LttngEventField[parsedMap.size()];
+        
+        String fieldName = null;
+        int position = 0;
+        Iterator<String> iterator = parsedMap.keySet().iterator();
+        while (iterator.hasNext()) {
+            fieldName = iterator.next();
+            returnedField[position] = new LttngEventField( fieldName, parsedMap.get(fieldName) );
+            position++;
+        }
+        
+        return returnedField;
+    }
+    
+    
+    
+    /* *** FIXME
+     * TEMPORARY IMPLEMENTATION
+     * THIS WILL DISAPEAR ( ?? )
+     */
+    public LttngEventField[] parse(HashMap<String, Object> parsedEvents) {
+        LttngEventField[] returnedField = new LttngEventField[parsedEvents.size()];
+        
+        String fieldName = null;
+        int position = 0;
+        Iterator<String> iterator = parsedEvents.keySet().iterator();
+        while (iterator.hasNext()) {
+            fieldName = iterator.next();
+            returnedField[position] = new LttngEventField( fieldName, parsedEvents.get(fieldName) );
+            position++;
+        }
+        
+        return returnedField;
+    }
+    
+    /* *** FIXME ***
+     * Evil "do at least something" parse function
+     * THIS IS JUST FOR COMPATIBILITY! DO NOT USE!
+     * Content/Format/Fields interelation need to be revisited ASAP
+     */ 
+    public LttngEventField[] parse(String uselessContent) {
+        // *** Begining of the evil "parse String" function
+        // 
+        // - 1st : Find the number of ":" in the String. This will be the number of fields in the String. 
+        //      Highly unreliable, as we depend on String content that we don't control!
+        int nbFields = 0;
+        for ( int pos = 0; pos < uselessContent.length(); pos++ ) {
+            if ( uselessContent.substring(pos, pos+1).equals(":") ) {
+                nbFields++;
+            }
+        }
+        
+        // - 2nd : Create the fields array
+        LttngEventField[] tmpFields = new LttngEventField[nbFields];
+        
+        // - 3rd : Fill the array
+        int fieldPosition = 0;
+        
+        int lastFieldPos = 0;
+        int lastDoubleDottedPos = 0;
+        int lastSpacePos = 0;
+        
+        for ( int pos = 0; pos < uselessContent.length(); pos++ ) {
+            if ( uselessContent.substring(pos, pos+1).equals(":") ) {
+                lastDoubleDottedPos = pos;
+            }
+            else if ( uselessContent.substring(pos, pos+1).equals(" ") ) {
+                lastSpacePos = pos;
+                
+                // ANOTHER highly unreliable assumption : 
+                //  Usually, most fields are in the form : "NAME : DATA"
+                //  We need to skip the space following the double dots
+                if ( pos > lastDoubleDottedPos+1 ) {
+                    tmpFields[fieldPosition] = new LttngEventField( uselessContent.substring(lastFieldPos, lastDoubleDottedPos), uselessContent.substring(lastDoubleDottedPos, lastSpacePos)  );
+                    
+                    lastFieldPos = pos;
+                }
+            }
+        }
+        
+        return tmpFields;
+    }
+
+}
index 9ed06528543ea7cbcde4eecfa41d3ec305a7422b..6873f76409a97681197538d4cb89cb61bd7fbf9c 100644 (file)
@@ -15,74 +15,36 @@ package org.eclipse.linuxtools.lttng.event;
 import org.eclipse.linuxtools.tmf.event.*;
 
 /**
- * <b><u>LttngEventReference</u></b><p>
- * 
+ * <b><u>LttngEventReference</u></b>
+ * <p>
  * Lttng specific implementation of the TmfEventReference
+ * <p>
+ * The Lttng implementation is the same as the basic Tmf Implementation but allow construction with a String
  */
 public class LttngEventReference extends TmfEventReference {
     
-    private String tracename = ""; 
     
-    /**
-     * Constructor with parameters.<p>
-     * 
-     * @param newTraceName      Trace name 
-     */
-    public LttngEventReference(String newTraceName) {
-        super("");
-        tracename = newTraceName;
-    }
+    private String tracepath = ""; 
     
     /**
-     * Constructor with parameters with optional tracefile path.<p>
+     * Constructor with parameters
      * 
-     * @param newTracefilePath  Complete tracefile path
-     * @param newTraceName      Trace name 
+     * @param referencePath  A string that will be our reference
      */
-    public LttngEventReference(String newTracefilePath, String newTraceName) {
+    public LttngEventReference(String newTracefilePath, String newTracePath) {
         super(newTracefilePath);
         
-        // Save the name of the trace 
-        tracename = newTraceName;
-    }
-    
-    /**
-     * Copy Constructor.<p>
-     * 
-     * @param oldReference  LttngEventReference to copy from.
-     */
-    public LttngEventReference(LttngEventReference oldReference) {
-        this( oldReference.getValue().toString(), oldReference.getTracepath() );
+        // Save the path of the trace 
+        tracepath = newTracePath;
     }
     
     
     public String getTracepath() {
-        return tracename;
-    }
-    
-    public void setTracepath(String tracename) {
-        this.tracename = tracename;
-    }
-    
-    public String getValue() {
-        return (String)fReference;
+        return tracepath;
     }
-    
-    public void setValue(String newReference) {
-        fReference = newReference;
-    }
-    
-    /**
-     * toString() method.<p>
-     * 
-     * We return only tracename, as it will be used directly in the eventsView.
-     *  Returning only tracename gives a better output.
-     * 
-     * @return tracename as String
-     */
-    @Override
-       public String toString() {
-       return tracename;
+
+    public void setTracepath(String tracepath) {
+        this.tracepath = tracepath;
     }
     
 }
index 861c03bb383adac1eafd85ff8ab5c4a69cddba59..28486852d951da2f3999d2e272329e2f6a7c7dd7 100644 (file)
@@ -15,51 +15,19 @@ package org.eclipse.linuxtools.lttng.event;
 import org.eclipse.linuxtools.tmf.event.*;
 
 /**
- * <b><u>LttngEventSource</u></b><p>
- * 
+ * <b><u>LttngEventSource</u></b>
+ * <p>
  * Lttng specific implementation of the TmfEventSource
+ * <p>
+ * The Lttng implementation is the same as the basic Tmf Implementation but allow construction with a String as paramter
  */
 public class LttngEventSource extends TmfEventSource {
-    
-    /**
-     * Default Constructor.<p>
-     * 
-     */
-    public LttngEventSource() {
-        super();
-    }
-    
     /**
-     * Copy Constructor.<p>
+     * Constructor with parameters
      * 
-     * @param newSource  Source of the event as string.
+     * @param newSource    Name as string of the source.
      */
     public LttngEventSource(String newSource) {
         super(newSource);
     }
-    
-    
-    /**
-     * Copy Constructor.<p>
-     * 
-     * @param oldSource  LttngEventSource to copy from.
-     */
-    public LttngEventSource(LttngEventSource oldSource) {
-        this( (String)oldSource.getSourceId() );
-    }
-    
-    
-    @Override
-       public String getSourceId() {
-        return (String)fSourceId;
-    }
-    
-    public void setSourceId(String newSource) {
-        fSourceId = newSource;
-    }
-    
-    @Override
-       public String toString() {
-        return fSourceId.toString();
-    }
 }
index 156cd4e8f4bafec03c581933950622c2c71ffe84..4cd4f8f75da0a45685cbf06447074c1f91dae231 100644 (file)
@@ -15,73 +15,56 @@ package org.eclipse.linuxtools.lttng.event;
 import org.eclipse.linuxtools.tmf.event.*;
 
 /**
- * <b><u>LttngEventType</u></b><p>
- * 
- * Lttng specific implementation of the TmfEventType.<p>
- * 
+ * <b><u>LttngEventType</u></b>
+ * <p>
+ * Lttng specific implementation of the TmfEventType
+ * <p>
  * This implementation add some attributes to the basic Tmf object.
  */
 public class LttngEventType extends TmfEventType {
-    
-    private String tracefileName    = null;
-    private Long   cpuId            = null;
-    private String markerName       = null;
-    
-    /**
-     * Default Constructor.<p>
-     * 
-     */
-    public LttngEventType() {
-        super();
-    }
+    private String  channelName = "";
+    private long    cpuId = 0;
+    private String  markerName = "";
     
     /**
-     * Constructor with parameters.<p>
+     * Constructor with parameters
      * 
-     * @param thisTracefileName                Tracefile (channel) name in Ltt
-     * @param thisMarkerName           Marker name in LTT
-     * @param thisMarkerfieldsName  MarkerFields related to this marker        
+     * @param thisChannelName   Channel name. It is the Tracefile name in LTT.
+     * @param thisCpuId         CPU id number from LTT
+     * @param thisMarkerName    JniMarker name. It is the marker_info name in LTT.
+     * @param thisFormat        The format relative to the event
+     * @see org.eclipse.linuxtools.lttng.event.LttngEventFormat
      */
-    public LttngEventType(String thisTracefileName, Long thisCpuId, String thisMarkerName, String[] thisMarkerfieldsName) {
-        super( thisTracefileName + "/" + thisCpuId + "/" + thisMarkerName, thisMarkerfieldsName);
+    public LttngEventType(String thisChannelName, long thisCpuId, String thisMarkerName, LttngEventFormat thisFormat) {
+        super( thisChannelName + "/" + thisCpuId + "/" + thisMarkerName, thisFormat);
         
-        tracefileName   = thisTracefileName;
-        cpuId           = thisCpuId;
-        markerName      = thisMarkerName;
+        channelName = thisChannelName;
+        cpuId       = thisCpuId;
+        markerName  = thisMarkerName;
     }
 
-    /**
-     * Copy constructor.<p>
-     * 
-     * @param oldType   Type we want to copy from
-     */
-    public LttngEventType(LttngEventType oldType) {
-        this(oldType.tracefileName, oldType.cpuId, oldType.markerName, oldType.getLabels());
-    }
     
-    
-    public String getTracefileName() {
-        return tracefileName;
+    public String getChannelName() {
+        return channelName;
     }
     
-    public Long getCpuId() {
+    
+    public long getCpuId() {
         return cpuId;
     }
     
+    
     public String getMarkerName() {
         return markerName;
     }
     
+    
     /**
      * toString() method.
      * 
-     * @return TypeId (channel/marker) of the object
+     * @return String  TypeId of the object
      */
-    @Override
-       public String toString() {
-        // *** TODO ***
-        // This is used as-it in the events view, so we won't change its format.
-        //  ...but maybe we should?
-        return tracefileName + "/" + cpuId.toString() + "/" + markerName;
+    public String toString() {
+        return getTypeId();
     }
 }
index df1da9e42a003d3680f72051f329da0724e912bf..8b4c30c4bac6f7002b61402a7b6431d391768868 100644 (file)
@@ -15,87 +15,103 @@ package org.eclipse.linuxtools.lttng.event;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 
 /**
- * <b><u>LttngTimestamp</u></b><p>
- * 
- * Lttng specific implementation of the TmfTimestamp.<p>
- * 
- * The Lttng implementation is the same as the basic Tmf Implementation but allow construction with a TmfTimestamp or a long.
+ * <b><u>LttngTimestamp</u></b>
+ * <p>
+ * Lttng specific implementation of the TmfTimestamp
+ * <p>
+ * The Lttng implementation is the same as the basic Tmf Implementation but allow construction with a TmfTimestamp and a long
  */
 public class LttngTimestamp extends TmfTimestamp {
     
-    // Required by Serializable
-       private static final long serialVersionUID = -7016853105162491273L;
-       
     /**
-     * Default Constructor.<p>
+     * Copy Constructor<br>
+     * <br>
+     * Note : this constructor require a TmfTimestamp instead of a LttngTimestamp to save us some casts
      * 
+     * @param newEventTime    The TmfTimestamp object we want to copy
      */
-       public LttngTimestamp() {
-           super(Long.MIN_VALUE, (byte) -9);
-       }
-       
-       /**
-     * Constructor with parameters.<p>
+    public LttngTimestamp(TmfTimestamp newEventTime) {
+        super(newEventTime);
+    }
+    
+    /**
+     * Constructor with parameters
      * 
-     * @param newEventTime    Time as long, unit expected to be nanoseconds
+     * @param newEventTime    JniTime as long, unit expected to be nanoseconds.
      */
     public LttngTimestamp(long newEventTime) {
         super(newEventTime, (byte) -9);
     }
     
     /**
-     * Copy Constructor.<p>
+     * toString() method.
      * 
-     * @param oldEventTime    The timestamp object we want to copy from
+     * @return String  Attributes of this object.
      */
-    public LttngTimestamp(TmfTimestamp oldEventTime) {
-        this(oldEventTime.getValue());
-    }
-    
-    @Override
-    public long getValue() {
-        return fValue;
-    }
-    
-    public void setValue(long newValue) {
-        fValue = newValue;
+    public String toString() {
+//        String returnData = "";
+//
+//        returnData += "[lttng_Timestamp: " + getValue() / Jni_C_Common.NANO;
+//        returnData += "." + getValue() % Jni_C_Common.NANO;
+//        returnData += " ]";
+//
+//        return returnData;
+
+        // If we are dealing with units of seconds (or higher),
+        // use the plain formatter
+        if (fScale >= 0) {
+            Double value = fValue * Math.pow(10, fScale);
+            return value.toString();
+        }
+
+        // Define a format string
+        String format = String.format("%%1d.%%0%dd", -fScale);
+
+        // And format the timestamp value
+        double scale = Math.pow(10, fScale);
+        long seconds = (long) (fValue * scale);
+        long fracts  = fValue - (long) ((double) seconds / scale); 
+        String result = String.format(format, seconds, fracts);
+
+        return result;
     }
-    
+
        /**
-        * Get the second part in timestamp.<p>
-        * 
-        * Note : We do not use scale and assumes contents to be in nano seconds.
+        * This method does not use scale and assumes contents to be in nano seconds
         * 
-        * @return Seconds in the object, in string.
+        * @return String Attributes of this object.
         */
        public String getSeconds() {
                return formatSecs(fValue);
        }
 
        /**
-     * Get the nanosecond part in timestamp.<p>
-     * 
-     * Note : We do not use scale and assumes contents to be in nanoseconds.
+        * This method does not use scale and assumes contents to be in nano seconds
         * 
-        * @return Seconds in the object, in string.
+        * @return String Attributes of this object.
         */
        public String getNanoSeconds() {
                return formatNs(fValue);
        }
-       
-       /*
-        * Use the exponent to format the second in the correct format.
+
+       /**
+        * @param time
+        * @return
         */
        private String formatSecs(long time) {
                long sec = (long) (time * 1E-9);
                return String.valueOf(sec);
        }
 
-       /*
+       /**
         * Obtains the remainder fraction on unit Seconds of the entered value in
-        * nanoseconds. e.g. input: 1241207054171080214 ns.
-        * The number of fraction seconds can be obtained by removing the last 9 digits: 
-        * In 1241207054, the fractional portion of seconds, expressed in ns is: 171080214
+        * nanoseconds. e.g. input: 1241207054171080214 ns The number of fraction
+        * seconds can be obtained by removing the last 9 digits: 1241207054 the
+        * fractional portion of seconds, expressed in ns is: 171080214
+        * 
+        * @param time
+        * @param res
+        * @return
         */
        private String formatNs(long time) {
                boolean neg = time < 0;
@@ -105,7 +121,8 @@ public class LttngTimestamp extends TmfTimestamp {
                // The following approach could be used although performance
                // decreases in half.
                // String strVal = String.format("%09d", time);
-               // String tmp = strVal.substring(strVal.length() - 9)
+               // String tmp = strVal.substring(strVal.length() - 9);
+
                StringBuffer temp = new StringBuffer();
                long ns = time;
                ns %= 1000000000;
@@ -131,31 +148,4 @@ public class LttngTimestamp extends TmfTimestamp {
                return temp.toString();
        }
 
-       
-    /**
-     * toString() method.
-     * 
-     * @return timestamp, as string
-     */
-    @Override
-       public String toString() {
-
-        // If we are dealing with units of seconds (or higher),
-        // use the plain formatter
-        if (fScale >= 0) {
-            Double value = fValue * Math.pow(10, fScale);
-            return value.toString();
-        }
-
-        // Define a format string
-        String format = String.format("%%1d.%%0%dd", -fScale);
-
-        // And format the timestamp value
-        double scale = Math.pow(10, fScale);
-        long seconds = (long) (fValue * scale);
-        long fracts  = fValue - (long) ((double) seconds / scale); 
-        String result = String.format(format, seconds, fracts);
-
-        return result;
-    }
 }
index c9acabe9f93ebb28fc5d191e741e6e6e348e07a8..2e034bf82952cddbf3f12c88dad9c2dd49d3484d 100644 (file)
@@ -1,4 +1,3 @@
-package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -11,44 +10,46 @@ package org.eclipse.linuxtools.lttng.jni;
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
+package org.eclipse.linuxtools.lttng.jni;
 
 import java.util.HashMap;
 
 /**
- * <b><u>JniEvent</u></b> <p>
- * 
- * A JniEvent has the actual content that got traced by Lttng.<br>
- * Provides access to the LttEvent C structure in java. <p>
- * 
+ * <b><u>JniEvent</u></b>
+ * <p>
+ * A JniEvent has the actual content that got traced by Lttng It provides access to the LttEvent C structure in java.
+ * <p>
  * Most important fields in the JniEvent are :
  * <ul>
- * <li>an event time, which is a digested timestamp.
+ * <li>an event time, which is a digested timestamp
  * </ul>
  * Note that the JniEvent content is not directly accessibe and should be obtained
- * using the parseAllFields() or parseFieldBy...() methods.
+ * using the requestEventContent() or parse() method.
  */
-public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent> {
+public final class JniEvent extends Jni_C_Common {
     // Variables to detect if the event have been filled at least once
     // this make possible the detection of "uninitialized" struct in Ltt
     // Can be "EOK", "ERANGE" or "EPERM" (defined in Jaf_C_Common)
     private int eventState = EPERM; // Start with EPERM to ensure sanity
 
     // Internal C pointer of the JniEvent used in LTT
-    private Jni_C_Pointer thisEventPtr = new Jni_C_Pointer();
+    private C_Pointer thisEventPtr = new C_Pointer();
 
     // Reference to the parent tracefile
     private JniTracefile parentTracefile = null;
 
     // This map hold marker relative to the parent tracefile of this event
     // They are "our" marker in this event
-    private HashMap<Integer, JniMarker> markersMap = null;
+    private HashMap<Integer, JniMarker> markersMap;
 
     // Data we should populate from ltt
     // Note that all type have been scaled up as there is no "unsigned" in java
     // This might be a problem about "unsigned long" as there is no equivalent
     // in java
-    private Jni_C_Pointer tracefilePtr = new Jni_C_Pointer();
+    private C_Pointer tracefilePtr = new C_Pointer();;
+    private int eventMarkerId = 0;
     private JniTime eventTime = null;
+    private long eventDataSize = 0;
 
     // These methods need a tracefile pointer, instead of a event pointer
     private native int      ltt_readNextEvent(long tracefilePtr);
@@ -66,8 +67,6 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     @SuppressWarnings("unused")
     private native long     ltt_getTimestamp(long eventPtr);
     private native int      ltt_getEventMarkerId(long eventPtr);
-    private native long     ltt_getNanosencondsTime(long eventPtr);
-    @SuppressWarnings("unused")
     private native void     ltt_feedEventTime(long eventPtr, JniTime eventTime);
     private native long     ltt_getEventDataSize(long eventPtr);
     @SuppressWarnings("unused")
@@ -96,9 +95,10 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     };
 
     /**
-     * Copy constructor.<p>
+     * Copy constructor.
      * 
-     * @param oldEvent      Reference to the JniEvent you want to copy. 
+     * @param oldEvent
+     *            A reference to the JniEvent you want to copy. 
      */
     public JniEvent(JniEvent oldEvent) {
         thisEventPtr = oldEvent.thisEventPtr;
@@ -107,26 +107,24 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
         eventState = oldEvent.eventState;
 
         tracefilePtr = oldEvent.tracefilePtr;
+        eventMarkerId = oldEvent.eventMarkerId;
         eventTime = oldEvent.eventTime;
+        eventDataSize = oldEvent.eventDataSize;
     }
     
     /**
-     * Constructor with parameters<p>
-     * 
-     * This constructor could throw. It will happen if an event can not be populated on <u>first read</u>.<br>
+     * Constructor with parameters<br>
+     * <br>
+     * This constructor could throw. It will happen if an event can not be populated on first read.<br>
      * In that case, the parent tracefile is probably useless and should be deleted.
      * 
      * @param newEventPtr         C pointer (converted in long) of the LttEvent C structure.
      * @param newMarkersMap       Reference an already populated HashMap of JniMarker objects 
      * @param newParentTracefile  Reference to the parent JniTracefile of this JniEvent
      *            
-     * @exception JniException
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @exception JniException           
      */
-    public JniEvent(Jni_C_Pointer newEventPtr, HashMap<Integer, JniMarker> newMarkersMap, JniTracefile newParentTracefile) throws JniException {
+    public JniEvent(C_Pointer newEventPtr, HashMap<Integer, JniMarker> newMarkersMap, JniTracefile newParentTracefile) throws JniException {
 
         // Basic test to make sure we didn't get null/empty value 
         if ((newEventPtr.getPointer() == NULL)
@@ -135,20 +133,23 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
                 || (newParentTracefile == null)) {
             throw new JniEventException("Null or empty value passed to constructor, object is invalid! (JniEvent)");
         }
-        
+
         thisEventPtr = newEventPtr;
         tracefilePtr = newParentTracefile.getTracefilePtr();
         markersMap = newMarkersMap;
         parentTracefile = newParentTracefile;
 
         eventTime = new JniTime();
-        
+
         // Try to move to the first event
-        // If the event is Out of Range (ERANGE) at the first read, 
-        //  this event type will never be usable.
-        // In that case, throw JniNoSuchEventException to warn the tracefile.
+        // If the event is Out of Range (ERANGE) at the first range, this event
+        // type will never been usable
+        // In that case, throw JafEventOutOfRangeException to warn the parent
+        // tracefile
+        //
+        // Position ourself on the next (first?) event
         eventState = positionToFirstEvent();
-        if (eventState != EOK)  {
+        if (eventState != EOK) {
             throw new JniNoSuchEventException("Object not populated, unusable. There is probably no event of that type in the trace. (JniEvent)");
         }
         else {
@@ -157,38 +158,37 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     }
 
     /**
-     * Move to the next event and populate the java object with LttEvent structure.<p>
-     * 
-     * If the move fails, the event will not get populated and the last event data will still be available.
-     * 
-     * @return LTT read status, as defined in Jni_C_Common.
+     * Move to the next event and populate LttEvent structure into the java object.<br>
+     * <br>
+     * If the move fails, the event will not get populated and the last event's data will still be available.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @return The read status, as defined in Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
      public int readNextEvent() {
         // Ask Ltt to read the next event for this particular tracefile
-        eventState = ltt_readNextEvent( tracefilePtr.getPointer() );
+        eventState = ltt_readNextEvent(tracefilePtr.getPointer() );
+
         // If the event state is sane populate it
         if (eventState == EOK) {
             populateEventInformation();
         }
-        
+
         return eventState;
     }
 
     /**
-     * Seek to a certain time.<p>
-     * 
-     * Seek to a certain time and read event at this exact time or the next one if there is no event there.<p>
-     * 
-     * Note that this function can seek in an invalid position if the timestamp is after the last event.<br>
-     * In that case, a seek back would be required to get back to a consistent state.<p>
-     * 
-     * If the seek fails, the event will not get populated and the last event data will still be available.<p>
-     * 
-     * @return LTT read status, as defined in Jni_C_Common
+     * Seek to a certain time.<br>
+     * <br>
+     * Seek to a certain time and read event at this exact time or the next one if there is no event there.<br>
+     * <br>
+     * Note that this function could end in an invalid position if we seek after the last event. <br>
+     * In that case, a seek back would be required to get back to a consistent state.<br>
+     * <br>
+     * If the seek fails, the event will not get populated and the last event's data will still be available.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @return The read status, as defined in Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
     public int seekToTime(JniTime seekTime) {
         // Ask Ltt to read the next event for this particular tracefile
@@ -203,29 +203,30 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     }
 
     /**
-     * Try to seek to a certain time and seek back if it failed.<p>
-     * 
-     * Seek to a certain time and read event at this exact time or the next one if there is no event there.<p>
-     * 
-     * If the seek fails, we will seek back to the previous position, so the event will stay in a consistent state.<p> 
-     * 
-     * @return LTT read status, as defined in Jni_C_Common
+     * Seek to a certain time or seek back if it fails.<br>
+     * <br>
+     * Seek to a certain time and read event at this exact time or the next one if there is no event there.<br>
+     * If the seek fails, we will seek back to the previous position, so the event will stay in a consistent state. 
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @return The read status, as defined in Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
     public int seekOrFallBack(JniTime seekTime) {
         // Save the old time
-        JniTime oldTime = new JniTime(eventTime);
+        JniTime oldTime = eventTime;
 
         // Call seek to move ahead
-        // Save the state for the return (eventState will be modified if we seek back)
-        int returnState = seekToTime(seekTime);
+        seekToTime(seekTime);
+        // Save the state for the return
+        int returnState = eventState;
 
         // If the event state is sane populate it
-        if (returnState == EOK) {
+        if (eventState == EOK) {
             populateEventInformation();
         }
-        else {
+
+        // Move to Next event only if the state of the event is sane
+        if (eventState != EOK) {
             seekToTime(oldTime);
         }
 
@@ -233,15 +234,13 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     }
 
     /**
-     * Position on the first event in the tracefile.<p>
-     * 
-     * The function return the read status after the first event.<p>
-     * 
-     * A status different of EOK probably means there is no event associated to this tracefile.
-     * 
-     * @return LTT read status, as defined in Jni_C_Common
+     * Position on the first event in the tracefile.<br>
+     * <br>
+     * The function will return the read status of the event.<br>
+     * An erronous status probably means there is no event of that type associated to the tracefile.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @return The read status, as defined in Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
     public int positionToFirstEvent() {
         eventState = ltt_positionToFirstEvent(tracefilePtr.getPointer());
@@ -250,86 +249,70 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     }
     
     /**
-     * Obtain a marker associated with this tracefile's event.
+     * Method to obtain a marker associated with this particular event.
      * 
-     * @return Reference to the marker for this tracefile's event or null if none.
-     *  
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
+     * @return  Reference to the JniMarker object for this event or null if none. 
+     * @see org.eclipse.linuxtools.lttng.jni.JniMarker
      */
     public JniMarker requestEventMarker() {
-        return markersMap.get(getEventMarkerId());
+        return markersMap.get(eventMarkerId);
     }
 
     /**
-     * Obtain the raw data of a LttEvent object.<p>
-     * 
-     * The data will be in raw C bytes, not java bytes.<br>
-     * Note : This function is mostly untested and provided "as is".
+     * Method to obtain the raw data of a LttEvent object.<br>
+     * <br>
+     * Note : The data will be in raw C bytes, not java bytes. 
      * 
-     * @return  Bytes array of raw data (contain raw C bytes).
+     * @return  bytes array of raw data.
      */
     public byte[] requestEventContent() {
-        byte dataContent[] = new byte[(int) getEventDataSize()];
 
-        ltt_getDataContent(thisEventPtr.getPointer(), getEventDataSize(), dataContent);
+        byte dataContent[] = new byte[(int) eventDataSize];
+
+        ltt_getDataContent(thisEventPtr.getPointer(), eventDataSize, dataContent);
 
         return dataContent;
     }
-    
+
+    // *** TODO ***
+    // No "Source" of event exist in Ltt so far
+    // It would be a good addition to have a way to detect where an event come
+    // from, like "kernel" or "userspace"
+    // 
     /**
-     * Obtain an event source.<p>
-     * 
+     * Method to obtain an event source.<br>
+     * <br>
      * This is not implemented yet and will always return "Kernel core" for now.
      * 
      * @return  Reference to the JniMarker object for this event or null if none. 
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
+     * @see org.eclipse.linuxtools.lttng.jni.JniMarker
      */
     public String requestEventSource() {
-        // *** TODO ***
-        // No "Source" of event exists in Ltt so far
-        // It would be a good addition to have a way to detect where an event come
-        // from, like "kernel" or "userspace"
-        // 
         return "Kernel Core";
     }
     
     /**
-     * Parse a particular field in the event payload, identified by its id (position).<p>
-     * 
-     * Note : Position are relative to an event marker (i.e. requestEventMarker().getMarkerFieldsArrayList() )
-     * 
-     * @param fieldId   Position of the field to parse.
+     * Method to parse a particular field in the event payload, identified by its id (position).
      * 
      * @return Object that contain the parsed payload
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser
      */
     public Object parseFieldById(int fieldId) {
         return JniParser.parseField(this, fieldId);
     }
     
     /**
-     * Parse a particular field in the event payload, identified by its name.<p>
-     * 
-     * Note : Name are relative to an event marker (i.e. requestEventMarker().getMarkerFieldsHashMap() )
-     * 
-     * @param fieldName   Position of the field to parse.
+     * Method to parse a particular field in the event payload, identified by its name.
      * 
      * @return Object that contain the parsed payload
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser
      */
     public Object parseFieldByName(String fieldName) {
         return JniParser.parseField(this, fieldName);
     }
     
     /**
-     * Method to parse all the event payload.<p>
-     * 
-     * @return HashMap<String, Object> which is the parsedContent objects and their name as key.
+     * Method to parse all the event payload.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser 
+     * @return  ArrayList of ParsedContent objects. 
      */
     public HashMap<String, Object> parseAllFields() {
         return JniParser.parseAllFields(this);
@@ -338,57 +321,61 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     /* 
      * This function populates the event data with data from LTT
      * 
-     * NOTE : To get better performance, we copy very few data into memory here
-     * 
      */
     private void populateEventInformation() {
-       // We need to save the time, as it is not a primitive (can't be dynamically called in getter)
-       eventTime.setTime(ltt_getNanosencondsTime(thisEventPtr.getPointer() ));
+        if (thisEventPtr.getPointer() == NULL) {
+            printlnC("Pointer is NULL, trace closed? (populateEventInformation)");
+        }
+        else {
+            tracefilePtr = new C_Pointer( ltt_getTracefilePtr(thisEventPtr.getPointer()) );
+            eventMarkerId = ltt_getEventMarkerId(thisEventPtr.getPointer());
+
+            // Creation of time is a bit different, we need to pass the object
+            // reference to C
+            ltt_feedEventTime(thisEventPtr.getPointer(), eventTime);
+
+            eventDataSize = ltt_getEventDataSize(thisEventPtr.getPointer());
+        }
     }
     
+    public int getEventMarkerId() {
+        return eventMarkerId;
+    }
+
     public JniTime getEventTime() {
         return eventTime;
     }
-    
-    // *** To get better performance, all getter belows call LTT directly ****
-    //     That way, we can avoid copying data into memory
-    public int getEventMarkerId() {
-        return ltt_getEventMarkerId(thisEventPtr.getPointer());
-    }
 
     public long getEventDataSize() {
-        return ltt_getEventDataSize(thisEventPtr.getPointer());
+        return eventDataSize;
     }
 
     public HashMap<Integer, JniMarker> getMarkersMap() {
         return markersMap;
     }
 
+    
     /**
-     * Pointer to the parent LTTTracefile C structure.<br>
+     * Pointer to the parent LttEvent C structure<br>
      * <br>
-     * The pointer should only be used <u>INTERNALY</u>, do not use unless you
+     * The pointer should only be used INTERNALY, do not use these unless you
      * know what you are doing.
      * 
-     * @return The actual (long converted) pointer or NULL.
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @return The actual (long converted) pointer or NULL
      */
-    public Jni_C_Pointer getTracefilePtr() {
-        return new Jni_C_Pointer( ltt_getTracefilePtr(thisEventPtr.getPointer()) );
+    public C_Pointer getTracefilePtr() {
+        return tracefilePtr;
     }
 
     /**
-     * Pointer to the LttEvent C structure.<br>
+     * Pointer to the LttEvent C structure<br>
      * <br>
-     * The pointer should only be used <u>INTERNALY</u>, do not use unless you
+     * The pointer should only be used INTERNALY, do not use these unless you
      * know what you are doing.
      * 
-     * @return The actual (long converted) pointer or NULL.
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @return The actual (long converted) pointer or NULL
      */
-    public Jni_C_Pointer getEventPtr() {
+    public C_Pointer getEventPtr() {
         return thisEventPtr;
     }
 
@@ -399,50 +386,39 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
     /**
      * Getter to the parent tracefile for this event.
      *
-     * @return  The parent tracefile 
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @return  the parent tracefile 
+     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
      */
     public JniTracefile getParentTracefile() {
         return parentTracefile;
     }
-    
+
     /**
-     * Compare fonction for JNIEvent.<p>
-     * <p>
-     * This will compare the current JNIEvent with a passed one by timestamp AND tracefile ("type").<br>
-     * If both are equal but type differs, current event is considered to be older (-1 returned).
+     * toString() method. <u>Intended to debug</u><br>
      * 
-     * @return -1 if given event happens before, 0 if equal, 1 if passed event happens after.
+     * @return String Attributes of the object concatenated in String
      */
-    public int compareTo(JniEvent rightEvent ){
-       
-       // Note : this = left hand operand
-       
-        // By default, we consider the current event to be older.
-        int eventComparaison = -1; 
-        
-        // Test against null before performing anything
-        if ( rightEvent != null ) {
-            // Compare the timestamp first
-            eventComparaison = this.getEventTime().compareTo( rightEvent.getEventTime() );
-            
-            // If timestamp is equal, compare the parent tracefile ("event type")
-            if ( (eventComparaison == 0) && ( !this.parentTracefile.equals(rightEvent.parentTracefile)) ) {
-                eventComparaison = 1;
-            }
-        }
-        return eventComparaison;
+    public String toString() {
+        String returnData = "";
+
+        returnData += "tracefilePtr            : " + tracefilePtr + "\n";
+        returnData += "eventMarkerId           : " + eventMarkerId + "\n";
+        returnData += "eventTime               : " + eventTime.getReferenceToString() + "\n";
+        returnData += "   seconds              : " + eventTime.getSeconds() + "\n";
+        returnData += "   nanoSeconds          : " + eventTime.getNanoSeconds() + "\n";
+        returnData += "eventDataSize           : " + eventDataSize + "\n";
+        returnData += "markersMap              : " + markersMap.keySet() + "\n"; // Hack to avoid ending up with markersMap.toString()
+
+        return returnData;
     }
-    
+
     /**
-     * Print information for this event. 
-     * <u>Intended to debug</u><br>
-     * 
-     * This function will call Ltt to print, so information printed will be 
-     * the one from the C structure, not the one populated in java.<p>
+     * Print information for this event. <u>Intended to debug</u><br>
      * 
-     * This function will not throw but will complain loudly if pointer is NULL.
+     * This function will call Ltt to print, so information printed will be the one from the C structure<br>
+     * <br>
+     * This function will not throw but will complain loudly if pointer is NULL
      */
     public void printEventInformation() {
 
@@ -454,25 +430,4 @@ public final class JniEvent extends Jni_C_Common implements Comparable<JniEvent>
             ltt_printEvent(thisEventPtr.getPointer());
         }
     }
-    
-    /**
-     * toString() method. 
-     * <u>Intended to debug.</u><p>
-     * 
-     * @return Attributes of the object concatenated in String
-     */
-    @Override
-       public String toString() {
-        String returnData = "";
-
-        returnData += "tracefilePtr            : " + tracefilePtr + "\n";
-        returnData += "eventMarkerId           : " + getEventMarkerId() + "\n";
-        returnData += "eventTime               : " + eventTime.getReferenceToString() + "\n";
-        returnData += "   seconds              : " + eventTime.getSeconds() + "\n";
-        returnData += "   nanoSeconds          : " + eventTime.getNanoSeconds() + "\n";
-        returnData += "eventDataSize           : " + getEventDataSize() + "\n";
-        returnData += "markersMap              : " + markersMap.keySet() + "\n"; // Hack to avoid ending up with markersMap.toString()
-
-        return returnData;
-    }
 }
index 7f8adf6e0db9bc6d61f2231dfd1249b7ce5701ee..6e3870a450d7c72a9f6b0513228b321bc9fc8994 100644 (file)
@@ -1,4 +1,3 @@
-package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -11,11 +10,12 @@ package org.eclipse.linuxtools.lttng.jni;
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
+package org.eclipse.linuxtools.lttng.jni;
 
 /**
  * <b><u>JniException</u></b>
  * <p>
- * Super class for JNI exception.
+ * Super exception class for JNI
  */
 public class JniException extends Exception {
     private static final long serialVersionUID = -6620784221853154537L;
index 3990bfc15c7f154948fc47fe8d8fbcbbfb46f255..41138ff81e0472161f1dbca15997ab3cd1d58d8c 100644 (file)
@@ -1,4 +1,3 @@
-package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -11,18 +10,17 @@ package org.eclipse.linuxtools.lttng.jni;
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
+package org.eclipse.linuxtools.lttng.jni;
 
 import java.util.ArrayList;
 import java.util.HashMap;
 
 /**
- * <b><u>JniMarker</u></b><p>
- * 
+ * <b><u>JniMarker</u></b>
+ * <p>
  * A JniMarker contain information how to interpret the unparsed content (payload) of an event.<br>
  * Each JniMarker contains several MarkerFields for each fields in the event's payload.
- * 
- * Provides access to the marker_info C structure (from LTT) in java. 
- * 
+ * <p>
  * Most important fields in the JniMarker are :
  * <ul>
  * <li> the name of the marker in String
@@ -33,7 +31,7 @@ import java.util.HashMap;
 public final class JniMarker extends Jni_C_Common
 {
     // Internal C pointer of the JniEvent used in LTT
-    private Jni_C_Pointer thisMarkerPtr = new Jni_C_Pointer();
+    private C_Pointer thisMarkerPtr = new C_Pointer();
 
     private String name = "";
     private String formatOverview = "";
@@ -72,7 +70,7 @@ public final class JniMarker extends Jni_C_Common
         System.loadLibrary("lttvtraceread");
     }
 
-    /*
+    /**
      * Default constructor is forbidden
      */
     @SuppressWarnings("unused")
@@ -80,9 +78,10 @@ public final class JniMarker extends Jni_C_Common
     }
     
     /**
-     * Copy constructor.<p>
+     * Copy constructor.
      * 
-     * @param oldMarker Reference to the JniMarker you want to copy. 
+     * @param oldMarker
+     *            A reference to the JniMarker you want to copy. 
      */
     public JniMarker(JniMarker oldMarker) {
         thisMarkerPtr = oldMarker.thisMarkerPtr;
@@ -94,13 +93,13 @@ public final class JniMarker extends Jni_C_Common
     }
 
     /**
-     * Constructor, using pointer.<p>
+     * Copy constructor, using pointer.
      * 
      * @param newMarkerPtr  Pointer to a C marker_info structure
      * 
      * @exception JniException
      */
-    public JniMarker(Jni_C_Pointer newMarkerPtr) throws JniException {
+    public JniMarker(C_Pointer newMarkerPtr) throws JniException {
         thisMarkerPtr = newMarkerPtr;
         markerFieldsArrayList = new ArrayList<JniMarkerField>();
         markerFieldsHashMap = new HashMap<String, JniMarkerField>();
@@ -140,7 +139,7 @@ public final class JniMarker extends Jni_C_Common
         // Create a new Jaf_markerField object and insert it in the map
         // the maker field fill itself with LTT data while being constructed
         try {
-            JniMarkerField newMarkerField = new JniMarkerField( new Jni_C_Pointer(markerFieldPtr) );
+            JniMarkerField newMarkerField = new JniMarkerField( new C_Pointer(markerFieldPtr) );
             markerFieldsArrayList.add(newMarkerField);
             markerFieldsHashMap.put(markerFieldName, newMarkerField);
             
@@ -165,47 +164,40 @@ public final class JniMarker extends Jni_C_Common
     public ArrayList<JniMarkerField> getMarkerFieldsArrayList() {
         return markerFieldsArrayList;
     }
-    
+
+
     /**
-     * Pointer to the marker_info C structure.<p>
-     * 
-     * The pointer should only be used <u>INTERNALY</u>, do not use unless you
-     * know what you are doing.<p>
+     * Pointer to the marker_info C structure<br>
+     * <br>
+     * The pointer should only be used INTERNALY, do not use these unless you
+     * know what you are doing.
      * 
      * @return The actual (long converted) pointer or NULL
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
-    public Jni_C_Pointer getMarkerPtr() {
+    public C_Pointer getMarkerPtr() {
         return thisMarkerPtr;
     }
-    
-    
+
     /**
-     * Print information for this JniMarker. 
-     * <u>Intended to debug</u><br>
-     * 
-     * This function will call Ltt to print, so information printed will be the one from 
-     * the C structure, not the one populated in java.<p>
+     * toString() method. <u>Intended to debug</u><br>
      * 
-     * This function will not throw but will complain loudly if pointer is NULL
+     * @return String Attributes of the object concatenated in String
      */
-    public void printMarkerInformation() {
+    public String toString() {
+        String returnData = "";
 
-        // If null pointer, print a warning!
-        if (thisMarkerPtr.getPointer() == NULL) {
-            printlnC("Pointer is NULL, cannot print. (printMarkerInformation)");
-        } else {
-            ltt_printMarker(thisMarkerPtr.getPointer());
-        }
+        returnData += "name                    : " + name + "\n";
+        returnData += "formatOverview          : " + formatOverview + "\n";
+        returnData += "markerFieldArrayList    : " + markerFieldsArrayList.toArray() + "\n";
+
+        return returnData;
     }
+
     
     /**
-     * Print information for ALL marker fields for this marker. 
-     * <u>Intended to debug</u><br>
+     * Print information for ALL marker fields for this marker. <u>Intended to debug</u><br>
      * 
-     * This function will call Ltt to print, so information printed will be the one from 
-     * the C structure, not the one populated in java.
+     * This function will call Ltt to print, so information printed will be the one from the C structure
      */
     public void printAllMarkerFieldsInformation() {
         Object[] allMarkersField = markerFieldsArrayList.toArray();
@@ -214,22 +206,21 @@ public final class JniMarker extends Jni_C_Common
             printlnC(allMarkersField[pos].toString());
         }
     }
-    
+
     /**
-     * toString() method. 
-     * <u>Intended to debug</u><br>
+     * Print information for this JniMarker. <u>Intended to debug</u><br>
      * 
-     * @return Attributes of the object concatenated in String
+     * This function will call Ltt to print, so information printed will be the one from the C structure<br>
+     * <br>
+     * This function will not throw but will complain loudly if pointer is NULL
      */
-    @Override
-       public String toString() {
-        String returnData = "";
-
-        returnData += "name                    : " + name + "\n";
-        returnData += "formatOverview          : " + formatOverview + "\n";
-        returnData += "markerFieldArrayList    : " + markerFieldsArrayList.toArray() + "\n";
+    public void printMarkerInformation() {
 
-        return returnData;
+        // If null pointer, print a warning!
+        if (thisMarkerPtr.getPointer() == NULL) {
+            printlnC("Pointer is NULL, cannot print. (printMarkerInformation)");
+        } else {
+            ltt_printMarker(thisMarkerPtr.getPointer());
+        }
     }
-    
 }
index de2422f2aba4a619dba2fb33d938492c28621888..23fe636d0e85f017055809764e39f2ecc34dc35b 100644 (file)
@@ -1,4 +1,3 @@
-package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -11,13 +10,13 @@ package org.eclipse.linuxtools.lttng.jni;
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
+package org.eclipse.linuxtools.lttng.jni;
 
 /**
- * <b><u>JniMarkerField</u></b> <p>
- * A JniMarkerField is one of the field of the unparsed content (payload) of an event. <p>
- * 
- * Provides access to the marker_field C structure (from LTT) in java.<p>
- * 
+ * <b><u>JniMarkerField</u></b>
+ * <p>
+ * A JniMarkerField is one of the field of the unparsed content (payload) of an event
+ * <p>
  * Most important attributes in the JniMarkerField are :
  * <ul>
  * <li> the name (field) of in String
@@ -27,11 +26,11 @@ package org.eclipse.linuxtools.lttng.jni;
 public final class JniMarkerField extends Jni_C_Common
 {
     // Internal C pointer of the JniEvent used in LTT
-    private Jni_C_Pointer thisMarkerFieldPtr = new Jni_C_Pointer();
+    private C_Pointer thisMarkerFieldPtr = new C_Pointer();
 
     private String field = "";
     private String format = "";
-    
+
     // Native access method
     private native String ltt_getField(long markerFieldPtr);
     @SuppressWarnings("unused")
@@ -55,7 +54,7 @@ public final class JniMarkerField extends Jni_C_Common
         System.loadLibrary("lttvtraceread");
     }
 
-    /*
+    /**
      * Default constructor is forbidden
      */
     @SuppressWarnings("unused")
@@ -63,9 +62,10 @@ public final class JniMarkerField extends Jni_C_Common
     }
 
     /**
-     * Copy constructor.<p>
+     * Copy constructor.
      * 
-     * @param oldMarkerField Reference to the JniMarkerField you want to copy. 
+     * @param oldMarkerField
+     *            A reference to the JniMarkerField you want to copy. 
      */
     public JniMarkerField(JniMarkerField oldMarkerField) {
         thisMarkerFieldPtr = oldMarkerField.getMarkerFieldPtr();
@@ -74,13 +74,13 @@ public final class JniMarkerField extends Jni_C_Common
     }
 
     /**
-     * Constructor, using pointer.<p>
+     * Copy constructor, using pointer.
      * 
      * @param newMarkerFieldPtr  Pointer to a C marker_field structure
      * 
      * @exception JniException
      */
-    public JniMarkerField(Jni_C_Pointer newMarkerFieldPtr) throws JniException {
+    public JniMarkerField(C_Pointer newMarkerFieldPtr) throws JniException {
         thisMarkerFieldPtr = newMarkerFieldPtr;
 
         // Populate the marker field
@@ -110,25 +110,34 @@ public final class JniMarkerField extends Jni_C_Common
     }
 
     /**
-     * Pointer to the marker_field C structure.<p>
-     * 
-     * The pointer should only be used <u>INTERNALY</u>, do not use these unless you
-     * know what you are doing.<p>
+     * Pointer to the marker_field C structure<br>
+     * <br>
+     * The pointer should only be used INTERNALY, do not use these unless you
+     * know what you are doing.
      * 
      * @return The actual (long converted) pointer or NULL
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
-    public Jni_C_Pointer getMarkerFieldPtr() {
+    public C_Pointer getMarkerFieldPtr() {
         return thisMarkerFieldPtr;
     }
-    
+
     /**
-     * Print information for this event. <u>Intended to debug</u><br>
+     * toString() method. <u>Intended to debug</u><br>
      * 
-     * This function will call Ltt to print, so information printed will be the one from 
-     * the C structure, not the one populated in java.<p>
+     * @return String Attributes of the object concatenated in String
+     */
+    public String toString() {
+        String returnData = "";
+        returnData += "field                   : " + field + "\n";
+        returnData += "format                  : " + format + "\n";
+        return returnData;
+    }
+
+    /**
+     * Print information for this event. <u>Intended to debug</u><br>
      * 
+     * This function will call Ltt to print, so information printed will be the one from the C structure<br>
+     * <br>
      * This function will not throw but will complain loudly if pointer is NULL
      */
     public void printMarkerFieldInformation() {
@@ -140,19 +149,4 @@ public final class JniMarkerField extends Jni_C_Common
             ltt_printMarkerField(thisMarkerFieldPtr.getPointer());
         }
     }
-    
-    /**
-     * toString() method. 
-     * <u>Intended to debug</u><br>
-     * 
-     * @return Attributes of the object concatenated in String
-     */
-    @Override
-    public String toString() {
-        String returnData = "";
-        returnData += "field                   : " + field + "\n";
-        returnData += "format                  : " + format + "\n";
-        
-        return returnData;
-    }
 }
index 4f1ee63f23ae0a20b56bb53f79b5a36b85839b9a..ceeb4965ba2c323cb0a9f5207bca629ccf4033ea 100644 (file)
@@ -1,4 +1,3 @@
-package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -11,15 +10,14 @@ package org.eclipse.linuxtools.lttng.jni;
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
+package org.eclipse.linuxtools.lttng.jni;
 
 import java.util.HashMap;
-import java.util.Iterator;
 
 /**
- * <b><u>JniParser</u></b><p>
- * 
- * JniParser is used to parse an event payload into something usable.<p>
- * 
+ * <b><u>JniParser</u></b>
+ * <p>
+ * JniParser class.
  * All methods are static, the parser shouldn't be instantiated.
  */
 public class JniParser extends Jni_C_Common
@@ -29,32 +27,25 @@ public class JniParser extends Jni_C_Common
     static {
         System.loadLibrary("lttvtraceread");
     }
-    
-    // *** HACK ***
-    // We cannot use "Object" directly as java does not support swapping primitive value
-    //    We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
-    //    Another (ugly) hack would be to pass an array to modify the reference's reference.
-    // ***
-    private static ParsedObjectContent parsedData = new ParsedObjectContent();
-    
-    /*
+
+    /**
      * Default constructor is forbidden
      */
     private JniParser() {
     }
     
     
+    
     /**
-     * Method to parse a single field identified by its id.<p>
-     * 
-     * All parsing will be done on C side as we need LTT functions.
+     * Method to parse a single field identified by its id<br>
+     * All parsing will be done on C side as we need Ltt function
      * 
      * @param   eventToParse    The jni event we want to parse. 
      * @param   fieldPosition   The position (or id) of the field we want to parse
      * 
      * @return                  An Object that contain the JniEvent payload parsed by the C, or null, if if was impossible to parse (i.e., wrong position)
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     static public Object parseField(JniEvent eventToParse, int fieldPosition) {
         
@@ -63,26 +54,29 @@ public class JniParser extends Jni_C_Common
             return null;
         }
         
-        JniMarkerField tmpField = eventToParse.requestEventMarker().getMarkerFieldsArrayList().get(fieldPosition);
+        // *** HACK ***
+        // We cannot use "Object" directly as java does not support swapping primitive value
+        //  We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
+        // ***
+        ParsedObjectContent parsedData = new ParsedObjectContent();
         
         // Call the parsing function in C. The result will be put in parsedData object
-        ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), tmpField.getMarkerFieldPtr().getPointer() );
+        ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), eventToParse.requestEventMarker().getMarkerFieldsArrayList().get(fieldPosition).getMarkerFieldPtr().getPointer() );
         
         return parsedData.getData();
     }
     
     
     /**
-     * Method to parse a single field identified by its name.<p>
-     * 
-     * All parsing will be done on C side as we need LTT functions.
+     * Method to parse a single field identified by its name<br>
+     * All parsing will be done on C side as we need Ltt function
      * 
      * @param   eventToParse    The jni event we want to parse. 
-     * @param   fieldName       The name of the field we want to parse.
+     * @param   fieldPosition   The position (or id) of the field we want to parse
      * 
      * @return                  An Object that contain the JniEvent payload parsed by the C, or null, if if was impossible to parse (i.e., wrong position)
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     static public Object parseField(JniEvent eventToParse, String fieldName) {
         
@@ -93,6 +87,12 @@ public class JniParser extends Jni_C_Common
             return null;
         }
         
+        // *** HACK ***
+        // We cannot use "Object" directly as java does not support swapping on primitive value
+        //  We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
+        // ***
+        ParsedObjectContent parsedData = new ParsedObjectContent();
+        
         ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), tmpField.getMarkerFieldPtr().getPointer() );
         
         return parsedData.getData();
@@ -101,51 +101,39 @@ public class JniParser extends Jni_C_Common
     
     
     /**
-     * Method to parse all fields at once.<p>
-     * 
-     * All parsing will be done on C side as we need LTT functions.
+     * Method to parse all field at once<br>
+     * All parsing will be done on C side as we need Ltt function
      * 
      * @param   eventToParse    The jni event we want to parse.  
      * @return                  An HashMap of Object that contain the is the JniEvent's payload parsed by the C
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     static public HashMap<String, Object> parseAllFields(JniEvent eventToParse) {
-        HashMap<String,JniMarkerField> markerFieldData = eventToParse.requestEventMarker().getMarkerFieldsHashMap();
-               
-               // This hashmap will contain the parsed content.
-               // ParsedContent is a local class defined at the end of this file
-               
-               // *** HACK ***
-               // We want (need?) the map that contain the parsed data to be in the same order as markerField map
-               // The "instinctive way" would be to use : 
-               //       HashMap<String, Object> parsedDataMap = new HashMap<String, Object>(nbMarkerField);
-               //
-               // However, we cannot ensure that the newly created hashmap will use the same order.
-               // The hard way would be to override the default hash function for both hashmap
-               // However, this is way easier to abuse the fact that both hashmap are of type <String, something...>
-               // Therefore we can abuse the java-cast with clone() : 
-               //       HashMap<String, Object> parsedDataMap = (HashMap<String, Object>)markerFieldData.clone();
-               // Or even safer, use HashMap constructor to do so : 
-        HashMap<String, Object> parsedDataMap = new HashMap<String, Object>(markerFieldData);
-                
-        String              newKey             = null; 
-        JniMarkerField      newMarkerField  = null;
-        Iterator<String>    iterator        = markerFieldData.keySet().iterator();
+        JniMarker markerData = eventToParse.requestEventMarker();
+        int nbMarkerField = markerData.getMarkerFieldsArrayList().size();
         
-        while ( iterator.hasNext() ) {
-            newKey = iterator.next();
-            newMarkerField = markerFieldData.get(newKey);
+         // This hashmap will contain the parsed content.
+         // ParsedContent is defined at the end of this file
+         HashMap<String, Object> parsedDataArray = new HashMap<String, Object>(nbMarkerField);
+        
+         // *** HACK ***
+         // We cannot use "Object" directly as java does not support swapping on primitive value
+         //  We either need to create a new object type or to use a "non-primitive" type that have "Setter()" functions
+         // ***
+         ParsedObjectContent parsedData = new ParsedObjectContent();
+         
+        // Loop on markerfield, as we need to parse each field in the event data
+        for (int pos = 0; pos < nbMarkerField; pos++) {
             // Call the C to parse the data
-            ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), newMarkerField.getMarkerFieldPtr().getPointer() );
+            ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), markerData.getMarkerFieldsArrayList().get(pos).getMarkerFieldPtr().getPointer() );
             // Save the result into the HashMap
-            parsedDataMap.put(newMarkerField.getField(), parsedData.getData() );
+            parsedDataArray.put(markerData.getMarkerFieldsArrayList().get(pos).getField(), parsedData.getData() );
         }
-        return parsedDataMap;
+        
+         return parsedDataArray;
     }
     
-    
     /* 
      * Add a parsed String value to the Array<br>
      * <br>
@@ -159,7 +147,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addStringToParsingFromC(Object contentHolder, String stringToAdd) {
+    static private void addStringToParsingFromC(Object contentHolder, String fieldName, String stringToAdd) {
         ((ParsedObjectContent)contentHolder).setData( stringToAdd);
     }
 
@@ -176,8 +164,8 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addLongPointerToParsingFromC(Object contentHolder, long pointerToAdd) {
-        ((ParsedObjectContent)contentHolder).setData( new Jni_C_Pointer((long) pointerToAdd));
+    static private void addLongPointerToParsingFromC(Object contentHolder, String fieldName, long pointerToAdd) {
+        ((ParsedObjectContent)contentHolder).setData( new C_Pointer((long) pointerToAdd));
     }
 
     /* 
@@ -193,8 +181,8 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addIntPointerToParsingFromC(Object contentHolder, long pointerToAdd) {
-        ((ParsedObjectContent)contentHolder).setData( new Jni_C_Pointer((int) pointerToAdd));
+    static private void addIntPointerToParsingFromC(Object contentHolder, String fieldName, long pointerToAdd) {
+        ((ParsedObjectContent)contentHolder).setData( new C_Pointer((int) pointerToAdd));
     }
 
     /* 
@@ -210,7 +198,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addShortToParsingFromC(Object contentHolder, short shortToAdd) {
+    static private void addShortToParsingFromC(Object contentHolder, String fieldName, short shortToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Short(shortToAdd));
     }
 
@@ -227,7 +215,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addIntegerToParsingFromC(Object contentHolder, int intToAdd) {
+    static private void addIntegerToParsingFromC(Object contentHolder, String fieldName, int intToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Integer(intToAdd));
     }
 
@@ -244,7 +232,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addLongToParsingFromC(Object contentHolder, long longToAdd) {
+    static private void addLongToParsingFromC(Object contentHolder, String fieldName, long longToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Long(longToAdd));
     }
 
@@ -261,7 +249,7 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addFloatToParsingFromC(Object contentHolder, float floatToAdd) {
+    static private void addFloatToParsingFromC(Object contentHolder, String fieldName, float floatToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Float(floatToAdd));
     }
 
@@ -279,17 +267,17 @@ public class JniParser extends Jni_C_Common
      * @param formatToAdd   The format of the raw data
      */
     @SuppressWarnings("unused")
-    static private void addDoubleToParsingFromC(Object contentHolder, double doubleToAdd) {
+    static private void addDoubleToParsingFromC(Object contentHolder, String fieldName, double doubleToAdd) {
         ((ParsedObjectContent)contentHolder).setData( new Double(doubleToAdd));
     }
     
 }
 
 /**
- * <b><u>ParsedObjectContent</u></b><p>
- * 
+ * <b><u>ParsedObjectContent</u></b>
+ * <p>
  * ParsedObjectContent class.
- * Only be used locally in this object to parse event data more efficiently in the C.
+ * This class will only be used locally in this object to parse event data more efficiently in the C
  */
 class ParsedObjectContent {
     private Object parsedData = null;
index e6d64de9af58209ab2c7dc62c5dabf63fd629bed..ca936922f262b63f4fd729a4b9272198932a6909 100644 (file)
@@ -1,4 +1,3 @@
-package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -11,163 +10,143 @@ package org.eclipse.linuxtools.lttng.jni;
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
+package org.eclipse.linuxtools.lttng.jni;
 
 /**
  * <b><u>JniTime</u></b>
  * <p>
- * Used to store (event, trace, tracefile, ...) timestamp.
- * 
- * Mimic the behavior of the LttTime C structure.
+ * JniTime object linked to the LttTime C structure
  */
-public final class JniTime extends Jni_C_Common implements Comparable<JniTime>
+public final class JniTime extends Jni_C_Common
 {
     private long time = 0;
 
     /**
-     * Default constructor.<p>
-     * 
-     * Note : Time will be set to 0.
-     * 
+     * Default constructor.
+     *          
      */
-    public JniTime() {
+    JniTime() {
         time = 0;
     }
 
     /**
      * Copy constructor.
      * 
-     * @param oldTime   Reference to the JniTime you want to copy.           
+     * @param oldTime A reference to the JniTime you want to copy.           
      */
-    public JniTime(JniTime oldTime) {
+    JniTime(JniTime oldTime) {
         time = oldTime.getTime();
     }
 
     /**
-     * Constructor with parameters.<p>
-     * 
-     * "LTT style" constructor with Seconds et Nanoseconds
+     * Constructor with parameters
+     * <br>
+     * "Ltt style" constructor with Seconds et Nanoseconds
      * 
      * @param newSec      Seconds of the JniTime
      * @param newNanoSec  Nanoseconds of the JniTime
      */
-    public JniTime(long newSec, long newNanoSec) {
+    JniTime(long newSec, long newNanoSec) {
         time = (newSec * NANO) + newNanoSec;
     }
 
     /**
-     * Constructor with parameters.<p>
+     * Constructor with parameters
+     * <br>
+     * Usual "nanosecond only" constructor
      * 
-     * Usual "nanosecond only" constructor.
-     * 
-     * @param newNanoSecTime  Time in nanoseconds
+     * @param newNanoSecTime  JniTime in nanoseconds
      */
     public JniTime(long newNanoSecTime) {
         time = newNanoSecTime;
     }
 
     /**
-     * Second of the time.<p>
-     * 
-     * Returns seconds, i.e. multiple of 1 000 000, of the stored nanoseconds time.
+     * Getter for the second of the time
+     * <br>
+     * This only return seconds part, i.e. multiple of 1 000 000, of the stored time
      * 
-     * @return Second of this time.
+     * @return long Second of the time
      */
     public long getSeconds() {
         return (time / NANO);
     }
 
     /**
-     * Getter for the nanosecond of the time.<p>
-     * 
-     * Returns nanoseconds part, i.e. modulo of 1 000 000, of the stored nanoseconds time.
+     * Getter for the nanosecond of the time
+     * <br>
+     * This only nanosecondspart , i.e. modulo of 1 000 000, of the stored time
      * 
-     * @return Nanoseconds of this time
+     * @return long Nanoseconds of the time
      */
     public long getNanoSeconds() {
         return time % NANO;
     }
 
     /**
-     * Full time, in nanoseconds.<p>
+     * Getter for the full time, in nanoseconds
      * 
-     * @return Complete time in nanoseconds
+     * @return The complete time in nanoseconds
      */
     public long getTime() {
         return time;
     }
-    
+     
     /**
-     * Changes the current time for this object<p>
-     * 
-     * @param newTime  New time to set, in nanoseconds.
-     */
-    public void setTime(long newTime) {
-        time = newTime;
-    }
-    
-    /* 
-     * Populate this time object
-     * 
-     * Note: This function is called from C side.
-     * 
-     * @param newTime The time we want to populate
-     */
-    @SuppressWarnings("unused")
-    private void setTimeFromC(long newTime) {
-        time = newTime;
-    }
-    
-    /**
-     * Comparaison operator smaller or equal than "<=" .<p>
+     * Comparaison operator <=
      * 
      * @param comparedTime  The time we want to compare with this one
-     * 
-     * @return true if compared time is smaller or equal, false otherwise
+     * @return boolean true if the compared time is smaller or equal, false otherwise
      */
-    public boolean isSmallerOrEqual(JniTime comparedTime) {
+    public boolean isGivenTimeSmallerOrEqual(JniTime comparedTime) {
 
         // NOTE : We check <= instead of just <
-        // This mean the LEFT OPERAND (comparedTime) always prevails
-        if (this.getTime() <= comparedTime.getTime() ) {
+        // This mean the RIGHT OPERAND (comparedTime) always prevails
+        if (comparedTime.getTime() < this.getTime()) {
             return true;
-        } 
-        else {
+        } else {
             return false;
         }
     }
     
     /**
-     * compareTo operator.<p>
-     * 
-     * @param right  The time we want to compare with this one
+     * Integer Comparaison operator
      * 
-     * @return int of value -1, 0 or 1, as the pased argument is bigger, equal or smaller than this time
+     * @param comparedTime  The time we want to compare with this one
+     * @return int Integer of value -1, 0 or 1, as the pased argument is bigger, equal or smaller than this time
      */
-    public int compareTo(JniTime right) {
-        long leftTime = this.getTime();
-        long rightTime = right.getTime();
-        
-        if ( leftTime < rightTime ) { 
-            return -1;
+    public int compare(JniTime comparedTime) {
+        if ( comparedTime.getTime() < this.getTime() ) {
+                return 1;
         }
-        else if ( leftTime > rightTime ) {
-            return  1;
+        else if ( comparedTime.getTime() > this.getTime() ) {
+                return -1;
         }
         else {
             return 0;
         }
     }
+
+    /* 
+     * Populate this time object
+     * 
+     * Note: This function is called from C side.
+     * 
+     * @param newTime The time we want to populate
+     */
+    @SuppressWarnings("unused")
+    private void setTimeFromC(long newTime) {
+        time = newTime;
+    }
     
     /**
-     * toString() method.
-     * <u>Intended to debug</u><p>
-     * 
-     * NOTE : We output the time in the same format as LTT (seconds and nanosecond separatly)
+     * toString() method. <u>Intended to debug</u><br>
+     * <br>
+     * NOTE : we output the time in the same format as LTT (seconds and nanosecond separatly)
      * 
      * @return String Attributes of the object concatenated in String
      */
-    @Override
-       public String toString() {
+    public String toString() {
         String returnData = "";
 
         returnData += "seconds     : " + this.getSeconds() + "\n";
index 113c04168f4da01e3550ce641a51e1d5590c1e97..c80eeb9056eb88f614e640d1dac8a3818e06f0ff 100644 (file)
@@ -1,4 +1,3 @@
-package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -11,7 +10,9 @@ package org.eclipse.linuxtools.lttng.jni;
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
+package org.eclipse.linuxtools.lttng.jni;
 
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.PriorityQueue;
@@ -29,11 +30,9 @@ import java.util.PriorityQueue;
  * </ul>
  */
 public class JniTrace extends Jni_C_Common {
-    
-    private final static boolean DEFAULT_LTT_DEBUG = false;
-    
+        
     // Internal C pointer of the JniTrace used in LTT
-    private Jni_C_Pointer thisTracePtr = new Jni_C_Pointer();
+    private C_Pointer thisTracePtr = new C_Pointer();
 
     // Data we should populate from LTT
     // Note that all type have been scaled up as there is no "unsigned" in java
@@ -52,23 +51,27 @@ public class JniTrace extends Jni_C_Common {
     private long   startFreq = 0;
     private long   startTimestampCurrentCounter = 0;
     private long   startMonotonic = 0;
-    private JniTime startTimeNoAdjustement = null;
-    private JniTime startTime = null;
-    private JniTime endTime = null;
-    
+    private JniTime   startTime = null;
+    private JniTime   startTimeFromTimestampCurrentCounter = null;
+
     // This Map holds a reference to the tracefiles owned by this trace
     private HashMap<String, JniTracefile> tracefilesMap = null;
     // The priority queue (similar to heap) hold events 
     private PriorityQueue<JniEvent> eventsHeap = null;
     
     // This variable will hold the content of the "last" event we read
-    private JniEvent currentEvent = null;  
+    private JniTime currentEventTimestamp = new JniTime();
+    
+    // Comparator we will need for the heap construction
+    private Comparator<JniEvent> eventComparator = new Comparator<JniEvent>() {
+       public int compare(JniEvent left, JniEvent right ){
+               return ( left.getEventTime().compare( right.getEventTime() ) );
+       }
+    };
     
-    // Should we print debug in the C library or not?
-    private boolean printLttDebug = DEFAULT_LTT_DEBUG;
     
     // Open/close native functions
-    private native long ltt_openTrace(String pathname, boolean printDebug);
+    private native long ltt_openTrace(String pathname);
     private native void ltt_closeTrace(long tracePtr);
 
     // Native access functions
@@ -84,55 +87,35 @@ public class JniTrace extends Jni_C_Common {
     private native long   ltt_getStartFreq(long tracePtr);
     private native long   ltt_getStartTimestampCurrentCounter(long tracePtr);
     private native long   ltt_getStartMonotonic(long tracePtr);
-    
+
     // Native function to fill out startTime
     private native void ltt_feedStartTime(long tracePtr, JniTime startTime);
-    
+
     // Native function to fill out startTimeFromTimestampCurrentCounter
     private native void ltt_feedStartTimeFromTimestampCurrentCounter(long tracePtr, JniTime startTime);
 
     // Native function to fill out tracefilesMap
-    private native void ltt_feedAllTracefiles(long tracePtr);
-    
-    // Native function to fill out the start and end time of the trace
-    private native void ltt_feedTracefileTimeRange(long tracePtr, JniTime startTime, JniTime endTime);
-    
+    private native void ltt_getAllTracefiles(long tracePtr);
+
     // Debug native function, ask LTT to print trace structure
     private native void ltt_printTrace(long tracePtr);
 
     static {
         System.loadLibrary("lttvtraceread");
     }
-    
-    /*
+        
+    /**
      * Default constructor is forbidden
      */
     @SuppressWarnings("unused")
     private JniTrace() {
     }
-    
-    /**
-     * Constructor that takes a tracepath parameter.<p>
-     * 
-     * This constructor also opens the trace.
-     * 
-     * @param newpath The <b>directory</b> of the trace to be opened
-     * @param newPrintDebug Should the debug information be printed in the LTT C library
-     * 
-     * @exception JniException
-     */
-    public JniTrace(String newpath, boolean newPrintDebug) throws JniException {
-        tracepath = newpath;
-        thisTracePtr = new Jni_C_Pointer();
-        printLttDebug = newPrintDebug;
-        
-        openTrace(newpath);
-    }
-    
+
     /**
      * Copy constructor.
      * 
-     * @param oldTrace  A reference to the JniTrace to copy.           
+     * @param oldTrace
+     *            A reference to the JniTrace you want to copy.           
      */
     public JniTrace(JniTrace oldTrace) {
         thisTracePtr  = oldTrace.thisTracePtr;
@@ -149,46 +132,56 @@ public class JniTrace extends Jni_C_Common {
         startFreq       = oldTrace.startFreq;
         startTimestampCurrentCounter = oldTrace.startTimestampCurrentCounter;
         startMonotonic  = oldTrace.startMonotonic;
-        startTimeNoAdjustement = oldTrace.startTimeNoAdjustement;
         startTime       = oldTrace.startTime;
-        endTime         = oldTrace.endTime;
+        startTimeFromTimestampCurrentCounter = oldTrace.startTimeFromTimestampCurrentCounter;
 
         tracefilesMap = new HashMap<String, JniTracefile>(oldTrace.tracefilesMap.size());
         tracefilesMap = oldTrace.tracefilesMap;
         
-        eventsHeap = new PriorityQueue<JniEvent>( oldTrace.eventsHeap.size());
+        eventsHeap = new PriorityQueue<JniEvent>( oldTrace.eventsHeap.size(), eventComparator );
         eventsHeap = oldTrace.eventsHeap;
-        
-        printLttDebug = oldTrace.printLttDebug;
     }        
         
     /**
-     * Constructor, using C pointer.<p>
+     * Copy constructor, using pointer.
      * 
-     * @param newPtr The pointer to an already opened LttTrace C structure.
-     * @param newPrintDebug Should the debug information be printed in the LTT C library
+     * @param newPtr The pointer to an already opened LttTrace C structure
      *            
      * @exception JniException
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
-    public JniTrace(Jni_C_Pointer newPtr, boolean newPrintDebug) throws JniException {
+    public JniTrace(C_Pointer newPtr) throws JniException {
         thisTracePtr = newPtr;
-        printLttDebug = newPrintDebug;
         
         // Populate our trace
         populateTraceInformation();
     }
         
     /**
-     * Open an existing trace.<p>
+     * Constructor that takes a tracepath parameter
+     * <br>
+     * This constructor also opens the trace
      * 
-     * The tracepath is a directory and needs to exist, otherwise
-     * a JafOpenTraceFailedException is throwed.
+     * @param newpath The <b>directory</b> of the trace to be opened
      * 
-     * @param newPath The <b>directory</b> of the trace to be opened
+     * @exception JniException
+     */
+    public JniTrace(String newpath) throws JniException {
+        tracepath = newpath;
+        thisTracePtr = new C_Pointer();
+        
+        openTrace(newpath);
+    }
+        
+    /**
+     * Open an existing trace<br>
+     * <br>
+     * The tracepath is a directory and needs to exist, otherwise
+     * a JafOpenTraceFailedException is raised.
      * 
-     * @exception JniOpenTraceFailedException Thrown if the open failed
+     * @param newPath
+     *            The <b>directory</b> of the trace to be opened
+     * @exception JafOpenTraceFailedException
+     *                Thrown if the open failed
      */
     public void openTrace(String newPath) throws JniException {
         // If open is called while a trace is already opened, we will try to close it first
@@ -202,11 +195,12 @@ public class JniTrace extends Jni_C_Common {
     }
         
     /**
-     * Open an existing trace.<p>
-     * 
+     * Open an existing trace<br>
+     * <br>
      * The tracepath should have been set already,
      * 
-     * @exception JniOpenTraceFailedException  Thrown if the open failed
+     * @exception JafOpenTraceFailedException
+     *                Thrown if the open failed
      */
     public void openTrace() throws JniException {
         
@@ -221,27 +215,27 @@ public class JniTrace extends Jni_C_Common {
         }
 
         // Call the LTT to open the trace
-        long newPtr = ltt_openTrace(tracepath, printLttDebug);
+        long newPtr = ltt_openTrace(tracepath);
         if (newPtr == NULL) {
             throw new JniOpenTraceFailedException("Error while opening trace. Is the tracepath correct? (openTrace)");
         }
-        
+
         // This is OUR pointer
-        thisTracePtr = new Jni_C_Pointer(newPtr);
+        thisTracePtr = new C_Pointer(newPtr);
 
         // Populate the trace with LTT information
         populateTraceInformation();
     }
         
     /**
-     * Close a trace.<p>
+     * Close a trace
      * 
      * If the trace is already closed, will silently do nothing.
      */
     public void closeTrace() {
         if (thisTracePtr.getPointer() != NULL) {
             ltt_closeTrace(thisTracePtr.getPointer());
-            thisTracePtr = new Jni_C_Pointer(NULL);
+            thisTracePtr = new C_Pointer(NULL);
 
             // Clear the tracefile map
             tracefilesMap.clear();
@@ -260,7 +254,7 @@ public class JniTrace extends Jni_C_Common {
     /* 
      * This function populates the trace data with data from LTT
      * 
-     * @throws JniException
+     * @throws JafException
      */
     private void populateTraceInformation() throws JniException {
         if (thisTracePtr.getPointer() == NULL) {
@@ -282,29 +276,21 @@ public class JniTrace extends Jni_C_Common {
         startMonotonic = ltt_getStartMonotonic( thisTracePtr.getPointer() );
 
         // Creation of time is a bit different, we need to pass the object reference to C
-        //
-        // *** NOTE : LTTv consider "raw startTime" (time without any frequency adjustement) to be default startTime
-        //                       So "startTimeNoAdjustement" is obtain throught "ltt_feedStartTime()" and
-        //                       "startTime" is obtained from ltt_feedStartTimeFromTimestampCurrentCounter()
-        startTimeNoAdjustement = new JniTime();
-        ltt_feedStartTime( thisTracePtr.getPointer(), startTimeNoAdjustement );
-        
         startTime = new JniTime();
-        ltt_feedStartTimeFromTimestampCurrentCounter( thisTracePtr.getPointer(), startTime );
+        ltt_feedStartTime( thisTracePtr.getPointer(), startTime );
+
+        startTimeFromTimestampCurrentCounter = new JniTime();
+        ltt_feedStartTimeFromTimestampCurrentCounter( thisTracePtr.getPointer(), startTimeFromTimestampCurrentCounter );
 
         // Call the fill up function for the tracefiles map
         if ( tracefilesMap== null ) {
             tracefilesMap = new HashMap<String, JniTracefile>();
         }
-        ltt_feedAllTracefiles( thisTracePtr.getPointer() );
         
-        // Now, obtain the trace "endTime"
-        // Note that we discard "startTime" right away, as we already have it
-        endTime = new JniTime();
-        ltt_feedTracefileTimeRange(thisTracePtr.getPointer(), new JniTime(), endTime);
+        ltt_getAllTracefiles( thisTracePtr.getPointer() );
         
         if (eventsHeap == null) {
-            eventsHeap = new PriorityQueue<JniEvent>(tracefilesMap.size());
+            eventsHeap = new PriorityQueue<JniEvent>(tracefilesMap.size(), eventComparator);
         }
         
         // Populate the heap with events
@@ -316,7 +302,7 @@ public class JniTrace extends Jni_C_Common {
      * It should be called after each seek or when the object is constructed
      */
     private void populateEventHeap() {
-        currentEvent = null;
+        currentEventTimestamp = new JniTime();
         eventsHeap.clear();
         
         Object new_key = null;
@@ -345,14 +331,11 @@ public class JniTrace extends Jni_C_Common {
      */
     @SuppressWarnings("unused")
     private void addTracefileFromC(String tracefileName, long tracefilePtr) {
-        
-        JniTracefile newTracefile = null;
-            
         // Create a new tracefile object and insert it in the map
         //    the tracefile fill itself with LTT data while being constructed
         try {
-            newTracefile = new JniTracefile( new Jni_C_Pointer(tracefilePtr), this );
-            tracefilesMap.put( (tracefileName + newTracefile.getCpuNumber()), newTracefile);
+            JniTracefile newTracefile = new JniTracefile( new C_Pointer(tracefilePtr), this );
+            tracefilesMap.put(tracefileName, newTracefile);
         }
         catch(JniTracefileWithoutEventException e) {
             printlnC("JniTracefile " + tracefileName + " has no event (addTracefileFromC). Ignoring.");
@@ -361,26 +344,16 @@ public class JniTrace extends Jni_C_Common {
             printlnC("Failed to add tracefile " + tracefileName + " to tracefilesMap!(addTracefileFromC)\n\tException raised : " + e.toString() );
         }
     }
-    
-    /**
-     * Return the top event in the events stack, determined by timestamp, in the trace (all the tracefiles).<p>
-     * 
-     * Note : If the events were read before, the top event and the event currently loaded (currentEvent) are most likely the same.
-     * 
-     * @return The top event in the stack or null if no event is available.
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
-     */
-    public JniEvent findNextEvent() {
-        return eventsHeap.peek();
-    }
-    
+        
+        
     /**
-     * Return the next event in the events stack, determined by timestamp, in the trace (all the tracefiles).<p>
+     * Return the next event, determined by timestamp, among the trace files.
+     * The event content is populated.
+     *  
+     * Returns  null in case of error or if we reach end of trace.
      * 
-     * @return The next event in the trace or null if no event is available.
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @return The next event in the trace or null
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent readNextEvent() {
         // Get the "next" event on the top of the heap but DO NOT remove it
@@ -392,8 +365,7 @@ public class JniTrace extends Jni_C_Common {
         }
         
         // Otherwise, we need to make sure the timestamp of the event we got is not the same as the last "NextEvent" we requested 
-        // NOTE : JniEvent.compareTo() compare by timestamp AND type, as 2 events of different type could have the same timestamp.
-        if ( tmpEvent.compareTo(currentEvent) == 0 ) {
+        if (tmpEvent.getEventTime().getTime() == currentEventTimestamp.getTime() ) {
             // Remove the event on top as it is the same currentEventTimestamp
             eventsHeap.poll();
             
@@ -408,179 +380,89 @@ public class JniTrace extends Jni_C_Common {
             // Pick the top event again
             tmpEvent = eventsHeap.peek();
             
-            // Save the event we just read as the "current event"
-            currentEvent = tmpEvent;
+            // Save the timestamp if the event is not null (null mean we reached the last event in the trace)
+            if (tmpEvent != null) {
+                currentEventTimestamp = tmpEvent.getEventTime();
+            }
         }
-        // If the event on top has different timestamp than the currentTimestamp, just save this timestamp as current
+        // If the event on top has differetn timestamp than the currentTimestamp, just save this timestamp as current
         else {
-            currentEvent = tmpEvent;
+            currentEventTimestamp = tmpEvent.getEventTime();
         }
-        
+            
         return tmpEvent;
     }
     
     /**
-     * Read the next event on a certain tracefile.<p>
-     * 
-     * By calling this function make sure the "global" readNextEvent() stay synchronised.
-     * Calling  readNextEvent() after this function will consider this tracefile moved and is then consistent.
-     * 
-     * @param targetTracefile  The tracefile object to read from
-     * 
-     * @return The next event in the tracefile or null if no event is available.
+     * Return the next event, determined by timestamp, among the trace files.
+     * The event content is NOT populated (requires a call to readNextEvent()).
+     *  
+     * Returns null in case of error or EOF.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @return The next event, or null if none is available
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
-    public JniEvent readNextEvent(JniTracefile targetTracefile) {
-        JniEvent returnedEvent = null;
-       
-        // There is 2 special cases where we should read the CURRENT event, not the next one
-        // 1- The currentEvent is null                      --> We never read or we just seeked
-        // 2- The currentEvent is of another type  --> We last read on a DIFFERENT tracefile
-        if ( (currentEvent == null) || 
-              (currentEvent.getParentTracefile().equals(targetTracefile) == false)
-            ) {
-            returnedEvent = targetTracefile.getCurrentEvent();
-            // Save the event we read
-            currentEvent = returnedEvent; 
-        }
-        else {
-               // Remove from the event related to this tracefile from the event heap, if it exists.
-               // WARNING : This only safe as long getCurrentEvent() never return "null" in any case.
-               eventsHeap.remove(targetTracefile.getCurrentEvent() );
-               
-               // If status EOK, we can return the event, otherwise something wrong happen (out of range, read error, etc...)
-               if ( targetTracefile.readNextEvent() == EOK) {
-                   returnedEvent = targetTracefile.getCurrentEvent();
-                       // Add back to the heap the read event
-                       eventsHeap.add(returnedEvent);
-               }
-               // Save the event we read... 
-               // Note : might be null if the read failed and it's ok
-               currentEvent = targetTracefile.getCurrentEvent(); 
-        }
-        
-       return returnedEvent;
+    public JniEvent findNextEvent() {
+        return eventsHeap.peek();
     }
     
     /**
-    * Seek to a certain time but <b>do not</b> read the next event.<p>
-    * 
-    * This only position the trace, it will not return anything.<p>
-    * 
-    * @param seekTime     The time where we want to seek to
-    * 
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
-    */
-    public void seekToTime(JniTime seekTime) {
-        
-        // Invalidate the last read event
-        currentEvent = null;
-        
-        Object tracefile_name = null;
-       Iterator<String> iterator = tracefilesMap.keySet().iterator();
-       
-       while (iterator.hasNext() ) {
-           // We seek to the given event for ALL tracefiles
-           tracefile_name = iterator.next();
-               seekToTime(seekTime, tracefilesMap.get(tracefile_name));
-       }
-       
-       populateEventHeap();
-    }
-       
-    /**
-    * Seek to a certain time on a certain tracefile but <b>do not</b> read the next event.<p>
-    * 
-    * This only position the trace, it will not return anything.<p>
-    * 
-    * @param targetTracefile   The tracefile object to read from
-    * @param seekTime                  The time where we want to seek to
-    * 
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
-    */
-    public void seekToTime(JniTime seekTime, JniTracefile targetTracefile) {
-        // Invalidate the current read event
-        currentEvent = null;
-        
-        // Remove from the event related to this tracefile from the event heap, if it exists.
-        // WARNING : This is only safe as long getCurrentEvent() never return "null" in any case.
-        eventsHeap.remove(targetTracefile.getCurrentEvent() );
-        
-        // Perform the actual seek on the tracefile
-        // Add the event to the heap if it succeed
-        if ( targetTracefile.seekToTime(seekTime) == EOK) {
-               // Add back to the heap the read event
-            eventsHeap.add(targetTracefile.getCurrentEvent());
-        }
-    }
-       
-    /**
-    * Seek to a certain timestamp and read the next event.
-    * <p>
-    * If no more events are available or an error happen, null will be returned.
-    * 
-    * @param seekTime      The time where we want to seek to.
-    * 
-    * @return The event just after the seeked time or null if none available.
-    * 
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
-    */
-    public JniEvent seekAndRead(JniTime seekTime) { 
-         JniEvent returnedEvent = null;
-         seekToTime(seekTime);
-            
-         // The trace should be correctly positionned, let's get the event
-         returnedEvent = readNextEvent();
-             
-         return returnedEvent;
-    }
-       
-    /**
-    * Seek to a certain timestamp on a certain tracefile and read the next event.<p>
-    * 
-    * If no more events are available or an error happen, null will be returned.
-    * 
-    * Calling  readNextEvent() after this function will consider this tracefile moved and is then consistent.<br>
-    * 
-    * @param tracefileName   The tracefile object to read from
-    * @param seekTime           The time where we want to seek to
-    * 
-    * @return The event just after the seeked time or null if none available.
-    * 
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
-    */
-    public JniEvent seekAndRead(JniTime seekTime, JniTracefile targetTracefile) { 
-        seekToTime(seekTime, targetTracefile);
-        return readNextEvent(targetTracefile);
-    }
-     
-    /**
-     * Get a certain tracefile from its given name.<p>
+     * Seek to a certain time and read the next event from that time.<br>
+     * <br>
+     * If no more events are available or an error happen, null will be returned
      * 
-     * @param tracefileName     The name of the tracefile.
+     * @param seekTime  The time where we want to seek to
+     * @return JniEvent    The next event after the seek time or null
      * 
-     * @return The tracefile found or null if none.
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     */
+     public JniEvent seekAndRead(JniTime seekTime) { 
+          JniEvent returnedEvent = null;
+          seekToTime(seekTime);
+              
+          // The trace should be correctly positionned, let's get the event
+          returnedEvent = readNextEvent();
+               
+          return returnedEvent;
+     }
+    
+     /**
+      * Seek to a certain time but <b>do not</b> read the next event.<br>
+      * <br>
+      * This only position the trace, it will not return anything.
+      * 
+      * @param seekTime     The time where we want to seek to
+      */
+      public void seekToTime(JniTime seekTime) {
+           Object tracefile_name = null;
+           Iterator<String> iterator = tracefilesMap.keySet().iterator();
+           
+           while (iterator.hasNext() ) {
+               // We seek to the given event for ALL tracefiles
+               tracefile_name = iterator.next();
+               tracefilesMap.get(tracefile_name).seekToTime(seekTime);
+           }
+           
+           populateEventHeap();
+      }
+     
+    /**
+     * Get a certain tracefile from its given name<br>
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @param tracefileName The name of the tracefile
+     * @return JniTracefile The tracefile found or null if none
+     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
      */
     public JniTracefile requestTracefileByName(String tracefileName) {
         return tracefilesMap.get(tracefileName);
     }        
         
     /**
-     * Get a certain event associated to a tracefile from the tracefile name.<p>
-     * 
-     * @param tracefileName     The name of the trace file.
-     * 
-     * @return Event of the tracefile or null if none found.
+     * Get a certain event associated to a trace file from the trace file name<br>
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @param tracefileName The name of the trace file
+     * @return The JniEvent found or null if none
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent requestEventByName(String tracefileName) {
         JniEvent returnValue = null;
@@ -648,92 +530,65 @@ public class JniTrace extends Jni_C_Common {
     public JniTime getStartTime() {
         return startTime;
     }
-    
-    public JniTime getEndTime() {
-        return endTime;
-    }
 
-    public JniTime getStartTimeNoAdjustement() {
-        return startTimeNoAdjustement;
+    public JniTime getStartTimeFromTimestampCurrentCounter() {
+        return startTimeFromTimestampCurrentCounter;
     }
-    
+
     public HashMap<String, JniTracefile> getTracefilesMap() {
         return tracefilesMap;
     }        
     
     /**
-     * The timestamp of the last read event.<p>
-     * 
-     * Note : If no event is available, Long.MAX_VALUE is returned.
+     * Getter for the last read event timestamp<br>
      * 
-     * @return Time of the last event read
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
+     * @return The time of the last event read
      */
     public JniTime getCurrentEventTimestamp() {
-        JniTime returnedTime = null;
-        
-        // If no event were read or we reach the last event in the trace, 
-        //      currentEvent will be null
-        if (  currentEvent != null ) {
-            returnedTime = currentEvent.getEventTime();
-        }
-        else {
-            returnedTime = new JniTime(Long.MAX_VALUE);
-        }
-        return returnedTime;
+        return currentEventTimestamp;
     }
     
     /**
-     * Pointer to the LttTrace C structure.<p>
-     * 
-     * The pointer should only be used <u>INTERNALY</u>, do not use unless you
+     * Pointer to the LttTrace C structure<br>
+     * <br>
+     * The pointer should only be used INTERNALY, do not use these unless you
      * know what you are doing.
      * 
-     * @return The actual (long converted) pointer or NULL.
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @return The actual (long converted) pointer or NULL
      */
-    public Jni_C_Pointer getTracePtr() {
+    public C_Pointer getTracePtr() {
         return thisTracePtr;
     }        
-    
-    /**
-     * Return boolean value saying if the debug is enabled in LTT or not.<p>
-     * 
-     * Note : this need to be set at construction.
-     * 
-     * @return If the debug is set or not
-     */
-    public boolean isPrintingLttDebug() {
-        return printLttDebug;
-    }
-    
+        
     /**
      * Print information for all the tracefiles associated with this trace.
-     * <u>Intended to debug</u><p>
+     * <u>Intended to debug</u><br>
      * 
      * This function will call Ltt to print, so information printed will be the
-     * one from the C structure, not the one populated in java.
+     * one from the C structure
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
      */
     public void printAllTracefilesInformation() {
-        JniTracefile tracefile = null;
+
+        Object new_key = null;
+        JniTracefile tracefile;
 
         Iterator<String> iterator = tracefilesMap.keySet().iterator();
         while (iterator.hasNext()) {
-            tracefile = tracefilesMap.get(iterator.next());
+            new_key = iterator.next();
+
+            tracefile = tracefilesMap.get(new_key);
+
             tracefile.printTracefileInformation();
         }
     }        
         
     /**
-     * Print information for this trace. 
-     * <u>Intended to debug</u><p>
+     * Print information for this trace. <u>Intended to debug</u><br>
      * 
      * This function will call Ltt to print, so information printed will be the
-     * one from the C structure, not the one populated in java.<p>
+     * one from the C structure<br>
      * <br>
      * This function will not throw but will complain loudly if pointer is NULL
      */
@@ -742,20 +597,17 @@ public class JniTrace extends Jni_C_Common {
         // If null pointer, print a warning!
         if (thisTracePtr.getPointer() == NULL) {
             printlnC("Pointer is NULL, cannot print. (printTraceInformation)");
-        } 
-        else {
+        } else {
             ltt_printTrace( thisTracePtr.getPointer() );
         }
     }
         
     /**
-     * toString() method. 
-     * <u>Intended to debug</u><br>
+     * toString() method. <u>Intended to debug</u><br>
      * 
-     * @return Attributes of the object concatenated in String
+     * @return String Attributes of the object concatenated in String
      */
-    @Override
-       public String toString() {
+    public String toString() {
         String returnData = "";
         returnData += "tracepath                            : " + tracepath + "\n";
         returnData += "cpuNumber                            : " + cpuNumber + "\n";
@@ -769,17 +621,121 @@ public class JniTrace extends Jni_C_Common {
         returnData += "startFreq                            : " + startFreq + "\n";
         returnData += "startTimestampCurrentCounter         : " + startTimestampCurrentCounter + "\n";
         returnData += "startMonotonic                       : " + startMonotonic + "\n";
-        returnData += "startTimeNoAdjustement               : " + startTimeNoAdjustement.getReferenceToString() + "\n";
-        returnData += "   seconds                           : " + startTimeNoAdjustement.getSeconds() + "\n";
-        returnData += "   nanoSeconds                       : " + startTimeNoAdjustement.getNanoSeconds() + "\n";
         returnData += "startTime                            : " + startTime.getReferenceToString() + "\n";
         returnData += "   seconds                           : " + startTime.getSeconds() + "\n";
         returnData += "   nanoSeconds                       : " + startTime.getNanoSeconds() + "\n";
-        returnData += "endTime                              : " + endTime.getReferenceToString() + "\n";
-        returnData += "   seconds                           : " + endTime.getSeconds() + "\n";
-        returnData += "   nanoSeconds                       : " + endTime.getNanoSeconds() + "\n";
+        returnData += "startTimeFromTimestampCurrentCounter : " + startTimeFromTimestampCurrentCounter.getReferenceToString() + "\n";
+        returnData += "   seconds                           : " + startTimeFromTimestampCurrentCounter.getSeconds() + "\n";
+        returnData += "   nanoSeconds                       : " + startTimeFromTimestampCurrentCounter.getNanoSeconds() + "\n";
         returnData += "tracefilesMap                        : " + tracefilesMap.keySet() + "\n";      // Hack to avoid ending up with tracefilesMap.toString()
 
         return returnData;
     }
+     
+     /* 
+     *  MAIN : For testing only!
+     */
+     public static void main(String[] args) {
+         JniTrace testTrace = null;
+         JniEvent tmpEvent = null;
+         
+         try {
+             testTrace = new JniTrace("/home/william/trace1");
+         }
+         catch (JniException e) {
+             System.out.println(e.getMessage() );
+             return;
+         }
+         
+         
+         testTrace.printlnC( testTrace.toString() );
+         
+         long nbEvent = 0;
+         
+         testTrace.printlnC("Beginning test run on 600k events");
+         tmpEvent = testTrace.readNextEvent();
+         while (tmpEvent != null) {
+             nbEvent++;
+             tmpEvent = testTrace.readNextEvent();
+             
+             if ( tmpEvent != null ) {
+                 tmpEvent.parseAllFields();
+             }
+         }
+         testTrace.printlnC("We read " + nbEvent + " total events (JAF)\n");
+         
+         
+         /*
+         
+         tmpEvent = testTrace.readNextEvent();
+         
+         JniTime test_time = new JniTime(960386633737L);
+         tmpEvent = testTrace.seekAndRead(test_time);
+         
+         testTrace.printlnC(tmpEvent.getParentTracefile().getTracefileName().toString() );
+         testTrace.printlnC(tmpEvent.toString() );
+         
+         
+         test_time = new JniTime(960386638531L);
+         tmpEvent = testTrace.seekAndRead(test_time);
+         
+         testTrace.printlnC(tmpEvent.getParentTracefile().getTracefileName().toString() );
+         testTrace.printlnC(tmpEvent.toString() );
+         
+         
+         tmpEvent = testTrace.readNextEvent();
+         if ( tmpEvent == null ) {
+             testTrace.printlnC("NULL NULL NULL1");
+         }
+         else {
+             testTrace.printlnC(tmpEvent.getParentTracefile().getTracefileName().toString() );
+             testTrace.printlnC(tmpEvent.toString() );
+         }
+         
+         tmpEvent = testTrace.readNextEvent();
+         if ( tmpEvent == null ) {
+             testTrace.printlnC("NULL NULL NULL2");
+         }
+         else {
+             testTrace.printlnC(tmpEvent.getParentTracefile().getTracefileName().toString() );
+             testTrace.printlnC(tmpEvent.toString() );
+         }
+         */
+         
+         
+         
+         
+         
+         
+         /*
+         testTrace.printlnC("Beginning test run seek time");        
+         JniTime test_time = new JniTime(953, 977711854);
+         testTrace.seekToTime(test_time);
+         tmpEvent = testTrace.findNextEvent();
+         testTrace.printlnC(tmpEvent.toString() );
+         */
+         
+         /*
+         testTrace.printlnC("Beginning test run parsing event"); 
+         Object[] parsedName = null;
+         HashMap<String,Object> parsedData = null;
+         for ( int x = 0; x<30; x++) {
+             tmpEvent = testTrace.readNextEvent();
+                 
+             testTrace.printlnC(tmpEvent.getParentTracefile().getTracefileName().toString() );
+             testTrace.printC(tmpEvent.toString() );
+                 
+             testTrace.printlnC("Format                  : " + tmpEvent.requestEventMarker().getFormatOverview().toString() );
+             parsedData = tmpEvent.parse();
+             parsedName = parsedData.keySet().toArray();
+             
+             testTrace.printC("                          ");
+             for ( int pos=0; pos<parsedName.length; pos++) {
+                 testTrace.printC( parsedName[pos].toString() + " " + parsedData.get(parsedName[pos]).toString() + " ");
+             }
+             testTrace.printlnC("\n");
+         }*/
+         
+     }
+     
 }
\ No newline at end of file
index e3a4927cd0fada761b45a0ef97eb91c0b3d44a98..adb350baaa9ad6ee0ac85af7e7eb3ebebbe5b3bf 100644 (file)
@@ -1,4 +1,3 @@
-package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -11,18 +10,19 @@ package org.eclipse.linuxtools.lttng.jni;
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
+package org.eclipse.linuxtools.lttng.jni;
 
 import java.util.HashMap;
 
 /**
  * <b><u>JniTracefile</u></b>
  * <p>
- * A tracefile own an event of a certain type.<br>
- * Provides access to the LttTracefile C structure in java.
+ * A tracefile own an event of a certain type
+ * It provides access to the LttTracefile C structure in java.
  * <p>
  * Most important fields in the JniTracefile are :
  * <ul>
- * <li> a JniTracefile path (a tracefile <b>file</b> within a JniTrace directory)
+ * <li> a JniTracefile path (a tracefile <b>file</b> with a JniTrace directory)
  * <li> a name (basically the name without the directory part)
  * <li> a reference to a single event object
  * <li> a HashMap of marker associated with this tracefile
@@ -31,7 +31,7 @@ import java.util.HashMap;
 public final class JniTracefile extends Jni_C_Common {
         
     // Internal C pointer of the JniTracefile used in LTT
-    private Jni_C_Pointer thisTracefilePtr = new Jni_C_Pointer();
+    private C_Pointer thisTracefilePtr = new C_Pointer();
     
     // Reference to the parent trace
     private JniTrace parentTrace = null;
@@ -46,11 +46,8 @@ public final class JniTracefile extends Jni_C_Common {
     private long    tid = 0;
     private long    pgid = 0;
     private long    creation = 0;
-    
-    // Internal C pointer for trace and marker
-    private Jni_C_Pointer tracePtr = null;
-    private Jni_C_Pointer markerDataPtr = null;
-    
+    private long    tracePtr = 0;
+    private long    markerDataPtr = 0;
     private int     CFileDescriptor = 0;
     private long    fileSize = 0;
     private long    blocksNumber = 0;
@@ -65,14 +62,11 @@ public final class JniTracefile extends Jni_C_Common {
     private long    eventsLost = 0;
     private long    subBufferCorrupt = 0;
     private JniEvent   currentEvent = null;
-    
-    // Internal C pointer for trace and marker
-    private Jni_C_Pointer bufferPtr = null;
-    
+    private long    bufferPtr = NULL;
     private long    bufferSize = 0;
 
     // This map will hold markers_info owned by this tracefile
-    private HashMap<Integer, JniMarker> tracefileMarkersMap = null;        
+    private HashMap<Integer, JniMarker> tracefileMarkersMap;        
 
     // Native access functions
     private native boolean  ltt_getIsCpuOnline(long tracefilePtr);
@@ -102,16 +96,16 @@ public final class JniTracefile extends Jni_C_Common {
     private native long     ltt_getBufferSize(long tracefilePtr);
 
     // Method to fill a map with marker object
-    private native void ltt_feedAllMarkers(long tracefilePtr);
-    
+    private native void ltt_getAllMarkers(long tracefilePtr);
+
     // Debug native function, ask LTT to print tracefile structure
     private native void ltt_printTracefile(long tracefilePtr);
-    
+
     static {
         System.loadLibrary("lttvtraceread");
     }
         
-    /*
+    /**
      * Default constructor is forbidden
      */
     @SuppressWarnings("unused")
@@ -119,14 +113,16 @@ public final class JniTracefile extends Jni_C_Common {
     };
 
     /**
-     * Copy constructor.<p>
+     * Copy constructor.
      * 
-     * @param oldTracefile      Reference to the JniTracefile you want to copy. 
+     * @param oldTracefile
+     *            A reference to the JniTracefile you want to copy. 
      */
     public JniTracefile(JniTracefile oldTracefile) {
         thisTracefilePtr    = oldTracefile.thisTracefilePtr;
         parentTrace         = oldTracefile.parentTrace;
         tracefileMarkersMap = oldTracefile.tracefileMarkersMap;
+
         isCpuOnline         = oldTracefile.isCpuOnline;
         tracefilePath       = oldTracefile.tracefilePath;
         tracefileName       = oldTracefile.tracefileName;
@@ -155,16 +151,13 @@ public final class JniTracefile extends Jni_C_Common {
     }
 
     /**
-     * Constructor, using C pointer.<p>
+     * Copy constructor, using pointer.
      * 
-     * @param newPtr  The pointer of an already opened LttTracefile C Structure
+     * @param newPtr  The pointer to an already opened LttTracefile C Structure
      * 
      * @exception JniException
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTrace
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
      */
-    public JniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException {
+    public JniTracefile(C_Pointer newPtr, JniTrace newParentTrace) throws JniException {
         thisTracefilePtr = newPtr;
         parentTrace = newParentTrace;
         tracefileMarkersMap = new HashMap<Integer, JniMarker>();
@@ -179,28 +172,21 @@ public final class JniTracefile extends Jni_C_Common {
     }        
 
     /**
-     * Read the next event of this tracefile.<p>
+     * Move the current event to the next one.
      * 
-     * Note : If the read succeed, the event will be populated.<p>
-     *      
-     * @return LTT read status, as defined in Jni_C_Common
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @return The read status, as defined in Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
     public int readNextEvent() {
         return currentEvent.readNextEvent();
     }        
 
     /**
-     * Seek to the given time.<p>
-     * 
-     * Note : If the seek succeed, the event will be populated.
-     * 
-     * @param seekTime      The timestamp where to seek.
-     * 
-     * @return LTT read status, as defined in Jni_C_Common
+     * Move the current event to the time given.<br>
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @param seekTime JniTime where to seek to
+     * @return The read status, as defined in Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.Jni_C_Common
      */
     public int seekToTime(JniTime seekTime) {
         return currentEvent.seekToTime(seekTime);
@@ -209,7 +195,7 @@ public final class JniTracefile extends Jni_C_Common {
     /* 
      * This function populates the tracefile data with data from LTT
      * 
-     * @throws JniException
+     * @throws JafException
      */
     private void populateTracefileInformation() throws JniException {
         if (thisTracefilePtr.getPointer() == NULL) {
@@ -224,8 +210,8 @@ public final class JniTracefile extends Jni_C_Common {
         tid = ltt_getTid( thisTracefilePtr.getPointer() );
         pgid = ltt_getPgid( thisTracefilePtr.getPointer() );
         creation = ltt_getCreation( thisTracefilePtr.getPointer() );
-        tracePtr = new Jni_C_Pointer(ltt_getTracePtr( thisTracefilePtr.getPointer()) );
-        markerDataPtr = new Jni_C_Pointer(ltt_getMarkerDataPtr( thisTracefilePtr.getPointer()) );
+        tracePtr = ltt_getTracePtr( thisTracefilePtr.getPointer() );
+        markerDataPtr = ltt_getMarkerDataPtr( thisTracefilePtr.getPointer() );
         CFileDescriptor = ltt_getCFileDescriptor( thisTracefilePtr.getPointer() );
         fileSize = ltt_getFileSize( thisTracefilePtr.getPointer() );
         blocksNumber = ltt_getBlockNumber( thisTracefilePtr.getPointer() );
@@ -239,13 +225,13 @@ public final class JniTracefile extends Jni_C_Common {
         currentTimestampCounterMaskNextBit = ltt_getCurrentTimestampCounterMaskNextBit( thisTracefilePtr.getPointer() );
         eventsLost = ltt_getEventsLost( thisTracefilePtr.getPointer() );
         subBufferCorrupt = ltt_getSubBufferCorrupt( thisTracefilePtr.getPointer() );
-        bufferPtr = new Jni_C_Pointer(ltt_getBufferPtr( thisTracefilePtr.getPointer()) );
+        bufferPtr = ltt_getBufferPtr( thisTracefilePtr.getPointer() );
         bufferSize = ltt_getBufferSize( thisTracefilePtr.getPointer() );
 
         // To fill the map is a bit different
-        ltt_feedAllMarkers( thisTracefilePtr.getPointer() );
+        ltt_getAllMarkers( thisTracefilePtr.getPointer() );
 
-        Jni_C_Pointer tmpEventPointer = new Jni_C_Pointer(ltt_getEventPtr(thisTracefilePtr.getPointer()));
+        C_Pointer tmpEventPointer = new C_Pointer(ltt_getEventPtr(thisTracefilePtr.getPointer()));
         currentEvent = new JniEvent(tmpEventPointer , tracefileMarkersMap, this);
     }        
     
@@ -264,19 +250,19 @@ public final class JniTracefile extends Jni_C_Common {
         // Create a new tracefile object and insert it in the map
         // the tracefile fill itself with LTT data while being constructed
         try {
-            JniMarker newMarker = new JniMarker( new Jni_C_Pointer(markerInfoPtr) );
+            JniMarker newMarker = new JniMarker( new C_Pointer(markerInfoPtr) );
 
             tracefileMarkersMap.put(markerId, newMarker);
         } catch (Exception e) {
             printlnC("Failed to add marker to tracefileMarkersMap!(addMarkersFromC)\n\tException raised : " + e.toString());
         }
-    }
-    
+    }        
+
     // Access to class variable. Most of them doesn't have setter
     public boolean getIsCpuOnline() {
         return isCpuOnline;
     }
-    
+
     public String getTracefilePath() {
         return tracefilePath;
     }
@@ -301,11 +287,11 @@ public final class JniTracefile extends Jni_C_Common {
         return creation;
     }
 
-    public Jni_C_Pointer getTracePtr() {
+    public long getTracePtr() {
         return tracePtr;
     }
 
-    public Jni_C_Pointer getMarkerDataPtr() {
+    public long getMarkerDataPtr() {
         return markerDataPtr;
     }
 
@@ -365,7 +351,7 @@ public final class JniTracefile extends Jni_C_Common {
         return currentEvent;
     }
 
-    public Jni_C_Pointer getBufferPtr() {
+    public long getBufferPtr() {
         return bufferPtr;
     }
 
@@ -378,58 +364,34 @@ public final class JniTracefile extends Jni_C_Common {
     }
 
     /**
-     * Parent trace of this tracefile.<p>
+     * Getter to the parent trace for this tracefile.
      *
-     * @return The parent trace
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTrace
+     * @return  the parent trace
+     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
      */
     public JniTrace getParentTrace() {
         return parentTrace;
     }
     
     /**
-     * Pointer to the LttTracefile C structure<p>
+     * Pointer to the LttTracefile C structure<br>
+     * <br>
+     * The pointer should only be used INTERNALY, do not use these unless you
+     * know what you are doing.
      * 
-     * The pointer should only be used <u>INTERNALY</u>, do not use unless you
-     * know what you are doing.<p>
-     * 
-     * @return The actual (long converted) pointer or NULL.
-     * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @return The actual (long converted) pointer or NULL
      */
-    public Jni_C_Pointer getTracefilePtr() {
+    public C_Pointer getTracefilePtr() {
         return thisTracefilePtr;
     }
-    
-    /**
-     * Print information for this tracefile. 
-     * <u>Intended to debug</u><p>
-     * 
-     * This function will call Ltt to print, so information printed will be the
-     * one from the C structure, not the one populated in java.<p>
-     * 
-     * This function will not throw but will complain loudly if pointer is NULL.
-     */
-    public void printTracefileInformation() {
 
-        // If null pointer, print a warning!
-        if (thisTracefilePtr.getPointer() == NULL) {
-            printlnC("Pointer is NULL, cannot print. (printTracefileInformation)");
-        } 
-        else {
-            ltt_printTracefile( thisTracefilePtr.getPointer() );
-        }
-    }
-    
     /**
-     * toString() method. 
-     * <u>Intended to debug</u><p>
+     * toString() method. <u>Intended to debug</u><br>
      * 
-     * @return Attributes of the object concatenated in String
+     * @return String Attributes of the object concatenated in String
      */
-       @Override
-       public String toString() {
+    public String toString() {
         String returnData = "";
                 
         returnData += "isCpuOnline                        : " + isCpuOnline + "\n";
@@ -439,8 +401,8 @@ public final class JniTracefile extends Jni_C_Common {
         returnData += "tid                                : " + tid + "\n";
         returnData += "pgid                               : " + pgid + "\n";
         returnData += "creation                           : " + creation + "\n";
-        returnData += "tracePtr                           : " + tracePtr + "\n";
-        returnData += "markerDataPtr                      : " + markerDataPtr + "\n";
+        returnData += "tracePtr                           : 0x" + java.lang.Long.toHexString(tracePtr) + "\n";
+        returnData += "markerDataPtr                      : 0x" + java.lang.Long.toHexString(markerDataPtr) + "\n";
         returnData += "CFileDescriptor                    : " + CFileDescriptor + "\n";
         returnData += "fileSize                           : " + fileSize + "\n";
         returnData += "blocksNumber                       : " + blocksNumber + "\n";
@@ -455,11 +417,29 @@ public final class JniTracefile extends Jni_C_Common {
         returnData += "eventsLost                         : " + eventsLost + "\n";
         returnData += "subBufferCorrupt                   : " + subBufferCorrupt + "\n";
         returnData += "currentEvent                       : " + currentEvent.getReferenceToString() + "\n"; // Hack to avoid ending up with event.toString()
-        returnData += "bufferPtr                          : " + bufferPtr + "\n";
+        returnData += "bufferPtr                          : 0x" + java.lang.Long.toHexString(bufferPtr) + "\n";
         returnData += "bufferSize                         : " + bufferSize + "\n";
         returnData += "tracefileMarkersMap                : " + tracefileMarkersMap.keySet() + "\n"; // Hack to avoid ending up with tracefileMarkersMap.toString()
 
         return returnData;
     }
+
+    /**
+     * Print information for this tracefile. <u>Intended to debug</u><br>
+     * 
+     * This function will call Ltt to print, so information printed will be the
+     * one from the C structure<br>
+     * <br>
+     * This function will not throw but will complain loudly if pointer is NULL
+     */
+    public void printTracefileInformation() {
+
+        // If null pointer, print a warning!
+        if (thisTracefilePtr.getPointer() == NULL) {
+            printlnC("Pointer is NULL, cannot print. (printTracefileInformation)");
+        } else {
+            ltt_printTracefile( thisTracefilePtr.getPointer() );
+        }
+    }
 }
 
index 23904606db322ce3a657316215c9230d5b472880..c59022b3dbbc03610b6407a3b4435bbab59f2f66 100644 (file)
@@ -1,4 +1,3 @@
-package org.eclipse.linuxtools.lttng.jni;
 /*******************************************************************************
  * Copyright (c) 2009 Ericsson
  * 
@@ -11,14 +10,15 @@ package org.eclipse.linuxtools.lttng.jni;
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
+package org.eclipse.linuxtools.lttng.jni;
 
 /**
  * <b><u>Jni_C_Common</u></b>
  * <p>
- * Common constants and methods that should be shared between JNI objects
+ * Common constante and methods that should be shared between JNI objects
  */
 public abstract class Jni_C_Common {
-    
+
     // Needed for native types
     public static final int NULL = 0;
 
@@ -27,7 +27,7 @@ public abstract class Jni_C_Common {
     public static final int EPERM  =  1;
     public static final int ERANGE = 34;
 
-    // Timestamps are in nanoseconds, this const ease up the math
+    // Timestamps are in nanoseconds
     public static final long NANO = 1000000000;
 
     // Native console printing function
@@ -39,37 +39,98 @@ public abstract class Jni_C_Common {
     }
 
     /**
-     * Java-side console printing function.<p>
+     * Java-side console printing function.
      * 
      * Call the C printing function to make sure all printing happen on the same side.
      * 
-     * @param msg   The string to print in C.
+     * @param msg
      */
     public void printC(String msg) {
-        // Need to escape "%" for C printf 
+        // Need to escape "%"
         msg = msg.replaceAll("%", "%%");
         ltt_printC(msg);
     }
 
     /**
-     * Java-side console printing function that add carriage return. <p>
+     * Java-side console printing function. Add a return line at the end of the message.
      * 
      * Call the C printing function to make sure all printing happen on the same side.
      * 
-     * @param msg   The string to print in C.
+     * @param msg
      */
     public void printlnC(String msg) {
         printC(msg + "\n");
     }
 
     /**
-     * "Alternate" .toString()<p>
-     * 
+     * This method is to be used as an "alternate" .toString()<br>
+     * <br>
      * Simulates the way Java Object implements "toString()"
      * 
-     * @return The Java hashed UID of the object (i.e. : NAME@HASH)
+     * @return the Java hashed UID of the object (i.e. : NAME@HASH)
      */
     public String getReferenceToString() {
         return this.getClass().getName() + "@" + Integer.toHexString(this.hashCode());
     }
-}
\ No newline at end of file
+}
+
+/**
+ * <b><u>C_Pointer</u></b>
+ * <p>
+ * Class pointer to handle properly "C pointer" <br>
+ * 
+ * Can transparently handle pointer of 32 or 64 bits.
+ */
+class C_Pointer extends Jni_C_Common {
+
+    private long ptr = NULL;
+    private boolean isLong = true;
+
+    public C_Pointer() {
+        ptr  = NULL;
+    }
+
+    public C_Pointer(long newPtr) {
+        ptr = newPtr;
+        isLong = true; 
+    }
+
+    public C_Pointer(int newPtr) {
+        ptr = (long)newPtr;
+        isLong = false; 
+    }
+
+    public long getPointer() {
+        return ptr;
+    }
+
+    public void setPointer(long newPtr) {
+        ptr = newPtr;
+        isLong = true;
+    }
+
+    public void setPointer(int newPtr) {
+        ptr = newPtr;
+        isLong = false;
+    }
+
+    /**
+     * toString() method<br>
+     * <br>
+     * Convert the pointer to a nice looking hexadecimal format 
+     * 
+     * @return String Attributes of the object concatenated in String
+     */
+    public String toString() {
+        String returnData = "0x";
+
+        if (isLong == true) {
+            returnData += Long.toHexString(ptr);
+        }
+        else {
+            returnData += Integer.toHexString((int) ptr);
+        }
+
+        return returnData;
+    }
+}
diff --git a/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LttngEventStream.java b/org.eclipse.linuxtools.lttng/src/org/eclipse/linuxtools/lttng/trace/LttngEventStream.java
new file mode 100644 (file)
index 0000000..0450c40
--- /dev/null
@@ -0,0 +1,249 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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:
+ *   William Bourque (wbourque@gmail.com) - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.lttng.trace;
+
+import java.io.FileNotFoundException;
+
+import org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.event.LttngEventContent;
+import org.eclipse.linuxtools.lttng.event.LttngEventField;
+import org.eclipse.linuxtools.lttng.event.LttngEventFormat;
+import org.eclipse.linuxtools.lttng.event.LttngEventReference;
+import org.eclipse.linuxtools.lttng.event.LttngEventSource;
+import org.eclipse.linuxtools.lttng.event.LttngEventType;
+import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
+import org.eclipse.linuxtools.lttng.jni.JniEvent;
+import org.eclipse.linuxtools.lttng.jni.JniException;
+import org.eclipse.linuxtools.lttng.jni.JniTime;
+import org.eclipse.linuxtools.lttng.jni.JniTrace;
+import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.trace.TmfTrace;
+
+/**
+ * <b><u>LttngEventStream</u></b>
+ * <p>
+ * LTTng trace implementation. It accesses the C trace handling library
+ * (seeking, reading and parsing) through the JNI component.
+ */
+public class LttngEventStream extends TmfTrace {
+
+       private final static boolean IS_PARSING_NEEDED_DEFAULT = true;
+       private final static int     CHECKPOINT_PAGE_SIZE = 1000;
+       
+    // Reference to the current LttngEvent
+    private LttngEvent currentLttngEvent = null;
+    
+    // Reference to our JNI trace
+    private JniTrace currentJniTrace = null;
+    
+    /**
+     * Constructor
+     * <p>
+     * @param path Path to a <b>directory</b> that contain an LTTng trace.
+     * @exception Exception Trace opening failed (FileNotFoundException)
+     * 
+     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
+     */
+    public LttngEventStream(String path) throws Exception {
+        super(path, CHECKPOINT_PAGE_SIZE);
+        try {
+            currentJniTrace = new JniTrace(path);
+        }
+        catch (JniException e) {
+            throw new FileNotFoundException();
+        }
+        TmfTimestamp startTime = new LttngTimestamp(currentJniTrace.getStartTimeFromTimestampCurrentCounter().getTime());
+        setTimeRange(new TmfTimeRange(startTime, startTime));
+        indexStream();
+    }
+    
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseNextEvent()
+        */
+       public synchronized TmfEvent parseNextEvent() {
+       JniEvent jniEvent = currentJniTrace.readNextEvent();
+       currentLttngEvent = convertJniEventToTmf(jniEvent);
+        return currentLttngEvent;
+       }
+
+    /**
+     * Return a reference to the current LttngTrace we are reading from.
+     * 
+     * @return JniTrace
+     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
+     */
+    public JniTrace getCurrentJniTrace() {
+        return currentJniTrace;
+    }
+    
+    
+    /**
+     * Return a reference to the current LttngEvent we are reading.
+     * 
+     * @return LttngEvent
+     * @see org.eclipse.linuxtools.lttng.event.LttngEvent
+     */
+    public LttngEvent getCurrentEvent() {
+        return currentLttngEvent;
+    }
+    
+    
+    /**
+     * Method to convert a JniEvent into a LttngEvent.<br>
+     * <br>
+     * Note : This method will call LttngEvent convertEventJniToTmf(JniEvent, boolean)
+     * with a default value for isParsingNeeded
+     * 
+     * @param   newEvent     The JniEvent to convert
+     * @return  LttngEvent   The converted event
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     */
+    public LttngEvent convertJniEventToTmf(JniEvent newEvent) {
+       LttngEvent event = null;
+       if (newEvent != null)
+               event = convertJniEventToTmf(newEvent, IS_PARSING_NEEDED_DEFAULT);
+       return event;
+    }
+    
+    /**
+     * Method tp convert a JniEvent into a LttngEvent
+     * 
+     * @param   jniEvent        The JniEvent to convert
+     * @param   isParsingNeeded A boolean value telling if the event should be parsed or not.
+     * @return  LttngEvent   The converted event
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     */
+    // Conversion method to transform a JafEvent into a TmfEvent
+    public LttngEvent convertJniEventToTmf(JniEvent jniEvent, boolean isParsingNeeded) {
+        LttngEventFormat eventFormat = new LttngEventFormat();
+        String content = "";
+        LttngEventField[] fields = null;
+
+        if (isParsingNeeded == true) {
+            fields = eventFormat.parse(jniEvent.parseAllFields());
+            for (int y = 0; y < fields.length; y++) {
+                content += fields[y].toString() + " ";
+            }
+        }
+        
+        LttngEvent event = new LttngEvent(
+                       new LttngTimestamp(jniEvent.getEventTime().getTime()),
+                new LttngEventSource(jniEvent.requestEventSource() ), 
+                new LttngEventType(jniEvent.getParentTracefile().getTracefileName(),
+                                   jniEvent.getParentTracefile().getCpuNumber(),
+                                   jniEvent.requestEventMarker().getName(),
+                                   eventFormat),
+                new LttngEventContent(eventFormat, content, fields), 
+                new LttngEventReference(jniEvent.getParentTracefile().getTracefilePath(), this.getName()),
+                jniEvent);
+        
+        return event;
+    }
+    
+    
+    /**
+     * Return location (timestamp) of our current position in the trace.
+     * 
+     * @return LttngTimestamp The current Ltt timestamp, in long. Unit is nanosecond.
+     */
+    public Object getCurrentLocation() {
+        return new LttngTimestamp(currentJniTrace.getCurrentEventTimestamp().getTime());
+    }
+    
+    /**
+     * Seek (move) to a certain location in the trace.
+     * 
+     * @param location  a LttngTimestamp of a position in the trace
+     * @return StreamContext pointing to the current (after seek) position in the trace
+     */
+    public TmfTraceContext seekLocation(Object location) {
+        
+        // If location is null, interpret this as a request to get back to the beginning of the trace
+        // Change the location, the seek will happen below
+       if (location == null) {
+               location = getStartTime();
+       }
+       
+        TmfTraceContext context = null;
+       if (location instanceof LttngTimestamp) {
+               long value = ((LttngTimestamp) location).getValue();
+               if (value != currentJniTrace.getCurrentEventTimestamp().getTime()) {
+                       currentJniTrace.seekToTime(new JniTime(value));
+                       context = new TmfTraceContext(new LttngTimestamp(currentJniTrace.getCurrentEventTimestamp().getTime()), 0);
+               }
+       }
+       
+        return context;
+    }
+    
+    
+    // !!! THIS MAIN IS FOR TESTING ONLY !!!
+    public static void main(String[] args) {
+
+//        LttngEventStream testStream = null;
+//        try {
+//            testStream = new LttngEventStream("/home/william/trace1");
+//            Thread.sleep(5000);
+//            
+//            System.out.println("NB Events : " + testStream.getNbEvents());
+//            System.out.println("Beginning test run parsing event");
+//            
+//            LttngEvent tmpEvent = null;
+//            Random generator = new Random();
+//            
+//            int number = 0;
+//            long execStartTime = System.currentTimeMillis();
+//            for (int x = 0; x < 10; x++) {
+//                number = generator.nextInt(testStream.getNbEvents());
+//                
+//                tmpEvent = (LttngEvent) testStream.getEvent(new TmfTraceContext(null), number);
+//                
+//                
+//                System.out.println("GETTING EVENT #" + number);
+//                
+//                // *****************
+//                // ***  OLD EVIL WAY  
+//                TmfEventField[] tmpJoieFields = tmpEvent.getContent().getFields();
+//                for ( int pos = 0; pos< tmpJoieFields.length; pos++  )
+//                {
+//                    System.out.print(tmpJoieFields[pos].toString() + " ");
+//                }
+//                System.out.println("");
+//                // ***
+//                // *****************
+//                
+//                
+//                // *****************
+//                // ***  NEW CAST-O-RAMA WAY  
+//                TmfEventField[] tmpJoieFields2 = ( (LttngEventContent)tmpEvent.getContent()).getFields(tmpEvent);
+//                for ( int pos = 0; pos< tmpJoieFields2.length; pos++  )
+//                {
+//                    System.out.print(tmpJoieFields2[pos].toString() + " ");
+//                }
+//                System.out.println("");
+//                // ***
+//                // *****************
+//            }
+//            long execEndTime = System.currentTimeMillis();
+//            System.out.println("Execution time: " + (execEndTime - execStartTime) + "ms");
+//            
+//
+//        } catch (Exception e) {
+//            System.out.println("FAILED WITH : " + e.getMessage() + "\n");
+//        }
+
+    }
+
+}
index 67470399bc20c8f419a83b1bb26c7992ecb01c80..833e10efa8e2c2ff14818f6176bf2a46d7d93a8c 100644 (file)
@@ -75,17 +75,17 @@ public class TmfTimestampTest {
     @Test
     public void testCopyConstructorBigBang() throws Exception {
         TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigBang);
-        assertEquals("getValue",     0, ts.getValue());
-        assertEquals("getscale",     0, ts.getScale());
-        assertEquals("getPrecision", 0, ts.getPrecision());
+        assertEquals("getValue",     TmfTimestamp.BigBang.getValue(), ts.getValue());
+        assertEquals("getscale",     TmfTimestamp.BigBang.getScale(), ts.getScale());
+        assertEquals("getPrecision", TmfTimestamp.BigBang.getPrecision(), ts.getPrecision());
     }
 
     @Test
     public void testCopyConstructorBigCrunch() throws Exception {
         TmfTimestamp ts = new TmfTimestamp(TmfTimestamp.BigCrunch);
-        assertEquals("getValue", Long.MAX_VALUE, ts.getValue());
-        assertEquals("getscale", Byte.MAX_VALUE, ts.getScale());
-        assertEquals("getPrecision",          0, ts.getPrecision());
+        assertEquals("getValue",     TmfTimestamp.BigCrunch.getValue(), ts.getValue());
+        assertEquals("getscale",     TmfTimestamp.BigCrunch.getScale(), ts.getScale());
+        assertEquals("getPrecision", TmfTimestamp.BigCrunch.getPrecision(), ts.getPrecision());
     }
 
     // ========================================================================
@@ -177,18 +177,6 @@ public class TmfTimestampTest {
         assertEquals("getPrecision", 120, ts.getPrecision());
     }
 
-    @Test
-    public void testSynchronizeWithArithmeticException() throws Exception {
-        TmfTimestamp bigBang   = new TmfTimestamp(TmfTimestamp.BigBang);
-        TmfTimestamp bigCrunch = new TmfTimestamp(TmfTimestamp.BigCrunch);
-
-        try {
-            bigCrunch.synchronize(bigBang.getValue(), bigBang.getScale());
-            fail("Exception not thrown");
-        } catch (ArithmeticException e) {          
-        }
-    }
-
     // ========================================================================
     // getAdjustment
     // ========================================================================
@@ -214,15 +202,6 @@ public class TmfTimestampTest {
         assertEquals("delta", 0, delta);
     }
 
-    @Test
-    public void testGetAdjustmentDifferentScaleWithException() throws Exception {
-        try {
-            TmfTimestamp.BigBang.getAdjustment(TmfTimestamp.BigCrunch);
-            fail("ArithmeticException not thrown");
-        } catch (ArithmeticException e) {
-        }
-    }
-
     // ========================================================================
     // CompareTo
     // ========================================================================
@@ -324,10 +303,10 @@ public class TmfTimestampTest {
         TmfTimestamp ts3 = new TmfTimestamp( 1, Byte.MAX_VALUE);
         TmfTimestamp ts4 = new TmfTimestamp( 1, Byte.MIN_VALUE);
 
-        assertTrue(ts1.compareTo(TmfTimestamp.BigBang,   false) < 0);
+        assertTrue(ts1.compareTo(TmfTimestamp.BigBang,   false) > 0);
         assertTrue(ts1.compareTo(TmfTimestamp.BigCrunch, false) < 0);
 
-        assertTrue(ts2.compareTo(TmfTimestamp.BigBang,   false) < 0);
+        assertTrue(ts2.compareTo(TmfTimestamp.BigBang,   false) > 0);
         assertTrue(ts2.compareTo(TmfTimestamp.BigCrunch, false) < 0);
 
         assertTrue(ts3.compareTo(TmfTimestamp.BigBang,   false) > 0);
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/stream/AllStreamTests.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/stream/AllStreamTests.java
deleted file mode 100644 (file)
index dab8a41..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.stream;
-
-import org.eclipse.linuxtools.tmf.stream.TmfEventStreamTest;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
-    TmfEventStreamTest.class
-})
-
-public class AllStreamTests {
-
-}
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/stream/TmfEventStreamTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/stream/TmfEventStreamTest.java
deleted file mode 100644 (file)
index 26790d5..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.stream;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-
-import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.trace.TmfEventParserStub;
-import org.eclipse.linuxtools.tmf.trace.TmfEventStreamStub;
-import org.eclipse.linuxtools.tmf.trace.ITmfTrace.StreamContext;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * <b><u>TmfEventStreamTest</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class TmfEventStreamTest {
-
-    private static final String DIRECTORY   = "testfiles";
-    private static final String TEST_STREAM = "M-Test-100K";
-    private static String testfile;
-    private static final int NB_EVENTS = 100000;
-    private static TmfEventStreamStub fStream;
-
-    private static byte SCALE = (byte) -3;
-
-    /**
-     * @throws java.lang.Exception
-     */
-    @BeforeClass
-    public static void setUpBeforeClass() throws Exception {
-       String directory = new File(".").getCanonicalPath() + File.separator + DIRECTORY;
-       testfile = directory + File.separator + TEST_STREAM;
-
-        TmfEventParserStub parser = new TmfEventParserStub();
-        fStream = new TmfEventStreamStub(testfile, parser, 500);
-        fStream.indexStream(true);
-
-    }
-
-    // ========================================================================
-    // Constructor
-    // ========================================================================
-
-    @Test
-    public void testDefaultConstructor() throws Exception {
-        TmfEventParserStub parser = new TmfEventParserStub();
-        TmfEventStreamStub stream = new TmfEventStreamStub(testfile, parser);
-        stream.indexStream(true);
-
-        assertEquals("getCacheSize", TmfEventStreamStub.DEFAULT_CACHE_SIZE, stream.getCacheSize());
-        assertEquals("getTraceSize", NB_EVENTS, stream.getNbEvents());
-        assertEquals("getRange-start", 1, stream.getTimeRange().getStartTime().getValue());
-        assertEquals("getRange-end", NB_EVENTS, stream.getTimeRange().getEndTime().getValue());
-    }
-
-    @Test
-    public void testNormalConstructor() throws Exception {
-        TmfEventParserStub parser = new TmfEventParserStub();
-        TmfEventStreamStub stream = new TmfEventStreamStub(testfile, parser, 500);
-        stream.indexStream(true);
-
-        assertEquals("getCacheSize",    500, stream.getCacheSize());
-        assertEquals("getTraceSize", NB_EVENTS, stream.getNbEvents());
-        assertEquals("getRange-start",    1, stream.getTimeRange().getStartTime().getValue());
-        assertEquals("getRange-end", NB_EVENTS, stream.getTimeRange().getEndTime().getValue());
-    }
-
-    // ========================================================================
-    // seek
-    // ========================================================================
-
-    @Test
-    public void testSeekOnCacheBoundary() throws Exception {
-       StreamContext context = new StreamContext(null);
-
-       TmfEvent event = fStream.getEvent(context, new TmfTimestamp(0, SCALE, 0));
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
-        event = fStream.getEvent(context, new TmfTimestamp(1000, SCALE, 0));
-        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
-
-        event = fStream.getEvent(context, new TmfTimestamp(4000, SCALE, 0));
-        assertEquals("Event timestamp", 4000, event.getTimestamp().getValue());
-    }
-
-    @Test
-    public void testSeekNotOnCacheBoundary() throws Exception {
-       StreamContext context = new StreamContext(null);
-
-       TmfEvent event = fStream.getEvent(context, new TmfTimestamp(1, SCALE, 0));
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
-        event = fStream.getEvent(context, new TmfTimestamp(999, SCALE, 0));
-        assertEquals("Event timestamp", 999, event.getTimestamp().getValue());
-
-        event = fStream.getEvent(context, new TmfTimestamp(4499, SCALE, 0));
-        assertEquals("Event timestamp", 4499, event.getTimestamp().getValue());
-    }
-
-    @Test
-    public void testSeekForEventOutOfBounds() throws Exception {
-       StreamContext context = new StreamContext(null);
-
-       // On lower bound, returns the first event (ts = 1)
-        TmfEvent event = fStream.getEvent(context, new TmfTimestamp(-1, SCALE, 0));
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
-        // On higher bound, returns null (no event)
-        event = fStream.getEvent(context, new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
-        assertEquals("Event timestamp", null, event);
-    }
-
-    // ========================================================================
-    // getNextEvent
-    // ========================================================================
-
-    @Test
-    public void testGetNextEvent() throws Exception {
-       StreamContext context = new StreamContext(null);
-
-       // On lower bound, returns the first event (ts = 0)
-        TmfEvent event = fStream.getEvent(context, new TmfTimestamp(0, SCALE, 0));
-        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
-
-        for (int i = 2; i < 20; i++) {
-            event = fStream.getNextEvent(context);
-            assertEquals("Event timestamp", i, event.getTimestamp().getValue());
-        }
-    }
-
-}
index f4f2dec2861404073d9623ea133cae0a0c4c1746..f7bfe968a208f7b53a19c731eeff6d7dc79a31d3 100644 (file)
@@ -17,7 +17,8 @@ import org.junit.runners.Suite;
 
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
-    TmfTraceTest.class
+       TmfTraceTest.class,
+    TmfExperimentTest.class
 })
 
 public class AllTraceTests {
diff --git a/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/TmfExperimentTest.java b/org.eclipse.linuxtools.tmf.tests/src/org/eclipse/linuxtools/tmf/trace/TmfExperimentTest.java
new file mode 100644 (file)
index 0000000..42dafc8
--- /dev/null
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.trace;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.Vector;
+
+import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * <b><u>TmfEventLogTest</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfExperimentTest {
+
+    private static final String DIRECTORY   = "testfiles";
+    private static final String TEST_STREAM = "M-Test-10K";
+    private static final String EXPERIMENT  = "MyExperiment";
+    private static String testfile;
+    private static int NB_EVENTS = 10000;
+    private static int fDefaultBlockSize = 1000;
+
+//    private static ITmfEventParser fParser;
+    private static ITmfTrace fStream;
+    private static TmfExperiment fExperiment;
+
+//    private static byte SCALE = (byte) -3;
+
+    @BeforeClass
+       public static void setUpBeforeClass() throws Exception {
+       String directory = new File(".").getCanonicalPath() + File.separator + DIRECTORY;
+       testfile = directory + File.separator + TEST_STREAM;
+
+               fStream = new TmfTraceStub(testfile);
+        fExperiment = new TmfExperiment(EXPERIMENT, new ITmfTrace[] { fStream });
+        while (fStream.getNbEvents() < NB_EVENTS) {
+               Thread.sleep(1000);
+        }
+       }
+
+    // ========================================================================
+    // Constructor
+    // ========================================================================
+
+       @Test
+       public void testBasicTmfTrace() {
+               assertEquals("GetId", EXPERIMENT, fExperiment.getExperimentId());
+        assertEquals("GetEpoch", TmfTimestamp.BigBang, fExperiment.getEpoch());
+        assertEquals("GetNbEvents", NB_EVENTS, fExperiment.getNbEvents());
+
+        TmfTimeRange timeRange = fExperiment.getTimeRange();
+        assertEquals("GetTimeRange-start", 1, timeRange.getStartTime().getValue());
+        assertEquals("GetTimeRange-end", NB_EVENTS, timeRange.getEndTime().getValue());
+       }
+
+    // ========================================================================
+    // Operators
+    // ========================================================================
+
+    @Test
+    public void testProcessRequestForNbEvents() throws Exception {
+        final int BLOCK_SIZE = 100;
+        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void handleData() {
+               TmfEvent[] events = getData();
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+            }
+        };
+        fExperiment.processRequest(request, true);
+
+        assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
+        assertTrue("isCompleted",  request.isCompleted());
+        assertFalse("isCancelled", request.isCancelled());
+
+        // Ensure that we have distinct events.
+        // Don't go overboard: we are not validating the stub! 
+        for (int i = 0; i < NB_EVENTS; i++) {
+            assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
+        }
+    }
+    
+    @Test
+    public void testProcessRequestForAllEvents() throws Exception {
+        final int NB_EVENTS  = -1;
+        final int BLOCK_SIZE =  1;
+        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+        int nbExpectedEvents = fExperiment.getNbEvents();
+
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void handleData() {
+               TmfEvent[] events = getData();
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+            }
+        };
+        fExperiment.processRequest(request, true);
+
+        assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
+        assertTrue("isCompleted",  request.isCompleted());
+        assertFalse("isCancelled", request.isCancelled());
+
+        // Ensure that we have distinct events.
+        // Don't go overboard: we are not validating the stub! 
+        for (int i = 0; i < nbExpectedEvents; i++) {
+            assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
+        }
+    }
+    
+    // ========================================================================
+    // cancel
+    // ========================================================================
+
+    @Test
+    public void testCancel() throws Exception {
+        final int BLOCK_SIZE = fDefaultBlockSize;
+        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
+
+        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
+        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
+            @Override
+            public void handleData() {
+               TmfEvent[] events = getData();
+                for (TmfEvent e : events) {
+                    requestedEvents.add(e);
+                }
+                // Cancel request after the first chunk is received
+                cancel();
+            }
+        };
+        fExperiment.processRequest(request, true);
+
+        assertEquals("nbEvents",  BLOCK_SIZE, requestedEvents.size());
+        assertTrue("isCompleted", request.isCompleted());
+        assertTrue("isCancelled", request.isCancelled());
+    }
+
+}
index 28a006db629efce3af47cb2ebd34a800d3f8654c..ff9dae14cfccefe52b4998fe623f2d14852857fa 100644 (file)
 package org.eclipse.linuxtools.tmf.trace;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
 
 import java.io.File;
-import java.util.Vector;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
+import org.eclipse.linuxtools.tmf.trace.TmfTraceStub;
+import org.eclipse.linuxtools.tmf.trace.ITmfTrace.TmfTraceContext;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 /**
- * <b><u>TmfEventLogTest</u></b>
+ * <b><u>TmfEventStreamTest</u></b>
  * <p>
  * TODO: Implement me. Please.
  */
 public class TmfTraceTest {
 
     private static final String DIRECTORY   = "testfiles";
-    private static final String TEST_STREAM = "M-Test-10K";
-    private static final String EXPERIMENT  = "MyExperiment";
+    private static final String TEST_STREAM = "M-Test-100K";
     private static String testfile;
-    private static int fTotalNbEvents = 10000;
-    private static int fDefaultBlockSize = 1000;
+    private static final int NB_EVENTS = 100000;
+    private static TmfTraceStub fTrace;
 
-    private static ITmfEventParser fParser;
-    private static ITmfTrace fStream;
-    private static TmfExperiment   fExperiment;
-
-//    private static byte SCALE = (byte) -3;
+    private static byte SCALE = (byte) -3;
 
+    /**
+     * @throws java.lang.Exception
+     */
     @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
+    public static void setUpBeforeClass() throws Exception {
        String directory = new File(".").getCanonicalPath() + File.separator + DIRECTORY;
        testfile = directory + File.separator + TEST_STREAM;
 
-               fParser = new TmfEventParserStub();
-               fStream = new TmfEventStreamStub(testfile, fParser);
-        fExperiment = new TmfExperiment(EXPERIMENT, new ITmfTrace[] { fStream });
-        fStream.indexStream(true);
-       }
+        fTrace = new TmfTraceStub(testfile, 500);
+
+        // Wait for the stream indexing to complete
+        while (fTrace.getNbEvents() < NB_EVENTS) {
+               Thread.sleep(1000);
+        }
+    }
 
     // ========================================================================
     // Constructor
     // ========================================================================
 
-       @Test
-       public void testBasicTmfEventLog() {
-               assertEquals("GetId", EXPERIMENT, fExperiment.getExperimentId());
-        assertEquals("GetEpoch", TmfTimestamp.BigBang, fExperiment.getEpoch());
-        assertEquals("GetNbEvents", fTotalNbEvents, fExperiment.getNbEvents());
-
-        TmfTimeRange timeRange = fExperiment.getTimeRange();
-        assertEquals("GetTimeRange-start", 1, timeRange.getStartTime().getValue());
-        assertEquals("GetTimeRange-end", fTotalNbEvents, timeRange.getEndTime().getValue());
-       }
-
-//  TODO: Fix the test when epoch is implemented
-//     @Test
-//     public void testTmfEventLogWithEpoch() {
-//             TmfTimestamp epoch = new TmfTimestamp(100, SCALE, 0);
-//             TmfEventLog eventLog = new TmfEventLog("MyEventLog", fStream, epoch);
-//
-//             assertEquals("GetId", "MyEventLog", eventLog.getId());
-//        assertEquals("GetEpoch", epoch, eventLog.getEpoch());
-//        assertEquals("GetNbEvents", fTotalNbEvents, eventLog.getNbEvents());
-//
-//        TmfTimeWindow timeRange = eventLog.getTimeRange();
-//        assertEquals("GetTimeRange-start", 1, timeRange.getStartTime().getValue());
-//        assertEquals("GetTimeRange-end", fTotalNbEvents, timeRange.getEndTime().getValue());
-//     }
-
-//    // ========================================================================
-//    // Accessors
-//    // ========================================================================
-//
-//    @Test
-//    public void testGetNbEvents() throws Exception {
-//     TmfTrace eventLog = new TmfTrace("MyEventLog", fStream);
-//        assertEquals("nbEvents", fTotalNbEvents, eventLog.getNbEvents());
-//    }
+    @Test
+    public void testDefaultConstructor() throws Exception {
+        TmfTraceStub stream = new TmfTraceStub(testfile);
+        // Wait for the stream indexing to complete
+        while (stream.getNbEvents() < NB_EVENTS) {
+               Thread.sleep(1000);
+        }
+
+        assertEquals("getCacheSize", TmfTraceStub.DEFAULT_PAGE_SIZE, stream.getPageSize());
+        assertEquals("getTraceSize", NB_EVENTS, stream.getNbEvents());
+        assertEquals("getRange-start", 1, stream.getTimeRange().getStartTime().getValue());
+        assertEquals("getRange-end", NB_EVENTS, stream.getTimeRange().getEndTime().getValue());
+    }
+
+    @Test
+    public void testNormalConstructor() throws Exception {
+        TmfTraceStub stream = new TmfTraceStub(testfile, 500);
+        // Wait for the stream indexing to complete
+        while (stream.getNbEvents() < NB_EVENTS) {
+               Thread.sleep(1000);
+        }
+
+        assertEquals("getCacheSize",    500, stream.getPageSize());
+        assertEquals("getTraceSize", NB_EVENTS, stream.getNbEvents());
+        assertEquals("getRange-start",    1, stream.getTimeRange().getStartTime().getValue());
+        assertEquals("getRange-end", NB_EVENTS, stream.getTimeRange().getEndTime().getValue());
+    }
 
     // ========================================================================
-    // Operators
+    // seek
     // ========================================================================
 
     @Test
-    public void testProcessRequestForNbEvents() throws Exception {
-        final int NB_EVENTS  = fTotalNbEvents;
-        final int BLOCK_SIZE = 100;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-
-        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        fStream.indexStream(true);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void handleData() {
-               TmfEvent[] events = getData();
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        fExperiment.processRequest(request, true);
-
-        assertEquals("nbEvents", NB_EVENTS, requestedEvents.size());
-        assertTrue("isCompleted",  request.isCompleted());
-        assertFalse("isCancelled", request.isCancelled());
-
-        // Ensure that we have distinct events.
-        // Don't go overboard: we are not validating the stub! 
-        for (int i = 0; i < NB_EVENTS; i++) {
-            assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
-        }
+    public void testSeekOnCacheBoundary() throws Exception {
+       TmfTraceContext context = new TmfTraceContext(null);
+
+       TmfEvent event = fTrace.getEvent(context, new TmfTimestamp(0, SCALE, 0));
+        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+
+        event = fTrace.getEvent(context, new TmfTimestamp(1000, SCALE, 0));
+        assertEquals("Event timestamp", 1000, event.getTimestamp().getValue());
+
+        event = fTrace.getEvent(context, new TmfTimestamp(4000, SCALE, 0));
+        assertEquals("Event timestamp", 4000, event.getTimestamp().getValue());
     }
-    
+
     @Test
-    public void testProcessRequestForAllEvents() throws Exception {
-        final int NB_EVENTS  = -1;
-        final int BLOCK_SIZE =  1;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-        int nbExpectedEvents = fExperiment.getNbEvents();
-
-        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void handleData() {
-               TmfEvent[] events = getData();
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-            }
-        };
-        fExperiment.processRequest(request, true);
-
-        assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
-        assertTrue("isCompleted",  request.isCompleted());
-        assertFalse("isCancelled", request.isCancelled());
-
-        // Ensure that we have distinct events.
-        // Don't go overboard: we are not validating the stub! 
-        for (int i = 0; i < nbExpectedEvents; i++) {
-            assertEquals("Distinct events", i+1, requestedEvents.get(i).getTimestamp().getValue());
-        }
+    public void testSeekNotOnCacheBoundary() throws Exception {
+       TmfTraceContext context = new TmfTraceContext(null);
+
+       TmfEvent event = fTrace.getEvent(context, new TmfTimestamp(1, SCALE, 0));
+        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+
+        event = fTrace.getEvent(context, new TmfTimestamp(999, SCALE, 0));
+        assertEquals("Event timestamp", 999, event.getTimestamp().getValue());
+
+        event = fTrace.getEvent(context, new TmfTimestamp(4499, SCALE, 0));
+        assertEquals("Event timestamp", 4499, event.getTimestamp().getValue());
     }
-    
-//    // @Test
-//    // TODO: Implement offset handling first...
-//    public void testProcessRequestWithOffset() throws Exception {
-//        final int NB_EVENTS  = -1;
-//        final int BLOCK_SIZE =  1;
-//        final int OFFSET = 5;
-//        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-//        int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
-//
-//        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-//        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
-//            @Override
-//            public void handlePartialResult() {
-//             TmfEvent[] events = getData();
-//                for (TmfEvent e : events) {
-//                    requestedEvents.add(e);
-//                }
-//            }
-//        };
-//        fEventLog.process(request, true);
-//
-//        assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
-//        assertTrue("isCompleted",  request.isCompleted());
-//        assertFalse("isCancelled", request.isCancelled());
-//
-//        // Ensure that we have distinct events.
-//        // Don't go overboard: we are not validating the stub! 
-//        for (int i = 0; i < nbExpectedEvents; i++) {
-//            assertEquals("Distinct events", i + OFFSET, requestedEvents.get(i).getTimestamp().getValue());
-//        }
-//    }
-    
-//    // l@Test
-//    public void testProcessRequestWithNegativeOffset() throws Exception {
-//        final int NB_EVENTS  = -1;
-//        final int BLOCK_SIZE =  1;
-//        final int OFFSET = -5;
-//        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-//        int nbExpectedEvents = TmfRequestHandlerStub.MAX_GENERATED_EVENTS;
-//
-//        TmfTimeWindow range = new TmfTimeWindow(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-//        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, OFFSET, NB_EVENTS, BLOCK_SIZE) {
-//            @Override
-//            public void handlePartialResult() {
-//             TmfEvent[] events = getData();
-//                for (TmfEvent e : events) {
-//                    requestedEvents.add(e);
-//                }
-//            }
-//        };
-//        fEventLog.process(request, true);
-//
-//        assertEquals("nbEvents", nbExpectedEvents, requestedEvents.size());
-//        assertTrue("isCompleted",  request.isCompleted());
-//        assertFalse("isCancelled", request.isCancelled());
-//
-//        // Ensure that we have distinct events.
-//        // Don't go overboard: we are not validating the stub! 
-//        for (int i = 0; i < nbExpectedEvents; i++) {
-//            assertEquals("Distinct events", i + OFFSET, requestedEvents.get(i).getTimestamp().getValue());
-//        }
-//    }
-    
+
+    @Test
+    public void testSeekForEventOutOfBounds() throws Exception {
+       TmfTraceContext context = new TmfTraceContext(null);
+
+       // On lower bound, returns the first event (ts = 1)
+        TmfEvent event = fTrace.getEvent(context, new TmfTimestamp(-1, SCALE, 0));
+        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+
+        // On higher bound, returns null (no event)
+        event = fTrace.getEvent(context, new TmfTimestamp(NB_EVENTS + 1, SCALE, 0));
+        assertEquals("Event timestamp", null, event);
+    }
+
     // ========================================================================
-    // cancel
+    // getNextEvent
     // ========================================================================
 
     @Test
-    public void testCancel() throws Exception {
-        final int NB_EVENTS  = fTotalNbEvents;
-        final int BLOCK_SIZE = fDefaultBlockSize;
-        final Vector<TmfEvent> requestedEvents = new Vector<TmfEvent>();
-
-        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.BigBang, TmfTimestamp.BigCrunch);
-        final TmfDataRequest<TmfEvent> request = new TmfDataRequest<TmfEvent>(range, 0, NB_EVENTS, BLOCK_SIZE) {
-            @Override
-            public void handleData() {
-               TmfEvent[] events = getData();
-                for (TmfEvent e : events) {
-                    requestedEvents.add(e);
-                }
-                // Cancel request after the first chunk is received
-                cancel();
-            }
-        };
-        fExperiment.processRequest(request, true);
-
-        assertEquals("nbEvents",  BLOCK_SIZE, requestedEvents.size());
-        assertTrue("isCompleted", request.isCompleted());
-        assertTrue("isCancelled", request.isCancelled());
+    public void testGetNextEvent() throws Exception {
+       TmfTraceContext context = new TmfTraceContext(null);
+
+       // On lower bound, returns the first event (ts = 0)
+        TmfEvent event = fTrace.getEvent(context, new TmfTimestamp(0, SCALE, 0));
+        assertEquals("Event timestamp", 1, event.getTimestamp().getValue());
+
+        for (int i = 2; i < 20; i++) {
+            event = fTrace.getNextEvent(context);
+            assertEquals("Event timestamp", i, event.getTimestamp().getValue());
+        }
     }
 
 }
index 862a095f05cd0735c4b21c658cf9a92208e325ea..1e59e3104b8d3342dc8cf70d54bef09005d77887 100644 (file)
@@ -18,10 +18,8 @@ import java.util.Vector;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.trace.TmfEventParserStub;
-import org.eclipse.linuxtools.tmf.trace.TmfEventStreamStub;
-import org.eclipse.linuxtools.tmf.trace.ITmfTrace.StreamContext;
+import org.eclipse.linuxtools.tmf.trace.TmfTraceStub;
+import org.eclipse.linuxtools.tmf.trace.ITmfTrace.TmfTraceContext;
 
 /**
  * <b><u>TmfRequestHandlerStub</u></b>
@@ -36,15 +34,12 @@ public class TmfRequestHandlerStub implements ITmfRequestHandler<TmfEvent> {
     // A constant to limit the number of events for the tests
     public static final int MAX_GENERATED_EVENTS = 1000;
 
-    private ITmfEventParser fParser;
-    private TmfEventStreamStub fStream;
+    private TmfTraceStub fTrace;
 
     public TmfRequestHandlerStub() throws IOException {
        String directory = new File(".").getCanonicalPath() + File.separator + "testfiles";
        String filename  = directory + File.separator + TEST_STREAM;
-
-       fParser = new TmfEventParserStub();
-        fStream = new TmfEventStreamStub(filename, fParser);
+        fTrace = new TmfTraceStub(filename);
     }
 
     /* (non-Javadoc)
@@ -66,8 +61,8 @@ public class TmfRequestHandlerStub implements ITmfRequestHandler<TmfEvent> {
 
                 Vector<TmfEvent> events = new Vector<TmfEvent>();
                 int nbEvents = 0;
-               StreamContext context = new StreamContext(null);
-                TmfEvent event = fStream.getEvent(context, startTime);
+               TmfTraceContext context = new TmfTraceContext(null);
+                TmfEvent event = fTrace.getEvent(context, startTime);
                 while (!request.isCancelled() && nbEvents < nbRequestedEvents &&
                        event != null && event.getTimestamp().compareTo(endTime, false) <= 0 )
                 {
@@ -79,7 +74,7 @@ public class TmfRequestHandlerStub implements ITmfRequestHandler<TmfEvent> {
                         request.handleData();
                         events.removeAllElements();
                     }
-                    event = fStream.getNextEvent(context);
+                    event = fTrace.getNextEvent(context);
                 }
                TmfEvent[] result = new TmfEvent[events.size()];
                events.toArray(result);
index 68d32fb04359f96502589e578f0eb8391f7ed482..131f75e128cf18e7800b78d21be1ea8e518397c1 100644 (file)
@@ -65,11 +65,11 @@ public class TmfEventParserStub implements ITmfEventParser {
     static final String typePrefix = "Type-";
     public TmfEvent getNextEvent(ITmfTrace eventStream) throws IOException {
 
-        if (! (eventStream instanceof TmfEventStreamStub)) {
+        if (! (eventStream instanceof TmfTraceStub)) {
             return null;
         }
 
-        RandomAccessFile stream = ((TmfEventStreamStub) eventStream).getStream();
+        RandomAccessFile stream = ((TmfTraceStub) eventStream).getStream();
 
         try {
             long ts        = stream.readLong();
diff --git a/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfEventStreamStub.java b/org.eclipse.linuxtools.tmf.tests/stubs/org/eclipse/linuxtools/tmf/trace/TmfEventStreamStub.java
deleted file mode 100644 (file)
index a190642..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.trace;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.Map;
-
-
-/**
- * <b><u>TmfEventStreamStub</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class TmfEventStreamStub extends TmfTrace {
-
-    // ========================================================================
-    // Attributes
-    // ========================================================================
-
-    // The actual stream
-    private final RandomAccessFile fStream;
-
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-    /**
-     * @param filename
-     * @param parser
-     * @throws FileNotFoundException
-     */
-    public TmfEventStreamStub(String filename, ITmfEventParser parser) throws FileNotFoundException {
-        this(filename, parser, DEFAULT_CACHE_SIZE);
-    }
-
-    /**
-     * @param filename
-     * @param parser
-     * @param cacheSize
-     * @throws FileNotFoundException
-     */
-    public TmfEventStreamStub(String filename, ITmfEventParser parser, int cacheSize) throws FileNotFoundException {
-        super(filename, parser, cacheSize);
-        fStream = new RandomAccessFile(filename, "r");
-        indexStream(true);
-    }
-
-    // ========================================================================
-    // Accessors
-    // ========================================================================
-
-    public RandomAccessFile getStream() {
-        return fStream;
-    }
-
-    // ========================================================================
-    // Operators
-    // ========================================================================
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
-     */
-    public StreamContext seekLocation(Object location) {
-       StreamContext context = null;
-        try {
-                       fStream.seek((location != null) ? (Long) location : 0);
-                       context = new StreamContext(getCurrentLocation(), 0);
-               } catch (IOException e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               }
-               return context;
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
-     */
-    public Object getCurrentLocation() {
-        try {
-            return new Long(fStream.getFilePointer());
-        } catch (IOException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    // ========================================================================
-    // Helper functions
-    // ========================================================================
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
-     */
-    public Map<String, Object> getAttributes() {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-}
index 36ed9454cbfa790a750c51f94dd69b703dc5b45c..c0e767350a1a3db55bff0752b2f30889894a2776 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
+ * Copyright (c) 2009 Ericsson
  * 
  * All rights reserved. This program and the accompanying materials are
  * made available under the terms of the Eclipse Public License v1.0 which
@@ -15,41 +15,37 @@ package org.eclipse.linuxtools.tmf.trace;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.RandomAccessFile;
+import java.util.Map;
 
 import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.parser.ITmfEventParser;
 
 /**
  * <b><u>TmfTraceStub</u></b>
  * <p>
- * Dummy test trace. Use in conjunction with TmfEventParserStub.
+ * TODO: Implement me. Please.
  */
-public class TmfTraceStub extends TmfTrace<TmfEvent> {
+public class TmfTraceStub extends TmfTrace {
 
-    // ------------------------------------------------------------------------
+    // ========================================================================
     // Attributes
-    // ------------------------------------------------------------------------
+    // ========================================================================
 
     // The actual stream
-    private RandomAccessFile fTrace;
+    private final RandomAccessFile fTrace;
 
     // The associated event parser
-    private ITmfEventParser fParser;
+    private final ITmfEventParser fParser;
 
-    // ------------------------------------------------------------------------
+    // ========================================================================
     // Constructors
-    // ------------------------------------------------------------------------
+    // ========================================================================
 
     /**
      * @param filename
      * @throws FileNotFoundException
      */
     public TmfTraceStub(String filename) throws FileNotFoundException {
-        super("TmfTraceStub", TmfEvent.class, filename);
-        fTrace  = new RandomAccessFile(filename, "r");
-        fParser = new TmfEventParserStub();
+        this(filename, DEFAULT_PAGE_SIZE);
     }
 
     /**
@@ -58,136 +54,76 @@ public class TmfTraceStub extends TmfTrace<TmfEvent> {
      * @throws FileNotFoundException
      */
     public TmfTraceStub(String filename, int cacheSize) throws FileNotFoundException {
-        this(filename, cacheSize, false);
-    }
-
-    /**
-     * @param filename
-     * @param waitForCompletion
-     * @throws FileNotFoundException
-     */
-    public TmfTraceStub(String filename, boolean waitForCompletion) throws FileNotFoundException {
-        this(filename, DEFAULT_CACHE_SIZE, waitForCompletion);
-    }
-    
-    /**
-     * @param filename
-     * @param cacheSize
-     * @param waitForCompletion
-     * @throws FileNotFoundException
-     */
-    public TmfTraceStub(String filename, int cacheSize, boolean waitForCompletion) throws FileNotFoundException {
-        super(filename, TmfEvent.class, filename, cacheSize);
+        super(filename, cacheSize);
         fTrace = new RandomAccessFile(filename, "r");
         fParser = new TmfEventParserStub();
+        indexStream();
     }
 
-//    /**
-//     * @param other
-//     */
-//    public TmfTraceStub(TmfTraceStub other) {
-//        this(filename, DEFAULT_CACHE_SIZE, waitForCompletion);
-//    }
-    
-    /**
-     */
-    @Override
-       public TmfTraceStub clone() {
-       TmfTraceStub clone = null;
-               try {
-                       clone = (TmfTraceStub) super.clone();
-               clone.fTrace  = new RandomAccessFile(getName(), "r");
-               clone.fParser = new TmfEventParserStub();
-               } catch (CloneNotSupportedException e) {
-               } catch (FileNotFoundException e) {
-               }
-       return clone;
-    }
-    public ITmfTrace createTraceCopy() {
-               ITmfTrace returnedValue = null;
-               try {
-                       returnedValue = new TmfTraceStub(this.getName());
-               }
-               catch (FileNotFoundException e) {
-//                     e.printStackTrace();
-               }
-               return returnedValue;
-       }
-    
-    // ------------------------------------------------------------------------
+    // ========================================================================
     // Accessors
-    // ------------------------------------------------------------------------
+    // ========================================================================
 
     public RandomAccessFile getStream() {
         return fTrace;
     }
 
-    // ------------------------------------------------------------------------
+    // ========================================================================
     // Operators
-    // ------------------------------------------------------------------------
+    // ========================================================================
 
-       @Override
-       @SuppressWarnings("unchecked")
-       public TmfContext seekLocation(ITmfLocation<?> location) {
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#seekLocation(java.lang.Object)
+     */
+    public TmfTraceContext seekLocation(Object location) {
+       TmfTraceContext context = null;
         try {
-               synchronized(fTrace) {
-                       // Position the trace at the requested location and
-                       // returns the corresponding context
-                       long loc  = 0;
-                       long rank = 0;
-                       if (location != null) {
-                               loc = ((TmfLocation<Long>) location).getLocation();
-                               rank = ITmfContext.UNKNOWN_RANK;
-                       }
-                       if (loc != fTrace.getFilePointer()) {
-                               fTrace.seek(loc);
-                       }
-                       TmfContext context = new TmfContext(getCurrentLocation(), rank);
-                       return context;
-               }
+                       fTrace.seek((location != null) ? (Long) location : 0);
+                       context = new TmfTraceContext(getCurrentLocation(), 0);
                } catch (IOException e) {
+                       // TODO Auto-generated catch block
                        e.printStackTrace();
                }
-               return null;
+               return context;
     }
 
-    @Override
-       public TmfLocation<Long> getCurrentLocation() {
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfStreamLocator#getCurrentLocation()
+     */
+    public Object getCurrentLocation() {
         try {
-            return new TmfLocation<Long>(fTrace.getFilePointer());
+            return new Long(fTrace.getFilePointer());
         } catch (IOException e) {
+            // TODO Auto-generated catch block
             e.printStackTrace();
         }
         return null;
     }
 
-       @Override
-       public TmfEvent parseEvent(TmfContext context) {
-               try {
-                       // paserNextEvent updates the context
-                       TmfEvent event = fParser.parseNextEvent(this, context);
-                       return event;
-               }
-               catch (IOException e) {
-                       e.printStackTrace();
-               }
-               return null;
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.trace.TmfTrace#parseEvent()
+        */
+       public TmfEvent parseNextEvent() {
+               try {
+                       TmfEvent event = fParser.getNextEvent(this);
+                       return event;
+               }
+               catch (IOException e) {
+                       e.printStackTrace();
+               }
+               return null;
        }
 
-       @Override
-       public void setTimeRange(TmfTimeRange range) {
-       super.setTimeRange(range);
-    }
-
-       @Override
-       public void setStartTime(TmfTimestamp startTime) {
-       super.setStartTime(startTime);
-    }
+    // ========================================================================
+    // Helper functions
+    // ========================================================================
 
-       @Override
-       public void setEndTime(TmfTimestamp endTime) {
-       super.setEndTime(endTime);
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#getAttributes()
+     */
+    public Map<String, Object> getAttributes() {
+        // TODO Auto-generated method stub
+        return null;
     }
 
-}
\ No newline at end of file
+}
index 854a1536058a2fb215d1412e7fda395d254955e2..8b4c3110a96b2a2f28dbc93e4183848efa6a27b5 100644 (file)
@@ -20,7 +20,7 @@ import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
 import org.eclipse.linuxtools.tmf.signal.TmfTimeSynchSignal;
 import org.eclipse.linuxtools.tmf.trace.TmfExperiment;
 import org.eclipse.linuxtools.tmf.trace.TmfExperimentSelectedSignal;
-import org.eclipse.linuxtools.tmf.trace.TmfStreamUpdatedSignal;
+import org.eclipse.linuxtools.tmf.trace.TmfTraceUpdatedSignal;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
@@ -228,7 +228,7 @@ public class TmfEventsView extends TmfViewer {
     }
 
        @TmfSignalHandler
-    public void traceUpdated(TmfStreamUpdatedSignal signal) {
+    public void traceUpdated(TmfTraceUpdatedSignal signal) {
         // Perform the refresh on the UI thread
        fTable.getDisplay().asyncExec(new Runnable() {
                        public void run() {
index 1b37e7758d52dd9dea091a1d9c8d4218da319b2d..2bfc446aa21c395287e57eb637d1060c4400f829 100644 (file)
@@ -89,4 +89,11 @@ public class TmfEventContent {
                return fFields[id];
        }
 
+       /**
+        * @return
+        */
+       public void setFields(TmfEventField[] fields) {
+        fFields = fields;
+       }
+
 }
index 4cbdd370a1479cfb848768850f86939cf15c8539..7315dbac0ad8cbcd29d62262b4d163ea8706cd3e 100644 (file)
@@ -49,7 +49,7 @@ public class TmfTimestamp {
     // ========================================================================
 
     // The beginning and end of time
-    public static final TmfTimestamp BigBang = new TmfTimestamp(0, (byte) 0, 0);
+    public static final TmfTimestamp BigBang   = new TmfTimestamp(Long.MIN_VALUE, Byte.MAX_VALUE, 0);
     public static final TmfTimestamp BigCrunch = new TmfTimestamp(Long.MAX_VALUE, Byte.MAX_VALUE, 0);
 
     // ========================================================================
index feb9d09af5810c282ef13dfec87bf52dc2ffebae..3d12f29c2bd304324f510c435c0ed5a9f3d7b394 100644 (file)
@@ -17,7 +17,7 @@ import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 
 /**
- * <b><u>ITmfEventStream</u></b>
+ * <b><u>ITmfTrace</u></b>
  * <p>
  * TODO: Implement me. Please.
  */
@@ -26,19 +26,19 @@ public interface ITmfTrace {
        /**
         * <b><u>StreamContext</u></b>
         * <p>
-        * Stream context keeper to avoid conflicting, concurrent accesses to the
-        * underlying stream
+        * Stream context keeper. Used to prevent conflicting, concurrent accesses
+        * to the underlying trace
         */
-       public class StreamContext {
+       public class TmfTraceContext {
                public Object location;
                public int    index;
 
-               public StreamContext(Object loc, int ind) {
+               public TmfTraceContext(Object loc, int ind) {
                        location = loc;
                        index = ind;
                }
 
-               public StreamContext(StreamContext other) {
+               public TmfTraceContext(TmfTraceContext other) {
                        if (other != null) {
                                location = other.location;
                                index = other.index;
@@ -47,56 +47,75 @@ public interface ITmfTrace {
        }
     
        /**
-        * @return 
+        * @return the trace name 
         */
        public String getName();
     
        /**
-        * @return the number of events in the stream
+        * @return the number of events in the trace
         */
        public int getNbEvents();
     
        /**
-        * @return the stream time range
+        * Trace time range handlers
         */
-    public TmfTimeRange getTimeRange();
+       public void setTimeRange(TmfTimeRange range);
+       public void setStartTime(TmfTimestamp startTime);
+       public void setEndTime(TmfTimestamp endTime);
 
-//     /**
-//      * @return The stream time range
-//      */
-//    public Map<String, Object> getAttributes();
+       public TmfTimeRange getTimeRange();
+    public TmfTimestamp getStartTime();
+    public TmfTimestamp getEndTime();
 
     /**
-     * Positions the stream at the first event with timestamp.
+     * Positions the trace at the first event with the specified
+     * timestamp or index (i.e. the nth event in the trace)
      * 
      * @param timestamp
+     * @param index
      * @return a context object for subsequent reads
      */
-    public StreamContext seekEvent(TmfTimestamp timestamp);
-    public StreamContext seekEvent(int index);
+    public TmfTraceContext seekEvent(TmfTimestamp timestamp);
+    public TmfTraceContext seekEvent(int index);
 
     /**
-     * Reads and the next event on the stream and updates the context.
-     * If there is no event left, return null.
+     * These functions handle the mapping between an abstract trace
+     * and the actual implementation.
+     * 
+     * <code>parseEvent()</code> parses the event at the current
+     * trace location.
+     * 
+     * <code>processEvent()</code> is a hook for application
+     * specific processing once the event has been read.
+     */
+    public Object getCurrentLocation();
+    public TmfTraceContext seekLocation(Object location);
+    public TmfEvent parseNextEvent();
+       public void processEvent(TmfEvent event);
+
+    /**
+     * These functions return the event pointed by the supplied context
+     * (or null if no event left).
+     * 
+     * The context is updated to point to the next trace event, expect
+     * for tpeekEvent() which doesn't update the context.
      * 
      * @return the next event in the stream
      */
-    public TmfEvent peekEvent(StreamContext context);
-    public TmfEvent getEvent(StreamContext context, TmfTimestamp timestamp);
-    public TmfEvent getEvent(StreamContext context, int index);
-    public TmfEvent getNextEvent(StreamContext context);
+    public TmfEvent peekEvent(TmfTraceContext context);
+    public TmfEvent getEvent(TmfTraceContext context, TmfTimestamp timestamp);
+    public TmfEvent getEvent(TmfTraceContext context, int index);
+    public TmfEvent getNextEvent(TmfTraceContext context);
 
     /**
-     * Parse the stream and creates the checkpoint structure.
+     * Index the stream and creates the checkpoint structure.
      * Normally invoked once at the creation of the event stream.
      */
-    public void indexStream(boolean waitForCompletion);
-
-    public Object getCurrentLocation();
-    public StreamContext seekLocation(Object location);
+    public void indexStream();
 
     /**
-     * Returns the index of the event at that timestamp
+     * Returns the index of the first event at the supplied timestamp.
+     * If there is no such event, return the next one (null if none left).
      * 
      * @param timestamp
      * @return
@@ -105,6 +124,7 @@ public interface ITmfTrace {
 
        /**
         * Returns the timestamp of the event at position [index]
+        * (null if none left). 
         * 
         * @param index the event index
         * @return the corresponding timestamp
index 3f33cc701920cd0bb0e27c60900d28806a8bc07a..c57eea94ea407088f4215c8bd674dd2a0c4468f5 100644 (file)
@@ -21,7 +21,7 @@ import org.eclipse.linuxtools.tmf.request.ITmfRequestHandler;
 import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
 import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
 import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.trace.ITmfTrace.StreamContext;
+import org.eclipse.linuxtools.tmf.trace.ITmfTrace.TmfTraceContext;
 
 /**
  * <b><u>TmfExperiment</u></b>
@@ -29,7 +29,7 @@ import org.eclipse.linuxtools.tmf.trace.ITmfTrace.StreamContext;
  * TmfExperiment presents a time-ordered, unified view of a set of 
  * TmfTraces that are part of a tracing experiment. 
  * <p>
- * TODO: Implement me. Please.
+ * TODO: Complete multi-trace experiment
  */
 public class TmfExperiment implements ITmfRequestHandler<TmfEvent> {
 
@@ -37,7 +37,7 @@ public class TmfExperiment implements ITmfRequestHandler<TmfEvent> {
     // Attributes
     // ========================================================================
 
-       private final int CACHE_SIZE = 1000;
+//     private final int CACHE_SIZE = 10000;
 
     private String fExperimentId;
     private Vector<ITmfTrace> fTraces;
@@ -51,16 +51,13 @@ public class TmfExperiment implements ITmfRequestHandler<TmfEvent> {
 
     public TmfExperiment(String id, ITmfTrace[] traces) {
         this(id, traces, TmfTimestamp.BigBang);
-        for (ITmfTrace trace : traces) {
-               addTrace(trace);
-        }
     }
 
     public TmfExperiment(String id, ITmfTrace[] traces, TmfTimestamp epoch) {
        fExperimentId = id;
        fTraces = new Vector<ITmfTrace>();
        for (ITmfTrace trace : traces) {
-               fTraces.add(trace);
+               addTrace(trace);
        }
        fEpoch = epoch;
         TmfSignalManager.addListener(this);
@@ -101,6 +98,11 @@ public class TmfExperiment implements ITmfRequestHandler<TmfEvent> {
        return fTraces.firstElement().getIndex(ts);
     }
 
+    // TODO: Go over all the traces
+    public TmfTimestamp getTimestamp(int index) {
+       return fTraces.firstElement().getTimestamp(index);
+    }
+
 //     public TmfTimestamp getTimestamp(int index) {
 //             if (fIndices.size() == 0) {
 //                     indexExperiment();
@@ -193,7 +195,7 @@ public class TmfExperiment implements ITmfRequestHandler<TmfEvent> {
                Thread thread = new Thread() {
 
                        private ITmfTrace[] traces = new ITmfTrace[0];
-                       private StreamContext[] contexts;
+                       private TmfTraceContext[] contexts;
                        private TmfEvent[] peekEvents;
 
                        @Override
@@ -214,7 +216,7 @@ public class TmfExperiment implements ITmfRequestHandler<TmfEvent> {
 
                                // Initialize the traces array and position the streams
                                traces = fTraces.toArray(traces);
-                               contexts = new StreamContext[traces.length];
+                               contexts = new TmfTraceContext[traces.length];
                                peekEvents = new TmfEvent[traces.length];
                                for (int i = 0; i < contexts.length; i++) {
                                        contexts[i] = traces[i].seekEvent(startTime);
@@ -260,7 +262,7 @@ public class TmfExperiment implements ITmfRequestHandler<TmfEvent> {
                Thread thread = new Thread() {
 
                        private ITmfTrace[] traces = new ITmfTrace[0];
-                       private StreamContext[] contexts;
+                       private TmfTraceContext[] contexts;
                        private TmfEvent[] peekEvents;
 
                        @Override
@@ -279,7 +281,7 @@ public class TmfExperiment implements ITmfRequestHandler<TmfEvent> {
 
                                // Initialize the traces array and position the streams
                                traces = fTraces.toArray(traces);
-                               contexts = new StreamContext[traces.length];
+                               contexts = new TmfTraceContext[traces.length];
                                peekEvents = new TmfEvent[traces.length];
                                for (int i = 0; i < contexts.length; i++) {
                                        contexts[i] = traces[i].seekEvent(request.getIndex());
@@ -315,7 +317,7 @@ public class TmfExperiment implements ITmfRequestHandler<TmfEvent> {
 
     // Returns the next event in chronological order
        // TODO: Consider the time adjustment
-       private TmfEvent getNextEvent(ITmfTrace[] traces, StreamContext[] contexts, TmfEvent[] peekEvents) {
+       private TmfEvent getNextEvent(ITmfTrace[] traces, TmfTraceContext[] contexts, TmfEvent[] peekEvents) {
                int index = 0;
                TmfEvent evt = peekEvents[0];
                TmfTimestamp ts0 = evt != null ? evt.getTimestamp() : TmfTimestamp.BigCrunch;
@@ -333,53 +335,52 @@ public class TmfExperiment implements ITmfRequestHandler<TmfEvent> {
                return event;
        }
 
-       // TODO: Redesign me
-       private Vector<StreamContext[]> fIndices = new Vector<StreamContext[]>();
-       public void indexExperiment() {
-               ITmfTrace[] traces = new ITmfTrace[0];
-               StreamContext[] contexts;
-               TmfEvent[] peekEvents;
-
-               traces = fTraces.toArray(traces);
-               contexts = new StreamContext[traces.length];
-               peekEvents = new TmfEvent[traces.length];
-               for (int i = 0; i < contexts.length; i++) {
-                       contexts[i] = traces[i].seekEvent(TmfTimestamp.BigBang);
-                       peekEvents[i] = traces[i].peekEvent(contexts[i]);
-               }
-
-               // Initialize the indices
-               StreamContext[] ctx = new StreamContext[contexts.length];
-               for (int i = 0; i < ctx.length; i++) {
-                       ctx[i] = new StreamContext(contexts[i]);
-               }
-               fIndices.add(ctx);
-
-               // Get the ordered events and populate the indices
-               int nbEvents = 0;
-               while (getNextEvent(traces, contexts, peekEvents) != null)
-               {
-                       if (++nbEvents % CACHE_SIZE == 0) {
-                               ctx = new StreamContext[contexts.length];
-                               for (int i = 0; i < ctx.length; i++) {
-                                       ctx[i] = new StreamContext(contexts[i]);
-                               }
-                               fIndices.add(ctx);
-                       }
-               }
-       }
+//     private Vector<TraceContext[]> fIndices = new Vector<TraceContext[]>();
+//     public void indexExperiment() {
+//             ITmfTrace[] traces = new ITmfTrace[0];
+//             TraceContext[] contexts;
+//             TmfEvent[] peekEvents;
+//
+//             traces = fTraces.toArray(traces);
+//             contexts = new TraceContext[traces.length];
+//             peekEvents = new TmfEvent[traces.length];
+//             for (int i = 0; i < contexts.length; i++) {
+//                     contexts[i] = traces[i].seekEvent(TmfTimestamp.BigBang);
+//                     peekEvents[i] = traces[i].peekEvent(contexts[i]);
+//             }
+//
+//             // Initialize the indices
+//             TraceContext[] ctx = new TraceContext[contexts.length];
+//             for (int i = 0; i < ctx.length; i++) {
+//                     ctx[i] = new TraceContext(contexts[i]);
+//             }
+//             fIndices.add(ctx);
+//
+//             // Get the ordered events and populate the indices
+//             int nbEvents = 0;
+//             while (getNextEvent(traces, contexts, peekEvents) != null)
+//             {
+//                     if (++nbEvents % CACHE_SIZE == 0) {
+//                             ctx = new TraceContext[contexts.length];
+//                             for (int i = 0; i < ctx.length; i++) {
+//                                     ctx[i] = new TraceContext(contexts[i]);
+//                             }
+//                             fIndices.add(ctx);
+//                     }
+//             }
+//     }
 
     // ========================================================================
     // Signal handlers
     // ========================================================================
 
     @TmfSignalHandler
-    public void streamUpdated(TmfStreamUpdatedSignal signal) {
+    public void traceUpdated(TmfTraceUpdatedSignal signal) {
        synchronized(this) {
                updateNbEvents();
                updateTimeRange();
        }
-               TmfSignalManager.dispatchSignal(new TmfTraceUpdatedSignal(this, this));
+               TmfSignalManager.dispatchSignal(new TmfExperimentUpdatedSignal(this, this, signal.getTrace()));
     }
 
 }
diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfExperimentUpdatedSignal.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfExperimentUpdatedSignal.java
new file mode 100644 (file)
index 0000000..553bcbc
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.trace;
+
+import org.eclipse.linuxtools.tmf.signal.TmfSignal;
+
+/**
+ * <b><u>TmfExperimentUpdatedSignal</u></b>
+ * <p>
+ * TODO: Implement me. Please.
+ */
+public class TmfExperimentUpdatedSignal extends TmfSignal {
+
+       private final TmfExperiment fExperiment;
+       private final ITmfTrace fTrace;
+       
+       public TmfExperimentUpdatedSignal(Object source, TmfExperiment experiment, ITmfTrace trace) {
+               super(source);
+               fExperiment = experiment;
+               fTrace = trace;
+       }
+
+       public TmfExperiment getExperiment() {
+               return fExperiment;
+       }
+
+       public ITmfTrace getTrace() {
+               return fTrace;
+       }
+}
diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfStreamCheckpoint.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfStreamCheckpoint.java
deleted file mode 100644 (file)
index e4548b1..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.trace;
-
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-
-/**
- * <b><u>TmfStreamCheckpoint</u></b>
- * <p>
- * This class maps an event timestamp with a trace location.
- */
-public class TmfStreamCheckpoint implements Comparable<TmfStreamCheckpoint> {
-
-    // ========================================================================
-    // Attributes
-    // ========================================================================
-    
-    private final TmfTimestamp fTimestamp;
-    private final Object fLocation;
-
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-    /**
-     * @param ts
-     * @param location
-     */
-    public TmfStreamCheckpoint(TmfTimestamp ts, Object location) {
-        fTimestamp = ts;
-        fLocation = location;
-    }
-
-    // ========================================================================
-    // Accessors
-    // ========================================================================
-
-    /**
-     * @return the checkpoint event timestamp
-     */
-    public TmfTimestamp getTimestamp() {
-        return fTimestamp;
-    }
-
-    /**
-     * @return the checkpoint event stream location
-     */
-    public Object getLocation() {
-        return fLocation;
-    }
-
-    // ========================================================================
-    // Operators
-    // ========================================================================
-
-    public int compareTo(TmfStreamCheckpoint other) {
-        return fTimestamp.compareTo(other.fTimestamp, false);
-    }
-
-}
diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfStreamUpdatedSignal.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfStreamUpdatedSignal.java
deleted file mode 100644 (file)
index f87dd92..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.trace;
-
-import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.signal.TmfSignal;
-
-/**
- * <b><u>TmfStreamUpdatedEvent</u></b>
- * <p>
- * TODO: Implement me. Please.
- */
-public class TmfStreamUpdatedSignal extends TmfSignal {
-
-       private final ITmfTrace fEventStream;
-       private final TmfTimeRange fTimeRange;
-       
-       public TmfStreamUpdatedSignal(Object source, ITmfTrace stream, TmfTimeRange range) {
-               super(source);
-               fEventStream = stream;
-               fTimeRange = range;
-       }
-
-       public ITmfTrace getEventStream() {
-               return fEventStream;
-       }
-
-       public TmfTimeRange getEventRange() {
-               return fTimeRange;
-       }
-}
index 60f83cda3ab9f2d05e358c511e65e2bae8f5bb63..5fad45b101cdcd1f53693dd156dd5b43b81f4ae4 100644 (file)
@@ -13,7 +13,6 @@
 package org.eclipse.linuxtools.tmf.trace;
 
 import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.util.Collections;
 import java.util.Vector;
 
@@ -27,9 +26,12 @@ import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
 import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
 
 /**
- * <b><u>TmfEventStream</u></b>
+ * <b><u>TmfTrace</u></b>
  * <p>
- * TODO: Implement me. Please.
+ * Abstract implementation of ITmfTrace. It should be sufficient to extend this
+ * class and provide implementation for <code>getCurrentLocation()</code> and
+ * <code>seekLocation()</code>, as well as a proper parser, to have a working
+ * concrete imlpementation.
  */
 public abstract class TmfTrace implements ITmfTrace {
 
@@ -38,7 +40,7 @@ public abstract class TmfTrace implements ITmfTrace {
     // ========================================================================
 
     // The default number of events to cache
-    public static final int DEFAULT_CACHE_SIZE = 1000;
+    public static final int DEFAULT_PAGE_SIZE = 1000;
 
     // ========================================================================
     // Attributes
@@ -47,14 +49,11 @@ public abstract class TmfTrace implements ITmfTrace {
     // The stream name
     private final String fName;
 
-    // The stream parser
-    private final ITmfEventParser fParser;
-
-    // The cache size
-    private final int fCacheSize;
+    // The checkpoints page size
+    private final int fPageSize;
 
     // The set of event stream checkpoints (for random access)
-    private Vector<TmfStreamCheckpoint> fCheckpoints = new Vector<TmfStreamCheckpoint>();
+    protected Vector<TmfTraceCheckpoint> fCheckpoints = new Vector<TmfTraceCheckpoint>();
 
     // The number of events collected
     private int fNbEvents = 0;
@@ -67,24 +66,21 @@ public abstract class TmfTrace implements ITmfTrace {
     // ========================================================================
 
     /**
-     * @param filename
-     * @param parser
+     * @param name
      * @param cacheSize
      * @throws FileNotFoundException
      */
-    protected TmfTrace(String filename, ITmfEventParser parser, int cacheSize) throws FileNotFoundException {
-       fName = filename;
-        fParser = parser;
-        fCacheSize = cacheSize;
+    protected TmfTrace(String name, int cacheSize) throws FileNotFoundException {
+       fName = name;
+        fPageSize = cacheSize;
     }
 
     /**
-     * @param filename
-     * @param parser
+     * @param name
      * @throws FileNotFoundException
      */
-    protected TmfTrace(String filename, ITmfEventParser parser) throws FileNotFoundException {
-       this(filename, parser, DEFAULT_CACHE_SIZE);
+    protected TmfTrace(String name) throws FileNotFoundException {
+       this(name, DEFAULT_PAGE_SIZE);
     }
 
     // ========================================================================
@@ -92,14 +88,14 @@ public abstract class TmfTrace implements ITmfTrace {
     // ========================================================================
 
     /**
-     * @return
+     * @return the size of the cache
      */
-    public int getCacheSize() {
-        return fCacheSize;
+    public int getPageSize() {
+        return fPageSize;
     }
 
     /**
-     * @return
+     * @return the trace name
      */
     public String getName() {
         return fName;
@@ -119,11 +115,31 @@ public abstract class TmfTrace implements ITmfTrace {
         return fTimeRange;
     }
 
+    public TmfTimestamp getStartTime() {
+       return fTimeRange.getStartTime();
+    }
+
+    public TmfTimestamp getEndTime() {
+       return fTimeRange.getEndTime();
+    }
+
+    public void setTimeRange(TmfTimeRange range) {
+       fTimeRange = range;
+    }
+
+    public void setStartTime(TmfTimestamp startTime) {
+       fTimeRange = new TmfTimeRange(startTime, fTimeRange.getEndTime());
+    }
+
+    public void setEndTime(TmfTimestamp endTime) {
+       fTimeRange = new TmfTimeRange(fTimeRange.getStartTime(), endTime);
+    }
+
     /* (non-Javadoc)
      * @see org.eclipse.linuxtools.tmf.stream.ITmfEventStream#getIndex(org.eclipse.linuxtools.tmf.event.TmfTimestamp)
      */
     public int getIndex(TmfTimestamp timestamp) {
-       StreamContext context = seekEvent(timestamp);
+       TmfTraceContext context = seekEvent(timestamp);
        return context.index;
     }
 
@@ -131,7 +147,7 @@ public abstract class TmfTrace implements ITmfTrace {
      * @see org.eclipse.linuxtools.tmf.stream.ITmfEventStream#getTimestamp(int)
      */
     public TmfTimestamp getTimestamp(int index) {
-       StreamContext context = seekEvent(index);
+       TmfTraceContext context = seekEvent(index);
        TmfEvent event = peekEvent(context);
        return event.getTimestamp();
     }
@@ -140,10 +156,13 @@ public abstract class TmfTrace implements ITmfTrace {
     // Operators
     // ========================================================================
 
-    public StreamContext seekEvent(TmfTimestamp timestamp) {
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.event.TmfTimestamp)
+     */
+    public TmfTraceContext seekEvent(TmfTimestamp timestamp) {
 
         // First, find the right checkpoint
-       int index = Collections.binarySearch(fCheckpoints, new TmfStreamCheckpoint(timestamp, 0));
+       int index = Collections.binarySearch(fCheckpoints, new TmfTraceCheckpoint(timestamp, 0));
 
         // In the very likely event that the checkpoint was not found, bsearch
         // returns its negated would-be location (not an offset...). From that
@@ -154,11 +173,11 @@ public abstract class TmfTrace implements ITmfTrace {
 
         // Position the stream at the checkpoint
         Object location = (index < fCheckpoints.size()) ? fCheckpoints.elementAt(index).getLocation() : null;
-        StreamContext nextEventContext;
+        TmfTraceContext nextEventContext;
         synchronized(this) {
                nextEventContext = seekLocation(location);
         }
-        StreamContext currentEventContext = new StreamContext(nextEventContext.location, index * fCacheSize);
+        TmfTraceContext currentEventContext = new TmfTraceContext(nextEventContext.location, index * fPageSize);
 
         // And get the event
         TmfEvent event = getNextEvent(nextEventContext);
@@ -171,19 +190,22 @@ public abstract class TmfTrace implements ITmfTrace {
         return currentEventContext;
     }
 
-    public StreamContext seekEvent(int position) {
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#seekEvent(int)
+     */
+    public TmfTraceContext seekEvent(int position) {
 
         // Position the stream at the previous checkpoint
-        int index = position / fCacheSize;
+        int index = position / fPageSize;
         Object location = (index < fCheckpoints.size()) ? fCheckpoints.elementAt(index).getLocation() : null;
-        StreamContext nextEventContext;
+        TmfTraceContext nextEventContext;
         synchronized(this) {
                nextEventContext = seekLocation(location);
         }
-        StreamContext currentEventContext = new StreamContext(nextEventContext);
+        TmfTraceContext currentEventContext = new TmfTraceContext(nextEventContext);
 
         // And locate the event (if it exists)
-        int current = index * fCacheSize;
+        int current = index * fPageSize;
         TmfEvent event = getNextEvent(nextEventContext);
         while (event != null && current < position) {
                currentEventContext.location = nextEventContext.location;
@@ -194,59 +216,60 @@ public abstract class TmfTrace implements ITmfTrace {
         return currentEventContext;
     }
 
-    public TmfEvent peekEvent(StreamContext context) {
-       StreamContext ctx = new StreamContext(context);
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#peekEvent(org.eclipse.linuxtools.tmf.trace.ITmfTrace.TraceContext)
+     */
+    public TmfEvent peekEvent(TmfTraceContext context) {
+       TmfTraceContext ctx = new TmfTraceContext(context);
         return getNextEvent(ctx);
     }
 
-    public TmfEvent getEvent(StreamContext context, TmfTimestamp timestamp) {
-
-       // Position the stream and update the context object
-       StreamContext ctx = seekEvent(timestamp);
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#getEvent(org.eclipse.linuxtools.tmf.trace.ITmfTrace.TraceContext, org.eclipse.linuxtools.tmf.event.TmfTimestamp)
+     */
+    public TmfEvent getEvent(TmfTraceContext context, TmfTimestamp timestamp) {
+       TmfTraceContext ctx = seekEvent(timestamp);
        context.location = ctx.location; 
-
-        return getNextEvent(context);
+       return getNextEvent(context);
     }
 
-    public TmfEvent getEvent(StreamContext context, int position) {
-
-       // Position the stream and update the context object
-       StreamContext ctx = seekEvent(position);
+    /* (non-Javadoc)
+     * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#getEvent(org.eclipse.linuxtools.tmf.trace.ITmfTrace.TraceContext, int)
+     */
+    public TmfEvent getEvent(TmfTraceContext context, int position) {
+       TmfTraceContext ctx = seekEvent(position);
        context.location = ctx.location; 
-
-        return getNextEvent(context);
+       return getNextEvent(context);
     }
 
-    public synchronized TmfEvent getNextEvent(StreamContext context) {
-        try {
-               seekLocation(context.location);
-               TmfEvent event = fParser.getNextEvent(this);
-               context.location = getCurrentLocation();
-               return event;
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
+       /* (non-Javadoc)
+        * @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#getNextEvent(org.eclipse.linuxtools.tmf.trace.ITmfTrace.TraceContext)
+        */
+       public synchronized TmfEvent getNextEvent(TmfTraceContext context) {
+               seekLocation(context.location);
+               TmfEvent event = parseNextEvent();
+               processEvent(event);
+               context.location = getCurrentLocation();
+       return event;
+       }
 
-       private void notifyListeners(TmfTimeRange range) {
-               TmfSignalManager.dispatchSignal(new TmfStreamUpdatedSignal(this, this, range));
+       /**
+        * Hook for "special" processing by the extending class
+        * @param event
+        */
+       public void processEvent(TmfEvent event) {
+               // Do nothing by default
        }
-   
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfEventStream#indexStream()
-     */
-    public void indexStream(boolean waitForCompletion) {
+    
+    // ========================================================================
+    // Stream indexing. Essentially, parse the file asynchronously and build
+       // the checkpoints index. This index is used to quickly find an event based
+       // on a timestamp or an index.
+    // ========================================================================
+
+    public void indexStream() {
        IndexingJob job = new IndexingJob(fName);
        job.schedule();
-        if (waitForCompletion) {
-            try {
-                               job.join();
-                       } catch (InterruptedException e) {
-                               // TODO Auto-generated catch block
-                               e.printStackTrace();
-                       }
-        }
     }
 
     private class IndexingJob extends Job {
@@ -269,11 +292,11 @@ public abstract class TmfTrace implements ITmfTrace {
             monitor.beginTask("Indexing " + fName, IProgressMonitor.UNKNOWN);
 
             try {
-                StreamContext nextEventContext;
+                TmfTraceContext nextEventContext;
                 synchronized(this) {
                        nextEventContext = seekLocation(null);
                 }
-                StreamContext currentEventContext = new StreamContext(nextEventContext);
+                TmfTraceContext currentEventContext = new TmfTraceContext(nextEventContext);
                 TmfEvent event = getNextEvent(nextEventContext);
                 if (event != null) {
                        startTime = event.getTimestamp();
@@ -283,8 +306,8 @@ public abstract class TmfTrace implements ITmfTrace {
                 rangeStartTime = startTime;
                 while (event != null) {
                     lastTime = event.getTimestamp();
-                    if ((nbEvents++ % fCacheSize) == 0) {
-                        TmfStreamCheckpoint bookmark = new TmfStreamCheckpoint(lastTime, currentEventContext.location);
+                    if ((nbEvents++ % fPageSize) == 0) {
+                        TmfTraceCheckpoint bookmark = new TmfTraceCheckpoint(lastTime, currentEventContext.location);
                         synchronized(this) {
                                fCheckpoints.add(bookmark);
                                fNbEvents = nbEvents;
@@ -298,7 +321,10 @@ public abstract class TmfTrace implements ITmfTrace {
                         }
                     }
 
-                       currentEventContext.location = nextEventContext.location;
+                    // Do whatever
+                    processEvent(event);
+
+                    currentEventContext.location = nextEventContext.location;
                                        event = getNextEvent(nextEventContext);
                 }
             }
@@ -315,4 +341,8 @@ public abstract class TmfTrace implements ITmfTrace {
                }
     }
 
+    private void notifyListeners(TmfTimeRange range) {
+               TmfSignalManager.dispatchSignal(new TmfTraceUpdatedSignal(this, this, range));
+       }
+   
 }
diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTraceCheckpoint.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTraceCheckpoint.java
new file mode 100644 (file)
index 0000000..60a8d44
--- /dev/null
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.trace;
+
+import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
+
+/**
+ * <b><u>TmfTraceCheckpoint</u></b>
+ * <p>
+ * This class maps an event timestamp with a trace location.
+ */
+public class TmfTraceCheckpoint implements Comparable<TmfTraceCheckpoint> {
+
+    // ========================================================================
+    // Attributes
+    // ========================================================================
+    
+    private final TmfTimestamp fTimestamp;
+    private final Object fLocation;
+
+    // ========================================================================
+    // Constructors
+    // ========================================================================
+
+    /**
+     * @param ts
+     * @param location
+     */
+    public TmfTraceCheckpoint(TmfTimestamp ts, Object location) {
+        fTimestamp = ts;
+        fLocation = location;
+    }
+
+    // ========================================================================
+    // Accessors
+    // ========================================================================
+
+    /**
+     * @return the checkpoint event timestamp
+     */
+    public TmfTimestamp getTimestamp() {
+        return fTimestamp;
+    }
+
+    /**
+     * @return the checkpoint event stream location
+     */
+    public Object getLocation() {
+        return fLocation;
+    }
+
+    // ========================================================================
+    // Operators
+    // ========================================================================
+
+    public int compareTo(TmfTraceCheckpoint other) {
+        return fTimestamp.compareTo(other.fTimestamp, false);
+    }
+
+}
index a81cbf9fb9d8422e8351b36c6a316ea3653b39b9..64182c56480d81de3889bfb1e1544530140b1199 100644 (file)
 
 package org.eclipse.linuxtools.tmf.trace;
 
+import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
 import org.eclipse.linuxtools.tmf.signal.TmfSignal;
 
 /**
- * <b><u>TmfTraceUpdatedEvent</u></b>
+ * <b><u>TmfTraceUpdatedSignal</u></b>
  * <p>
  * TODO: Implement me. Please.
  */
 public class TmfTraceUpdatedSignal extends TmfSignal {
 
-       private final TmfExperiment fExperiment;
+       private final ITmfTrace fTrace;
+       private final TmfTimeRange fTimeRange;
        
-       public TmfTraceUpdatedSignal(Object source, TmfExperiment experiment) {
+       public TmfTraceUpdatedSignal(Object source, ITmfTrace trace, TmfTimeRange range) {
                super(source);
-               fExperiment = experiment;
+               fTrace = trace;
+               fTimeRange = range;
        }
 
-       public TmfExperiment getTrace() {
-               return fExperiment;
+       public ITmfTrace getTrace() {
+               return fTrace;
+       }
+
+       public TmfTimeRange getRange() {
+               return fTimeRange;
        }
 }
diff --git a/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace_old.java b/org.eclipse.linuxtools.tmf/src/org/eclipse/linuxtools/tmf/trace/TmfTrace_old.java
deleted file mode 100644 (file)
index 67e0d92..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 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.trace;
-
-import java.util.Vector;
-
-import org.eclipse.linuxtools.tmf.event.TmfEvent;
-import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.event.TmfTimestamp;
-import org.eclipse.linuxtools.tmf.request.ITmfRequestHandler;
-import org.eclipse.linuxtools.tmf.request.TmfDataRequest;
-import org.eclipse.linuxtools.tmf.signal.TmfSignalManager;
-import org.eclipse.linuxtools.tmf.trace.ITmfTrace.StreamContext;
-
-/**
- * <b><u>TmfTrace</u></b>
- * <p>
- * TmfTrace represents a time-ordered set of events tied to a single event
- * stream. It keeps track of the global information about the event log:
- * <ul>
- * <li> the epoch, a reference timestamp for the whole log (t0)
- * <li> the span of the log i.e. the timestamps range
- * <li> the total number of events
- * </ul>
- * As an ITmfRequestHandler, it provides an implementation of processRequest()
- * which handles event requests.
- * <p>
- * TODO: Handle concurrent and possibly overlapping requests in a way that
- * optimizes the stream access and event parsing.
- */
-public class TmfTrace_old implements ITmfRequestHandler<TmfEvent> {
-
-    // ========================================================================
-    // Attributes
-    // ========================================================================
-
-       private final String fTraceId;
-    private final ITmfTrace fStream;
-    private final TmfTimestamp fEpoch;
-    
-    // ========================================================================
-    // Constructors
-    // ========================================================================
-
-    public TmfTrace_old(String id, ITmfTrace stream) {
-        this(id, stream, TmfTimestamp.BigBang);
-    }
-
-    public TmfTrace_old(String id, ITmfTrace stream, TmfTimestamp epoch) {
-        assert stream != null;
-        fTraceId = id;
-        fStream = stream;
-        fEpoch = epoch;
-        TmfSignalManager.addListener(this);
-    }
-
-    public void dispose() {
-        TmfSignalManager.removeListener(this);
-    }
-
-    // ========================================================================
-    // Accessors
-    // ========================================================================
-
-    public String getTraceId() {
-       return fTraceId;
-    }
-
-    public ITmfTrace getStream() {
-       return fStream;
-    }
-
-    public TmfTimestamp getEpoch() {
-       return fEpoch;
-    }
-
-    public TmfTimeRange getTimeRange() {
-       return fStream.getTimeRange();
-    }
-
-    public int getNbEvents() {
-       return fStream.getNbEvents();
-    }
-
-    public int getIndex(TmfTimestamp ts) {
-       return fStream.getIndex(ts);
-    }
-
-    // ========================================================================
-    // Operators
-    // ========================================================================
-
-    private StreamContext fContext;
-    
-    public TmfEvent getEvent(TmfTimestamp timestamp) {
-       fContext = fStream.seekEvent(timestamp);
-       return fStream.getNextEvent(fContext);
-    }
-
-    public TmfEvent getEvent(int index) {
-       fContext = fStream.seekEvent(index);
-       return fStream.getNextEvent(fContext);
-    }
-
-    public TmfEvent getNextEvent() {
-       if (fContext == null) {
-               fContext = fStream.seekEvent(TmfTimestamp.BigBang);
-       }
-       return fStream.getNextEvent(fContext);
-    }
-
-    // ========================================================================
-    // ITmfRequestHandler
-    // ========================================================================
-
-    /* (non-Javadoc)
-     * @see org.eclipse.linuxtools.tmf.eventlog.ITmfRequestHandler#processRequest(org.eclipse.linuxtools.tmf.eventlog.TmfDataRequest, boolean)
-     */
-    public void processRequest(TmfDataRequest<TmfEvent> request, boolean waitForCompletion) {
-       if (request.getRange() != null) {
-               serviceEventRequestByTimestamp(request);
-       } else {
-               serviceEventRequestByIndex(request);
-       }
-        if (waitForCompletion) {
-            request.waitForCompletion();
-        }
-    }
-
-    /* (non-Javadoc)
-     * 
-     * @param request
-     */
-    private void serviceEventRequestByTimestamp(final TmfDataRequest<TmfEvent> request) {
-        Thread thread = new Thread() {
-            @Override
-                       public void run() {
-                TmfTimestamp startTime = request.getRange().getStartTime();
-                TmfTimestamp endTime   = request.getRange().getEndTime();
-                int blockSize = request.getBlockize();
-
-                int nbRequestedEvents = request.getNbRequestedItems();
-                if (nbRequestedEvents == -1) {
-                    nbRequestedEvents = Integer.MAX_VALUE;
-                }
-
-                Vector<TmfEvent> events = new Vector<TmfEvent>();
-                int nbEvents = 0;
-
-                StreamContext context = new StreamContext(null);
-                TmfEvent event = fStream.getEvent(context, startTime);
-
-                while (!request.isCancelled() && nbEvents < nbRequestedEvents && event != null &&
-                        event.getTimestamp().compareTo(endTime, false) <= 0 )
-                {
-                    events.add(event);
-                    if (++nbEvents % blockSize == 0) {
-                       TmfEvent[] result = new TmfEvent[events.size()];
-                       events.toArray(result);
-                       request.setData(result);
-                        request.handleData();
-                        events.removeAllElements();
-                    }
-                    // To avoid an unnecessary read passed the last event requested 
-                    if (nbEvents < nbRequestedEvents)
-                        event = fStream.getNextEvent(context);
-                }
-               TmfEvent[] result = new TmfEvent[events.size()];
-               events.toArray(result);
-               request.setData(result);
-
-               request.handleData();
-                request.done();
-            }
-        };
-        thread.start();
-    }
-
-    /* (non-Javadoc)
-     * 
-     * @param request
-     */
-    private void serviceEventRequestByIndex(final TmfDataRequest<TmfEvent> request) {
-//        Thread thread = new Thread() {
-//            @Override
-//                     public void run() {
-//                int blockSize = request.getBlockize();
-//
-//                int nbRequestedEvents = request.getNbRequestedItems();
-//                if (nbRequestedEvents == -1) {
-//                    nbRequestedEvents = Integer.MAX_VALUE;
-//                }
-//
-//                Vector<TmfEvent> events = new Vector<TmfEvent>();
-//                int nbEvents = 0;
-//
-//                StreamContext context = new StreamContext(null);
-//                TmfEvent event = fStream.getEvent(context, request.getIndex());
-//
-//                while (!request.isCancelled() && nbEvents < nbRequestedEvents && event != null)
-//                {
-//                    events.add(event);
-//                    if (++nbEvents % blockSize == 0) {
-//                     TmfEvent[] result = new TmfEvent[events.size()];
-//                     events.toArray(result);
-//                     request.setData(result);
-//                        request.handleData();
-//                        events.removeAllElements();
-//                    }
-//                    // To avoid an unnecessary read passed the last event requested 
-//                    if (nbEvents < nbRequestedEvents)
-//                        event = fStream.getNextEvent(context);
-//                }
-//             TmfEvent[] result = new TmfEvent[events.size()];
-//             events.toArray(result);
-//
-//             request.setData(result);
-//                request.handleData();
-//                request.done();
-//            }
-//        };
-//        thread.start();
-    }
-
-//    // ========================================================================
-//    // Signal handlers
-//    // ========================================================================
-//
-//    @TmfSignalHandler
-//    public void streamUpdated(TmfStreamUpdatedSignal signal) {
-//             TmfSignalManager.dispatchSignal(new TmfTraceUpdatedSignal(this, this));
-//    }
-
-}
This page took 0.117439 seconds and 5 git commands to generate.