* @param type
* @param id
* @param traces
- * @throws TmfTraceException
+ * @throws TmfTraceException
*/
public TmfExperiment(final Class<T> type, final String id, final ITmfTrace<T>[] traces) {
this(type, id, traces, DEFAULT_INDEX_PAGE_SIZE);
* @param id
* @param traces
* @param indexPageSize
- * @throws TmfTraceException
+ * @throws TmfTraceException
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public TmfExperiment(final Class<T> type, final String path, final ITmfTrace<T>[] traces, final int indexPageSize) {
}
if (fTraces != null) {
- for (final ITmfTrace trace : fTraces)
+ for (final ITmfTrace trace : fTraces) {
trace.dispose();
+ }
fTraces = null;
}
super.dispose();
// ------------------------------------------------------------------------
/* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String)
+ * @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class)
*/
@Override
- public boolean validate(final IProject project, final String path) {
- return true;
+ public void initTrace(final IResource resource, final String path, final Class<T> type) {
}
/* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#validate(org.eclipse.core.resources.IProject, java.lang.String)
*/
@Override
- public void initTrace(final IResource resource, final String path, final Class<T> type) {
+ public boolean validate(final IProject project, final String path) {
+ return true;
}
// ------------------------------------------------------------------------
/**
* Selects the current, framework-wide, experiment
- *
+ *
* @param experiment das experiment
*/
public static void setCurrentExperiment(final TmfExperiment<?> experiment) {
/**
* Get the list of traces. Handle with care...
- *
+ *
* @return the experiment traces
*/
public ITmfTrace<T>[] getTraces() {
/**
* Returns the timestamp of the event at the requested index. If none,
* returns null.
- *
+ *
* @param index the event index (rank)
* @return the corresponding event timestamp
*/
/**
* Set the file to be used for bookmarks on this experiment
- *
+ *
* @param file the bookmarks file
*/
public void setBookmarksFile(final IFile file) {
/**
* Get the file used for bookmarks on this experiment
- *
+ *
* @return the bookmarks file or null if none is set
*/
public IFile getBookmarksFile() {
*/
@Override
protected synchronized ITmfContext armRequest(final ITmfDataRequest<T> request) {
+
+ // Make sure we have something to read from
+ if (fTraces == null) {
+ return null;
+ }
+
if (request instanceof ITmfEventRequest<?>
&& !TmfTimestamp.BIG_BANG.equals(((ITmfEventRequest<T>) request).getRange().getStartTime())
&& request.getIndex() == 0)
// ITmfTrace trace positioning
// ------------------------------------------------------------------------
- /* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.TmfTrace#seekEvent(long)
- *
- * TmfTrace.seekEvent(rank) will return a context that will position the
- * trace to read the event at rank 'rank' in the trace. In the case of an
- * experiment context, that event has to be actually read in the fEvents
- * buffer and the corresponding trace context has to point to the next
- * event (rank + 1) in the trace (the sum of the traces contexts ranks
- * should equal [exp context rank + #traces] (corner cases not considered).
- *
- * In the likely case that TmfTrace.seekEvent() computed the context
- * by using a read loop (reading from the experiment), the 'lastTraceRead'
- * field will be set to the actual trace that needs to be read to obtain
- * event at rank 'rank'.
- *
- * Therefore, if 'lastTraceRead' is set, we need to read that particular
- * trace *and* then decrease the context rank (which has to correspond to
- * the rank of the event to be returned next by TmfExperiemnt.getNext().
- */
- @Override
- public synchronized ITmfContext seekEvent(final long rank) {
- TmfExperimentContext context = (TmfExperimentContext) super.seekEvent(rank);
- int lastTrace = context.getLastTrace();
- if (lastTrace != TmfExperimentContext.NO_TRACE) {
- getNext(context);
- context.setRank(rank);
- context.setLastTrace(TmfExperimentContext.NO_TRACE);
- }
- return context;
- }
-
/* (non-Javadoc)
*
- * Returns a brand new context based on the location provided and
+ * Returns a brand new context based on the location provided and
* initializes the event queues
- *
+ *
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#seekEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfLocation)
*/
@Override
// Instantiate the location
final TmfExperimentLocation expLocation = (location == null)
- ? new TmfExperimentLocation(new TmfLocationArray(new ITmfLocation<?>[fTraces.length]))
+ ? new TmfExperimentLocation(new TmfLocationArray(new ITmfLocation<?>[fTraces.length]))
: (TmfExperimentLocation) location.clone();
// Create and populate the context's traces contexts
// Finalize context
context.setLocation(expLocation);
context.setLastTrace(TmfExperimentContext.NO_TRACE);
- context.setRank(ITmfContext.UNKNOWN_RANK);
+ context.setRank((location == null) ? 0 : ITmfContext.UNKNOWN_RANK);
fExperimentContext = context;
- return (ITmfContext) context;
+ return context;
}
// ------------------------------------------------------------------------
final int lastTrace = expContext.getLastTrace();
if (lastTrace != TmfExperimentContext.NO_TRACE) {
final ITmfContext traceContext = expContext.getContexts()[lastTrace];
-
- TmfExperimentLocation location = (TmfExperimentLocation) expContext.getLocation();
- if (location != null) {
- location.getLocation().getLocations()[lastTrace] = traceContext.getLocation().clone();
- }
-
expContext.getEvents()[lastTrace] = fTraces[lastTrace].getNext(traceContext);
expContext.setLastTrace(TmfExperimentContext.NO_TRACE);
}
updateAttributes(expContext, event.getTimestamp());
expContext.increaseRank();
expContext.setLastTrace(trace);
- fExperimentContext = expContext;
+ final ITmfContext traceContext = expContext.getContexts()[trace];
+
+ TmfExperimentLocation location = (TmfExperimentLocation) expContext.getLocation();
+ if (location != null) {
+ location.getLocation().getLocations()[trace] = traceContext.getLocation().clone();
+ }
+
+ fExperimentContext = expContext.clone();
processEvent(event);
}
}
*/
@Override
@SuppressWarnings("nls")
- public String toString() {
+ public synchronized String toString() {
return "[TmfExperiment (" + getName() + ")]";
}
if (getStreamingInterval() == 0) {
final ITmfContext context = seekEvent(0);
final ITmfEvent event = getNext(context);
- if (event == null)
+ if (event == null) {
return;
+ }
final TmfTimeRange timeRange = new TmfTimeRange(event.getTimestamp().clone(), TmfTimestamp.BIG_CRUNCH);
final TmfExperimentRangeUpdatedSignal signal = new TmfExperimentRangeUpdatedSignal(this, this, timeRange);
final Thread thread = new Thread("Streaming Monitor for experiment " + getName()) { //$NON-NLS-1$
private ITmfTimestamp safeTimestamp = null;
+ private ITmfTimestamp lastSafeTimestamp = null;
private TmfTimeRange timeRange = null;
@Override
ITmfTimestamp startTimestamp = TmfTimestamp.BIG_CRUNCH;
ITmfTimestamp endTimestamp = TmfTimestamp.BIG_BANG;
for (final ITmfTrace<T> trace : fTraces) {
- if (trace.getStartTime().compareTo(startTimestamp) < 0)
+ if (trace.getStartTime().compareTo(startTimestamp) < 0) {
startTimestamp = trace.getStartTime();
- if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0)
+ }
+ if (trace.getStreamingInterval() != 0 && trace.getEndTime().compareTo(endTimestamp) > 0) {
endTimestamp = trace.getEndTime();
+ }
}
- if (safeTimestamp != null && safeTimestamp.compareTo(getTimeRange().getEndTime(), false) > 0)
+ if (safeTimestamp != null && (lastSafeTimestamp == null || safeTimestamp.compareTo(lastSafeTimestamp, false) > 0)) {
timeRange = new TmfTimeRange(startTimestamp, safeTimestamp);
- else
+ lastSafeTimestamp = safeTimestamp;
+ } else {
timeRange = null;
+ }
safeTimestamp = endTimestamp;
if (timeRange != null) {
final TmfExperimentRangeUpdatedSignal signal =
@Override
public long getStreamingInterval() {
long interval = 0;
- for (final ITmfTrace<T> trace : fTraces)
+ for (final ITmfTrace<T> trace : fTraces) {
interval = Math.max(interval, trace.getStreamingInterval());
+ }
return interval;
}
/**
* Signal handler for the TmfExperimentSelectedSignal signal
- *
+ *
* @param signal
*/
@TmfSignalHandler
/**
* Signal handler for the TmfEndSynchSignal signal
- *
+ *
* @param signal
*/
@TmfSignalHandler
/**
* Signal handler for the TmfTraceUpdatedSignal signal
- *
+ *
* @param signal
*/
@TmfSignalHandler
/**
* Signal handler for the TmfExperimentRangeUpdatedSignal signal
- *
+ *
* @param signal
*/
@TmfSignalHandler