traceTypeNames = new Vector<Integer>();
initialiseEventTypes(currentJniTrace);
- // *** VERIFY ***
- // Verify that all those "default constructor" are safe to use
+ // Build the re-used event structure
eventTimestamp = new LttngTimestamp();
eventSource = new LttngEventSource();
this.eventType = new LttngEventType();
// Set the currentEvent to the eventContent
eventContent.setEvent(currentLttngEvent);
- // // Bypass indexing if asked
- // if ( bypassIndexing == false ) {
- // indexTrace(true);
- // }
- // else {
- // Even if we don't have any index, set ONE checkpoint
- // fCheckpoints.add(new TmfCheckpoint(new LttngTimestamp(0L) , new
- // LttngLocation() ) );
-
// Set the time range of the trace
TmfContext context = seekLocation(null);
LttngEvent event = getNextEvent(context);
public LTTngTrace(String path, String traceLibPath, boolean waitForCompletion, boolean bypassIndexing)
throws Exception {
super(path, LttngEvent.class, path, CHECKPOINT_PAGE_SIZE, false);
- try {
- currentJniTrace = JniTraceFactory.getJniTrace(path, traceLibPath, SHOW_LTT_DEBUG_DEFAULT);
- } catch (Exception e) {
- throw new FileNotFoundException(e.getMessage());
- }
-
+ initTrace(path, LttngEvent.class, !bypassIndexing);
this.traceLibPath = traceLibPath;
- // Export all the event types from the JNI side
- traceTypes = new HashMap<Integer, LttngEventType>();
- traceTypeNames = new Vector<Integer>();
- initialiseEventTypes(currentJniTrace);
-
- // *** VERIFY ***
- // Verify that all those "default constructor" are safe to use
- eventTimestamp = new LttngTimestamp();
- eventSource = new LttngEventSource();
- eventType = new LttngEventType();
- eventContent = new LttngEventContent(currentLttngEvent);
- eventReference = new LttngEventReference(this.getName());
-
- // Create the skeleton event
- currentLttngEvent = new LttngEvent(this, eventTimestamp, eventSource, eventType, eventContent, eventReference,
- null);
-
- // Create a new current location
- previousLocation = new LttngLocation();
-
- // Set the currentEvent to the eventContent
- eventContent.setEvent(currentLttngEvent);
-
- // // Bypass indexing if asked
- // if ( bypassIndexing == false ) {
- // indexTrace(true);
- // }
- // else {
- // Even if we don't have any index, set ONE checkpoint
- // fCheckpoints.add(new TmfCheckpoint(new LttngTimestamp(0L) , new
- // LttngLocation() ) );
-
- // Set the time range of the trace
- TmfContext context = seekLocation(null);
- LttngEvent event = getNextEvent(context);
- LttngTimestamp startTime = new LttngTimestamp(event.getTimestamp());
- LttngTimestamp endTime = new LttngTimestamp(currentJniTrace.getEndTime().getTime());
- setTimeRange(new TmfTimeRange(startTime, endTime));
+// try {
+// currentJniTrace = JniTraceFactory.getJniTrace(path, traceLibPath, SHOW_LTT_DEBUG_DEFAULT);
+// } catch (Exception e) {
+// throw new FileNotFoundException(e.getMessage());
+// }
+//
+// // Export all the event types from the JNI side
+// traceTypes = new HashMap<Integer, LttngEventType>();
+// traceTypeNames = new Vector<Integer>();
+// initialiseEventTypes(currentJniTrace);
+//
+// // *** VERIFY ***
+// // Verify that all those "default constructor" are safe to use
+// eventTimestamp = new LttngTimestamp();
+// eventSource = new LttngEventSource();
+// eventType = new LttngEventType();
+// eventContent = new LttngEventContent(currentLttngEvent);
+// eventReference = new LttngEventReference(this.getName());
+//
+// // Create the skeleton event
+// currentLttngEvent = new LttngEvent(this, eventTimestamp, eventSource, eventType, eventContent, eventReference,
+// null);
+//
+// // Create a new current location
+// previousLocation = new LttngLocation();
+//
+// // Set the currentEvent to the eventContent
+// eventContent.setEvent(currentLttngEvent);
+//
+// // // Bypass indexing if asked
+// // if ( bypassIndexing == false ) {
+// // indexTrace(true);
+// // }
+// // else {
+// // Even if we don't have any index, set ONE checkpoint
+// // fCheckpoints.add(new TmfCheckpoint(new LttngTimestamp(0L) , new
+// // LttngLocation() ) );
+//
+// // Set the time range of the trace
+// TmfContext context = seekLocation(null);
+// LttngEvent event = getNextEvent(context);
+// LttngTimestamp startTime = new LttngTimestamp(event.getTimestamp());
+// LttngTimestamp endTime = new LttngTimestamp(currentJniTrace.getEndTime().getTime());
+//
+// setTimeRange(new TmfTimeRange(startTime, endTime));
}
/*
* Copy constructor is forbidden for LttngEvenmStream
*/
- public LTTngTrace(LTTngTrace oldTrace) throws Exception {
- this(oldTrace.getPath(), oldTrace.getTraceLibPath(), false, true);
-
- // *** VERIFY ***
- // Is this safe?
- this.fCheckpoints = oldTrace.fCheckpoints;
-
- /*
- * // This would only work if the index is already done this.fCheckpoints = new Vector<TmfCheckpoint>(
- * oldTrace.fCheckpoints.size() ); for (int x = 0; x<oldTrace.fCheckpoints.size(); x++){ TmfCheckpoint
- * tmpCheckPoint = oldTrace.fCheckpoints.get(x); this.fCheckpoints.add( new
- * TmfCheckpoint(tmpCheckPoint.getTimestamp(), tmpCheckPoint.getLocation()) ); }
- */
-
- // Set the start time of the trace
- setTimeRange(new TmfTimeRange(new LttngTimestamp(oldTrace.getStartTime()), new LttngTimestamp(
- oldTrace.getEndTime())));
+ public LTTngTrace(LTTngTrace other) throws Exception {
+ this(other.getPath(), other.getTraceLibPath(), false, true);
+ this.fCheckpoints = other.fCheckpoints;
+ setTimeRange(new TmfTimeRange(new LttngTimestamp(other.getStartTime()), new LttngTimestamp(other.getEndTime())));
}
@Override
*/
public abstract class TmfComponent implements ITmfComponent {
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
private String fName;
// ------------------------------------------------------------------------
}
public TmfComponent(String name) {
- fName = name;
- TmfSignalManager.register(this);
+ init(name);
}
- public TmfComponent(TmfComponent oldComponent) {
- fName = oldComponent.fName;
- TmfSignalManager.register(this);
+ public TmfComponent(TmfComponent other) {
+ init(other.fName);
}
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.component.ITmfComponent#getName()
- */
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
protected void setName(String name) {
fName = name;
}
// ITmfComponent
// ------------------------------------------------------------------------
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.component.ITmfComponent#getName()
- */
@Override
public String getName() {
return fName;
}
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.component.ITmfComponent#dispose()
- */
@Override
public void dispose() {
TmfSignalManager.deregister(this);
// if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "terminated");
}
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.component.ITmfComponent#broadcast(org.eclipse.linuxtools.tmf.signal.TmfSignal)
- */
@Override
public void broadcast(TmfSignal signal) {
TmfSignalManager.dispatchSignal(signal);
// Constants
// ------------------------------------------------------------------------
+ public static final int DEFAULT_BLOCK_SIZE = 50000;
+ public static final int DEFAULT_QUEUE_SIZE = 1000;
+
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
protected boolean fLogData;
protected boolean fLogError;
- public static final int DEFAULT_BLOCK_SIZE = 50000;
- public static final int DEFAULT_QUEUE_SIZE = 1000;
-
- protected int fQueueSize;
+ protected int fQueueSize = DEFAULT_QUEUE_SIZE;
protected BlockingQueue<T> fDataQueue;
protected TmfRequestExecutor fExecutor;
// ------------------------------------------------------------------------
public TmfDataProvider() {
+ super();
fQueueSize = DEFAULT_QUEUE_SIZE;
fDataQueue = new LinkedBlockingQueue<T>(fQueueSize);
fExecutor = new TmfRequestExecutor();
public void init(String name, Class<T> dataType) {
super.init(name);
fType = dataType;
- fQueueSize = DEFAULT_QUEUE_SIZE;
fDataQueue = (fQueueSize > 1) ? new LinkedBlockingQueue<T>(fQueueSize) : new SynchronousQueue<T>();
fExecutor = new TmfRequestExecutor();
TmfProviderManager.register(fType, this);
}
- public TmfDataProvider(String name, Class<T> type) {
- this(name, type, DEFAULT_QUEUE_SIZE);
- }
-
protected TmfDataProvider(String name, Class<T> type, int queueSize) {
- super(name);
- fType = type;
+ this();
fQueueSize = queueSize;
- fDataQueue = (fQueueSize > 1) ? new LinkedBlockingQueue<T>(fQueueSize) : new SynchronousQueue<T>();
-
- fExecutor = new TmfRequestExecutor();
- fSignalDepth = 0;
-
- fLogData = Tracer.isEventTraced();
- fLogError = Tracer.isErrorTraced();
-
- TmfProviderManager.register(fType, this);
- // if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "started");
+ init(name, type);
}
public TmfDataProvider(TmfDataProvider<T> other) {
- super(other);
- fType = other.fType;
- fQueueSize = other.fQueueSize;
- fDataQueue = (fQueueSize > 1) ? new LinkedBlockingQueue<T>(fQueueSize) : new SynchronousQueue<T>();
-
- fExecutor = new TmfRequestExecutor();
- fSignalDepth = 0;
+ this();
+ init(other.getName(), other.fType);
+ }
- fLogData = Tracer.isEventTraced();
- fLogError = Tracer.isErrorTraced();
+ public TmfDataProvider(String name, Class<T> type) {
+ this(name, type, DEFAULT_QUEUE_SIZE);
}
@Override
// if (Tracer.isComponentTraced()) Tracer.traceComponent(this, "stopped");
}
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
public int getQueueSize() {
return fQueueSize;
}
// The trace path
private String fPath;
+ // The trace name
+ private String fName;
+
// The cache page size AND checkpoints interval
protected int fIndexPageSize = DEFAULT_INDEX_PAGE_SIZE;
// ------------------------------------------------------------------------
public TmfTrace() {
+ super();
}
@Override
@Override
public void initTrace(String path, Class<T> eventType, int cacheSize, boolean indexTrace) throws FileNotFoundException {
- String simpleName = ""; //$NON-NLS-1$
fPath = path;
- if (path != null) {
- int sep = path.lastIndexOf(File.separator);
- simpleName = (sep >= 0) ? path.substring(sep + 1) : path;
+ if (fName == null) {
+ fName = ""; //$NON-NLS-1$
+ if (path != null) {
+ int sep = path.lastIndexOf(File.separator);
+ fName = (sep >= 0) ? path.substring(sep + 1) : path;
+ }
}
- super.init(simpleName, eventType);
-
+ super.init(fName, eventType);
fIndexPageSize = (cacheSize > 0) ? cacheSize : DEFAULT_INDEX_PAGE_SIZE;
-
if (indexTrace)
indexTrace(false);
}
* @throws FileNotFoundException
*/
protected TmfTrace(String name, Class<T> type, String path, int cacheSize, boolean indexTrace) throws FileNotFoundException {
- super(name, type);
- if (path != null) {
- int sep = path.lastIndexOf(File.separator);
- String simpleName = (sep >= 0) ? path.substring(sep + 1) : path;
- setName(simpleName);
- }
- fPath = path;
- fIndexPageSize = (cacheSize > 0) ? cacheSize : DEFAULT_INDEX_PAGE_SIZE;
- if (indexTrace) {
- indexTrace(false);
- }
+ super();
+ fName = name;
+ initTrace(path, type, cacheSize, indexTrace);
}
- /* (non-Javadoc)
- * @see java.lang.Object#clone()
- */
@SuppressWarnings("unchecked")
@Override
public TmfTrace<T> clone() throws CloneNotSupportedException {