* @throws FileNotFoundException
*/
public LTTngTraceStub(String filename, int cacheSize) throws FileNotFoundException {
- super(LttngEvent.class, filename, cacheSize);
+ super(filename, LttngEvent.class, filename, cacheSize);
fTrace = new RandomAccessFile(filename, "r");
fParser = new LTTngEventParserStub();
indexTrace(true);
});
}
- private boolean waitForCompletion = true;
+ private boolean waitForCompletion = false;
public void selectExperiment(LTTngExperimentNode experiment) {
String expId = experiment.getName();
}
public LTTngTextTrace(String path, boolean skipIndexing) throws Exception {
- super(LttngEvent.class, path, 1);
+ super(path, LttngEvent.class, path, 1);
tracepath = path;
traceTypes = new HashMap<String, LttngEventType>();
*
*/
public LTTngTrace(String path, boolean waitForCompletion, boolean bypassIndexing) throws Exception {
- super(LttngEvent.class, path, CHECKPOINT_PAGE_SIZE);
+ super(path, LttngEvent.class, path, CHECKPOINT_PAGE_SIZE);
try {
currentJniTrace = JniTraceFactory.getJniTrace(path, SHOW_LTT_DEBUG_DEFAULT);
}
private TmfTraceStub fTrace;
public TmfEventProviderStub(String path) throws IOException {
- super(TmfEvent.class);
+ super(path, TmfEvent.class);
URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
try {
File test = new File(FileLocator.toFileURL(location).toURI());
public static final int NB_EVENTS = 1000;
public TmfSyntheticEventProviderStub() {
- super(TmfSyntheticEventStub.class);
+ super("TmfSyntheticEventProviderStub", TmfSyntheticEventStub.class);
}
@SuppressWarnings("unchecked")
* @throws FileNotFoundException
*/
public TmfTraceStub(String filename) throws FileNotFoundException {
- super(TmfEvent.class, filename);
+ super("TmfTraceStub", TmfEvent.class, filename);
fTrace = new RandomAccessFile(filename, "r");
fParser = new TmfEventParserStub();
}
* @throws FileNotFoundException
*/
public TmfTraceStub(String filename, int cacheSize, boolean waitForCompletion) throws FileNotFoundException {
- super(TmfEvent.class, filename, cacheSize);
+ super(filename, TmfEvent.class, filename, cacheSize);
fTrace = new RandomAccessFile(filename, "r");
fParser = new TmfEventParserStub();
}
\r
public static void trace(String message) {\r
if (TRACE) {\r
- System.out.println(message);\r
+ System.out.println(Thread.currentThread() + ": " + message);\r
}\r
}\r
}\r
*/
public abstract class TmfComponent implements ITmfComponent {
- private final String fName;
+ private String fName;
// ------------------------------------------------------------------------
// Constructor
//register();
}
+ /* (non-Javadoc)
+ * @see org.eclipse.linuxtools.tmf.component.ITmfComponent#getName()
+ */
+ protected void setName(String name) {
+ fName = name;
+ }
+
// ------------------------------------------------------------------------
// ITmfComponent
// ------------------------------------------------------------------------
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.SynchronousQueue;
+import org.eclipse.linuxtools.tmf.Tracer;
import org.eclipse.linuxtools.tmf.event.TmfData;
import org.eclipse.linuxtools.tmf.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.request.TmfCoalescedDataRequest;
protected TmfDataProvider(String name, Class<T> type, int queueSize) {
super(name);
- fQueueSize = queueSize;
fType = type;
+ fQueueSize = queueSize;
fDataQueue = (queueSize > 1) ? new LinkedBlockingQueue<T>(fQueueSize) : new SynchronousQueue<T>();
- fExecutor = new TmfRequestExecutor();
+ Tracer.trace(getName() + " created");
+
+ fExecutor = new TmfRequestExecutor();
fCoalescingLevel = 0;
TmfProviderManager.register(fType, this);
- }
+ Tracer.trace(getName() + " started");
+}
- public TmfDataProvider(TmfDataProvider<T> oldDataProvider) {
- super(oldDataProvider);
-
- this.fType = oldDataProvider.fType;
- this.fQueueSize = oldDataProvider.fQueueSize;
-
- this.fExecutor = new TmfRequestExecutor();
- this.fDataQueue = (oldDataProvider.fQueueSize > 1) ? new LinkedBlockingQueue<T>(oldDataProvider.fQueueSize) : new SynchronousQueue<T>();
-
- this.fCoalescingLevel = 0;
+ 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();
+ fCoalescingLevel = 0;
}
@Override
public void dispose() {
TmfProviderManager.deregister(fType, this);
fExecutor.stop();
+ Tracer.trace(getName() + " stopped");
super.dispose();
}
protected void queueRequest(final ITmfDataRequest<T> request) {
+ final String provider = getName();
+
// Process the request
Thread thread = new Thread() {
}
// Get the ordered events
-// Tracer.trace("Thread #" + Thread.currentThread().getId() + ", request #" + request.getRequestId() + " starting");
+ Tracer.trace("Request #" + request.getRequestId() + " is serviced by " + provider);
T data = getNext(context);
+ Tracer.trace("Request #" + request.getRequestId() + " read first event");
while (data != null && !isCompleted(request, data, nbRead))
{
result.add(data);
// To avoid an unnecessary read passed the last data requested
if (nbRead < nbRequested) {
data = getNext(context);
-// if (data != null && data.isNull()) {
-// Tracer.trace("Thread #" + Thread.currentThread().getId() + ", request #" + request.getRequestId() + " end of data");
-// }
+ if (data == null || data.isNullRef()) {
+ Tracer.trace("Request #" + request.getRequestId() + " end of data");
+ }
}
}
pushData(request, result);
*/
public abstract class TmfEventProvider<T extends TmfEvent> extends TmfDataProvider<T> {
- public TmfEventProvider(Class<T> type) {
- super("TmfEventProvider", type);
+ public TmfEventProvider(String name, Class<T> type) {
+ super(name, type);
}
- public TmfEventProvider(Class<T> type, int queueSize) {
- super("TmfEventProvider", type, queueSize);
+ public TmfEventProvider(String name, Class<T> type, int queueSize) {
+ super(name, type, queueSize);
}
public TmfEventProvider(TmfEventProvider<T> oldProvider) {
// The currently selected experiment
private static TmfExperiment<?> fCurrentExperiment = null;
- // The experiment ID
- private String fExperimentId;
-
// The set of traces that constitute the experiment
private ITmfTrace[] fTraces;
* @param indexPageSize
*/
public TmfExperiment(Class<T> type, String id, ITmfTrace[] traces, TmfTimestamp epoch, int indexPageSize) {
- super(type);
+ super(id, type);
- fExperimentId = id;
fTraces = traces;
fEpoch = epoch;
fIndexPageSize = indexPageSize;
}
- public TmfExperiment(TmfExperiment<T> oldExperiment) {
- super(oldExperiment.fType);
-
- this.fExperimentId = oldExperiment.fExperimentId;
- this.fEpoch = oldExperiment.fEpoch;
-
- this.fIndexPageSize = oldExperiment.fIndexPageSize;
+ public TmfExperiment(TmfExperiment<T> other) {
+ super(other.getName(), other.fType);
- this.fTraces = new ITmfTrace[oldExperiment.fTraces.length];
+ fEpoch = other.fEpoch;
+ fIndexPageSize = other.fIndexPageSize;
- for ( int x=0; x<oldExperiment.fTraces.length; x++) {
- this.fTraces[x] = oldExperiment.fTraces[x].createTraceCopy();
+ fTraces = new ITmfTrace[other.fTraces.length];
+ for (int trace = 0; trace < other.fTraces.length; trace++) {
+ fTraces[trace] = other.fTraces[trace].createTraceCopy();
}
- // replace updateNbEvents()
- this.fNbEvents = oldExperiment.fNbEvents;
-
- // replace updateTimeRange()
- this.fTimeRange = oldExperiment.fTimeRange;
+ fNbEvents = other.fNbEvents;
+ fTimeRange = other.fTimeRange;
}
public TmfExperiment<T> createTraceCopy() {
return new TmfExperiment<T>(this);
}
-
/**
* Clears the experiment
*/
return null;
}
- @Override
- public String getName() {
- return fExperimentId;
- }
-
public long getNbEvents() {
return fNbEvents;
}
*/
@Override
public String toString() {
- return "[TmfExperiment (" + fExperimentId + ")]";
+ return "[TmfExperiment (" + getName() + ")]";
}
// ------------------------------------------------------------------------
fIndexing = true;
}
- job = new IndexingJob(fExperimentId);
+ job = new IndexingJob(new TmfExperiment<T>(this));
job.schedule();
if (waitForCompletion) {
private class IndexingJob extends Job {
- public IndexingJob(String name) {
- super(name);
+ private final String experimentId;
+ private final ITmfTrace[] traces;
+ private Vector<TmfCheckpoint> checkpoints;
+
+ public IndexingJob(TmfExperiment<T> experiment) {
+ super(experiment.getName());
+ experimentId = experiment.getName();
+ traces = experiment.getTraces();
}
/* (non-Javadoc)
protected IStatus run(IProgressMonitor monitor) {
// Minimal check
- if (fTraces.length == 0) {
+ if (traces.length == 0) {
fIndexing = false;
return Status.OK_STATUS;
}
- monitor.beginTask("Indexing " + fExperimentId, IProgressMonitor.UNKNOWN);
+ monitor.beginTask("Indexing " + experimentId, IProgressMonitor.UNKNOWN);
int nbEvents = 0;
TmfTimestamp startTime = null;
TmfTimestamp lastTime = null;
// Reset the index
- fCheckpoints = new Vector<TmfCheckpoint>();
+ checkpoints = new Vector<TmfCheckpoint>();
try {
// Position the trace at the beginning
while (event != null) {
lastTime = event.getTimestamp();
if ((nbEvents++ % fIndexPageSize) == 0) {
- fCheckpoints.add(new TmfCheckpoint(lastTime, location));
+ checkpoints.add(new TmfCheckpoint(lastTime, location));
monitor.worked(1);
}
finally {
synchronized(this) {
- fNbEvents = nbEvents;
- fTimeRange = new TmfTimeRange(startTime, lastTime);
- fIndexing = false;
- fIndexed = true;
+ fCheckpoints = checkpoints;
+ fNbEvents = nbEvents;
+ fTimeRange = new TmfTimeRange(startTime, lastTime);
+ fIndexing = false;
+ fIndexed = true;
}
notifyListeners(fTimeRange);
monitor.done();
package org.eclipse.linuxtools.tmf.request;
+import org.eclipse.linuxtools.tmf.Tracer;
import org.eclipse.linuxtools.tmf.event.TmfData;
/**
fNbRead = 0;
lock = new Object();
-// Tracer.trace("Thread #" + Thread.currentThread().getId() + ", request #" + fRequestId + " (" + getClass().getName() + ", " + fDataType.getName() + ") created");
-
+ Tracer.trace("Request #" + fRequestId + " (" + getClass().getName() + ", " + fDataType.getName() + ") created");
}
/**
*/
public void handleCompleted() {
if (fRequestFailed) {
-// Tracer.trace("Thread #" + Thread.currentThread().getId() + ", request #" + fRequestId + " failed, completed");
+ Tracer.trace("Request #" + fRequestId + " failed, completed");
handleFailure();
}
else if (fRequestCanceled) {
-// Tracer.trace("Thread #" + Thread.currentThread().getId() + ", request #" + fRequestId + " cancelled, completed");
+ Tracer.trace("Request #" + fRequestId + " cancelled, completed");
handleCancel();
}
else {
-// Tracer.trace("Thread #" + Thread.currentThread().getId() + ", request #" + fRequestId + " succeeded, completed");
+ Tracer.trace("Request #" + fRequestId + " succeeded, completed");
handleSuccess();
}
}
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
+import org.eclipse.linuxtools.tmf.Tracer;
+
/**
* <b><u>TmfRequestExecutor</u></b>
*
fExecutor = executor;
String canonicalName = fExecutor.getClass().getCanonicalName();
fExecutorName = canonicalName.substring(canonicalName.lastIndexOf('.') + 1);
+ Tracer.trace(fExecutor + " created");
}
/**
*/
public void stop() {
fExecutor.shutdown();
+ Tracer.trace(fExecutor + " terminated");
}
// ------------------------------------------------------------------------
* @see java.util.concurrent.Executor#execute(java.lang.Runnable)
*/
public synchronized void execute(final Runnable request) {
+ Tracer.trace("Queueing request " + request);
fRequestQueue.offer(new Runnable() {
public void run() {
try {
+ Tracer.trace("Processing request " + request);
request.run();
+ Tracer.trace("Finishing request " + request);
} finally {
scheduleNext();
}
// The trace path
private final String fPath;
- // The trace name
- private final String fName;
-
// The cache page size AND checkpoints interval
protected int fIndexPageSize;
* @param path
* @throws FileNotFoundException
*/
- protected TmfTrace(Class<T> type, String path) throws FileNotFoundException {
- this(type, path, DEFAULT_CACHE_SIZE);
+ protected TmfTrace(String name, Class<T> type, String path) throws FileNotFoundException {
+ this(name, type, path, DEFAULT_CACHE_SIZE);
}
/**
* @param cacheSize
* @throws FileNotFoundException
*/
- protected TmfTrace(Class<T> type, String path, int cacheSize) throws FileNotFoundException {
- super(type);
+ protected TmfTrace(String name, Class<T> type, String path, int cacheSize) throws FileNotFoundException {
+ super(name, type);
int sep = path.lastIndexOf(File.separator);
- fName = (sep >= 0) ? path.substring(sep + 1) : path;
+ String simpleName = (sep >= 0) ? path.substring(sep + 1) : path;
+ setName(simpleName);
fPath = path;
fIndexPageSize = (cacheSize > 0) ? cacheSize : DEFAULT_CACHE_SIZE;
}
return fPath;
}
- /**
- * @return the trace name
- */
- @Override
- public String getName() {
- return fName;
- }
+// /**
+// * @return the trace name
+// */
+// @Override
+// public String getName() {
+// return fName;
+// }
/* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.stream.ITmfEventStream#getNbEvents()
*/
@Override
public String toString() {
- return "[TmfTrace (" + fName + ")]";
+ return "[TmfTrace (" + getName() + ")]";
}
// ------------------------------------------------------------------------
fIndexing = true;
}
- job = new IndexingJob("Indexing " + fName);
+ job = new IndexingJob("Indexing " + getName());
job.schedule();
if (waitForCompletion) {
@Override
protected IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("Indexing " + fName, IProgressMonitor.UNKNOWN);
+ monitor.beginTask("Indexing " + getName(), IProgressMonitor.UNKNOWN);
int nbEvents = 0;
TmfTimestamp startTime = null;