import java.util.Collections;
import java.util.Vector;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
-import org.eclipse.linuxtools.tmf.core.signal.TmfEndSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentDisposedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentRangeUpdatedSignal;
-import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentSelectedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfExperimentUpdatedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfSignalHandler;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
// // The set of traces that constitute the experiment
// protected ITmfTrace<T>[] fTraces;
- // The total number of events
- protected long fNbEvents;
+// // The total number of events
+// protected long fNbEvents;
- // The experiment time range
- protected TmfTimeRange fTimeRange;
+// // The experiment time range
+// protected TmfTimeRange fTimeRange;
// The experiment reference timestamp (default: ZERO)
protected ITmfTimestamp fEpoch;
// The experiment index
- protected Vector<TmfCheckpoint> fCheckpoints = new Vector<TmfCheckpoint>();
+ protected Vector<TmfCheckpoint> fCheckpoints;
// The current experiment context
protected TmfExperimentContext fExperimentContext;
* @param indexPageSize
*/
public TmfLegacyExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces, final ITmfTimestamp epoch,
- final int indexPageSize) {
+ final int indexPageSize)
+ {
this(type, id, traces, TmfTimestamp.ZERO, indexPageSize, false);
}
final int indexPageSize, final boolean preIndexExperiment)
{
super(type, id, traces, epoch, indexPageSize, false);
+// fNbEvents = 0;
+ setTimeRange(TmfTimeRange.NULL_RANGE);
+ fEpoch = epoch;
+ fCheckpoints = new Vector<TmfCheckpoint>();
+ if (preIndexExperiment) {
+ indexExperiment(true, 0, TmfTimeRange.ETERNITY);
+ }
}
// protected TmfLegacyExperiment(final String id, final Class<T> type) {
* Clears the experiment
*/
@Override
- @SuppressWarnings({ "rawtypes", "unchecked" })
+ @SuppressWarnings( "rawtypes" )
public synchronized void dispose() {
final TmfExperimentDisposedSignal<T> signal = new TmfExperimentDisposedSignal<T>(this, this);
// return fTimeRange.getEndTime();
// }
- public Vector<TmfCheckpoint> getCheckpoints() {
- return fCheckpoints;
- }
+// public Vector<TmfCheckpoint> getCheckpoints() {
+// return fCheckpoints;
+// }
// ------------------------------------------------------------------------
// Accessors
* Update the global time range
*/
protected void updateTimeRange() {
- ITmfTimestamp startTime = fTimeRange != TmfTimeRange.NULL_RANGE ? fTimeRange.getStartTime() : TmfTimestamp.BIG_CRUNCH;
- ITmfTimestamp endTime = fTimeRange != TmfTimeRange.NULL_RANGE ? fTimeRange.getEndTime() : TmfTimestamp.BIG_BANG;
+ ITmfTimestamp startTime = getStartTime();
+ ITmfTimestamp endTime = getEndTime();
for (final ITmfTrace<T> trace : fTraces) {
final ITmfTimestamp traceStartTime = trace.getStartTime();
if (traceEndTime.compareTo(endTime, true) > 0)
endTime = traceEndTime;
}
- fTimeRange = new TmfTimeRange(startTime, endTime);
+ setTimeRange(new TmfTimeRange(startTime, endTime));
}
// ------------------------------------------------------------------------
final TmfExperimentContext context = new TmfExperimentContext(new ITmfContext[fTraces.length]);
// Tracer.trace("Ctx: SeekLocation - start");
- long rank = 0;
+// long rank = 0;
for (int i = 0; i < fTraces.length; i++) {
// Get the relevant trace attributes
final ITmfLocation<?> traceLocation = expLocation.getLocation().getLocations()[i];
* @param context the trace context
* @return the next event
*/
+ @SuppressWarnings("unchecked")
@Override
public synchronized T getNext(final ITmfContext context) {
/* (non-Javadoc)
* @see org.eclipse.linuxtools.tmf.trace.ITmfTrace#parseEvent(org.eclipse.linuxtools .tmf.trace.TmfContext)
*/
+ @SuppressWarnings("unchecked")
@Override
public T parseEvent(final ITmfContext context) {
// Indexing
// ------------------------------------------------------------------------
- private synchronized void initializeStreamingMonitor() {
- if (fInitialized)
- return;
- fInitialized = true;
-
- if (getStreamingInterval() == 0) {
- final TmfContext context = seekEvent(0);
- final ITmfEvent event = getNext(context);
- if (event == null)
- return;
- final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp().clone(), TmfTimestamp.BIG_CRUNCH);
- final TmfExperimentRangeUpdatedSignal signal = new TmfExperimentRangeUpdatedSignal(this, this, timeRange);
-
- // Broadcast in separate thread to prevent deadlock
- new Thread() {
- @Override
- public void run() {
- broadcast(signal);
- }
- }.start();
- return;
- }
-
- final Thread thread = new Thread("Streaming Monitor for experiment " + getName()) { ////$NON-NLS-1$
- private ITmfTimestamp safeTimestamp = null;
- private TmfTimeRange timeRange = null;
-
- @Override
- public void run() {
- while (!fExecutor.isShutdown()) {
- if (!isIndexingBusy()) {
- ITmfTimestamp startTimestamp = TmfTimestamp.BIG_CRUNCH;
- ITmfTimestamp endTimestamp = TmfTimestamp.BIG_BANG;
- for (final ITmfTrace<T> trace : fTraces) {
- if (trace.getStartTime().compareTo(startTimestamp) < 0)
- startTimestamp = trace.getStartTime();
- if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0)
- endTimestamp = trace.getEndTime();
- }
- if (safeTimestamp != null && safeTimestamp.compareTo(getTimeRange().getEndTime(), false) > 0)
- timeRange = new TmfTimeRange(startTimestamp, safeTimestamp);
- else
- timeRange = null;
- safeTimestamp = endTimestamp;
- if (timeRange != null) {
- final TmfExperimentRangeUpdatedSignal signal =
- new TmfExperimentRangeUpdatedSignal(TmfLegacyExperiment.this, TmfLegacyExperiment.this, timeRange);
- broadcast(signal);
- }
- }
- try {
- Thread.sleep(getStreamingInterval());
- } catch (final InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- };
- thread.start();
- }
+// private synchronized void initializeStreamingMonitor() {
+// if (fInitialized)
+// return;
+// fInitialized = true;
+//
+// if (getStreamingInterval() == 0) {
+// final TmfContext context = seekEvent(0);
+// final ITmfEvent event = getNext(context);
+// if (event == null)
+// return;
+// final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp().clone(), TmfTimestamp.BIG_CRUNCH);
+// final TmfExperimentRangeUpdatedSignal signal = new TmfExperimentRangeUpdatedSignal(this, this, timeRange);
+//
+// // Broadcast in separate thread to prevent deadlock
+// new Thread() {
+// @Override
+// public void run() {
+// broadcast(signal);
+// }
+// }.start();
+// return;
+// }
+//
+// final Thread thread = new Thread("Streaming Monitor for experiment " + getName()) { ////$NON-NLS-1$
+// private ITmfTimestamp safeTimestamp = null;
+// private TmfTimeRange timeRange = null;
+//
+// @Override
+// public void run() {
+// while (!fExecutor.isShutdown()) {
+// if (!isIndexingBusy()) {
+// ITmfTimestamp startTimestamp = TmfTimestamp.BIG_CRUNCH;
+// ITmfTimestamp endTimestamp = TmfTimestamp.BIG_BANG;
+// for (final ITmfTrace<T> trace : fTraces) {
+// if (trace.getStartTime().compareTo(startTimestamp) < 0)
+// startTimestamp = trace.getStartTime();
+// if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0)
+// endTimestamp = trace.getEndTime();
+// }
+// if (safeTimestamp != null && safeTimestamp.compareTo(getTimeRange().getEndTime(), false) > 0)
+// timeRange = new TmfTimeRange(startTimestamp, safeTimestamp);
+// else
+// timeRange = null;
+// safeTimestamp = endTimestamp;
+// if (timeRange != null) {
+// final TmfExperimentRangeUpdatedSignal signal =
+// new TmfExperimentRangeUpdatedSignal(TmfLegacyExperiment.this, TmfLegacyExperiment.this, timeRange);
+// broadcast(signal);
+// }
+// }
+// try {
+// Thread.sleep(getStreamingInterval());
+// } catch (final InterruptedException e) {
+// e.printStackTrace();
+// }
+// }
+// }
+// };
+// thread.start();
+// }
/*
* (non-Javadoc)
protected boolean fIndexing = false;
protected TmfTimeRange fIndexingPendingRange = TmfTimeRange.NULL_RANGE;
- private Integer fEndSynchReference;
+// private Integer fEndSynchReference;
// private static BufferedWriter fEventLog = null;
// private static BufferedWriter openLogFile(String filename) {
// return outfile;
// }
- protected boolean isIndexingBusy() {
- synchronized (fCheckpoints) {
- return fIndexing;
- }
- }
+// protected boolean isIndexingBusy() {
+// synchronized (fCheckpoints) {
+// return fIndexing;
+// }
+// }
@SuppressWarnings("unchecked")
private void indexExperiment(final boolean waitForCompletion, final int index, final TmfTimeRange timeRange) {
// long indexingStart = System.nanoTime();
- ITmfTimestamp startTime = (fTimeRange == TmfTimeRange.NULL_RANGE) ? null : fTimeRange.getStartTime();
- ITmfTimestamp lastTime = (fTimeRange == TmfTimeRange.NULL_RANGE) ? null : fTimeRange.getEndTime();
- long initialNbEvents = fNbEvents;
+ ITmfTimestamp startTime = (getTimeRange().equals(TmfTimeRange.NULL_RANGE)) ? null : getStartTime();
+ ITmfTimestamp lastTime = (getTimeRange().equals(TmfTimeRange.NULL_RANGE)) ? null : getEndTime();
+ long initialNbEvents = getNbEvents();
@Override
public void handleStarted() {
super.handleCompleted();
synchronized (fCheckpoints) {
fIndexing = false;
- if (fIndexingPendingRange != TmfTimeRange.NULL_RANGE) {
- indexExperiment(false, (int) fNbEvents, fIndexingPendingRange);
+ if (!(fIndexingPendingRange.equals(TmfTimeRange.NULL_RANGE))) {
+ indexExperiment(false, (int) getNbEvents(), fIndexingPendingRange);
fIndexingPendingRange = TmfTimeRange.NULL_RANGE;
}
}
private void updateExperiment() {
final int nbRead = getNbRead();
- if (startTime != null)
- fTimeRange = new TmfTimeRange(startTime, lastTime.clone());
+ if (startTime != null) {
+ setTimeRange(new TmfTimeRange(startTime, lastTime.clone()));
+ }
if (nbRead != 0) {
// updateTimeRange();
// updateNbEvents();
- fNbEvents = initialNbEvents + nbRead;
+ setNbEvents(initialNbEvents + nbRead);
notifyListeners();
}
}
// Signal handlers
// ------------------------------------------------------------------------
- @TmfSignalHandler
- public void experimentSelected(final TmfExperimentSelectedSignal<T> signal) {
- final TmfExperiment<?> experiment = signal.getExperiment();
- if (experiment == this) {
- setCurrentExperiment(experiment);
- fEndSynchReference = Integer.valueOf(signal.getReference());
- }
- }
-
- @TmfSignalHandler
- public void endSync(final TmfEndSynchSignal signal) {
- if (fEndSynchReference != null && fEndSynchReference.intValue() == signal.getReference()) {
- fEndSynchReference = null;
- initializeStreamingMonitor();
- }
- }
-
- @TmfSignalHandler
- public void experimentUpdated(final TmfExperimentUpdatedSignal signal) {
- }
-
+// @TmfSignalHandler
+// public void experimentSelected(final TmfExperimentSelectedSignal<T> signal) {
+// final TmfExperiment<?> experiment = signal.getExperiment();
+// if (experiment == this) {
+// setCurrentExperiment(experiment);
+// fEndSynchReference = Integer.valueOf(signal.getReference());
+// }
+// }
+//
+// @TmfSignalHandler
+// public void endSync(final TmfEndSynchSignal signal) {
+// if (fEndSynchReference != null && fEndSynchReference.intValue() == signal.getReference()) {
+// fEndSynchReference = null;
+// initializeStreamingMonitor();
+// }
+// }
+//
+// @TmfSignalHandler
+// public void experimentUpdated(final TmfExperimentUpdatedSignal signal) {
+// }
+//
+ @Override
@TmfSignalHandler
public void experimentRangeUpdated(final TmfExperimentRangeUpdatedSignal signal) {
if (signal.getExperiment() == this)
- indexExperiment(false, (int) fNbEvents, signal.getRange());
+ indexExperiment(false, (int) getNbEvents(), signal.getRange());
}
+ @Override
@TmfSignalHandler
public void traceUpdated(final TmfTraceUpdatedSignal signal) {
for (final ITmfTrace<T> trace : fTraces)
if (trace == signal.getTrace()) {
synchronized (fCheckpoints) {
if (fIndexing) {
- if (fIndexingPendingRange == TmfTimeRange.NULL_RANGE)
+ if (fIndexingPendingRange.equals(TmfTimeRange.NULL_RANGE))
fIndexingPendingRange = signal.getRange();
else {
ITmfTimestamp startTime = fIndexingPendingRange.getStartTime();
return;
}
}
- indexExperiment(false, (int) fNbEvents, signal.getRange());
+ indexExperiment(false, (int) getNbEvents(), signal.getRange());
return;
}
}
return null;
}
- /**
- * Set the file to be used for bookmarks on this experiment
- *
- * @param file the bookmarks file
- */
- public void setBookmarksFile(final IFile file) {
- fBookmarksFile = file;
- }
-
- /**
- * Get the file used for bookmarks on this experiment
- *
- * @return the bookmarks file or null if none is set
- */
- public IFile getBookmarksFile() {
- return fBookmarksFile;
- }
+// /**
+// * Set the file to be used for bookmarks on this experiment
+// *
+// * @param file the bookmarks file
+// */
+// public void setBookmarksFile(final IFile file) {
+// fBookmarksFile = file;
+// }
+//
+// /**
+// * Get the file used for bookmarks on this experiment
+// *
+// * @return the bookmarks file or null if none is set
+// */
+// public IFile getBookmarksFile() {
+// return fBookmarksFile;
+// }
/*
* (non-Javadoc)