import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.exceptions.TmfTraceException;
import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest;
/**
* The default trace cache size
*/
- public static final int DEFAULT_TRACE_CACHE_SIZE = 50000;
+ public static final int DEFAULT_TRACE_CACHE_SIZE = 10000;
// ------------------------------------------------------------------------
// Attributes
* @param cacheSize the trace cache size
* @throws FileNotFoundException
*/
- protected TmfTrace(final IResource resource, final Class<T> type, final String path, final int cacheSize) throws FileNotFoundException {
+ protected TmfTrace(final IResource resource, final Class<T> type, final String path, final int cacheSize) throws TmfTraceException {
this(resource, type, path, cacheSize, 0, null);
}
* @param interval the trace streaming interval
* @throws FileNotFoundException
*/
- protected TmfTrace(final IResource resource, final Class<T> type, final String path, final int cacheSize, final long interval) throws FileNotFoundException {
+ protected TmfTrace(final IResource resource, final Class<T> type, final String path, final int cacheSize, final long interval) throws TmfTraceException {
this(resource, type, path, cacheSize, interval, null);
}
* @throws FileNotFoundException
*/
protected TmfTrace(final IResource resource, final Class<T> type, final String path, final int cacheSize,
- final long interval, final ITmfTraceIndexer<?> indexer) throws FileNotFoundException {
+ final long interval, final ITmfTraceIndexer<?> indexer) throws TmfTraceException {
this(resource, type, path, cacheSize, interval, null, null);
}
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
protected TmfTrace(final IResource resource, final Class<T> type, final String path, final int cacheSize,
- final long interval, final ITmfTraceIndexer<?> indexer, final ITmfEventParser<ITmfEvent> parser) throws FileNotFoundException {
+ final long interval, final ITmfTraceIndexer<?> indexer, final ITmfEventParser<ITmfEvent> parser) throws TmfTraceException {
super();
fCacheSize = (cacheSize > 0) ? cacheSize : DEFAULT_TRACE_CACHE_SIZE;
fStreamingInterval = interval;
* @param trace the original trace
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
- public TmfTrace(final TmfTrace<T> trace) throws FileNotFoundException {
+ public TmfTrace(final TmfTrace<T> trace) throws TmfTraceException {
super();
if (trace == null)
throw new IllegalArgumentException();
* @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#initTrace(org.eclipse.core.resources.IResource, java.lang.String, java.lang.Class)
*/
@Override
- public void initTrace(final IResource resource, final String path, final Class<T> type) throws FileNotFoundException {
+ public void initTrace(final IResource resource, final String path, final Class<T> type) throws TmfTraceException {
initialize(resource, path, type);
fIndexer.buildIndex(false);
}
*
* @throws FileNotFoundException
*/
- protected void initialize(final IResource resource, final String path, final Class<T> type) throws FileNotFoundException {
+ protected void initialize(final IResource resource, final String path, final Class<T> type) throws TmfTraceException {
if (path == null)
- throw new FileNotFoundException();
+ throw new TmfTraceException("Invalid trace path"); //$NON-NLS-1$
fPath = path;
fResource = resource;
String traceName = (resource != null) ? resource.getName() : null;
final int sep = path.lastIndexOf(Path.SEPARATOR);
traceName = (sep >= 0) ? path.substring(sep + 1) : path;
}
+ if (fParser == null && !(this instanceof ITmfEventParser))
+ throw new TmfTraceException("Invalid trace parser"); //$NON-NLS-1$
super.init(traceName, type);
}
// And locate the requested event context
long pos = context.getRank();
if (pos < rank) {
- ITmfEvent event = readEvent(context);
+ ITmfEvent event = readNextEvent(context);
while (event != null && ++pos < rank) {
- event = readEvent(context);
+ event = readNextEvent(context);
}
}
return context;
// And locate the requested event context
final ITmfContext nextEventContext = context.clone(); // Must use clone() to get the right subtype...
- ITmfEvent event = readEvent(nextEventContext);
+ ITmfEvent event = readNextEvent(nextEventContext);
while (event != null && event.getTimestamp().compareTo(timestamp, false) < 0) {
context.setLocation(nextEventContext.getLocation().clone());
context.increaseRank();
- event = readEvent(nextEventContext);
+ event = readNextEvent(nextEventContext);
}
return context;
}
// ------------------------------------------------------------------------
/* (non-Javadoc)
- * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
+ * @see org.eclipse.linuxtools.tmf.core.trace.ITmfTrace#readNextEvent(org.eclipse.linuxtools.tmf.core.trace.ITmfContext)
*/
@Override
- public synchronized ITmfEvent readEvent(final ITmfContext context) {
+ public synchronized ITmfEvent readNextEvent(final ITmfContext context) {
// parseEvent() does not update the context
final ITmfEvent event = fParser.parseEvent(context);
if (event != null) {
@SuppressWarnings("unchecked")
public T getNext(final ITmfContext context) {
if (context instanceof TmfContext)
- return (T) readEvent(context);
+ return (T) readNextEvent(context);
return null;
}