try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
final File test = new File(FileLocator.toFileURL(location).toURI());
- trace = new TmfTraceStub(test.toURI().getPath(), 500, false);
+ trace = new TmfTraceStub(test.toURI().getPath(), 500, false, null, null);
} catch (final TmfTraceException e) {
e.printStackTrace();
} catch (final URISyntaxException e) {
try {
URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TmfTraceStub(test.getPath(), 500);
+ fTrace = new TmfTraceStub(test.getPath(), 500, false, null, null);
} catch (TmfTraceException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
final File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace = new TmfTraceStub(test.getPath(), 0, true);
+ final TmfTraceStub trace = new TmfTraceStub(test.getPath(), 0, true, null, null);
fTestTraces[0] = trace;
} catch (final TmfTraceException e) {
e.printStackTrace();
URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path1), null);
File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true);
+ final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true, null, null);
traces[0] = trace1;
location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path2), null);
test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true);
+ final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true, null, null);
traces[1] = trace2;
return traces;
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TmfTraceStub(test.toURI().getPath());
+ fTrace = new TmfTraceStub(test.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null, null);
fTrace.indexTrace(true);
} catch (final TmfTraceException e) {
e.printStackTrace();
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
testfile = new File(FileLocator.toFileURL(location).toURI());
- trace = new TmfTraceStub(testfile.toURI().getPath());
+ trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null, null);
trace.indexTrace(true);
} catch (final URISyntaxException e) {
fail("URISyntaxException");
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
testfile = new File(FileLocator.toFileURL(location).toURI());
- trace = new TmfTraceStub(testfile.toURI().getPath(), 0);
+ trace = new TmfTraceStub(testfile.toURI().getPath(), 0, false, null, null);
trace.indexTrace(true);
} catch (final URISyntaxException e) {
fail("URISyntaxException");
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
testfile = new File(FileLocator.toFileURL(location).toURI());
- trace = new TmfTraceStub(testfile.toURI().getPath());
+ trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null, null);
trace.indexTrace(true);
} catch (final URISyntaxException e) {
fail("URISyntaxException");
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
testfile = new File(FileLocator.toFileURL(location).toURI());
- trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, null);
+ trace = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, false, null, null);
trace.indexTrace(true);
} catch (final URISyntaxException e) {
fail("URISyntaxException");
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
testfile = new File(FileLocator.toFileURL(location).toURI());
- original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, new TmfCheckpointIndexer(null));
+ original = new TmfTraceStub(testfile.toURI().getPath(), BLOCK_SIZE, false, new TmfCheckpointIndexer(null), null);
trace = new TmfTraceStub(original);
trace.indexTrace(true);
} catch (final URISyntaxException e) {
try {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM), null);
testfile = new File(FileLocator.toFileURL(location).toURI());
- trace = new TmfTraceStub(testfile.toURI().getPath());
+ trace = new TmfTraceStub(testfile.toURI().getPath(), ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false, null, null);
// verify initial values
TmfTimestamp defaultInitRange = new TmfTimestamp(DEFAULT_INITIAL_OFFSET_VALUE, ITmfTimestamp.NANOSECOND_SCALE);
assertEquals("getInitialRangeOffset", defaultInitRange, trace.getInitialRangeOffset());
private class TestTrace extends TmfTraceStub {
public TestTrace(String path, int blockSize) throws TmfTraceException {
- super(path, blockSize);
+ super(path, blockSize, false, null, null);
setIndexer(new TestIndexer(this));
}
@Override
private class TestTrace extends TmfTraceStub {
public TestTrace(String path, int blockSize) throws TmfTraceException {
- super(path, blockSize);
+ super(path, blockSize, false, null, null);
setIndexer(new TestIndexer(this));
}
@Override
try {
URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path1), null);
File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true);
+ final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, true, null, null);
fTestTraces[0] = trace1;
location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path2), null);
test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true);
+ final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, true, null, null);
fTestTraces[1] = trace2;
} catch (final TmfTraceException e) {
e.printStackTrace();
try {
URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM1), null);
File test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, false);
+ final TmfTraceStub trace1 = new TmfTraceStub(test.getPath(), 0, false, null, null);
testTraces[0] = trace1;
location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(DIRECTORY + File.separator + TEST_STREAM2), null);
test = new File(FileLocator.toFileURL(location).toURI());
- final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, false);
+ final TmfTraceStub trace2 = new TmfTraceStub(test.getPath(), 0, false, null, null);
testTraces[1] = trace2;
} catch (final TmfTraceException e) {
e.printStackTrace();
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
try {
final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TmfTraceStub(test.getPath(), 0, true);
+ fTrace = new TmfTraceStub(test.getPath(), 0, true, null, null);
} catch (final TmfTraceException e) {
e.printStackTrace();
} catch (final URISyntaxException e) {
final URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(path), null);
try {
final File test = new File(FileLocator.toFileURL(location).toURI());
- fTrace = new TmfTraceStub(test.getPath(), 0, true);
+ fTrace = new TmfTraceStub(test.getPath(), 0, true, null, null);
} catch (final TmfTraceException e) {
e.printStackTrace();
} catch (final URISyntaxException e) {
import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.linuxtools.tmf.core.trace.ITmfEventParser;
-import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.core.trace.TmfContext;
import org.eclipse.linuxtools.tmf.core.trace.TmfTrace;
import org.eclipse.linuxtools.tmf.core.trace.indexer.ITmfTraceIndexer;
* <p>
* Dummy test trace. Use in conjunction with TmfEventParserStub.
*/
-@SuppressWarnings("javadoc")
public class TmfTraceStub extends TmfTrace implements ITmfEventParser {
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
+ /**
+ * Default constructor
+ */
public TmfTraceStub() {
super();
setParser(new TmfEventParserStub(this));
}
/**
+ * Constructor with which you can specify a custom streaming interval. The
+ * parser and indexer won't be specified.
+ *
* @param path
- * @throws FileNotFoundException
- */
- public TmfTraceStub(final String path) throws TmfTraceException {
- this(path, ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, false);
- }
-
- /**
- * @param path
+ * The path to the trace file
* @param cacheSize
- * @throws FileNotFoundException
+ * The cache size
+ * @param interval
+ * The trace streaming interval
+ * @throws TmfTraceException
+ * If an error occurred opening the trace
*/
- public TmfTraceStub(final String path, final int cacheSize) throws TmfTraceException {
- this(path, cacheSize, false);
- }
-
- /**
- * @param path
- * @param cacheSize
- * @throws FileNotFoundException
- */
- public TmfTraceStub(final String path, final int cacheSize, final long interval) throws TmfTraceException {
+ public TmfTraceStub(final String path,
+ final int cacheSize,
+ final long interval) throws TmfTraceException {
super(null, ITmfEvent.class, path, cacheSize, interval, null, null);
- try {
- fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$
- } catch (FileNotFoundException e) {
- throw new TmfTraceException(e.getMessage());
- }
+ setupTrace(path);
setParser(new TmfEventParserStub(this));
}
/**
+ * Constructor to specify the parser and indexer. The streaming interval
+ * will be 0.
+ *
* @param path
+ * The path to the trace file
* @param cacheSize
- * @throws FileNotFoundException
- */
- public TmfTraceStub(final String path, final int cacheSize, final ITmfTraceIndexer indexer) throws TmfTraceException {
- this(path, cacheSize, false, null, indexer);
- }
-
- /**
- * @param path
- * @param waitForCompletion
- * @throws FileNotFoundException
- */
- public TmfTraceStub(final String path, final boolean waitForCompletion) throws TmfTraceException {
- this(path, ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, waitForCompletion);
- }
-
- /**
- * @param path
- * @param cacheSize
+ * The cache size
* @param waitForCompletion
- * @throws FileNotFoundException
+ * Do we block the caller until the trace is indexed, or not.
+ * @param indexer
+ * The trace indexer to use
+ * @param parser
+ * The trace parser. If left 'null', it will use a
+ * {@link TmfEventParserStub}.
+ * @throws TmfTraceException
+ * If an error occurred opening the trace
*/
- public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion) throws TmfTraceException {
- super(null, ITmfEvent.class, path, cacheSize, 0, null, null);
- try {
- fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$
- } catch (FileNotFoundException e) {
- throw new TmfTraceException(e.getMessage());
- }
- setParser(new TmfEventParserStub(this));
+ public TmfTraceStub(final String path,
+ final int cacheSize,
+ final boolean waitForCompletion,
+ final ITmfTraceIndexer indexer,
+ final ITmfEventParser parser) throws TmfTraceException {
+ super(null, ITmfEvent.class, path, cacheSize, 0, indexer, null);
+ setupTrace(path);
+ setParser((parser != null) ? parser : new TmfEventParserStub(this));
if (waitForCompletion) {
indexTrace(true);
}
}
/**
- * @param path
- * @param cacheSize
- * @param waitForCompletion
- * @throws FileNotFoundException
+ * Copy constructor
+ *
+ * @param trace
+ * The trace to copy
+ * @throws TmfTraceException
+ * If an error occurred opening the trace
*/
- public TmfTraceStub(final IResource resource, final String path, final int cacheSize, final boolean waitForCompletion) throws TmfTraceException {
- super(resource, ITmfEvent.class, path, cacheSize, 0, null, null);
- try {
- fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$
- } catch (FileNotFoundException e) {
- throw new TmfTraceException(e.getMessage());
- }
+ public TmfTraceStub(final TmfTraceStub trace) throws TmfTraceException {
+ super(trace);
+ setupTrace(getPath()); // fPath will be set by the super-constructor
setParser(new TmfEventParserStub(this));
}
- /**
- * @param path
- * @param cacheSize
- * @param waitForCompletion
- * @param parser
- * @throws FileNotFoundException
- */
- public TmfTraceStub(final String path, final int cacheSize, final boolean waitForCompletion,
- final ITmfEventParser parser, final ITmfTraceIndexer indexer) throws TmfTraceException {
- super(null, ITmfEvent.class, path, cacheSize, 0, indexer, null);
+
+ private void setupTrace(String path) throws TmfTraceException {
try {
fTrace = new RandomAccessFile(path, "r"); //$NON-NLS-1$
} catch (FileNotFoundException e) {
throw new TmfTraceException(e.getMessage());
}
- setParser((parser != null) ? parser : new TmfEventParserStub(this));
}
- /**
- * Copy constructor
- */
- public TmfTraceStub(final TmfTraceStub trace) throws TmfTraceException {
- super(trace);
- try {
- fTrace = new RandomAccessFile(getPath(), "r"); //$NON-NLS-1$
- } catch (FileNotFoundException e) {
- throw new TmfTraceException(e.getMessage());
- }
- setParser(new TmfEventParserStub(this));
- }
+ // ------------------------------------------------------------------------
+ // Initializers
+ // ------------------------------------------------------------------------
@Override
public void initTrace(final IResource resource, final String path, final Class<? extends ITmfEvent> type) throws TmfTraceException {
// Accessors
// ------------------------------------------------------------------------
+ /**
+ * @return The file stream to the trace
+ */
public RandomAccessFile getStream() {
return fTrace;
}
+ /**
+ * Set the initial range offset.
+ *
+ * @param initOffset
+ * The new initial range offset
+ */
public void setInitialRangeOffset(ITmfTimestamp initOffset) {
fInitialRangeOffset = initOffset;
}
// Create test trace object
final URL location = FileLocator.find(FrameworkUtil.getBundle(this.getClass()), new Path("tracesets/sdEvents"), null);
final File test = new File(FileLocator.toFileURL(location).toURI());
- return new TmfTraceStub(test.getPath(), 500, true, parser, null);
+ return new TmfTraceStub(test.getPath(), 500, true, null, parser);
} catch (final TmfTraceException e) {
e.printStackTrace();
throw new RuntimeException(e);